Browse Source

预订变化下架花材

shish 2 years ago
parent
commit
19cf765cdd

+ 6 - 1
biz-ghs/notify/classes/NotifyClass.php

@@ -40,7 +40,7 @@ class NotifyClass extends BaseClass
                     'type' => 2,
                     'targetId' => $id,
                     'read' => 0,
-                    'content' => '预订减少,请下架' . $customName . '(' . $seatSn . ')' . $itemName . $num .'份',
+                    'content' => '预订减少,请下架' . $customName . '(' . $seatSn . ')' . $itemName . $num . '份',
                     'page' => '/admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName,
                 ];
                 self::add($data);
@@ -49,6 +49,11 @@ class NotifyClass extends BaseClass
                 $staff->save();
             }
         }
+        if ($num > 0) {
+            $noticeText = json_encode(['id' => $id, 'num' => $num, 'shopId' => $shopId]);
+            $noticeKey = "bookChangeOffItem";
+            Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+        }
     }
 
     //新增售后申请通过 ssh 20230814

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

@@ -1346,4 +1346,47 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //预订变化通知供货商员工下架花材 ssh 20240729
+    public static function bookChangeOutStockInform($shop, $bookItemCustomRes, $num)
+    {
+        $ptStyle = $shop->ptStyle;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        //取货提醒
+        $shortTempId = 'ZHH202407100108';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $adminList = ShopAdminClass::getRemainAdmin($shop);
+        if (empty($adminList)) {
+            return false;
+        }
+        $itemId = $bookItemCustomRes->itemId ?? 0;
+        $itemName = $bookItemCustomRes->name ?? '';
+        $customName = $bookItemCustomRes->customName ?? '';
+        $seatSn = $bookItemCustomRes->seatSn ?? 0;
+        $seatName = empty($seatSn) ? '' : '货位号' . $seatSn;
+        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" => [
+                    "thing8" => ["value" => $customName],
+                    "thing10" => ["value" => $seatName],
+                    "thing7" => ["value" => $itemName . ' ' . $num . '份'],
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName;
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
 }

+ 21 - 0
console/controllers/MqController.php

@@ -2,6 +2,7 @@
 
 namespace console\controllers;
 
+use bizGhs\book\classes\BookItemCustomClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\shop\classes\ShopClass;
 use biz\wx\classes\WxMessageClass;
@@ -12,6 +13,26 @@ use Yii;
 class MqController extends Controller
 {
 
+    //预订变化下架花材 ssh 20240729
+    public function actionBookChangeOutStock()
+    {
+        $noticeKey = "bookChangeOffItem";
+        while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
+            $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
+            if (!empty($json)) {
+                $arr = json_decode($json, true);
+                $id = $arr['id'] ?? 0;
+                $num = $arr['num'] ?? 0;
+                $shopId = $arr['shopId'] ?? 0;
+                $res = BookItemCustomClass::getById($id, true);
+                if (!empty($res)) {
+                    $shop = \biz\shop\classes\ShopClass::getById($shopId, true);
+                    WxMessageClass::bookChangeOutStockInform($shop, $res, $num);
+                }
+            }
+        }
+    }
+
     //花店采购通知供货商 ssh 20230805
     public function actionHdCgNoticeGhs()
     {