Explorar el Código

Merge branch 'dev' of http://git.huaml.com/zhh/huahuibao into dev

shish hace 6 meses
padre
commit
26e065e75b

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

@@ -1649,6 +1649,10 @@ class OrderController extends BaseController
 //                $push = new push('ghs', push::MSG_TYPE_ORDER);
 //                $push->ghsOrderMessage($shop, $cgShop, $order);
             }
+
+            if ($order->sendType == 2 && $order->status == 2) { //订单状态 2待配送
+                GhsDeliveryOrderClass::payAfter($order);// 付款成功之后呼叫跑腿
+            }
         }
 
         util::complete();

+ 2 - 2
app-hd/controllers/NoticeController.php

@@ -155,7 +155,7 @@ class NoticeController extends PublicController
                 $saleId = $cg->saleId ?? 0;
                 $order = OrderClass::getById($saleId, true);
 
-                if(!empty($order)){
+                if(!empty($order)  && $order->sendType == 2 && $order->status == 2) {
                     //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
                     GhsDeliveryOrderClass::payAfter($order);
                 }
@@ -372,7 +372,7 @@ class NoticeController extends PublicController
                 $saleId = $cg->saleId ?? 0;
                 $order = OrderClass::getById($saleId, true);
 
-                if(!empty($order)){
+                if(!empty($order) && $order->sendType == 2 && $order->status == 2) { //订单状态 2待配送
                     //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
                     GhsDeliveryOrderClass::payAfter($order);
                 }

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

@@ -756,9 +756,10 @@ class PurchaseController extends BaseController
             $saleId = $info->saleId ?? 0;
             $order = OrderClass::getById($saleId, true);
             if (!empty($order)) {
-
                 //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
-                GhsDeliveryOrderClass::payAfter($order);
+                if ($order->sendType == 2 && $order->status == 2) {
+                    GhsDeliveryOrderClass::payAfter($order);
+                }
 
                 $shopId = $order->shopId ?? 0;
                 $shop = ShopClass::getById($shopId, true);

+ 22 - 3
biz-ghs/express/classes/GhsDeliveryOrderClass.php

@@ -6,6 +6,7 @@ use bizGhs\base\classes\BaseClass;
 use bizGhs\order\classes\OrderClass;
 use common\components\delivery\services\DispatchService;
 use common\components\dict;
+use common\components\push;
 use mikemadisonweb\rabbitmq\components\ConsumerInterface;
 use common\components\noticeUtil;
 use Yii;
@@ -18,6 +19,7 @@ class GhsDeliveryOrderClass extends BaseClass
     public static function payAfter($order)
     {
         $orderId = $order->id;
+        $shopId = $order->shopId;
         try {
             noticeUtil::push('批发,付款成功之后要发跑腿的订单:' . $orderId, '15280215347');
             $cacheKey = 'ghs_pt_cacheData:' . $orderId;
@@ -27,7 +29,7 @@ class GhsDeliveryOrderClass extends BaseClass
 
                 $data = [
                     'orderId' => $orderId,
-                    'shopId' => $order->shopId,
+                    'shopId' => $shopId,
                     'mainId' => $order->mainId,
                     'platform' => $cachedData['deliveryPlatform'],
                     'ip' => '127.0.0.1',
@@ -36,15 +38,22 @@ class GhsDeliveryOrderClass extends BaseClass
                     'deliveryBracketContent' => $cachedData['deliveryBracketContent'],
                     'pickupTime' => $cachedData['pickupTime'],
                     'allParams' => $cachedData['deliveryAllParams'],
+                    // ----------
                     'weight' => $cachedData['weight'] ?? 1,
                     'remark' => $cachedData['deliveryRemark'] ?? '',
                     'price' => $order->actPrice,
+                    'consumerType' => '扫码付款'
                 ];
                 self::askCreateOrder($data);
             } else {
                 noticeUtil::push("批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
                 // 发送 app 通知
-                
+                $title = '发跑腿失败';
+                $msg = "批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}";
+                $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId' => $shopId]);
+                $cids = array_column($allDevices, 'clientId');
+                $push = new push('ghs', push::MSG_TYPE_WORK);
+                $push->pushByCloud($cids, $title, $msg, []);
                 return;
             }
         } catch (\Exception $e) {
@@ -76,7 +85,7 @@ class GhsDeliveryOrderClass extends BaseClass
                     } 
 
                     // 把跑腿数据缓存到 redis 中,等待付款成功后,再发跑腿订单
-                    $cacheKey = 'ghs_pt_orderId hd_pt_' . $saleId;
+                    $cacheKey = 'ghs_pt_cacheData:' . $saleId;
                     Yii::$app->redis->set($cacheKey, json_encode($post, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
                     Yii::$app->redis->expire($cacheKey, $expireTime);
                 } else {
@@ -104,6 +113,7 @@ class GhsDeliveryOrderClass extends BaseClass
                             'weight' => $post['weight'] ?? 1,
                             'remark' => $post['deliveryRemark'] ?? '',
                             'price' => $order->actPrice,
+                            'consumerType' => '已付款'
                         ];
                         self::askCreateOrder($data);
                     }
@@ -253,6 +263,15 @@ class GhsDeliveryOrderClass extends BaseClass
         } catch (\Exception $e) {
             Yii::error("ghs-orderId={$orderId}, 创建跑腿失败:" . $e->getMessage());
             noticeUtil::push("ghs-orderId={$orderId}, 创建跑腿失败:" . $e->getMessage());
+
+            // 发 App 通知
+            $title = '发跑腿失败';
+            $msg = "批发订单:{$orderId}, 创建跑腿失败:" . $e->getMessage();
+            $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId' => $shopId]);
+            $cids = array_column($allDevices, 'clientId');
+            $push = new push('ghs', push::MSG_TYPE_WORK);
+            $push->pushByCloud($cids, $title, $msg, []);
+
             return ConsumerInterface::MSG_REJECT;
         }
     }

+ 20 - 1
biz-hd/express/classes/HdDeliveryOrderClass.php

@@ -7,6 +7,7 @@ use bizHd\order\classes\OrderClass;
 use common\components\delivery\services\DispatchService;
 use common\components\dict;
 use common\components\noticeUtil;
+use common\components\push;
 use mikemadisonweb\rabbitmq\components\ConsumerInterface;
 use Yii;
 
@@ -17,6 +18,7 @@ class HdDeliveryOrderClass extends BaseClass
     public static function payAfter($order)
     {
         $orderId = $order->id;
+        $shopId = $order->shopId;
         try {
             noticeUtil::push('零售,付款成功之后要发跑腿的订单:' . $orderId, '15280215347');
             $cacheKey = 'hd_pt_cacheData:' . $orderId;
@@ -42,6 +44,14 @@ class HdDeliveryOrderClass extends BaseClass
                 self::askCreateOrder($data);
             } else {
                 noticeUtil::push("零售-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
+                // 发送 app 通知
+                $title = '发跑腿失败';
+                $msg = "零售-缓存数据不存在或已过期,cacheKey:{$cacheKey}";
+                $allDevices = \bizHd\device\classes\HdDeviceClass::getAllByCondition(['shopId' => $shopId]);
+                $cids = array_column($allDevices, 'clientId');
+                $push = new push('hd', push::MSG_TYPE_WORK);
+                $push->pushByCloud($cids, $title, $msg, []);
+
                 return;
             }
         } catch (\Exception $e) {
@@ -71,7 +81,7 @@ class HdDeliveryOrderClass extends BaseClass
                     }else{
                         $expireTime = 7200; // 默认缓存时长2小时
                     }
-                    $cacheKey = 'hd_pt_orderId hd_pt_' . $orderId;
+                    $cacheKey = 'hd_pt_cacheData:' . $orderId;
                     Yii::$app->redis->set($cacheKey, json_encode($post, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
                     Yii::$app->redis->expire($cacheKey, $expireTime);
                 } else {
@@ -238,6 +248,15 @@ class HdDeliveryOrderClass extends BaseClass
         } catch (\Exception $e) {
             Yii::error("hd-orderId={$orderId} 创建跑腿失败:" . $e->getMessage());
             noticeUtil::push("hd-orderId={$orderId} 创建跑腿失败:" . $e->getMessage());
+
+            // 发 App 通知
+            $title = '发跑腿失败';
+            $msg = "零售订单:{$orderId}, 创建跑腿失败:" . $e->getMessage();
+            $allDevices = \bizHd\device\classes\HdDeviceClass::getAllByCondition(['shopId' => $shopId]);
+            $cids = array_column($allDevices, 'clientId');
+            $push = new push('hd', push::MSG_TYPE_WORK);
+            $push->pushByCloud($cids, $title, $msg, []);
+            
             return ConsumerInterface::MSG_REJECT;
         }
     }