|
|
@@ -14,6 +14,7 @@ use bizHd\saas\classes\ApplyClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\httpUtil;
|
|
|
use common\components\qrCodeUtil;
|
|
|
+use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
@@ -24,6 +25,58 @@ class ShopClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizGhs\merchant\models\Shop';
|
|
|
|
|
|
+ public static function addMainShop($data, $oldShop, $sj)
|
|
|
+ {
|
|
|
+ if (isset($oldShop->lsShopId) == false || empty($oldShop->lsShopId)) {
|
|
|
+ util::fail('本店请先绑定零售店');
|
|
|
+ }
|
|
|
+ $mobile = $data['mobile'] ?? 0;
|
|
|
+ if (empty($mobile) || stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('请输入正确手机号');
|
|
|
+ }
|
|
|
+ $hasShop = ShopClass::getByCondition(['mobile' => $mobile], true);
|
|
|
+ if (!empty($hasShop)) {
|
|
|
+ util::fail('手机号已经使用');
|
|
|
+ }
|
|
|
+ $hasApply = ApplyClass::getByCondition(['mobile' => $mobile], true);
|
|
|
+ if (!empty($hasApply)) {
|
|
|
+ util::fail('手机号已注册过');
|
|
|
+ }
|
|
|
+
|
|
|
+ $defaultShopId = $sj['defaultShopId'] ?? 0;
|
|
|
+ $defaultShop = ShopClass::getById($defaultShopId, true);
|
|
|
+ if (empty($defaultShop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $defaultMainId = $defaultShop->mainId ?? 0;
|
|
|
+ if (empty($defaultMainId)) {
|
|
|
+ util::fail('没有找到main信息');
|
|
|
+ }
|
|
|
+
|
|
|
+ $adminId = $data['adminId'] ?? 0;
|
|
|
+ $main = MainClass::add(['id' => null], true);
|
|
|
+ $mainId = $main->id ?? 0;
|
|
|
+ $data['mainId'] = $mainId;
|
|
|
+ $newShop = self::addShop($data);
|
|
|
+
|
|
|
+ //从首店复制花材和分类
|
|
|
+ \bizGhs\item\services\ItemService::copyItem($defaultMainId, $mainId);
|
|
|
+
|
|
|
+ //初始化员工和角色
|
|
|
+ $initAdminData = ['mobile' => $mobile, 'adminId' => $adminId];
|
|
|
+ \bizGhs\admin\classes\AdminClass::initAdmin($initAdminData, $mainId, $newShop);
|
|
|
+
|
|
|
+ $lsOldShop = ShopClass::getById($oldShop->lsShopId, true);
|
|
|
+ $data['sjId'] = $lsOldShop->sjId ?? 0;
|
|
|
+ $data['ptStyle'] = dict::getDict('ptStyle', 'hd');
|
|
|
+ $lsNewShop = \biz\shop\classes\ShopClass::addShop($data);
|
|
|
+ //初始化员工和角色
|
|
|
+ $initAdminData = ['mobile' => $mobile, 'adminId' => $adminId];
|
|
|
+ \bizGhs\admin\classes\AdminClass::initAdmin($initAdminData, $mainId, $lsNewShop);
|
|
|
+
|
|
|
+ return $newShop;
|
|
|
+ }
|
|
|
+
|
|
|
//组装门店基本信息 ssh 2019.12.2
|
|
|
public static function groupBaseInfo($list)
|
|
|
{
|
|
|
@@ -71,11 +124,6 @@ class ShopClass extends BaseClass
|
|
|
//补充fullAddress lqh 2021.4.18
|
|
|
$data['fullAddress'] = $data['city'] . $data['address'] . $data['floor'];
|
|
|
$shop = self::add($data);
|
|
|
- $newShopId = $shop['id'];
|
|
|
- //初始化花材 lqh 2021.5.11
|
|
|
- $adminId = $data['adminId'] ?? 0;
|
|
|
- $shopId = $data['shopId'] ?? 0;
|
|
|
- ProductClass::newShopInitProduct($data['sjId'], $shopId, $newShopId, $adminId);
|
|
|
return $shop;
|
|
|
}
|
|
|
|
|
|
@@ -119,7 +167,6 @@ class ShopClass extends BaseClass
|
|
|
{
|
|
|
$ghsShopId = $ghsShop->id ?? 0;
|
|
|
$ghsMainId = $ghsShop->mainId ?? 0;
|
|
|
- $ghsSjId = $ghsShop->sjId ?? 0;
|
|
|
if (empty($ghsMainId)) {
|
|
|
util::fail('没有找到你的main信息');
|
|
|
}
|
|
|
@@ -173,7 +220,7 @@ class ShopClass extends BaseClass
|
|
|
$ghsShop->save();
|
|
|
|
|
|
//商品和分类初始化
|
|
|
- CategoryClass::initCategoryGoods($ghsMainId, $ghsSjId);
|
|
|
+ CategoryClass::initCategoryGoods($ghsMainId);
|
|
|
//商城和门店广告初始化
|
|
|
AdClass::initAdd($ghsMainId);
|
|
|
//商家商品配置信息
|