Browse Source

本客户由谁介绍

shish 4 years ago
parent
commit
26d1474a84
2 changed files with 17 additions and 3 deletions
  1. 10 1
      biz/ghs/classes/GhsClass.php
  2. 7 2
      biz/wx/classes/WxMessageClass.php

+ 10 - 1
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\sj\classes\SjClass;
 use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomClass;
 use common\components\imgUtil;
@@ -89,8 +90,16 @@ class GhsClass extends BaseClass
         $customId = $custom['id'] ?? 0;
         self::updateById($ghsId, ['customId' => $customId]);
 
+        $customSjId = $custom['sjId'] ?? 0;
+        $customSj = SjClass::getById($customSjId, true);
+        $parentShopId = $customSj->parentShopId ?? 0;
+        $introduce = [];
+        if (!empty($parentShopId)) {
+            $introduce = CustomClass::getByCondition(['ownShopId' => $ghsShopId, 'shopId' => $parentShopId], true);
+        }
+
         //有新客户提醒供货商
-        WxMessageClass::newGhsCustomInform($ghsShop, $custom);
+        WxMessageClass::newGhsCustomInform($ghsShop, $custom, $introduce);
 
         if ($type == 1) {
             return $ghs;

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

@@ -614,7 +614,7 @@ class WxMessageClass extends BaseClass
     }
 
     //供应商新客户通知 shish 20210909
-    public static function newGhsCustomInform($shop, $custom)
+    public static function newGhsCustomInform($shop, $custom, $introduce)
     {
         $shopId = $shop['id'] ?? 0;
         $ptStyle = $shop['ptStyle'] ?? 0;
@@ -633,6 +633,11 @@ class WxMessageClass extends BaseClass
         if (empty($adminList)) {
             return false;
         }
+        $first = '';
+        if (!empty($introduce)) {
+            $introName = $introduce->name ?? '';
+            $first = "本客户由【{$introName}】介绍";
+        }
         foreach ($adminList as $admin) {
             $openId = isset($admin['openId']) ? $admin['openId'] : '';
             if (empty($openId)) {
@@ -643,7 +648,7 @@ class WxMessageClass extends BaseClass
                 "template_id" => $tempId,
                 "url" => Yii::$app->params['ghsDomain'],
                 "data" => [
-                    "first" => ["value" => "", "color" => "#173177"],
+                    "first" => ["value" => $first, "color" => "#173177"],
                     "keyword1" => ["value" => $customId, "color" => "#173177"],
                     "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
                     "keyword3" => ["value" => $date, "color" => "#173177"],