Browse Source

新客户提示

shish 5 years ago
parent
commit
8eab030924
2 changed files with 78 additions and 1 deletions
  1. 5 0
      biz/ghs/classes/GhsClass.php
  2. 73 1
      biz/wx/classes/WxMessageClass.php

+ 5 - 0
biz/ghs/classes/GhsClass.php

@@ -5,6 +5,7 @@ namespace biz\ghs\classes;
 use biz\shop\classes\ShopClass;
 use biz\shop\services\ShopService;
 use biz\sj\classes\MerchantAssetClass;
+use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomClass;
 use common\components\imgUtil;
 use common\components\stringUtil;
@@ -90,6 +91,10 @@ class GhsClass extends BaseClass
         if ($type == 1) {
             return $ghs;
         }
+
+        //有新客户提醒供货商
+        WxMessageClass::newGhsCustomInform($ghsShop, $custom);
+
         return $custom;
     }
 

+ 73 - 1
biz/wx/classes/WxMessageClass.php

@@ -129,8 +129,10 @@ class WxMessageClass extends BaseClass
         if (!empty($customName)) {
             $first = '下单客户:' . $customName;
         }
-
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -170,6 +172,9 @@ class WxMessageClass extends BaseClass
         $orderId = $order->id;
         $actPrice = $order->actPrice;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -261,6 +266,9 @@ class WxMessageClass extends BaseClass
         $orderSn = (string)$order->orderSn;
         $totalFee = $order->actPrice;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -305,6 +313,9 @@ class WxMessageClass extends BaseClass
         $orderId = $order->id;
         $orderSn = (string)$order->orderSn;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         $ghsShopAdminName = $order->ghsShopAdminName ?? '';
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
@@ -347,6 +358,9 @@ class WxMessageClass extends BaseClass
         $name = $custom->name ?? '';
         $customId = $custom->id;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -387,6 +401,9 @@ class WxMessageClass extends BaseClass
         $actPrice = $order->actPrice;
         $orderId = $order->id;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -427,6 +444,9 @@ class WxMessageClass extends BaseClass
         }
         $amount = $cash->amount;
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -467,6 +487,9 @@ class WxMessageClass extends BaseClass
         $orderSn = (string)$order->orderSn ?? '';
         $customName = $order->customName ?? '';
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -507,6 +530,9 @@ class WxMessageClass extends BaseClass
         $orderId = $cg->id ?? '';
         $orderSn = (string)$cg->orderSn ?? '';
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -549,6 +575,9 @@ class WxMessageClass extends BaseClass
         $shopName = $shop->shopName ?? '';
         $date = date("Y-m-d H:i:s");
         $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
         foreach ($adminList as $admin) {
             if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
                 continue;
@@ -573,4 +602,47 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //供应商新客户通知 shish 20210909
+    public static function newGhsCustomInform($shop, $custom)
+    {
+        $shopId = $shop['id'] ?? 0;
+        $ptStyle = $shop['ptStyle'] ?? 0;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM206773265';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $customId = $custom['id'] ?? 0;
+        $customName = $custom['name'] ?? '';
+        $date = date("Y-m-d H:i:s");
+        $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        if (empty($adminList)) {
+            return false;
+        }
+        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" => $customId, "color" => "#173177"],
+                    "keyword2" => ["value" => $customName . "(店名)", "color" => "#D52B4D"],
+                    "keyword3" => ["value" => $date, "color" => "#173177"],
+                    "remark" => ["value" => '点击查看详情', "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
 }