|
|
@@ -27,8 +27,8 @@ class CustomClass extends BaseClass
|
|
|
{
|
|
|
if ($applyData['style'] == SjClass::STYLE_RETAIL) {
|
|
|
if ($applyData['introStyle'] == SjClass::STYLE_SUPPLIER) {
|
|
|
- $has = CustomClass::getByCondition(['ownSjId' => $applyData['introSjId'], 'sjId' => $sjId, 'shopId' => $shopId]);
|
|
|
- if (empty($has)) {
|
|
|
+ $custom = CustomClass::getByCondition(['ownShopId' => $applyData['introShopId'], 'shopId' => $shopId]);
|
|
|
+ if (empty($custom)) {
|
|
|
$customData = [
|
|
|
'sjId' => $sjId,//零售商家id
|
|
|
'shopId' => $shopId,//零售门店id
|
|
|
@@ -43,21 +43,23 @@ class CustomClass extends BaseClass
|
|
|
'long' => $applyData['long'],
|
|
|
'lat' => $applyData['lat'],
|
|
|
];
|
|
|
- CustomClass::addCustom($customData);
|
|
|
+ $custom = CustomClass::addCustom($customData);
|
|
|
}
|
|
|
+ $customId = $custom['id'];
|
|
|
|
|
|
$introShopId = $applyData['introShopId'] ?? 0;
|
|
|
$ghsShop = ShopClass::getShopInfo($introShopId);
|
|
|
if (empty($ghsShop)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
- $ghs = GhsClass::getByCondition(['ownSjId' => $sjId, 'sjId' => $ghsShop['merchantId'], 'shopId' => $ghsShop['id']]);
|
|
|
+ $ghs = GhsClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $ghsShop['id']]);
|
|
|
if (empty($ghs)) {
|
|
|
$name = $ghsShop['shopName'] ?? '';
|
|
|
$py = stringUtil::py($name);
|
|
|
$mobile = $ghsShop['mobile'] ?? '';
|
|
|
$ghsData = [
|
|
|
'sjId' => $ghsShop['merchantId'],
|
|
|
+ 'customId' => $customId,
|
|
|
'shopId' => $ghsShop['id'],
|
|
|
'ownSjId' => $sjId,
|
|
|
'ownShopId' => $sjId,
|
|
|
@@ -73,13 +75,16 @@ class CustomClass extends BaseClass
|
|
|
'lat' => $ghsShop['lat'] ?? '',
|
|
|
'long' => $ghsShop['long'] ?? '',
|
|
|
];
|
|
|
- GhsClass::addGhs($ghsData);
|
|
|
+ $ghs = GhsClass::addGhs($ghsData);
|
|
|
+ $ghsId = $ghs['id'] ?? 0;
|
|
|
+ CustomClass::updateById($customId, ['ghsId' => $ghsId]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if ($applyData['style'] == SjClass::STYLE_SUPPLIER) {
|
|
|
if ($applyData['introStyle'] == SjClass::STYLE_RETAIL) {
|
|
|
- $has = CustomClass::getByCondition(['ownSjId' => $sjId, 'sjId' => $applyData['introSjId'], 'shopId' => $applyData['introShopId']]);
|
|
|
+ $has = CustomClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $applyData['introShopId']]);
|
|
|
$introSjId = $applyData['introSjId'] ?? 0;
|
|
|
$introShopId = $applyData['introShopId'] ?? 0;
|
|
|
if (empty($has)) {
|
|
|
@@ -102,13 +107,14 @@ class CustomClass extends BaseClass
|
|
|
'long' => $applyData['long'],
|
|
|
'lat' => $applyData['lat'],
|
|
|
];
|
|
|
- CustomClass::addCustom($customData);
|
|
|
+ $has = CustomClass::addCustom($customData);
|
|
|
}
|
|
|
+ $customId = $has['id'] ?? 0;
|
|
|
$ghsShop = ShopClass::getShopInfo($shopId);
|
|
|
if (empty($ghsShop)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
- $ghs = GhsClass::getByCondition(['ownSjId' => $introSjId, 'sjId' => $sjId, 'shopId' => $shopId]);
|
|
|
+ $ghs = GhsClass::getByCondition(['ownShopId' => $introShopId, 'shopId' => $shopId]);
|
|
|
if (empty($ghs)) {
|
|
|
$name = $ghsShop['shopName'] ?? '';
|
|
|
$py = stringUtil::py($name);
|
|
|
@@ -119,6 +125,7 @@ class CustomClass extends BaseClass
|
|
|
'ownSjId' => $introSjId,
|
|
|
'ownShopId' => $introShopId,
|
|
|
'name' => $name,
|
|
|
+ 'customId' => $customId,
|
|
|
'py' => $py,
|
|
|
'mobile' => $mobile,
|
|
|
'province' => $ghsShop['province'] ?? '',
|
|
|
@@ -130,7 +137,9 @@ class CustomClass extends BaseClass
|
|
|
'lat' => $ghsShop['lat'] ?? '',
|
|
|
'long' => $ghsShop['long'] ?? '',
|
|
|
];
|
|
|
- GhsClass::addGhs($ghsData);
|
|
|
+ $ghs = GhsClass::addGhs($ghsData);
|
|
|
+ $ghsId = $ghs['id'] ?? 0;
|
|
|
+ CustomClass::updateById($customId, ['ghsId' => $ghsId]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -194,12 +203,12 @@ class CustomClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//权限判断 ssh 2021.1.8
|
|
|
- public static function valid($custom, $merchantId)
|
|
|
+ public static function valid($custom, $shopId)
|
|
|
{
|
|
|
if (empty($custom)) {
|
|
|
util::fail('没有找到客户');
|
|
|
}
|
|
|
- if ($custom['ownSjId'] != $merchantId) {
|
|
|
+ if ($custom['ownShopId'] != $shopId) {
|
|
|
util::fail('您没有权限操作此客户');
|
|
|
}
|
|
|
}
|