Ver código fonte

发跑腿相关优化

shish 6 meses atrás
pai
commit
1d20a6bbfb

+ 21 - 4
app-ghs/controllers/OrderController.php

@@ -637,6 +637,10 @@ class OrderController extends BaseController
                                 }
                             }
                         }
+
+                        //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                        GhsDeliveryOrderClass::payAfter($order);
+
                         ShopExtClass::ghsGatheringReport($order);
                     }
                     util::success(['returnStatus' => 'SUCCESS']);
@@ -817,6 +821,10 @@ class OrderController extends BaseController
                             }
                         }
                     }
+
+                    //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                    GhsDeliveryOrderClass::payAfter($order);
+
                     ShopExtClass::ghsGatheringReport($order);
                 }
                 util::success(['returnStatus' => 'SUCCESS']);
@@ -1149,7 +1157,7 @@ class OrderController extends BaseController
             $post['bookSn'] = $bookSn;
         }
 
-        $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付(待付款) 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
+        $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
         $post['debt'] = OrderClass::DEBT_NO;
         if ($hasPay == dict::getDict('hasPay', 'debt')) {
             $post['debt'] = OrderClass::DEBT_YES;
@@ -1302,6 +1310,14 @@ class OrderController extends BaseController
             }
         }
 
+        $callErrand = $post['callErrand'] ?? 0;
+        if ($callErrand == 1) {
+            $shopExt = $this->shopExt;
+            if ($shopExt->orderFlow == 0) {
+                util::fail('下单后要变待发货,才能直接发跑腿');
+            }
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
@@ -1640,6 +1656,10 @@ class OrderController extends BaseController
                     }
                 }
             }
+
+            //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+            GhsDeliveryOrderClass::payAfter($order);
+
             if ($order->status != 1 && $order->status != 5) {
                 //花店采购供货商端APP收到通知
                 //NoticeClass::ghsNewOrderNotice($order);
@@ -1650,9 +1670,6 @@ class OrderController extends BaseController
 //                $push->ghsOrderMessage($shop, $cgShop, $order);
             }
 
-            if ($order->sendType == 2 && $order->payStatus == 1) {
-                GhsDeliveryOrderClass::payAfter($order);// 付款成功之后呼叫跑腿
-            }
         }
 
         util::complete();

+ 10 - 16
app-hd/controllers/NoticeController.php

@@ -155,10 +155,8 @@ class NoticeController extends PublicController
                 $saleId = $cg->saleId ?? 0;
                 $order = OrderClass::getById($saleId, true);
 
-                if(!empty($order)  && $order->sendType == 2 && $order->payStatus == 1) {
-                    //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                    GhsDeliveryOrderClass::payAfter($order);
-                }
+                //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                GhsDeliveryOrderClass::payAfter($order);
 
                 //不是预订单,并且供货商不是源花汇、小明鲜花、淄博花超、云漫梦金鹏、海翔,则订单直接完成掉。是预订单,则确认发货时直接完成掉。有多个地方要修改,请搜索关键词zjFinish
                 if (!empty($cg) && !empty($order)) {
@@ -372,10 +370,8 @@ class NoticeController extends PublicController
                 $saleId = $cg->saleId ?? 0;
                 $order = OrderClass::getById($saleId, true);
 
-                if(!empty($order) && $order->sendType == 2 && $order->payStatus == 1) {
-                    //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                    GhsDeliveryOrderClass::payAfter($order);
-                }
+                //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                GhsDeliveryOrderClass::payAfter($order);
 
                 //不是预订单,并且供货商不是源花汇、小明鲜花、淄博花超、云漫梦金鹏、海翔、镜中花卉,则订单直接完成掉。是预订单,则确认发货时直接完成掉。有多个地方要修改,请搜索关键词zjFinish
                 if (!empty($cg) && !empty($order)) {
@@ -587,10 +583,9 @@ class NoticeController extends PublicController
                     $saleId = $cg->saleId ?? 0;
                     $order = OrderClass::getById($saleId, true);
                     if (!empty($order)) {
-                        if($order->sendType == 2 && $order->payStatus == 1) {
-                            //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                            GhsDeliveryOrderClass::payAfter($order);
-                        }
+
+                        //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                        GhsDeliveryOrderClass::payAfter($order);
 
                         //订单生成时唤起在线打印
                         if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
@@ -837,10 +832,9 @@ class NoticeController extends PublicController
                         $saleId = $cg->saleId ?? 0;
                         $order = OrderClass::getById($saleId, true);
                         if (!empty($order)) {
-                            if($order->sendType == 2 && $order->payStatus == 1) {
-                                //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                                GhsDeliveryOrderClass::payAfter($order);
-                            }
+
+                            //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                            GhsDeliveryOrderClass::payAfter($order);
 
                             //订单生成时唤起在线打印
                             if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {

+ 18 - 0
app-hd/controllers/OrderController.php

@@ -78,6 +78,10 @@ class OrderController extends BaseController
             }
 
             $transaction->commit();
+
+            //付款成功了,通知发跑腿功能,关键词 hd_pay_after_call_pt,多处要同步修改
+            HdDeliveryOrderClass::payAfter($info);
+
             util::complete('赊账成功');
         } catch (\Exception $exception) {
             $transaction->rollBack();
@@ -393,6 +397,8 @@ class OrderController extends BaseController
                             $newOrder->save();
                         }
 
+                        HdDeliveryOrderClass::payAfter($newOrder);
+
                         $shopId = $newOrder->shopId ?? 0;
                         $shop = ShopClass::getById($shopId, true);
                         WxMessageClass::gatheringIncomeInform($shop, $newOrder);
@@ -539,6 +545,9 @@ class OrderController extends BaseController
 
                     //打印小票
                     OrderClass::onlinePrint($newOrder);
+
+                    HdDeliveryOrderClass::payAfter($newOrder);
+
                     //语音播报
                     ShopExtClass::hdGatheringReport($newOrder);
                     $shopId = $newOrder->shopId ?? 0;
@@ -701,6 +710,15 @@ class OrderController extends BaseController
             $productList = [['productId' => $zjGatheringItem, 'unitType' => 0, 'num' => 1, 'property' => '1', 'unitPrice' => $lsGoodsPrice]];
         }
 
+        $callErrand = $post['callErrand'] ?? 0;
+        if ($callErrand == 1) {
+            $shopId = $this->shopId;
+            $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+            if (!empty($shopExt) && $shopExt->orderFlow == 0) {
+                util::fail('下单后要变待发货,才能直接发跑腿');
+            }
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {

+ 3 - 4
app-hd/controllers/PurchaseController.php

@@ -756,10 +756,6 @@ class PurchaseController extends BaseController
             $saleId = $info->saleId ?? 0;
             $order = OrderClass::getById($saleId, true);
             if (!empty($order)) {
-                //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                if ($order->sendType == 2 && $order->payStatus == 1) {
-                    GhsDeliveryOrderClass::payAfter($order);
-                }
 
                 $shopId = $order->shopId ?? 0;
                 $shop = ShopClass::getById($shopId, true);
@@ -800,6 +796,9 @@ class PurchaseController extends BaseController
                     }
                 }
 
+                //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
+                GhsDeliveryOrderClass::payAfter($order);
+
                 //更新最后下单时间
                 $customId = $order->customId ?? 0;
                 $custom = CustomClass::getById($customId, true);

+ 5 - 3
app-mall/controllers/NoticeController.php

@@ -171,9 +171,7 @@ class NoticeController extends PublicController
                         OrderClass::onlinePrint($order);
 
                         //付款成功了,通知发跑腿功能,关键词 hd_pay_after_call_pt,多处要同步修改
-                        if ($order->sendType == 2) {
-                            HdDeliveryOrderClass::payAfter($order);
-                        }
+                        HdDeliveryOrderClass::payAfter($order);
 
                         $shopId = $order->shopId ?? 0;
                         $shop = ShopClass::getById($shopId, true);
@@ -513,6 +511,10 @@ class NoticeController extends PublicController
                             $order->thirdLogNo = $thirdLogNo;
                             $order->save();
                             OrderClass::onlinePrint($order);
+
+                            //付款成功了,通知发跑腿功能,关键词 hd_pay_after_call_pt,多处要同步修改
+                            HdDeliveryOrderClass::payAfter($order);
+
                             $shopId = $order->shopId ?? 0;
                             $shop = ShopClass::getById($shopId, true);
                             //来自商城的新订单微信通知

+ 1 - 3
app-mall/controllers/OrderController.php

@@ -861,9 +861,7 @@ class OrderController extends BaseController
                     \bizHd\order\classes\OrderClass::onlinePrint($order);
 
                     //付款成功了,通知发跑腿功能,关键词 hd_pay_after_call_pt,多处要同步修改
-                    if ($order->sendType == 2) {
-                        HdDeliveryOrderClass::payAfter($order);
-                    }
+                    HdDeliveryOrderClass::payAfter($order);
 
                     $shopId = $order->shopId ?? 0;
                     $shop = ShopClass::getById($shopId, true);

+ 18 - 10
biz-ghs/express/classes/GhsDeliveryOrderClass.php

@@ -18,6 +18,15 @@ class GhsDeliveryOrderClass extends BaseClass
 
     public static function payAfter($order)
     {
+        if (empty($order)) {
+            return false;
+        }
+        if ($order->sendType != 2) {
+            return false;
+        }
+        if ($order->payStatus != 1) {
+            return false;
+        }
         $orderId = $order->id;
         $shopId = $order->shopId;
         try {
@@ -46,7 +55,7 @@ class GhsDeliveryOrderClass extends BaseClass
                 ];
                 self::askCreateOrder($data);
             } else {
-                noticeUtil::push("批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
+                //noticeUtil::push("批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
                 // 发送 app 通知
                 // $title = '发跑腿失败';
                 // $msg = "批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}";
@@ -54,12 +63,13 @@ class GhsDeliveryOrderClass extends BaseClass
                 // $cids = array_column($allDevices, 'clientId');
                 // $push = new push('ghs', push::MSG_TYPE_WORK);
                 // $push->pushByCloud($cids, $title, $msg, []);
-                return;
+                return false;
             }
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "批发,付款成功之后要发跑腿的订单,报错 {$orderId} {$msg}";
             noticeUtil::push($remind);
+            return false;
         }
     }
 
@@ -71,19 +81,17 @@ class GhsDeliveryOrderClass extends BaseClass
             $saleId = $order->id;
 
             if ($callErrand == 1) { // 是否立即发跑腿 1:是 0:否
-                $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付(待付款) 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
-
-                if ($hasPay == dict::getDict('hasPay', 'unPay')) { // 0:扫码付(待付款)
+                $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
+                if ($hasPay == dict::getDict('hasPay', 'unPay')) { // 0:扫码付
                     $deliveryPlatform = $post['deliveryPlatform'];
                     $expireTime = 0;
-                    if($deliveryPlatform == 'shansong'){
+                    if ($deliveryPlatform == 'shansong') {
                         $expireTime = 1800 - 60;
-                    }elseif($deliveryPlatform == 'didi'){
+                    } elseif ($deliveryPlatform == 'didi') {
                         $expireTime = 7200;
-                    }else{
+                    } else {
                         $expireTime = 7200; // 默认缓存时长2小时
-                    } 
-
+                    }
                     // 把跑腿数据缓存到 redis 中,等待付款成功后,再发跑腿订单
                     $cacheKey = 'ghs_pt_cacheData:' . $saleId;
                     Yii::$app->redis->set($cacheKey, json_encode($post, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));

+ 10 - 5
biz-hd/express/classes/HdDeliveryOrderClass.php

@@ -17,6 +17,12 @@ class HdDeliveryOrderClass extends BaseClass
 
     public static function payAfter($order)
     {
+        if(empty($order)){
+            return false;
+        }
+        if($order->sendType != 2){
+            return false;
+        }
         $orderId = $order->id;
         $shopId = $order->shopId;
         try {
@@ -43,7 +49,7 @@ class HdDeliveryOrderClass extends BaseClass
                 ];
                 self::askCreateOrder($data);
             } else {
-                noticeUtil::push("零售-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
+                //noticeUtil::push("零售-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
                 // 发送 app 通知
                 // $title = '发跑腿失败';
                 // $msg = "零售-缓存数据不存在或已过期,cacheKey:{$cacheKey}";
@@ -51,8 +57,7 @@ class HdDeliveryOrderClass extends BaseClass
                 // $cids = array_column($allDevices, 'clientId');
                 // $push = new push('hd', push::MSG_TYPE_WORK);
                 // $push->pushByCloud($cids, $title, $msg, []);
-
-                return;
+                return false;
             }
         } catch (\Exception $e) {
             $msg = $e->getMessage();
@@ -70,8 +75,8 @@ class HdDeliveryOrderClass extends BaseClass
             $callErrand = $post['callErrand']; // 是否立即发跑腿 1:是 0:否
 
             if ($callErrand == 1) {
-                $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付(待付款) 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
-                if ($hasPay == dict::getDict('hasPay', 'unPay')) { // 0:扫码付(待付款)
+                $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式  0:扫码付 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
+                if ($hasPay == dict::getDict('hasPay', 'unPay')) { // 0:扫码付
                     $deliveryPlatform = $post['deliveryPlatform'];
                     $expireTime = 0;
                     if($deliveryPlatform == 'shansong'){