Pārlūkot izejas kodu

新订单通知

shish 5 gadi atpakaļ
vecāks
revīzija
5c043fc6f6

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

@@ -7,6 +7,7 @@ use biz\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\models\Shop;
+use biz\wx\classes\WxMessageClass;
 use bizGhs\base\services\BaseService;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\models\Custom;
@@ -509,6 +510,10 @@ class OrderService extends BaseService
             self::withoutSend($order);
         }
 
+        if ($isPurchase) {
+            WxMessageClass::newOrderNotice($shop, $order);
+        }
+
     }
 
 }

+ 32 - 14
biz/shop/classes/ShopAdminClass.php

@@ -86,7 +86,7 @@ class ShopAdminClass extends BaseClass
     //取店长 ssh 2021.1.8
     public static function getManager($shopId)
     {
-        $relate = self::getByCondition(['shopId' => $shopId,'super'=>1]);
+        $relate = self::getByCondition(['shopId' => $shopId, 'super' => 1]);
         $adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
         $info = [];
         if (!empty($adminId)) {
@@ -214,30 +214,48 @@ class ShopAdminClass extends BaseClass
     //根据shopId 获取 员工的shopAdminId
 
 
-
     //通过shopId 获取相应的需要通知的 shopAdminIds (status=1 and delStatus=0 and remind=1)
     public static function getRemindShopAdminIdsByShopId($shopId)
     {
         $where = [
-            'shopId'=>$shopId,
-            'status'=>1,
-            'delStatus'=>0,
-            'remind'=>1
+            'shopId' => $shopId,
+            'status' => 1,
+            'delStatus' => 0,
+            'remind' => 1
         ];
-        $data = self::getAllByCondition($where,null,"id");
-        return array_column($data,'id');
+        $data = self::getAllByCondition($where, null, "id");
+        return array_column($data, 'id');
     }
 
     //通过shopId 获取相应的需要通知的 adminIds (status=1 and delStatus=0 and remind=1)
     public static function getRemindAdminIdsByShopId($shopId)
     {
         $where = [
-            'shopId'=>$shopId,
-            'status'=>1,
-            'delStatus'=>0,
-            'remind'=>1
+            'shopId' => $shopId,
+            'status' => 1,
+            'delStatus' => 0,
+            'remind' => 1
+        ];
+        $data = self::getAllByCondition($where, null, "adminId");
+        return array_column($data, 'adminId');
+    }
+
+    //获取需要通知的员工 shish 20210529
+    public static function getRemainAdmin($shopId)
+    {
+        $where = [
+            'shopId' => $shopId,
+            'status' => 1,
+            'delStatus' => 0,
+            'remind' => 1
         ];
-        $data = self::getAllByCondition($where,null,"adminId");
-        return array_column($data,'adminId');
+        $shopAdmin = self::getAllByCondition($where, null, 'adminId');
+        if (empty($shopAdmin)) {
+            return [];
+        }
+        $ids = array_column($shopAdmin, 'adminId');
+        $admin = AdminClass::getByIds($ids);
+        return $admin;
     }
+
 }

+ 0 - 57
biz/tm/classes/TMessageClass.php

@@ -1,67 +1,10 @@
 <?php
 namespace biz\tm\classes;
 
-
-use biz\admin\classes\AdminClass;
 use biz\base\classes\BaseClass;
-use biz\shop\classes\ShopAdminClass;
-use bizHd\wx\classes\WxOpenClass;
-use Yii;
 class TMessageClass extends BaseClass
 {
 
     public static $baseFile = '\biz\tm\models\TMessage';
 
-
-    //供货商开单后, 其他员工和客户收下单通知  linqh 2021.5.14
-    //员工打开的是供货商的订单详情页
-    //客户打卡的是零售端的采购订单详情页
-    //https://mp.weixin.qq.com/advanced/tmplmsg?action=tmpl_preview&t=tmplmsg/preview&id=OPENTM417768700&token=1127184201&lang=zh_CN
-    /*
-     *
-    {{first.DATA}}
-    订购数量:{{keyword1.DATA}}
-    支付金额:{{keyword2.DATA}}
-    支付方式:{{keyword3.DATA}}
-    下单时间:{{keyword4.DATA}}
-    配送地址:{{keyword5.DATA}}
-    {{remark.DATA}}
-     */
-    public static function orderTMNotice($order)
-    {
-        if(empty($order)){
-            return;
-        }
-        $shortId = "OPENTM418105100";
-        //获取sj 下的所有开启通知的员工id
-        $shopId = $order['shopId']??0;
-        if(!$shopId){
-            return;
-        }
-        $ghsSjWx = WxOpenClass::getGhsWxInfo();
-        //根据门店获取员工
-        $adminIds = ShopAdminClass::getRemindAdminIdsByShopId($shopId);
-        $ghsNoticeData = [
-            "touser" => '',
-            "template_id" => $shortId,
-            "data" => [
-                "first" => ["value" => "下单通知。", "color" => "#173177"],
-                "keyword1" => ["value" => $order['bigNum'], "color" => "#173177"],
-                "keyword2" => ["value" => $order['actPrice'].'元', "color" => "#173177"],
-                "keyword3" => ["value" => $order['addTime'], "color" => "#173177"],
-                "remark" => ["value" => "点击查看详情", "color" => "#173177"]
-            ]
-        ];
-        if(empty($adminIds)){
-            //循环通知(慢?后续可加队列)
-            $adminMap = AdminClass::getAdminMap($adminIds);
-            foreach ($adminIds as $v){
-                $openid = $adminMap[$v]['openid']??'';
-                if(isset($adminMap[$v]) && $openid && $adminMap[$v]['subscribe']){
-
-                }
-            }
-        }
-
-    }
 }

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

@@ -3,6 +3,7 @@
 namespace biz\wx\classes;
 
 use biz\base\classes\BaseClass;
+use biz\shop\classes\ShopAdminClass;
 use common\components\dict;
 use common\components\util;
 use common\components\wxUtil;
@@ -24,7 +25,6 @@ class WxMessageClass extends BaseClass
                 'TM00006' => '充值通知',
                 'OPENTM201205968' => '订单送达通知',
                 'OPENTM207777535' => '付款提醒',
-                'OPENTM200605630' => '任务处理通知',
                 'OPENTM207422813' => '收入提醒',
                 'OPENTM202297555' => '下单成功通知',
                 'OPENTM207327227' => '宝贝售出提醒',
@@ -38,7 +38,6 @@ class WxMessageClass extends BaseClass
                 'TM00006' => '充值通知',
                 'OPENTM201205968' => '订单送达通知',
                 'OPENTM207777535' => '付款提醒',
-                'OPENTM200605630' => '任务处理通知',
                 'OPENTM207422813' => '收入提醒',
                 'OPENTM202297555' => '下单成功通知',
                 'OPENTM207327227' => '宝贝售出提醒',
@@ -100,4 +99,46 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //新订单通知 shish 20210529
+    public static function newOrderNotice($shop, $order)
+    {
+        $shopId = $shop->id;
+        $ptStyle = $shop->ptStyle;
+        $wxBase = [
+            dict::getDict('ptStyle', 'hd') => \bizHd\wx\classes\WxOpenClass::getWxInfo(),
+            dict::getDict('ptStyle', 'ghs') => \bizHd\wx\classes\WxOpenClass::getGhsWxInfo(),
+            dict::getDict('ptStyle', 'mall') => \bizHd\wx\classes\WxOpenClass::getMallWxInfo(),
+        ];
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM417875155';//收入提醒
+        $tempId = isset($message[$shortTempId]) ? $message[$shortTempId] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $orderId = $order->id;
+        $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" => '查看', "color" => "#173177"],
+                    "keyword2" => ["value" => '优惠劵', "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);
+        }
+    }
+
 }