|
|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
use Yii;
|
|
|
@@ -37,29 +38,29 @@ class DeliveryController extends BaseController
|
|
|
{
|
|
|
$platformList = [];
|
|
|
$platformLogos = [
|
|
|
- 'dada' => ['name'=>'达达', 'logo'=>'📦'],
|
|
|
- 'shunfeng' => ['name'=>'顺丰同城', 'logo'=>'🚚'],
|
|
|
- 'meituan' => ['name'=>'美团', 'logo'=>'🍱'] ,
|
|
|
- 'fengniao' => ['name'=>'蜂鸟', 'logo'=>'🍜'],
|
|
|
- 'huolala' => ['name'=>'货拉拉跑腿', 'logo'=>'🚛'],
|
|
|
- 'shansong' => ['name'=>'闪送', 'logo'=>'⚡'],
|
|
|
- 'didi' => ['name'=>'滴滴', 'logo'=>'🚗'],
|
|
|
- 'uu' => ['name'=>'UU跑腿', 'logo'=>'🛵']
|
|
|
+ 'dada' => ['name' => '达达', 'logo' => '📦'],
|
|
|
+ 'shunfeng' => ['name' => '顺丰同城', 'logo' => '🚚'],
|
|
|
+ 'meituan' => ['name' => '美团', 'logo' => '🍱'],
|
|
|
+ 'fengniao' => ['name' => '蜂鸟', 'logo' => '🍜'],
|
|
|
+ 'huolala' => ['name' => '货拉拉跑腿', 'logo' => '🚛'],
|
|
|
+ 'shansong' => ['name' => '闪送', 'logo' => '⚡'],
|
|
|
+ 'didi' => ['name' => '滴滴', 'logo' => '🚗'],
|
|
|
+ 'uu' => ['name' => 'UU跑腿', 'logo' => '🛵']
|
|
|
];
|
|
|
$mainId = $this->mainId;
|
|
|
- $allDeliveries = DeliveryAuthTokenClass::getAllByCondition(['mainId'=>$mainId]);
|
|
|
- foreach($allDeliveries as $d){
|
|
|
+ $allDeliveries = DeliveryAuthTokenClass::getAllByCondition(['mainId' => $mainId]);
|
|
|
+ foreach ($allDeliveries as $d) {
|
|
|
$item = [
|
|
|
- 'id'=>$d['platform'],
|
|
|
- 'logo'=>$platformLogos[$d['platform']]['logo'],
|
|
|
- 'name'=>$platformLogos[$d['platform']]['name'],
|
|
|
+ 'id' => $d['platform'],
|
|
|
+ 'logo' => $platformLogos[$d['platform']]['logo'],
|
|
|
+ 'name' => $platformLogos[$d['platform']]['name'],
|
|
|
'is_authorized' => true,
|
|
|
- 'balance' => $d['balance']/100.0,
|
|
|
+ 'balance' => $d['balance'] / 100.0,
|
|
|
'access_type' => 'oauth'
|
|
|
];
|
|
|
$platformList[] = $item;
|
|
|
}
|
|
|
- util::success(['platformList'=>$platformList]);
|
|
|
+ util::success(['platformList' => $platformList]);
|
|
|
}
|
|
|
|
|
|
public function actionGetAuthUrl()
|
|
|
@@ -68,7 +69,7 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$Auth = new \common\components\delivery\services\AuthService();
|
|
|
$mainId = $this->mainId;
|
|
|
- switch($platform){
|
|
|
+ switch ($platform) {
|
|
|
case 'shansong':
|
|
|
$Auth->shansongAuth($mainId);
|
|
|
break;
|
|
|
@@ -101,28 +102,28 @@ class DeliveryController extends BaseController
|
|
|
// 有平台有对应的取消授权接口,有的没有。
|
|
|
// 有的就对接下,然后再删除数据。没有的直接删除数据就行。
|
|
|
$platform = Yii::$app->request->get('platform');
|
|
|
- $delivery = DeliveryAuthTokenClass::getByCondition(['mainId'=>$this->mainId, 'platform'=>$platform]);
|
|
|
- if($delivery) {
|
|
|
- if($platform == 'shansong') {
|
|
|
+ $delivery = DeliveryAuthTokenClass::getByCondition(['mainId' => $this->mainId, 'platform' => $platform]);
|
|
|
+ if ($delivery) {
|
|
|
+ if ($platform == 'shansong') {
|
|
|
$auth = new \common\components\delivery\platform\shansong\Auth();
|
|
|
$result = $auth->cancelAuthorization($delivery['accessToken']);
|
|
|
- if($result['success']) {
|
|
|
+ if ($result['success']) {
|
|
|
// 授权已取消
|
|
|
- }else{
|
|
|
- if($result['message'] == '商户未授权,请授权后再次尝试'){
|
|
|
+ } else {
|
|
|
+ if ($result['message'] == '商户未授权,请授权后再次尝试') {
|
|
|
Yii::info($this->mainId . '--商户未授权,请授权后再次尝试');
|
|
|
- }else{
|
|
|
- util::fail('取消授权失败:'.$result['message']);
|
|
|
+ } else {
|
|
|
+ util::fail('取消授权失败:' . $result['message']);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
util::fail('取消授权失败,数据未找到');
|
|
|
}
|
|
|
|
|
|
- $ret = DeliveryAuthTokenClass::deleteByCondition(['mainId'=>$this->mainId, 'platform'=>$platform]);
|
|
|
- if($ret > 0){
|
|
|
- util::success(['message'=>'取消授权成功']);
|
|
|
+ $ret = DeliveryAuthTokenClass::deleteByCondition(['mainId' => $this->mainId, 'platform' => $platform]);
|
|
|
+ if ($ret > 0) {
|
|
|
+ util::success(['message' => '取消授权成功']);
|
|
|
} else {
|
|
|
util::fail('取消授权失败');
|
|
|
}
|
|
|
@@ -133,7 +134,7 @@ class DeliveryController extends BaseController
|
|
|
public function actionHuolalaVehicle()
|
|
|
{
|
|
|
$mainId = $this->mainId;
|
|
|
- $authPlatforms = DeliveryAuthTokenClass::getByCondition(['mainId'=>$mainId, 'platform'=>'huolala']);
|
|
|
+ $authPlatforms = DeliveryAuthTokenClass::getByCondition(['mainId' => $mainId, 'platform' => 'huolala']);
|
|
|
$huolalaAdapter = new HuolalaAdapter($authPlatforms['access_token']);
|
|
|
$cities = $huolalaAdapter->getCityVehicleList(1006);
|
|
|
return $this->asJson($cities);
|
|
|
@@ -150,7 +151,7 @@ class DeliveryController extends BaseController
|
|
|
$newCitiesArr = [];
|
|
|
|
|
|
$citiesArr = $cities['data'];
|
|
|
- foreach($citiesArr as $block) {
|
|
|
+ foreach ($citiesArr as $block) {
|
|
|
foreach ($block['cities'] as $city) {
|
|
|
$newCitiesArr[$city['name']] = $city;
|
|
|
}
|
|
|
@@ -162,7 +163,7 @@ class DeliveryController extends BaseController
|
|
|
$newCitiesArr = [
|
|
|
'expire' => $cities['data']['expire'],
|
|
|
];
|
|
|
- foreach($citiesArr as $city) {
|
|
|
+ foreach ($citiesArr as $city) {
|
|
|
$newCitiesArr[$city['name']] = [
|
|
|
'city_id' => $city['city_id'],
|
|
|
'city_name' => $city['name'],
|
|
|
@@ -212,7 +213,7 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$ds = new DispatchService($this->mainId);
|
|
|
$platformQuotes = $ds->getAllPlatformPrice($order, $shop, $orderTime);
|
|
|
- if(isset($platformQuotes['error'])){
|
|
|
+ if (isset($platformQuotes['error'])) {
|
|
|
util::fail($platformQuotes['error']);
|
|
|
}
|
|
|
|
|
|
@@ -232,20 +233,23 @@ class DeliveryController extends BaseController
|
|
|
$form->loadAndValidate();
|
|
|
|
|
|
$post = $form->getAttributes();
|
|
|
- $orderId = $post['orderId']; // xhGhsOrder.id
|
|
|
- $params = $post['allParams'];
|
|
|
- $platform = $params['en_name'];// 平台英文名,$post['platform'] 是中文
|
|
|
- $pickupTime = $post['pickupTime'];
|
|
|
+ $orderId = $post['orderId'] ?? 0; // xhGhsOrder.id
|
|
|
+ $params = $post['allParams'] ?? '';
|
|
|
+ $platform = $params['en_name'] ?? '';// 平台英文名,$post['platform'] 是中文
|
|
|
+ if (empty($platform)) {
|
|
|
+ util::fail('请选择跑腿');
|
|
|
+ }
|
|
|
+ $pickupTime = $post['pickupTime'] ?? '';
|
|
|
|
|
|
$params['mainId'] = $this->mainId;
|
|
|
$params['ip'] = Yii::$app->request->userIP;
|
|
|
- $params['weight'] = $post['weight'];
|
|
|
- $params['remark'] = $post['remark'];
|
|
|
- $params['total_price_fen'] = $post['price'];
|
|
|
- $params['pickupTime'] = $pickupTime['value'];
|
|
|
+ $params['weight'] = $post['weight'] ?? 1;
|
|
|
+ $params['remark'] = $post['remark'] ?? '';
|
|
|
+ $params['total_price_fen'] = $post['price'] ?? 1;
|
|
|
+ $params['pickupTime'] = $pickupTime['value'] ?? '';
|
|
|
|
|
|
$ghsOrder = OrderClass::getById($orderId, true);
|
|
|
- if(!in_array($ghsOrder['sendStatus'], [-4, -1])) {
|
|
|
+ if (!in_array($ghsOrder['sendStatus'], [-4, -1])) {
|
|
|
Yii::error('订单已经发过跑腿');
|
|
|
util::fail('订单已经发过跑腿');
|
|
|
}
|
|
|
@@ -258,7 +262,7 @@ class DeliveryController extends BaseController
|
|
|
$ret = $ds->createOrder($ghsOrder, 'xhGhsOrder', $this->shopId, $params);
|
|
|
|
|
|
if (isset($ret['code']) && $ret['code'] == 0) {
|
|
|
- $gdo = GhsDeliveryOrderClass::getByCondition(['mainId'=>$this->mainId, 'orderId'=>$ret['data']['order_id']]);
|
|
|
+ $gdo = GhsDeliveryOrderClass::getByCondition(['mainId' => $this->mainId, 'orderId' => $ret['data']['order_id']]);
|
|
|
if (empty($gdo)) {
|
|
|
$data = [
|
|
|
'mainId' => $this->mainId,
|
|
|
@@ -284,7 +288,7 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
util::success($ret, "success");
|
|
|
} else {
|
|
|
- if(isset($ret['msg'])){
|
|
|
+ if (isset($ret['msg'])) {
|
|
|
util::fail($ret['msg']);
|
|
|
}
|
|
|
util::fail('创建跑腿失败');
|
|
|
@@ -309,8 +313,8 @@ class DeliveryController extends BaseController
|
|
|
$ret = $ds->selectOrder($orderId, $orderSn);
|
|
|
|
|
|
$return = isset($ret['ret']) ? $ret['ret'] : $ret['code']; // 各平台兼容处理
|
|
|
- if($return == 0) {
|
|
|
- util::success($ret, "success");
|
|
|
+ if ($return == 0) {
|
|
|
+ util::success($ret, "success");
|
|
|
}
|
|
|
util::fail('查询失败');
|
|
|
}
|
|
|
@@ -326,34 +330,34 @@ class DeliveryController extends BaseController
|
|
|
$ghsOrderId = $post['ghsOrderId'];
|
|
|
|
|
|
// 先获取配送订单,确保 $gdo 始终可用
|
|
|
- $gdo = GhsDeliveryOrderClass::getByCondition(['mainId'=>$this->mainId, 'ghsOrderId'=>$ghsOrderId, 'orderStatus!='=> -1], true);
|
|
|
- if(empty($gdo)) {
|
|
|
+ $gdo = GhsDeliveryOrderClass::getByCondition(['mainId' => $this->mainId, 'ghsOrderId' => $ghsOrderId, 'orderStatus!=' => -1], true);
|
|
|
+ if (empty($gdo)) {
|
|
|
util::fail('未找到对应订单: ' . $ghsOrderId);
|
|
|
}
|
|
|
|
|
|
// 如果没有提供平台和订单ID,从配送订单中获取
|
|
|
- if($platform == '' || $orderId == 0) {
|
|
|
- $orderId = $gdo->orderId;
|
|
|
- $platform = $gdo->deliveryId;
|
|
|
+ if ($platform == '' || $orderId == 0) {
|
|
|
+ $orderId = $gdo->orderId;
|
|
|
+ $platform = $gdo->deliveryId;
|
|
|
}
|
|
|
|
|
|
$ds = new DispatchService($this->mainId, $platform);
|
|
|
|
|
|
$cancelCostCent = 0;
|
|
|
- if($platform == 'fengniao') {
|
|
|
+ if ($platform == 'fengniao') {
|
|
|
//请求订单预取消接口,获取是否可取消。如果运单状态不允许取消,则直接返回
|
|
|
- $cancelParams = ['order_id'=>$orderId, 'order_cancel_code'=>$post['order_cancel_code']];
|
|
|
+ $cancelParams = ['order_id' => $orderId, 'order_cancel_code' => $post['order_cancel_code']];
|
|
|
$res = $ds->getAdapter()->preCancelOrder($cancelParams);
|
|
|
- if($res['code'] != 0){
|
|
|
+ if ($res['code'] != 0) {
|
|
|
util::fail('运单状态不允许取消');
|
|
|
}
|
|
|
$cancelCostCent = $res['data']['actual_cancel_cost_cent']; //取消实际需金额(单位:分)
|
|
|
}
|
|
|
- if($platform == 'shunfeng') {
|
|
|
+ if ($platform == 'shunfeng') {
|
|
|
//请求订单预取消接口,获取是否可取消。如果运单状态不允许取消,则直接返回
|
|
|
- $cancelParams = ['order_id'=>$orderId, 'order_cancel_code'=>$post['order_cancel_code']];
|
|
|
+ $cancelParams = ['order_id' => $orderId, 'order_cancel_code' => $post['order_cancel_code']];
|
|
|
$res = $ds->getAdapter()->preCancelOrder($cancelParams);
|
|
|
- if($res['code'] != 0){
|
|
|
+ if ($res['code'] != 0) {
|
|
|
util::fail('运单状态不允许取消');
|
|
|
}
|
|
|
$post['order_type'] = 1; //查询订单ID类型 1、顺丰订单号 2、商家订单号
|
|
|
@@ -361,11 +365,11 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$post['order_cancel_role'] = 1; //1:商户取消, 2:用户取消
|
|
|
$ret = $ds->cancelOrder($orderId, $post);
|
|
|
- if($ret['code'] == 0) {
|
|
|
+ if ($ret['code'] == 0) {
|
|
|
// 更新跑腿订单与批发订单状态
|
|
|
$gdo->orderStatus = -1;
|
|
|
$gdo->cancelCost = $ret['platform'] !== 'fengniao' ? $ret['data']['deductionFee'] : $cancelCostCent; // 由于蜂鸟平台返回的扣费不一样造成
|
|
|
- if(!$gdo->save()) {
|
|
|
+ if (!$gdo->save()) {
|
|
|
Yii::error('保存配送订单失败: ' . json_encode($gdo->errors));
|
|
|
util::fail('保存配送订单失败');
|
|
|
}
|
|
|
@@ -375,11 +379,11 @@ class DeliveryController extends BaseController
|
|
|
$ghsOrder->sendStatus = -1;
|
|
|
// $ghsOrder->deliveryId = ''; // 为了获取上一次的配送记录,不要置空
|
|
|
$ghsOrder->sendTip = 0;
|
|
|
- if(!$ghsOrder->save()) {
|
|
|
+ if (!$ghsOrder->save()) {
|
|
|
Yii::error('保存批发订单失败: ' . json_encode($ghsOrder->errors));
|
|
|
util::fail('保存批发订单失败');
|
|
|
}
|
|
|
- OrderClass::cancelOrderSend($ghsOrder, ['staffId'=>0, 'staffName'=>'']);
|
|
|
+ OrderClass::cancelOrderSend($ghsOrder, ['staffId' => 0, 'staffName' => '']);
|
|
|
|
|
|
util::success($ret['data'], "success");
|
|
|
}
|
|
|
@@ -396,8 +400,8 @@ class DeliveryController extends BaseController
|
|
|
$ghsOrderId = $post['ghsOrderId'];
|
|
|
$platform = $post['platform'];
|
|
|
|
|
|
- $gdo = GhsDeliveryOrderClass::getByCondition(['mainId'=>$this->mainId, 'ghsOrderId'=>$ghsOrderId, 'orderStatus!='=>-1], true);
|
|
|
- if(!empty($gdo)) {
|
|
|
+ $gdo = GhsDeliveryOrderClass::getByCondition(['mainId' => $this->mainId, 'ghsOrderId' => $ghsOrderId, 'orderStatus!=' => -1], true);
|
|
|
+ if (!empty($gdo)) {
|
|
|
$orderId = $gdo->orderId;
|
|
|
//$platform = $gdo->deliveryId;
|
|
|
} else {
|
|
|
@@ -406,10 +410,10 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$ds = new DispatchService($this->mainId, $platform);
|
|
|
$ret = $ds->getCancelReasonList($orderId);
|
|
|
- if($ret['code'] == 0){
|
|
|
+ if ($ret['code'] == 0) {
|
|
|
util::success($ret['data']);
|
|
|
- }else{
|
|
|
- Yii::error('获取订单取消原因:'.json_encode($ret));
|
|
|
+ } else {
|
|
|
+ Yii::error('获取订单取消原因:' . json_encode($ret));
|
|
|
util::fail($ret['msg']);
|
|
|
}
|
|
|
}
|
|
|
@@ -424,29 +428,29 @@ class DeliveryController extends BaseController
|
|
|
$platform = $post['platform'];
|
|
|
$tips = intval($post['tips']);
|
|
|
|
|
|
- if($tips < 0) {
|
|
|
+ if ($tips < 0) {
|
|
|
util::fail('小费金额至少为1元');
|
|
|
}
|
|
|
$tips *= 100;
|
|
|
|
|
|
- $gdo = GhsDeliveryOrderClass::getByCondition(['mainId'=>$this->mainId, 'ghsOrderId'=>$ghsOrderId, 'orderStatus'=>['in',[0,1,2,10]]], true);
|
|
|
- if($gdo == null){
|
|
|
+ $gdo = GhsDeliveryOrderClass::getByCondition(['mainId' => $this->mainId, 'ghsOrderId' => $ghsOrderId, 'orderStatus' => ['in', [0, 1, 2, 10]]], true);
|
|
|
+ if ($gdo == null) {
|
|
|
util::fail('当前配送状态无法加小费');
|
|
|
}
|
|
|
|
|
|
$ds = new DispatchService($this->mainId, $platform);
|
|
|
- $ret = $ds->addTip(['orderId'=>$gdo->orderId, 'tips'=>$tips]);
|
|
|
- if($ret['code'] == 0){
|
|
|
+ $ret = $ds->addTip(['orderId' => $gdo->orderId, 'tips' => $tips]);
|
|
|
+ if ($ret['code'] == 0) {
|
|
|
$gdo->tip = $tips + $gdo->tip;
|
|
|
$gdo->save();
|
|
|
|
|
|
$orderObj = OrderClass::getById($gdo->ghsOrderId, true, 'id,sendTip');
|
|
|
- $orderObj->sendTip = $tips/100 + $orderObj->sendTip;
|
|
|
+ $orderObj->sendTip = $tips / 100 + $orderObj->sendTip;
|
|
|
$orderObj->save();
|
|
|
|
|
|
util::success($ret['data']);
|
|
|
- }else{
|
|
|
- Yii::error('添加小费请求失败,请求数据是:'.json_encode($ret));
|
|
|
+ } else {
|
|
|
+ Yii::error('添加小费请求失败,请求数据是:' . json_encode($ret));
|
|
|
util::fail($ret['msg']);
|
|
|
}
|
|
|
}
|
|
|
@@ -491,11 +495,11 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$obj = new \common\components\delivery\platform\shansong\OrderStatusCallBack();
|
|
|
$ret = $obj->handle($callbackData);
|
|
|
- if($ret) {
|
|
|
- return $this->asJson(['status' => 200, 'msg' => 'OK', "data"=> null]);
|
|
|
+ if ($ret) {
|
|
|
+ return $this->asJson(['status' => 200, 'msg' => 'OK', "data" => null]);
|
|
|
} else {
|
|
|
Yii::error('闪送回调失败: ' . json_encode($callbackData, JSON_UNESCAPED_UNICODE));
|
|
|
- return $this->asJson(['status' => 200, 'msg' => '回调失败', "data"=> null]);
|
|
|
+ return $this->asJson(['status' => 200, 'msg' => '回调失败', "data" => null]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -514,9 +518,9 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
$fa = new \common\components\delivery\services\adapter\FengniaoAdapter();
|
|
|
$paramSign = $fa->generateSignature($param);
|
|
|
- if($paramSign == $callbackData['signature']){
|
|
|
+ if ($paramSign == $callbackData['signature']) {
|
|
|
$businessData = isset($callbackData['business_data']) ? $callbackData['business_data'] : '';
|
|
|
- if(empty($businessData)){
|
|
|
+ if (empty($businessData)) {
|
|
|
$this->asJson(['return_code' => -1, 'return_msg' => 'business data is empty']);
|
|
|
}
|
|
|
$businessData = json_decode($businessData, true);
|
|
|
@@ -524,7 +528,7 @@ class DeliveryController extends BaseController
|
|
|
$ret = $cbnObj->handle($businessData['callback_business_type'], $businessData['param']);
|
|
|
|
|
|
return $this->asJson(['return_code' => 0, 'return_msg' => 'OK']);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Yii::error('蜂鸟回调接口签名出错');
|
|
|
}
|
|
|
}
|
|
|
@@ -536,9 +540,9 @@ class DeliveryController extends BaseController
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
Yii::info('货拉拉回调接口post:' . json_encode($post, JSON_UNESCAPED_UNICODE), 'delivery');
|
|
|
-
|
|
|
+
|
|
|
$action = $post['action'] ?? '';
|
|
|
- if($action != 'order_update') {
|
|
|
+ if ($action != 'order_update') {
|
|
|
Yii::error('当前接口只处理货拉拉订单状态变更事件');
|
|
|
return $this->asJson(['return_code' => 0, 'msg' => '当前接口只处理货拉拉订单状态变更事件']);
|
|
|
}
|
|
|
@@ -547,16 +551,16 @@ class DeliveryController extends BaseController
|
|
|
unset($param['signature']);
|
|
|
$huolala = new \common\components\delivery\platform\huolala\Huolala();
|
|
|
$paramSign = $huolala->generateSignatureWithoutAppSecret($param); //注意:不用拼接secret,所有的参数都参与计算,包含空值。
|
|
|
- if($paramSign == $post['signature']){
|
|
|
+ if ($paramSign == $post['signature']) {
|
|
|
$cbh = new \common\components\delivery\platform\huolala\CallBackHandler();
|
|
|
$ret = $cbh->handler($post);
|
|
|
- if($ret) {
|
|
|
+ if ($ret) {
|
|
|
return $this->asJson(['serial_no' => $post['serial_no']]);
|
|
|
} else {
|
|
|
Yii::error('货拉拉回调失败: ' . json_encode($post, JSON_UNESCAPED_UNICODE));
|
|
|
return $this->asJson(['return_code' => -1, 'return_msg' => 'failed']);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Yii::error('蜂鸟回调接口签名出错');
|
|
|
return $this->asJson(['return_code' => -1, 'return_msg' => 'signature error']);
|
|
|
}
|
|
|
@@ -570,7 +574,7 @@ class DeliveryController extends BaseController
|
|
|
$post = Yii::$app->request->post();
|
|
|
$cbh = new \common\components\delivery\platform\shunfeng\CallBackHandler();
|
|
|
$ret = $cbh->handle($post);// 各回调处理
|
|
|
- if($ret) {
|
|
|
+ if ($ret) {
|
|
|
return $this->asJson(['error_code' => 0, 'error_msg' => 'success']);
|
|
|
} else {
|
|
|
Yii::error('顺丰回调失败: ' . json_encode($post, JSON_UNESCAPED_UNICODE));
|
|
|
@@ -580,6 +584,7 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------- 授权回调接口 ----------------------------------------------------------
|
|
|
+
|
|
|
/**
|
|
|
* 闪送授权回调接口
|
|
|
*/
|
|
|
@@ -633,7 +638,7 @@ class DeliveryController extends BaseController
|
|
|
$template = file_get_contents($templatePath);
|
|
|
}
|
|
|
if ($template === false || $template === '') {
|
|
|
- throw new \yii\web\HttpException(500, '返回h5页面不存在');
|
|
|
+ throw new \yii\web\HttpException(500, '返回h5页面不存在');
|
|
|
}
|
|
|
|
|
|
$content = strtr($template, [
|
|
|
@@ -653,7 +658,7 @@ class DeliveryController extends BaseController
|
|
|
*/
|
|
|
public function actionHuolalaAuthCallback()
|
|
|
{
|
|
|
- $get = Yii::$app->request->get();
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
$getData = json_encode($get, JSON_UNESCAPED_UNICODE);
|
|
|
Yii::info($getData);
|
|
|
$code = $get['code'];
|
|
|
@@ -713,7 +718,7 @@ class DeliveryController extends BaseController
|
|
|
Yii::info('蜂鸟授权回调:' . json_encode($callbackData, JSON_UNESCAPED_UNICODE), 'fengniao');
|
|
|
|
|
|
$get = Yii::$app->request->get();
|
|
|
- if(!isset($get['main_id'])){
|
|
|
+ if (!isset($get['main_id'])) {
|
|
|
Yii::error('蜂鸟授权回调的回调地址 authCallbackUrl 中没有带 main_id');
|
|
|
noticeUtil::push('蜂鸟授权回调的回调地址 authCallbackUrl 中没有带 main_id,回调数据:' . json_encode($callbackData, JSON_UNESCAPED_UNICODE), 'fengniao');
|
|
|
return;
|
|
|
@@ -737,9 +742,9 @@ class DeliveryController extends BaseController
|
|
|
$result = $result['data'];
|
|
|
|
|
|
$exist = DeliveryAuthTokenClass::exists(['mainId' => $mainId, 'platform' => 'fengniao']);
|
|
|
- if($exist){
|
|
|
+ if ($exist) {
|
|
|
noticeUtil::push("mainId=" . $mainId . ' 已成功授权了。如果蜂鸟不能正确使用,请查询数据库进行检查。');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 保存授权信息到数据库
|
|
|
$data = [
|
|
|
'mainId' => $mainId,
|
|
|
@@ -767,11 +772,11 @@ class DeliveryController extends BaseController
|
|
|
Yii::info($getData);
|
|
|
// {"sourceId":"1003654","ticket":"b8b4e56a86934b73a512ea9994e7774e","state":"huidiao_biaoshi","shopNo":"1003654-88547413"}
|
|
|
// 用merchanId 来保存 sourceId
|
|
|
- if($getData['state'] != 'huidiao_biaoshi'){
|
|
|
+ if ($getData['state'] != 'huidiao_biaoshi') {
|
|
|
Yii::error('达达授权回调 state 参数不对');
|
|
|
return;
|
|
|
}
|
|
|
- if(!isset($getData['mainId'])){
|
|
|
+ if (!isset($getData['mainId'])) {
|
|
|
Yii::error('达达授权回调缺少必要参数 mainId');
|
|
|
return;
|
|
|
}
|
|
|
@@ -790,7 +795,7 @@ class DeliveryController extends BaseController
|
|
|
];
|
|
|
DeliveryAuthTokenClass::add($data);
|
|
|
Yii::info('达达授权回调保存成功', 'dada');
|
|
|
- }catch(\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Yii::error('达达授权回调保存失败' . $e->getMessage(), 'dada');
|
|
|
}
|
|
|
}
|