瀏覽代碼

微信通知(待完成)

林琦海 5 年之前
父節點
當前提交
eb8d721e29

+ 5 - 1
biz-ghs/ws/services/WsService.php

@@ -5,7 +5,7 @@ namespace bizGhs\ws\services;
 use GatewayClient\Gateway;
 class WsService
 {
-    //到账通知
+    //到账通知 $adminId 为 shopAdminId
     public static function arrivalNotice($adminId,$money,$payWay='')
     {
         $msg = '到账'.$money;
@@ -13,4 +13,8 @@ class WsService
         Gateway::sendToUid($adminId, json_encode($data));
         return true;
     }
+
+    //零售端采购时,提示供货商(下所有有开启通知的员工),你有新订单
+    //商城客户下单时,提示零售花店(下所有有开启通知的员工) 你有新的订单
+    //todo
 }

+ 8 - 0
biz/admin/classes/AdminClass.php

@@ -16,4 +16,12 @@ class AdminClass extends BaseClass
     const OPEN_SHOP_CHECK = 2;
     const OPEN_SHOP_YES = 3;
 
+    //linqh 2021.5.14  [id=>adminData]
+    public static function getAdminMap($adminIds)
+    {
+        $where = [];
+        $where['id'] =  ['in', $adminIds];
+        $data = self::getAllByCondition($where,null,"*");
+        return array_column($data,null,"id");
+    }
 }

+ 31 - 2
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]);
+        $relate = self::getByCondition(['shopId' => $shopId,'super'=>1]);
         $adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
         $info = [];
         if (!empty($adminId)) {
@@ -211,4 +211,33 @@ class ShopAdminClass extends BaseClass
         AdminRoleClass::counters(['num' => -1], ['id' => $relation->roleId]);
     }
 
-}
+    //根据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
+        ];
+        $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
+        ];
+        $data = self::getAllByCondition($where,null,"adminId");
+        return array_column($data,'adminId');
+    }
+}

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

@@ -0,0 +1,67 @@
+<?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']){
+
+                }
+            }
+        }
+
+    }
+}

+ 13 - 0
biz/tm/models/TMessage.php

@@ -0,0 +1,13 @@
+<?php
+namespace biz\tm\models;
+use biz\base\models\Base;
+
+class TMessage extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhTMessage';
+	}
+
+}