shish 5 лет назад
Родитель
Сommit
01ea282331
2 измененных файлов с 46 добавлено и 1 удалено
  1. 5 1
      biz-ghs/order/services/OrderService.php
  2. 41 0
      biz/wx/classes/WxMessageClass.php

+ 5 - 1
biz-ghs/order/services/OrderService.php

@@ -153,7 +153,7 @@ class OrderService extends BaseService
             }
         }
         $shopId = $order->shopId ?? 0;
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
@@ -162,6 +162,10 @@ class OrderService extends BaseService
         self::finish($order, $shop);
 
         OrderSendClass::reach($order);
+
+        //模板消息通知
+        WxMessageClass::reachInform($shop, $order);
+
     }
 
     //订单完成

+ 41 - 0
biz/wx/classes/WxMessageClass.php

@@ -397,4 +397,45 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //订单送达通知 shish 20210607
+    public static function reachInform($shop, $order)
+    {
+        $shopId = $shop->id;
+        $ptStyle = $shop->ptStyle;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM201205968';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $orderId = $order->id ?? '';
+        $orderSn = (string)$order->orderSn ?? '';
+        $customName = $order->customName ?? '';
+        $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        foreach ($adminList as $admin) {
+            if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
+                continue;
+            }
+            $openId = isset($admin['openId']) ? $admin['openId'] : '';
+            $data = [
+                "touser" => $openId,
+                "template_id" => $tempId,
+                "url" => Yii::$app->params['ghsDomain'],
+                "data" => [
+                    "first" => ["value" => '客户订单已送达', "color" => "#173177"],
+                    "keyword1" => ["value" => $orderSn, "color" => "#173177"],
+                    "keyword2" => ["value" => $customName, "color" => "#173177"],
+                    "keyword3" => ["value" => '已送达', "color" => "#173177"],
+                    "remark" => ["value" => '。。。。。。。', "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
+
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
 }