|
|
@@ -23,8 +23,14 @@ class CustomClass extends BaseClass
|
|
|
|
|
|
//申请开店建立客户关系 ssh 2021.2.28
|
|
|
//GhsClass::build()也有相似流程
|
|
|
- public static function buildCustom($applyData, $sjId, $shopId)
|
|
|
+ public static function buildCustom($applyData, $newSj, $newShop)
|
|
|
{
|
|
|
+ $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 = CustomClass::getByCondition(['ownShopId' => $applyData['introShopId'], 'shopId' => $shopId]);
|
|
|
@@ -33,7 +39,8 @@ class CustomClass extends BaseClass
|
|
|
'sjId' => $sjId,//零售商家id
|
|
|
'shopId' => $shopId,//零售门店id
|
|
|
'ownSjId' => $applyData['introSjId'],//供货商id
|
|
|
- 'name' => $applyData['name'],
|
|
|
+ 'name' => $currentName,
|
|
|
+ 'py' => $currentPy,
|
|
|
'mobile' => $applyData['mobile'],
|
|
|
'province' => $applyData['province'] ?? '',
|
|
|
'city' => $applyData['city'] ?? '',
|
|
|
@@ -52,9 +59,16 @@ class CustomClass extends BaseClass
|
|
|
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)) {
|
|
|
- $name = $ghsShop['shopName'] ?? '';
|
|
|
+ $shopName = $ghsShop['shopName'] ?? '';
|
|
|
+ $ghsSjName = $ghsSj['name'] ?? '';
|
|
|
+ $name = $ghsSjName . ' ' . $shopName;
|
|
|
$py = stringUtil::py($name);
|
|
|
$mobile = $ghsShop['mobile'] ?? '';
|
|
|
$ghsData = [
|
|
|
@@ -89,7 +103,14 @@ class CustomClass extends BaseClass
|
|
|
$introShopId = $applyData['introShopId'] ?? 0;
|
|
|
if (empty($has)) {
|
|
|
$shop = ShopClass::getShopInfo($introShopId);
|
|
|
- $name = $shop['shopName'] ?? '';
|
|
|
+ $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 = [
|
|
|
@@ -97,6 +118,7 @@ class CustomClass extends BaseClass
|
|
|
'shopId' => $introShopId,//零售门店id
|
|
|
'ownSjId' => $sjId,//供货商id
|
|
|
'name' => $name,
|
|
|
+ 'py' => $py,
|
|
|
'mobile' => $mobile,
|
|
|
'isOpen' => 1,
|
|
|
'province' => $applyData['province'] ?? '',
|
|
|
@@ -110,15 +132,13 @@ class CustomClass extends BaseClass
|
|
|
$has = CustomClass::addCustom($customData);
|
|
|
}
|
|
|
$customId = $has['id'] ?? 0;
|
|
|
- $ghsShop = ShopClass::getShopInfo($shopId);
|
|
|
- if (empty($ghsShop)) {
|
|
|
- util::fail('没有找到门店');
|
|
|
- }
|
|
|
$ghs = GhsClass::getByCondition(['ownShopId' => $introShopId, 'shopId' => $shopId]);
|
|
|
if (empty($ghs)) {
|
|
|
- $name = $ghsShop['shopName'] ?? '';
|
|
|
+ $shopName = $newShop['shopName'] ?? '';
|
|
|
+ $sjName = $newSj['name'] ?? '';
|
|
|
+ $name = $sjName . ' ' . $shopName;
|
|
|
$py = stringUtil::py($name);
|
|
|
- $mobile = $ghsShop['mobile'] ?? '';
|
|
|
+ $mobile = $newShop['mobile'] ?? '';
|
|
|
$ghsData = [
|
|
|
'sjId' => $sjId,
|
|
|
'shopId' => $shopId,
|
|
|
@@ -128,14 +148,14 @@ class CustomClass extends BaseClass
|
|
|
'customId' => $customId,
|
|
|
'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'] ?? '',
|
|
|
+ '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;
|