|
|
@@ -118,15 +118,6 @@ class ShopClass extends BaseClass
|
|
|
public static function bindLsShopByCustomId($ghsShop, $id)
|
|
|
{
|
|
|
$ghsShopId = $ghsShop->id ?? 0;
|
|
|
- $custom = CustomClass::getById($id, true);
|
|
|
- if (empty($custom)) {
|
|
|
- util::fail('门店信息没有找到');
|
|
|
- }
|
|
|
- $customShopId = $custom->shopId ?? 0;
|
|
|
- $customShop = self::getById($customShopId, true);
|
|
|
- if (isset($customShop->pfShopId) && !empty($customShop->pfShopId)) {
|
|
|
- util::fail('这个零售店已经绑定了一个批发店');
|
|
|
- }
|
|
|
$ghsMainId = $ghsShop->mainId ?? 0;
|
|
|
if (empty($ghsMainId)) {
|
|
|
util::fail('没有找到你的main信息');
|
|
|
@@ -135,16 +126,30 @@ class ShopClass extends BaseClass
|
|
|
if (empty($ghsMain)) {
|
|
|
util::fail('没有找到main信息');
|
|
|
}
|
|
|
- $customMobile = $customShop->mobile ?? 0;
|
|
|
$ghsMobile = $ghsShop->mobile ?? 0;
|
|
|
- if (empty($ghsShop)) {
|
|
|
+ if (empty($ghsMobile)) {
|
|
|
util::fail('手机号有问题?');
|
|
|
}
|
|
|
+ $customMobile = 0;
|
|
|
+ $customShop = null;
|
|
|
+ $customShopId = 0;
|
|
|
+ if (!empty($id)) {
|
|
|
+ $custom = CustomClass::getById($id, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('门店信息没有找到');
|
|
|
+ }
|
|
|
+ $customShopId = $custom->shopId ?? 0;
|
|
|
+ $customShop = self::getById($customShopId, true);
|
|
|
+ if (isset($customShop->pfShopId) && !empty($customShop->pfShopId)) {
|
|
|
+ util::fail('这个零售店已经绑定了一个批发店');
|
|
|
+ }
|
|
|
+ $customMobile = $customShop->mobile ?? 0;
|
|
|
+ }
|
|
|
if ($ghsMobile != $customMobile) {
|
|
|
//如果绑定的零售店跟批发店手机号不一样,则先查批发店这个手机号有没创建过零售店,没有则自动给创建,有则提醒选的零售店不对
|
|
|
- $has = ShopClass::getByCondition(['mobile' => $customMobile, 'ptStyle' => dict::getDict('ptStyle', 'hd')], true);
|
|
|
- if (!empty($has)) {
|
|
|
- util::fail('请确认此零售店开通时用的手机号要与本批发店一致?');
|
|
|
+ $has = ShopClass::getByCondition(['mobile' => $ghsMobile, 'ptStyle' => dict::getDict('ptStyle', 'hd')], true);
|
|
|
+ if (!empty($has) && !empty($id)) {
|
|
|
+ util::fail('请确认此零售店开通时用的手机号与本批发店一致?');
|
|
|
} else {
|
|
|
//创建零售店
|
|
|
$apply = ApplyClass::getByCondition(['mobile' => $ghsMobile]);
|