|
|
@@ -6,7 +6,6 @@ use biz\ghs\classes\GhsClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use biz\sj\classes\MerchantClass;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
-use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -15,14 +14,14 @@ class GhsController extends BaseController
|
|
|
|
|
|
public $guestAccess = [];
|
|
|
|
|
|
- //绑定供货商 shish 2021.3.29 !!!!!!!!!!!!!!!!!!!!!!这个方法有问题,绑了供货商,没互绑客户 todo
|
|
|
+ //绑定供货商 shish 2021.3.29
|
|
|
public function actionBindGhs()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
$ownSjId = $get['ownSjId'] ?? '';
|
|
|
$sjId = $get['sjId'] ?? '';
|
|
|
if ($ownSjId == $sjId) {
|
|
|
- util::fail('不能绑自己');
|
|
|
+ util::fail('不能自己绑自己');
|
|
|
}
|
|
|
$sj = MerchantClass::getMerchantById($ownSjId);
|
|
|
if (isset($sj['style']) == false || $sj['style'] != SjClass::STYLE_SUPPLIER) {
|
|
|
@@ -32,17 +31,9 @@ class GhsController extends BaseController
|
|
|
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('供货商已经不止一家门店,不能再进行绑定');
|
|
|
+ util::fail('供货商已经不止一家门店,不知道要绑供货商的哪家店,所以不能再进行绑定');
|
|
|
}
|
|
|
$currentShop = ShopClass::getByCondition(['delStatus' => 0, 'merchantId' => $sjId]);
|
|
|
if (empty($currentShop)) {
|
|
|
@@ -53,15 +44,14 @@ class GhsController extends BaseController
|
|
|
if (!empty($has)) {
|
|
|
util::fail('您已经绑定这个供货商了');
|
|
|
}
|
|
|
- $name = $ghsSj['name'] ?? '';
|
|
|
- $data = [
|
|
|
- 'name' => $name,
|
|
|
- 'py' => stringUtil::getSpelling($name),
|
|
|
- 'shopId' => $currentShopId,
|
|
|
- 'sjId' => $sjId,
|
|
|
- 'ownSjId' => $ownSjId,
|
|
|
- ];
|
|
|
- GhsClass::addGhs($data);
|
|
|
+ $list = ShopClass::getAllByCondition(['merchantId' => $ownSjId, 'delStatus' => 0]);
|
|
|
+ if (empty($list)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ foreach ($list as $current) {
|
|
|
+ $thisShopId = $current['id'];
|
|
|
+ GhsClass::build($currentShopId, $thisShopId, $ownSjId);
|
|
|
+ }
|
|
|
util::complete();
|
|
|
}
|
|
|
|