Bladeren bron

预订变更通知

shish 1 jaar geleden
bovenliggende
commit
d43c9d8b19
3 gewijzigde bestanden met toevoegingen van 77 en 0 verwijderingen
  1. 9 0
      biz-ghs/book/classes/BookItemClass.php
  2. 49 0
      biz/wx/classes/WxMessageClass.php
  3. 19 0
      console/controllers/MqController.php

+ 9 - 0
biz-ghs/book/classes/BookItemClass.php

@@ -198,6 +198,10 @@ class BookItemClass extends BaseClass
             $bookItemRes->save();
             $bookCustomRes->save();
             util::unlock($cacheKey);
+
+            $noticeText = json_encode(['orderId' => $orderId,'customName'=>$customName,'customId'=>$customId,'itemId'=>$itemId,'itemName'=>$name,'io'=>0,'num'=>$num,'shopId'=>$shopId]);
+            $noticeKey = "bookChangeNoticeStaff";
+            Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
         }
     }
 
@@ -346,6 +350,11 @@ class BookItemClass extends BaseClass
             //添加到缓存,所有待入库采购单重新找货位号
             $cacheKey = 'assign_seat_main_book_sn_list';
             Yii::$app->redis->executeCommand('SADD', [$cacheKey, $bookSn]);
+
+            //预订变化通知
+            $noticeText = json_encode(['orderId' => $orderId,'customName'=>$customName,'customId'=>$customId,'itemId'=>$itemId,'itemName'=>$name,'io'=>1,'num'=>$num,'shopId'=>$shopId]);
+            $noticeKey = "bookChangeNoticeStaff";
+            Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
         }
     }
 

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

@@ -510,6 +510,55 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //预订增加减少通知 ssh 20240820
+    public static function bookChangeInform($shop, $arr)
+    {
+        $orderId = $arr['orderId']??0;
+        $ptStyle = $shop->ptStyle;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM417875155';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $itemName = $arr['itemName']??'';
+        $io = $arr['io']??0;
+        $plus = $io == 1 ? '+' : '-';
+        $num = $arr['num']??0;
+        $title = $itemName.' '.$plus.$num;
+        $customName = $arr['customName'] ?? '';
+        $customName = stringUtil::subStringUtf8($customName, 5, '...');
+
+        $adminList = ShopAdminClass::getRemainAdmin($shop);
+        if (empty($adminList)) {
+            return false;
+        }
+
+        foreach ($adminList as $admin) {
+            $openId = isset($admin['openId']) ? $admin['openId'] : '';
+            if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+                $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
+            }
+            $data = [
+                "touser" => $openId,
+                "template_id" => $tempId,
+                "url" => Yii::$app->params['ghsDomain'],
+                "data" => [
+                    "first" => ["value" => '', "color" => "#173177"],
+                    "keyword1" => ["value" => $title, "color" => "#173177"],
+                    "keyword2" => ["value" => $customName, "color" => "#173177"],
+                    "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+                    "remark" => ["value" => "点击查看详情", "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
     //花店新采购单通知 ssh 20231128
     public static function hdNewCgOrderInform($shop, $cg)
     {

+ 19 - 0
console/controllers/MqController.php

@@ -55,6 +55,25 @@ class MqController extends Controller
         }
     }
 
+    //预订增加减少通知 ssh 20240820
+    public function actionBookChangeNotice()
+    {
+        $noticeKey = "bookChangeNoticeStaff";
+        while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
+            $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
+            if (!empty($json)) {
+                $arr = json_decode($json, true);
+                $shopId = $arr['shopId'] ?? 0;
+                if (!empty($orderId)) {
+                    $shop = ShopClass::getById($shopId, true);
+                    if (!empty($shop)) {
+                        WxMessageClass::bookChangeInform($shop, $arr);
+                    }
+                }
+            }
+        }
+    }
+
     //供货商开单通知花店 ssh 20231129
     public function actionGhsKdNoticeHd()
     {