request->get(); $ownSjId = $get['ownSjId'] ?? ''; $sjId = $get['sjId'] ?? ''; if ($ownSjId == $sjId) { util::fail('不能绑自己'); } $sj = MerchantClass::getMerchantById($ownSjId); if (isset($sj['style']) == false || $sj['style'] != SjClass::STYLE_SUPPLIER) { util::fail('城市供货商才能发起绑定'); } $ghsSj = MerchantClass::getMerchantById($sjId); if (isset($ghsSj['style']) == false || $ghsSj['style'] != SjClass::STYLE_KM_SUPPLIER) { util::fail('请选择昆明供货商'); } $count = ShopClass::getCount(['delStatus' => 0, 'merchantId' => $ownSjId]); if ($count > 1) { util::fail('发起人已经不止一家门店,不能再进行绑定'); } $shop = ShopClass::getByCondition(['delStatus' => 0, 'merchantId' => $ownSjId]); if (empty($shop)) { util::fail('没有找到门店'); } $count = ShopClass::getCount(['delStatus' => 0, 'merchantId' => $sjId]); if ($count > 1) { util::fail('供货商已经不止一家门店,不能再进行绑定'); } $currentShop = ShopClass::getByCondition(['delStatus' => 0, 'merchantId' => $sjId]); if (empty($currentShop)) { util::fail('没有找到门店'); } $currentShopId = $currentShop['id'] ?? 0; $has = GhsClass::getByCondition(['ownSjId' => $ownSjId, 'sjId' => $sjId, 'shopId' => $currentShopId]); if (!empty($has)) { util::fail('您已经绑定这个供货商了'); } $name = $ghsSj['name'] ?? ''; $data = [ 'name' => $name, 'py' => stringUtil::getSpelling($name), 'shopId' => $currentShopId, 'sjId' => $sjId, 'ownSjId' => $ownSjId, ]; GhsClass::addGhs($data); util::complete(); } }