Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

sorry 5 лет назад
Родитель
Сommit
c26b482e1a

+ 11 - 9
app-ghs/controllers/SetMealController.php

@@ -52,18 +52,20 @@ class SetMealController extends BaseController
 		$detail = SetMealService::getSetById($id);
 		$detail['introduce'] = '可以满足日常的经常、管理和营销需求。';
 		$function = [
-			['name' => '小程序商城', 'has' => 1],
-			['name' => '节日涨价', 'has' => 1],
-			['name' => '客户管理', 'has' => 1],
-			['name' => '图库管理', 'has' => 1],
-			['name' => '收银工具', 'has' => 1],
-			['name' => '老带新', 'has' => 1],
-			['name' => '员工管理', 'has' => 1],
+			['name' => '商城', 'has' => 1],
+			['name' => '开单功能', 'has' => 1],
+			['name' => '改价', 'has' => 1],
+			['name' => '自动调价', 'has' => 1],
+			['name' => '欠款管理', 'has' => 1],
 			['name' => '门店管理', 'has' => 1],
-			['name' => '优惠券管理', 'has' => 1],
+            ['name' => '花材功能', 'has' => 1],
+            ['name' => '库存管理', 'has' => 1],
+            ['name' => '调拨出库', 'has' => 1],
+            ['name' => '调拨入库', 'has' => 1],
+			['name' => '员工管理', 'has' => 1],
 			['name' => '订单管理', 'has' => 1],
 			['name' => '发货管理', 'has' => 1],
-			['name' => '刷脸支付', 'has' => 0],
+			['name' => '客户管理', 'has' => 1],
 		];
 		$free = rand(0, 1);
 		$data = ['detail' => $detail, 'function' => $function, 'free' => $free];

+ 10 - 0
app-ghs/controllers/ShopAdminController.php

@@ -3,6 +3,7 @@
 namespace ghs\controllers;
 
 use biz\admin\classes\AdminClass;
+use biz\shop\classes\ShopClass;
 use bizHd\wx\classes\WxOpenClass;
 use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\admin\services\AdminRoleService;
@@ -48,6 +49,15 @@ class ShopAdminController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
+        $admin = $this->admin;
+        $currentShopId = $admin['currentShopId'] ?? 0;
+        if (!empty($currentShopId)) {
+            $shop = ShopClass::getShopInfo($currentShopId);
+            //一个人不能同时在二个商家门店下工作
+            if (isset($shop['merchantId']) && $shop['merchantId'] != $this->sjId) {
+                util::fail('您已经是别的商家员工');
+            }
+        }
         $respond = ShopAdminService::generateAdmin($post);
         util::success($respond);
     }

+ 1 - 1
app-hd/controllers/GhsController.php

@@ -31,7 +31,7 @@ class GhsController extends BaseController
     public function actionInfo()
     {
         $shopId = Yii::$app->request->get('shopId');
-        $ghs = GhsClass::build($shopId, $this->shopId, $this->sjId);
+        $ghs = GhsClass::build($shopId, $this->shopId);
         util::success($ghs);
     }
 

+ 1 - 1
app-hd/controllers/ProductController.php

@@ -123,7 +123,7 @@ class ProductController extends BaseController
 
             if (empty($id)) {
                 if (!empty($this->shopId)) {
-                    $ghs = GhsClass::build($shopId, $this->shopId, $this->sjId);
+                    $ghs = GhsClass::build($shopId, $this->shopId);
                     $sjId = $ghs['sjId'] ?? 0;
                 } else {
                     $shop = ShopClass::getShopInfo($shopId);

+ 1 - 1
app-hd/controllers/PurchaseController.php

@@ -169,7 +169,7 @@ class PurchaseController extends BaseController
         $id = Yii::$app->request->get('id', 0);
         $info = GhsClass::getGhsInfo($id);
         GhsClass::valid($info, $this->shopId);
-        $where = ['ghsId' => $id];
+        $where = ['ghsId' => $id, 'debt' => PurchaseClass::DEBT_YES];
         $respond = PurchaseService::getDebtList($where);
         util::success($respond);
     }

+ 11 - 0
app-hd/controllers/ShopAdminController.php

@@ -3,6 +3,7 @@
 namespace hd\controllers;
 
 use biz\admin\classes\AdminClass;
+use biz\shop\classes\ShopClass;
 use bizGhs\shop\classes\ShopAdminClass;
 use bizHd\admin\services\AdminRoleService;
 use bizHd\admin\services\ShopAdminService;
@@ -46,6 +47,16 @@ class ShopAdminController extends BaseController
     public function actionGenerateAdmin()
     {
         $post = Yii::$app->request->post();
+        $post['adminId'] = $this->adminId;
+        $admin = $this->admin;
+        $currentShopId = $admin['currentShopId'] ?? 0;
+        if (!empty($currentShopId)) {
+            $shop = ShopClass::getShopInfo($currentShopId);
+            //一个人不能同时在二个商家门店下工作
+            if (isset($shop['merchantId']) && $shop['merchantId'] != $this->sjId) {
+                util::fail('您已经是别的商家员工');
+            }
+        }
         $respond = ShopAdminService::generateAdmin($post);
         util::success($respond);
     }

+ 1 - 1
app-pt/controllers/GhsController.php

@@ -49,7 +49,7 @@ class GhsController extends BaseController
         try {
             foreach ($list as $current) {
                 $ownShopId = $current['id'];
-                GhsClass::build($currentShopId, $ownShopId, $ownSjId);
+                GhsClass::build($currentShopId, $ownShopId);
             }
             $transaction->commit();
             util::complete();

+ 3 - 145
biz-ghs/custom/classes/CustomClass.php

@@ -3,14 +3,10 @@
 namespace bizGhs\custom\classes;
 
 use biz\ghs\classes\GhsClass;
-use biz\shop\classes\ShopClass;
 use biz\sj\classes\MerchantClass;
-use biz\sj\classes\SjClass;
 use common\components\business;
 use common\components\imgUtil;
-use common\components\stringUtil;
 use common\components\util;
-use Yii;
 use bizHd\base\classes\BaseClass;
 
 class CustomClass extends BaseClass
@@ -21,148 +17,10 @@ class CustomClass extends BaseClass
     const IS_DEBT_NO = 0;
     const IS_DEBT_YES = 1;
 
-    //申请开店建立客户关系 ssh 2021.2.28
-    //GhsClass::build()也有相似流程
-    public static function buildCustom($applyData, $newSj, $newShop)
+    //建立客户和供货商关系
+    public static function build($ghsShopId, $hdShopId)
     {
-        $sjId = $newSj['id'] ?? 0;
-        $shopId = $newShop['id'] ?? 0;
-        $sjName = $newSj['name'] ?? '';
-        $shopName = $newShop['shopName'] ?? '';
-        $currentName = $sjName . ' ' . $shopName;
-        $currentPy = stringUtil::py($currentName);
-        if ($applyData['style'] == SjClass::STYLE_RETAIL) {
-            if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
-                $custom = self::getByCondition(['ownShopId' => $applyData['introShopId'], 'shopId' => $shopId]);
-                if (empty($custom)) {
-                    $customData = [
-                        'sjId' => $sjId,//零售商家id
-                        'shopId' => $shopId,//零售门店id
-                        'ownSjId' => $applyData['introSjId'],//供货商id
-                        'name' => $currentName,
-                        'py' => $currentPy,
-                        'mobile' => $applyData['mobile'],
-                        'province' => $applyData['province'] ?? '',
-                        'city' => $applyData['city'] ?? '',
-                        'dist' => $applyData['dist'] ?? '',
-                        'address' => $applyData['address'] ?? '',
-                        'fullAddress' => $applyData['fullAddress'],
-                        'long' => $applyData['long'],
-                        'lat' => $applyData['lat'],
-                    ];
-                    $custom = self::addCustom($customData);
-                }
-                $customId = $custom['id'];
-
-                $introShopId = $applyData['introShopId'] ?? 0;
-                $ghsShop = ShopClass::getShopInfo($introShopId);
-                if (empty($ghsShop)) {
-                    util::fail('没有找到门店');
-                }
-                $introSjId = $applyData['introSjId'] ?? 0;
-                $ghsSj = SjClass::getById($introSjId);
-                if (empty($ghsSj)) {
-                    util::fail('没有找到商家');
-                }
-                $ghs = GhsClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $ghsShop['id']]);
-                if (empty($ghs)) {
-                    $shopName = $ghsShop['shopName'] ?? '';
-                    $ghsSjName = $ghsSj['name'] ?? '';
-                    $name = $ghsSjName . ' ' . $shopName;
-                    $py = stringUtil::py($name);
-                    $mobile = $ghsShop['mobile'] ?? '';
-                    $ghsData = [
-                        'sjId' => $ghsShop['merchantId'],
-                        'customId' => $customId,
-                        'shopId' => $ghsShop['id'],
-                        'ownSjId' => $sjId,
-                        'ownShopId' => $sjId,
-                        'name' => $name,
-                        'py' => $py,
-                        'mobile' => $mobile,
-                        'province' => $ghsShop['province'] ?? '',
-                        'city' => $ghsShop['city'] ?? '',
-                        'dist' => $ghsShop['dist'] ?? '',
-                        'address' => $ghsShop['address'] ?? '',
-                        'floor' => $ghsShop['floor'] ?? '',
-                        'fullAddress' => $ghsShop['fullAddress'] ?? '',
-                        'lat' => $ghsShop['lat'] ?? '',
-                        'long' => $ghsShop['long'] ?? '',
-                    ];
-                    $ghs = GhsClass::addGhs($ghsData);
-                    $ghsId = $ghs['id'] ?? 0;
-                    self::updateById($customId, ['ghsId' => $ghsId]);
-                }
-            }
-        }
-
-        if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
-            if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
-                $has = self::getByCondition(['ownShopId' => $shopId, 'shopId' => $applyData['introShopId']]);
-                $introSjId = $applyData['introSjId'] ?? 0;
-                $introShopId = $applyData['introShopId'] ?? 0;
-                if (empty($has)) {
-                    $shop = ShopClass::getShopInfo($introShopId);
-                    $thisSj = SjClass::getById($introSjId);
-                    if (empty($thisSj)) {
-                        util::fail('没有找到商家');
-                    }
-                    $shopName = $shop['shopName'] ?? '';
-                    $sjName = $thisSj['name'] ?? '';
-                    $name = $sjName . ' ' . $shopName;
-                    $py = stringUtil::py($name);
-                    $super = ShopClass::getSuper($introShopId);
-                    $mobile = $super['mobile'] ?? '';
-                    $customData = [
-                        'sjId' => $introSjId,//零售商id
-                        'shopId' => $introShopId,//零售门店id
-                        'ownSjId' => $sjId,//供货商id
-                        'name' => $name,
-                        'py' => $py,
-                        'mobile' => $mobile,
-                        'isOpen' => 1,
-                        'province' => $applyData['province'] ?? '',
-                        'city' => $applyData['city'] ?? '',
-                        'dist' => $applyData['dist'] ?? '',
-                        'address' => $applyData['address'] ?? '',
-                        'fullAddress' => $applyData['fullAddress'],
-                        'long' => $applyData['long'],
-                        'lat' => $applyData['lat'],
-                    ];
-                    $has = self::addCustom($customData);
-                }
-                $customId = $has['id'] ?? 0;
-                $ghs = GhsClass::getByCondition(['ownShopId' => $introShopId, 'shopId' => $shopId]);
-                if (empty($ghs)) {
-                    $shopName = $newShop['shopName'] ?? '';
-                    $sjName = $newSj['name'] ?? '';
-                    $name = $sjName . ' ' . $shopName;
-                    $py = stringUtil::py($name);
-                    $mobile = $newShop['mobile'] ?? '';
-                    $ghsData = [
-                        'sjId' => $sjId,
-                        'shopId' => $shopId,
-                        'ownSjId' => $introSjId,
-                        'ownShopId' => $introShopId,
-                        'name' => $name,
-                        'customId' => $customId,
-                        'py' => $py,
-                        'mobile' => $mobile,
-                        'province' => $newShop['province'] ?? '',
-                        'city' => $newShop['city'] ?? '',
-                        'dist' => $newShop['dist'] ?? '',
-                        'address' => $newShop['address'] ?? '',
-                        'floor' => $newShop['floor'] ?? '',
-                        'fullAddress' => $newShop['fullAddress'] ?? '',
-                        'lat' => $newShop['lat'] ?? '',
-                        'long' => $newShop['long'] ?? '',
-                    ];
-                    $ghs = GhsClass::addGhs($ghsData);
-                    $ghsId = $ghs['id'] ?? 0;
-                    self::updateById($customId, ['ghsId' => $ghsId]);
-                }
-            }
-        }
+        return GhsClass::build($ghsShopId, $hdShopId, 2);
     }
 
     //添加客户 ssh 2021.2.24

+ 22 - 2
biz-ghs/custom/services/CustomService.php

@@ -2,16 +2,36 @@
 
 namespace bizGhs\custom\services;
 
+use biz\sj\classes\SjClass;
 use bizHd\base\services\BaseService;
 use bizGhs\custom\classes\CustomClass;
-use biz\shop\classes\ShopClass;
-use Yii;
 
 class CustomService extends BaseService
 {
 
     public static $baseFile = '\bizGhs\custom\classes\CustomClass';
 
+    //分享建立客户和供货商关系 ssh 2021.2.28
+    public static function shareBuildTrade($applyData, $newSj, $newShop)
+    {
+        $sjId = $newSj['id'] ?? 0;
+        $shopId = $newShop['id'] ?? 0;
+        $introSjId = $applyData['introSjId'] ?? 0;
+        $introShopId = $applyData['introShopId'] ?? 0;
+        //申请人是花店,介绍人是供货商
+        if ($applyData['style'] == SjClass::STYLE_RETAIL) {
+            if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
+                CustomClass::buildTrade($introShopId, $introSjId, $shopId, $sjId);
+            }
+        }
+        //申请人是供货商,介绍人是花店
+        if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
+            if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
+                CustomClass::buildTrade($shopId, $sjId, $introShopId, $introSjId);
+            }
+        }
+    }
+
     public static function getCustomList($where)
     {
         $data = CustomClass::getList('*', $where, 'addTime DESC');

+ 1 - 6
biz-ghs/order/classes/OrderClass.php

@@ -490,12 +490,7 @@ class OrderClass extends BaseClass
         } elseif ($type == 1) {
             //欠款
             $customId = $order['customId'] ?? 0;
-            $customInfo = [];
-            if (!empty($customId)) {
-                $customInfo = CustomClass::getCustom($customId);
-                $debtAmount = bcadd($customInfo['debtAmount'], $amount, 2);
-                CustomClass::updateById($customId, ['debtAmount' => $debtAmount, 'isDebt' => 1]);
-            }
+            $customInfo = CustomClass::getCustom($customId);
             if (empty($customInfo)) {
                 util::fail('欠款必须选择客户');
             }

+ 3 - 10
biz-ghs/shop/services/ShopAdminService.php

@@ -5,18 +5,11 @@ namespace bizGhs\shop\services;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\admin\classes\AdminRoleClass;
 use bizGhs\shop\classes\ShopAdminClass;
-use bizGhs\auth\services\AuthService;
 use bizHd\base\services\BaseService;
 use bizGhs\merchant\classes\ShopClass;
-use bizGhs\merchant\services\MerchantService;
-use bizGhs\user\services\UserService;
-use common\components\error;
 use common\components\imgUtil;
 use common\components\miniUtil;
-use common\components\stringUtil;
 use common\components\util;
-use common\components\wxUtil;
-use common\services\xhTMessageService;
 use Yii;
 
 class ShopAdminService extends BaseService
@@ -24,7 +17,7 @@ class ShopAdminService extends BaseService
 
     public static $baseFile = '\bizGhs\shop\classes\ShopAdminClass';
 
-    ///创建管理员生成小程序 ssh 2020.4.17
+    //创建管理员生成小程序 ssh 2020.4.17
     public static function prepareBindAdmin($data)
     {
         $merchant = $data['merchant'];
@@ -39,6 +32,7 @@ class ShopAdminService extends BaseService
         return ['miniCode' => $imgUrl];
     }
 
+    //创建员工 shish 2021.5.9
     public static function generateAdmin($data)
     {
         $recommendAdminId = $data['recommendAdminId'] ?? 0;
@@ -115,7 +109,6 @@ class ShopAdminService extends BaseService
     }
 
     //获取管理员 ssh 2020.4.21
-    // $sensitive true 密码等敏感信息不显示
     public static function getAdminList($where, $sensitive = true)
     {
         $data = ShopAdminClass::getList('*', $where, 'addTime DESC');
@@ -145,7 +138,7 @@ class ShopAdminService extends BaseService
     public static function getNoticeAdminList($shopId)
     {
         $where = ['shopId' => $shopId];
-        $respond = self::getAdminList($where, false);
+        $respond = self::getAdminList($where);
         $list = isset($respond['list']) ? $respond['list'] : [];
         if (!empty($list)) {
             foreach ($list as $key => $val) {

+ 1 - 1
biz-hd/admin/services/ShopAdminService.php

@@ -133,7 +133,7 @@ class ShopAdminService extends BaseService
     public static function getNoticeAdminList($shopId)
     {
         $where = ['shopId' => $shopId];
-        $respond = self::getAdminList($where, false);
+        $respond = self::getAdminList($where);
         $list = isset($respond['list']) ? $respond['list'] : [];
         if (!empty($list)) {
             foreach ($list as $key => $val) {

+ 5 - 5
biz-hd/purchase/classes/PurchaseClass.php

@@ -257,7 +257,7 @@ class PurchaseClass extends BaseClass
             util::fail('订单不是待付款状态');
         }
 
-        //零售采购单状态变化
+        /**零售采购单状态变化**/
         $info->payWay = $payWay;
         $info->status = self::STATUS_UN_SEND;
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
@@ -266,7 +266,7 @@ class PurchaseClass extends BaseClass
         }
         $info->save();
 
-        //零售门店资产变化
+        /**零售门店资产变化**/
         $shopId = $info['shopId'] ?? 0;
         $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
         if (empty($shop)) {
@@ -283,7 +283,7 @@ class PurchaseClass extends BaseClass
         $shop->totalPurchaseOrder += 1;
         $shop->save();
 
-        //零售的供货商资产变化
+        /**零售的供货商资产变化**/
         $ghsId = $info->ghsId ?? 0;
         $ghs = Ghs::findBySql('select * from ' . Ghs::tableName() . ' where id = :id for update', ['id' => $ghsId])->one();
         if (empty($ghs)) {
@@ -299,7 +299,7 @@ class PurchaseClass extends BaseClass
         $ghs->expendNum += 1;
         $ghs->save();
 
-        //供货商销售单状态变化
+        /**供货商销售单状态变化**/
         $saleId = $info->saleId ?? 0;
         $ghsOrder = OrderClass::getById($saleId, true);
         if (empty($ghsOrder)) {
@@ -318,7 +318,7 @@ class PurchaseClass extends BaseClass
         $shop->totalOrderNum += 1;
         $shop->save();
 
-        //供货商的客户资产变化
+        /**供货商的客户资产变化**/
         $customId = $ghsOrder->customId;
         $custom = Custom::findBySql('select * from ' . Custom::tableName() . ' where id = :id for update', ['id' => $customId])->one();
         if ($payWay == dict::getDict('payWay', 'debtPay')) {

+ 1 - 1
biz-mall/admin/services/ShopAdminService.php

@@ -122,7 +122,7 @@ class ShopAdminService extends BaseService
     public static function getNoticeAdminList($shopId)
     {
         $where = ['shopId' => $shopId];
-        $respond = self::getAdminList($where, false);
+        $respond = self::getAdminList($where);
         $list = isset($respond['list']) ? $respond['list'] : [];
         if (!empty($list)) {
             foreach ($list as $key => $val) {

+ 66 - 59
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 bizGhs\custom\classes\CustomClass;
 use common\components\imgUtil;
 use common\components\stringUtil;
@@ -16,72 +17,78 @@ class GhsClass extends BaseClass
 
     public static $baseFile = '\biz\ghs\models\Ghs';
 
-    //新增供货商 shish 2021.4.13
-    //CustomClass::buildCustom()也有相似流程
-    public static function build($thisShopId, $shopId, $sjId)
+    //新增客户和供货商关系 shish 2021.4.13
+    public static function build($ghsShopId, $hdShopId, $type = 1)
     {
-        $ghsShop = ShopClass::getShopInfo($thisShopId);
-        if (empty($ghsShop)) {
-            util::fail('没有找到供货商门店');
-        }
-        $thisSjId = $ghsShop['merchantId'] ?? 0;
-        $ghs = self::getByCondition(['ownShopId' => $shopId, 'shopId' => $thisShopId]);
-        $createGhs = false;
-        if (empty($ghs)) {
-            $name = $ghsShop['merchantName'] . ' ' . $ghsShop['shopName'];
-            $py = stringUtil::py($name);
-            $data = [
-                'sjId' => $thisSjId,
-                'shopId' => $thisShopId,
-                'ownSjId' => $sjId,
-                'ownShopId' => $shopId,
-                'name' => $name,
-                'py' => $py,
-                'mobile' => $ghsShop['mobile'] ?? '',
-                'province' => $ghsShop['province'] ?? '',
-                'city' => $ghsShop['city'] ?? '',
-                'dist' => $ghsShop['dist'] ?? '',
-                'address' => $ghsShop['address'] ?? '',
-                'floor' => $ghsShop['floor'] ?? '',
-                'fullAddress' => $ghsShop['fullAddress'] ?? '',
-                'lat' => $ghsShop['lat'] ?? '',
-                'long' => $ghsShop['long'] ?? '',
-            ];
-            $ghs = self::addGhs($data);
-            $createGhs = true;
+        if ($type == 1) {
+            $ghs = self::getByCondition(['ownShopId' => $hdShopId, 'shopId' => $ghsShopId]);
+            if (!empty($ghs)) {
+                return $ghs;
+            }
+        } else {
+            $custom = CustomClass::getByCondition(['ownShopId' => $ghsShopId, 'shopId' => $hdShopId]);
+            if (!empty($custom)) {
+                return $custom;
+            }
         }
+        $ghsShop = ShopClass::getShopInfo($ghsShopId);
+        $ghsSjId = $ghsShop['merchantId'] ?? 0;
+        $ghsSj = SjClass::getById($ghsSjId);
+        $name = $ghsSj['name'] . ' ' . $ghsShop['shopName'];
+        $py = stringUtil::py($name);
 
-        $shop = ShopClass::getShopInfo($shopId);
-        $name = $shop['merchantName'] . ' ' . $shop['shopName'];
+        $ghShop = ShopClass::getShopInfo($hdShopId);
+        $hdSjId = $ghShop['merchantId'] ?? 0;
+
+        $data = [
+            'sjId' => $ghsSjId,
+            'shopId' => $ghsShopId,
+            'ownSjId' => $hdSjId,
+            'ownShopId' => $hdShopId,
+            'name' => $name,
+            'py' => $py,
+            'mobile' => $ghsShop['mobile'] ?? '',
+            'province' => $ghsShop['province'] ?? '',
+            'city' => $ghsShop['city'] ?? '',
+            'dist' => $ghsShop['dist'] ?? '',
+            'address' => $ghsShop['address'] ?? '',
+            'floor' => $ghsShop['floor'] ?? '',
+            'fullAddress' => $ghsShop['fullAddress'] ?? '',
+            'lat' => $ghsShop['lat'] ?? '',
+            'long' => $ghsShop['long'] ?? '',
+        ];
+        $ghs = self::addGhs($data);
+
+        $shop = ShopClass::getShopInfo($hdShopId);
+        $sjId = $shop['merchantId'] ?? 0;
+        $sj = SjClass::getById($sjId);
+        $name = $sj['name'] . ' ' . $shop['shopName'];
         $py = stringUtil::py($name);
         $mobile = $shop['mobile'] ?? '';
         $ghsId = $ghs['id'] ?? 0;
-
-        $custom = CustomClass::getByCondition(['ownShopId' => $thisShopId, 'shopId' => $shopId]);
-        if (empty($custom)) {
-            $customData = [
-                'sjId' => $sjId,
-                'ghsId' => $ghsId,
-                'shopId' => $shopId,
-                'ownSjId' => $thisSjId,
-                'ownShopId' => $thisShopId,
-                'name' => $name,
-                'py' => $py,
-                'mobile' => $mobile,
-                'city' => $shop['city'] ?? '',
-                'dist' => $shop['dist'] ?? '',
-                'address' => $shop['address'] ?? '',
-                'fullAddress' => $shop['fullAddress'] ?? '',
-                'long' => $shop['long'] ?? '',
-                'lat' => $shop['lat'] ?? '',
-            ];
-            $custom = CustomClass::addCustom($customData);
-        }
-        if ($createGhs) {
-            $customId = $custom['id'] ?? 0;
-            self::updateById($ghsId, ['customId' => $customId]);
+        $customData = [
+            'sjId' => $hdSjId,
+            'ghsId' => $ghsId,
+            'shopId' => $hdShopId,
+            'ownSjId' => $ghsSjId,
+            'ownShopId' => $ghsShopId,
+            'name' => $name,
+            'py' => $py,
+            'mobile' => $mobile,
+            'city' => $shop['city'] ?? '',
+            'dist' => $shop['dist'] ?? '',
+            'address' => $shop['address'] ?? '',
+            'fullAddress' => $shop['fullAddress'] ?? '',
+            'long' => $shop['long'] ?? '',
+            'lat' => $shop['lat'] ?? '',
+        ];
+        $custom = CustomClass::addCustom($customData);
+        $customId = $custom['id'] ?? 0;
+        self::updateById($ghsId, ['customId' => $customId]);
+        if ($type == 1) {
+            return $ghs;
         }
-        return $ghs;
+        return $custom;
     }
 
     //增加供货商 shish 2021.3.29

+ 1 - 1
biz/shop/services/ShopAdminService.php

@@ -122,7 +122,7 @@ class ShopAdminService extends BaseService
     public static function getNoticeAdminList($shopId)
     {
         $where = ['shopId' => $shopId];
-        $respond = self::getAdminList($where, false);
+        $respond = self::getAdminList($where);
         $list = isset($respond['list']) ? $respond['list'] : [];
         if (!empty($list)) {
             foreach ($list as $key => $val) {

+ 3 - 2
biz/sj/services/MerchantService.php

@@ -3,6 +3,7 @@
 namespace biz\sj\services;
 
 use biz\sj\classes\SjClass;
+use bizGhs\custom\services\CustomService;
 use bizHd\agent\classes\AgentAssetClass;
 use bizHd\auth\services\AuthService;
 use bizHd\goods\classes\GoodsSettingClass;
@@ -171,8 +172,8 @@ class MerchantService extends BaseService
         $sjData['status'] = $sjStatus;
         MerchantClass::updateById($sjId, $sjData);
 
-        //建立客户关系
-        CustomClass::buildCustom($applyData, $sj, $shopRespond);
+        //建立供货商和客户关系
+        CustomService::shareBuildTrade($applyData, $sj, $shopRespond);
 
         return $sj;
     }

+ 1 - 1
common/components/stringUtil.php

@@ -139,7 +139,7 @@ class stringUtil
             return '';
         }
         $pinyin = new Pinyin();
-        return $pinyin->abbr($string, PINYIN_KEEP_NUMBER);
+        return $pinyin->abbr($string, PINYIN_KEEP_ENGLISH);
     }
 
     //取随机数

+ 4 - 1
sql.sql

@@ -2394,7 +2394,10 @@ ALTER TABLE xhPurchase ADD ghsAvatar VARCHAR(500) NOT NULL DEFAULT '' COMMENT '
 ALTER TABLE xhPurchase DROP COLUMN `ghsInfo`;
 ALTER TABLE xhPurchase MODIFY ghsName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '供货商名称' AFTER `ghsId`;
 ALTER TABLE xhPurchase MODIFY ghsAvatar VARCHAR(500) NOT NULL DEFAULT '' COMMENT '供货商头像' AFTER `ghsName`;
-
+DROP TABLE IF EXISTS `xhClear`;
+DROP TABLE IF EXISTS `xhClearSn`;
+ALTER TABLE xhCustom DROP INDEX `custom`;
+ALTER TABLE xhCustom ADD UNIQUE INDEX custom(`shopId`,`userId`);
 
 =======linqh
 ==