Browse Source

建立客户关系

shish 5 years ago
parent
commit
fa70352fd6

+ 0 - 18
app/saas/controllers/ApplyController.php

@@ -54,23 +54,5 @@ class ApplyController extends BaseController
         util::complete();
     }
 
-    //申请试用登记 shish 2020.1.11
-    public function actionRegister()
-    {
-        $post = Yii::$app->request->post();
-        $rand = rand(0, 1);
-        $data = ['focus' => 1, 'qrCode' => ''];
-        if ($rand == 0) {
-            $data = ['focus' => 0, 'qrCode' => 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3602624501,870193918&fm=26&gp=0.jpg'];
-        }
-        util::success($data);
-    }
-
-    //申请状态
-    public function actionApplyStatus()
-    {
-        $status = rand(0, 4);
-        util::success(['status' => $status]);
-    }
 
 }

+ 35 - 9
biz-ghs/custom/classes/CustomClass.php

@@ -2,6 +2,7 @@
 
 namespace bizGhs\custom\classes;
 
+use bizTy\shop\classes\ShopClass;
 use bizTy\sj\classes\MerchantClass;
 use common\components\business;
 use common\components\util;
@@ -18,15 +19,40 @@ class CustomClass extends BaseClass
     {
         if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
             if ($applyData['introStyle'] == MerchantClass::STYLE_SUPPLIER) {
-                $customData = [
-                    'customSjId' => $sjId,
-                    'customShopId' => $shopId,
-                    'sjId' => $applyData['introSjId'],
-                    'name' => $applyData['name'],
-                    'mobile' => $applyData['mobile'],
-                    'isOpen' => $isOpen,
-                ];
-                CustomClass::addCustom($customData);
+                $has = CustomClass::getByCondition(['sjId' => $applyData['introSjId'], 'customSjId' => $sjId, 'customShopId' => $shopId]);
+                if (empty($has)) {
+                    $customData = [
+                        'customSjId' => $sjId,
+                        'customShopId' => $shopId,
+                        'sjId' => $applyData['introSjId'],
+                        'name' => $applyData['name'],
+                        'mobile' => $applyData['mobile'],
+                        'isOpen' => $isOpen,
+                    ];
+                    CustomClass::addCustom($customData);
+                }
+            }
+        }
+        if ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
+            if ($applyData['introStyle'] == MerchantClass::STYLE_RETAIL) {
+                $has = CustomClass::getByCondition(['sjId' => $sjId, 'customSjId' => $applyData['introSjId'], 'customShopId' => $applyData['introShopId']]);
+                if (empty($has)) {
+                    $introSjId = $applyData['introSjId'] ?? 0;
+                    $introShopId = $applyData['introShopId'] ?? 0;
+                    $shop = ShopClass::getShopInfo($introShopId);
+                    $name = $shop['shopName'] ?? '';
+                    $super = ShopClass::getSuper($introShopId);
+                    $mobile = $super['mobile'] ?? '';
+                    $customData = [
+                        'customSjId' => $introSjId,
+                        'customShopId' => $introShopId,
+                        'sjId' => $sjId,
+                        'name' => $name,
+                        'mobile' => $mobile,
+                        'isOpen' => 1,
+                    ];
+                    CustomClass::addCustom($customData);
+                }
             }
         }
     }

+ 3 - 4
biz-ghs/custom/services/CustomService.php

@@ -3,8 +3,8 @@
 namespace bizGhs\custom\services;
 
 use biz\base\services\BaseService;
-use bizGhs\merchant\classes\ShopClass;
 use bizGhs\custom\classes\CustomClass;
+use bizTy\shop\classes\ShopClass;
 use Yii;
 
 class CustomService extends BaseService
@@ -25,7 +25,6 @@ class CustomService extends BaseService
         return $data;
     }
 
-
     //获取客户信息,包括商家头像和店长信息 shish 2021.1.8
     public static function getCustomInfo($customId)
     {
@@ -36,8 +35,8 @@ class CustomService extends BaseService
         $list = CustomClass::groupBaseInfo([$custom]);
         $custom = current($list);
         $customShopId = $custom['customShopId'] ?? 0;
-        $customShop = \biz\merchant\classes\ShopClass::getById($customShopId);
-        $super = \biz\merchant\classes\ShopClass::getSuper($customShopId);
+        $customShop = ShopClass::getShopInfo($customShopId);
+        $super = ShopClass::getSuper($customShopId);
         $custom['province'] = $customShop['province'] ?? '';
         $custom['city'] = $customShop['city'] ?? '';
         $custom['address'] = $customShop['address'] ?? '';

+ 114 - 109
biz-ty/shop/classes/ShopClass.php

@@ -13,113 +13,118 @@ use bizTy\base\classes\BaseClass;
 
 class ShopClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizTy\shop\models\Shop';
-	
-	public static function getShopList($where)
-	{
-		$list = self::getList('*', $where, 'addTime DESC');
-		return $list;
-	}
-	
-	//获取商家默认的门店ID shish 2020.1.19
-	public static function getDefaultShopId($merchant)
-	{
-		return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
-	}
-
-	//创建门店 shish 2020.2.8
-	public static function addShop($data)
-	{
-		$data['createTime'] = date("Y-m-d H:i:s");
-		$shopName = isset($data['shopName']) ? $data['shopName'] : '';
-		if (empty($shopName)) {
-			util::fail('请填写门店名称');
-		}
-		$exists = self::getByCondition(['merchantId' => $data['merchantId'], 'shopName' => $shopName]);
-		if (!empty($exists)) {
-			util::fail('门店名称已经存在');
-		}
-		$shop = self::add($data);
-		return $shop;
-	}
-
-	//更新门店 shish 2020.2.29
-	public static function updateShop($id, $data)
-	{
-		$shopName = isset($data['shopName']) ? $data['shopName'] : '';
-		$merchantId = $data['merchantId'];
-		$findShop = self::getByCondition(['merchantId' => $merchantId, 'shopName' => $shopName]);
-		if (!empty($findShop) && $findShop['id'] != $id) {
-			util::fail('门店名称已经存在');
-		}
-		return self::updateById($id, $data);
-	}
-	
-	//取商家所有门店 shish 2020.2.29
-	public static function getAllShop($merchantId)
-	{
-		return self::getAllByCondition(['merchantId' => $merchantId]);
-	}
-	
-	//验证所属权限 shish 2020.2.29
-	public static function valid($shop, $merchantId)
-	{
-		if (empty($shop)) {
-			util::fail('门店无效');
-		}
-		if (isset($shop['merchantId']) == false || $shop['merchantId'] != $merchantId) {
-			util::fail('您没有权限访问');
-		}
-	}
-	
-	//删除门店 shish 2020.3.1
-	public static function deleteShop($shop)
-	{
-		if (isset($shop['default']) && $shop['default'] == 1) {
-			util::fail('默认门店不允许删除');
-		}
-		$id = $shop['id'];
-		self::updateById($id, ['delStatus' => 1]);
-	}
-	
-	//生成收款码 shish 2020.3.9
-	public static function generateGatheringCode($merchantId, $shopId)
-	{
-		$url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
-		//强制转成https
-		$url = httpUtil::becomeHttps($url);
-		$gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
-		return $gatheringCode;
-	}
-	
-	//取门店长信息 shish 2021.1.17
-	public static function getSuper($id)
-	{
-		$shop = self::getById($id);
-		if (empty($shop)) {
-			return [];
-		}
-		$adminId = $shop['adminId'] ?? 0;
-		return \biz\admin\classes\AdminClass::getDetail($adminId);
-	}
-	
-	//增加余额 shish 2021.2.21
-	//$fix = false 余额使用时不需要指定在谁那边用
-	public static function addBalance($shop, $amount, $fix = false)
-	{
-		$shop->balance += $amount;
-		$shop->totalRecharge += $amount;
-		if ($fix) {
-			$shop->fixBalance += $amount;
-		}
-		$shop->save();
-	}
-	
-	//获取商家所有的门店 shish 2021.2.26
-	public static function getSjShopList($sjId)
-	{
-		return self::getAllByCondition(['merchantId' => $sjId, 'delStatus' => 0], null, ['id']);
-	}
-	
+
+    public static $baseFile = '\bizTy\shop\models\Shop';
+
+    public static function getShopInfo($id)
+    {
+        return self::getById($id);
+    }
+
+    public static function getShopList($where)
+    {
+        $list = self::getList('*', $where, 'addTime DESC');
+        return $list;
+    }
+
+    //获取商家默认的门店ID shish 2020.1.19
+    public static function getDefaultShopId($merchant)
+    {
+        return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
+    }
+
+    //创建门店 shish 2020.2.8
+    public static function addShop($data)
+    {
+        $data['createTime'] = date("Y-m-d H:i:s");
+        $shopName = isset($data['shopName']) ? $data['shopName'] : '';
+        if (empty($shopName)) {
+            util::fail('请填写门店名称');
+        }
+        $exists = self::getByCondition(['merchantId' => $data['merchantId'], 'shopName' => $shopName]);
+        if (!empty($exists)) {
+            util::fail('门店名称已经存在');
+        }
+        $shop = self::add($data);
+        return $shop;
+    }
+
+    //更新门店 shish 2020.2.29
+    public static function updateShop($id, $data)
+    {
+        $shopName = isset($data['shopName']) ? $data['shopName'] : '';
+        $merchantId = $data['merchantId'];
+        $findShop = self::getByCondition(['merchantId' => $merchantId, 'shopName' => $shopName]);
+        if (!empty($findShop) && $findShop['id'] != $id) {
+            util::fail('门店名称已经存在');
+        }
+        return self::updateById($id, $data);
+    }
+
+    //取商家所有门店 shish 2020.2.29
+    public static function getAllShop($merchantId)
+    {
+        return self::getAllByCondition(['merchantId' => $merchantId]);
+    }
+
+    //验证所属权限 shish 2020.2.29
+    public static function valid($shop, $merchantId)
+    {
+        if (empty($shop)) {
+            util::fail('门店无效');
+        }
+        if (isset($shop['merchantId']) == false || $shop['merchantId'] != $merchantId) {
+            util::fail('您没有权限访问');
+        }
+    }
+
+    //删除门店 shish 2020.3.1
+    public static function deleteShop($shop)
+    {
+        if (isset($shop['default']) && $shop['default'] == 1) {
+            util::fail('默认门店不允许删除');
+        }
+        $id = $shop['id'];
+        self::updateById($id, ['delStatus' => 1]);
+    }
+
+    //生成收款码 shish 2020.3.9
+    public static function generateGatheringCode($merchantId, $shopId)
+    {
+        $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
+        //强制转成https
+        $url = httpUtil::becomeHttps($url);
+        $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
+        return $gatheringCode;
+    }
+
+    //增加余额 shish 2021.2.21
+    //$fix = false 余额使用时不需要指定在谁那边用
+    public static function addBalance($shop, $amount, $fix = false)
+    {
+        $shop->balance += $amount;
+        $shop->totalRecharge += $amount;
+        if ($fix) {
+            $shop->fixBalance += $amount;
+        }
+        $shop->save();
+    }
+
+    //获取商家所有的门店 shish 2021.2.26
+    public static function getSjShopList($sjId)
+    {
+        return self::getAllByCondition(['merchantId' => $sjId, 'delStatus' => 0], null, ['id']);
+    }
+
+    //取门店长信息 shish 2021.1.17
+    public static function getSuper($id)
+    {
+        $shop = self::getById($id);
+        if (empty($shop)) {
+            return [];
+        }
+        $adminId = $shop['adminId'] ?? 0;
+        return \biz\admin\classes\AdminClass::getDetail($adminId);
+    }
+
 }

+ 5 - 1
biz-ty/sj/services/MerchantService.php

@@ -34,6 +34,9 @@ class MerchantService extends BaseService
     //补充营业执照后变更商家信息 shish 2021.2.28
     public static function certChangeSjInfo($applyData)
     {
+        if ($applyData['style'] != MerchantClass::STYLE_RETAIL) {
+            return false;
+        }
         $applyId = $applyData['id'] ?? 0;
         $apply = ApplyClass::getById($applyId);
         $customId = $apply['customId'] ?? 0;
@@ -152,8 +155,10 @@ class MerchantService extends BaseService
         $sjData['defaultShopId'] = $shopId;
         $sjStatus = MerchantClass::STATUS_FREEZE;
         if (isset($applyData['licenseNo']) && !empty($applyData['licenseNo'])) {
+
             //员工角色、商品、分类等等初始化
             MerchantClass::initMore($applyData, $sjId, $shopId);
+
             $isOpen = 1;
             $sjStatus = MerchantClass::STATUS_HAS_CHECK;
         }
@@ -194,7 +199,6 @@ class MerchantService extends BaseService
         $commonIdList = in_array('*', $setIdList) ? $idList : array_intersect($idList, $setIdList);
 
         return $commonIdList;
-
     }
 
     //获取默认门店

+ 6 - 0
biz/custom/classes/CustomClass.php

@@ -59,4 +59,10 @@ class CustomClass extends BaseClass
         return $list;
     }
 
+    //添加客户 shish 2021.2.28
+    public static function addCustom($data)
+    {
+        return self::add($data);
+    }
+
 }

+ 0 - 11
biz/merchant/classes/ShopClass.php

@@ -94,17 +94,6 @@ class ShopClass extends BaseClass
         return $gatheringCode;
     }
 
-    //取门店长信息 shish 2021.1.17
-    public static function getSuper($id)
-    {
-        $shop = self::getById($id);
-        if (empty($shop)) {
-            return [];
-        }
-        $adminId = $shop['adminId'] ?? 0;
-        return \biz\admin\classes\AdminClass::getDetail($adminId);
-    }
-
     //增加余额 shish 2021.2.21
     //$fix = false 余额使用时不需要指定在谁那边用
     public static function addBalance($shop, $amount, $fix = false)

+ 20 - 20
biz/saas/classes/ApplyClass.php

@@ -34,26 +34,6 @@ class ApplyClass extends BaseClass
     const CERT_TYPE_PERSON = 2;
     const CERT_TYPE_MOBILE = 3;
 
-    //添加申请 shish 2020.2.10
-    public static function addApply($data)
-    {
-        //邀请人数+1
-        $introSjId = isset($data['introSjId']) ? $data['introSjId'] : '';
-        if (!empty($introSjId)) {
-            $agent = AgentAssetClass::getByCondition(['merchantId' => $introSjId], true);
-            if (empty($agent)) {
-                $agent = AgentAssetClass::add(['merchantId' => $introSjId], true);
-            }
-            $agent->inviteNum += 1;
-            $agent->save();
-        }
-        $apply = self::add($data);
-        $id = $apply['id'];
-        $data['applyId'] = $id;
-        ApplyExtendClass::add($data);
-        return $apply;
-    }
-
     //更新申请 shish 2021.2.27
     public static function updateRetail($data)
     {
@@ -128,4 +108,24 @@ class ApplyClass extends BaseClass
         return $respond;
     }
 
+    //添加申请 shish 2020.2.10
+    public static function addApply($data)
+    {
+        //邀请人数+1
+        $introSjId = isset($data['introSjId']) ? $data['introSjId'] : '';
+        if (!empty($introSjId)) {
+            $agent = AgentAssetClass::getByCondition(['merchantId' => $introSjId], true);
+            if (empty($agent)) {
+                $agent = AgentAssetClass::add(['merchantId' => $introSjId], true);
+            }
+            $agent->inviteNum += 1;
+            $agent->save();
+        }
+        $apply = self::add($data);
+        $id = $apply['id'];
+        $data['applyId'] = $id;
+        ApplyExtendClass::add($data);
+        return $apply;
+    }
+
 }