|
@@ -12,7 +12,6 @@ use bizHd\shop\classes\ShopClass;
|
|
|
use bizMall\hd\classes\HdClass;
|
|
use bizMall\hd\classes\HdClass;
|
|
|
use common\components\business;
|
|
use common\components\business;
|
|
|
use common\components\dict;
|
|
use common\components\dict;
|
|
|
-use common\components\errCode;
|
|
|
|
|
use common\components\orderSn;
|
|
use common\components\orderSn;
|
|
|
use common\components\stringUtil;
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
use common\components\util;
|
|
@@ -128,14 +127,27 @@ class GroupBuyController extends BaseController
|
|
|
}
|
|
}
|
|
|
$detail['activityGoods'] = $landing;
|
|
$detail['activityGoods'] = $landing;
|
|
|
|
|
|
|
|
- $currentShopId = Yii::$app->request->get('account', 0);
|
|
|
|
|
- $hd = HdClass::getByCondition(['shopId'=>$currentShopId, 'userId'=>$this->userId], false, null, 'id, customId');
|
|
|
|
|
|
|
+ $currentShopId = intval(Yii::$app->request->get('account', 0));
|
|
|
|
|
+ $hd = HdClass::getByCondition(['shopId' => $currentShopId, 'userId' => $this->userId], false, null, 'id, customId');
|
|
|
if (empty($hd)) {
|
|
if (empty($hd)) {
|
|
|
- // 创建关系???
|
|
|
|
|
- // util::fail('客户暂无关联此店');
|
|
|
|
|
- util::error(errCode::GROUP_BUY_HD_NOT_BOUND, '客户暂无关联此店');
|
|
|
|
|
|
|
+ // util::error(errCode::GROUP_BUY_HD_NOT_BOUND, '客户暂无关联此店');
|
|
|
|
|
+
|
|
|
|
|
+ // 客户与当前门店无关系时,立即建立
|
|
|
|
|
+ if (empty($this->user)) {
|
|
|
|
|
+ util::fail('请先登录');
|
|
|
|
|
+ }
|
|
|
|
|
+ $shop = ShopClass::getById($currentShopId, true);
|
|
|
|
|
+ if (empty($shop)) {
|
|
|
|
|
+ util::fail('门店不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $respond = CustomClass::buildRelation($shop, $this->user);
|
|
|
|
|
+ if (empty($respond) || empty($respond['hd'])) {
|
|
|
|
|
+ util::fail('关联门店失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ $hdId = intval($respond['hd']->id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $hdId = intval($hd['id']);
|
|
|
}
|
|
}
|
|
|
- $hdId = $hd['id'];
|
|
|
|
|
$detail['hdId'] = $hdId;
|
|
$detail['hdId'] = $hdId;
|
|
|
|
|
|
|
|
util::success($detail);
|
|
util::success($detail);
|
|
@@ -206,16 +218,23 @@ class GroupBuyController extends BaseController
|
|
|
$form->loadAndValidate();
|
|
$form->loadAndValidate();
|
|
|
$mainId = intval($this->mainId);
|
|
$mainId = intval($this->mainId);
|
|
|
$custom = $this->custom;
|
|
$custom = $this->custom;
|
|
|
- $currentShopId = Yii::$app->request->get('account', 0);
|
|
|
|
|
|
|
+ $currentShopId = intval(Yii::$app->request->get('account', 0));
|
|
|
if (empty($custom)) {
|
|
if (empty($custom)) {
|
|
|
- //util::fail('请先登录');
|
|
|
|
|
- $hd = HdClass::getByCondition(['shopId'=>$currentShopId, 'userId'=>$this->userId], false, null, 'id, customId');
|
|
|
|
|
|
|
+ $hd = HdClass::getByCondition(['shopId' => $currentShopId, 'userId' => $this->userId], false, null, 'id, customId');
|
|
|
if (empty($hd)) {
|
|
if (empty($hd)) {
|
|
|
- // 创建关系???
|
|
|
|
|
- util::fail('客户暂无关联此店');
|
|
|
|
|
|
|
+ // 客户与当前门店无关系时,立即建立
|
|
|
|
|
+ if (empty($this->user) || empty($this->shop)) {
|
|
|
|
|
+ util::fail('请先登录');
|
|
|
|
|
+ }
|
|
|
|
|
+ $respond = CustomClass::buildRelation($this->shop, $this->user);
|
|
|
|
|
+ if (empty($respond) || empty($respond['custom'])) {
|
|
|
|
|
+ util::fail('关联门店失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ $custom = $respond['custom'];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $customId = $hd['customId'];
|
|
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
}
|
|
}
|
|
|
- $customId = $hd['customId'];
|
|
|
|
|
- $custom = CustomClass::getById($customId, true);
|
|
|
|
|
}
|
|
}
|
|
|
$customId = intval($custom->id);
|
|
$customId = intval($custom->id);
|
|
|
$groupBuyId = intval($form->groupBuyId);
|
|
$groupBuyId = intval($form->groupBuyId);
|