|
|
@@ -9,6 +9,7 @@ use biz\admin\classes\ShopAdminClass;
|
|
|
use biz\coupon\classes\CouponAssetClass;
|
|
|
use biz\goods\classes\CategoryClass;
|
|
|
use biz\goods\classes\GoodsSettingClass;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
use bizTy\sj\classes\MerchantAssetClass;
|
|
|
use bizTy\shop\classes\ShopClass;
|
|
|
use common\components\business;
|
|
|
@@ -21,238 +22,247 @@ use biz\base\classes\BaseClass;
|
|
|
|
|
|
class MerchantClass extends BaseClass
|
|
|
{
|
|
|
-
|
|
|
- public static $baseFile = '\bizTy\sj\models\Merchant';
|
|
|
-
|
|
|
- //常用链接
|
|
|
- public static $commonUrl = [
|
|
|
- 1 => ['id' => 1, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '商城'],
|
|
|
- 2 => ['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
|
|
|
- 3 => ['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
|
|
|
- ];
|
|
|
-
|
|
|
- //零售店
|
|
|
- const STYLE_RETAIL = 1;
|
|
|
- //供货商
|
|
|
- const STYLE_SUPPLIER = 2;
|
|
|
-
|
|
|
- //商家信息组合 shish 2019.12.20
|
|
|
- public static function groupMerchantBaseInfo($list)
|
|
|
- {
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
- public static function getMerchantByIds($ids)
|
|
|
- {
|
|
|
- return self::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
|
|
|
- }
|
|
|
-
|
|
|
- public static function getMerchantById($id)
|
|
|
- {
|
|
|
- $merchant = self::getById($id);
|
|
|
- if (empty($merchant)) {
|
|
|
- return $merchant;
|
|
|
- }
|
|
|
- $list = self::groupBaseInfo([$merchant]);
|
|
|
- return current($list);
|
|
|
- }
|
|
|
-
|
|
|
- public static function groupBaseInfo($list)
|
|
|
- {
|
|
|
- foreach ($list as $key => $val) {
|
|
|
- $list[$key] = business::formatMerchantLogo($list[$key]);
|
|
|
- $list[$key]['address'] = '厦门市思明区后埭溪路128号-5';
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
- //创建商家信息 shish 2020.2.11
|
|
|
- public static function generateSj($applyData)
|
|
|
- {
|
|
|
- //生成商家
|
|
|
- $applyData['accountStyle'] = 0;
|
|
|
- $applyData['status'] = 1;
|
|
|
- $applyData['shopLat'] = isset($applyData['lat']) ? $applyData['lat'] : (string)0;
|
|
|
- $applyData['shopLong'] = isset($applyData['long']) ? $applyData['long'] : (string)0;
|
|
|
- $applyData['shopPrecision'] = (string)0;
|
|
|
- $applyData['wxToken'] = stringUtil::buildWxToken(0);
|
|
|
- $applyData['shopPhotoList'] = isset($applyData['shopPhotoList']) ? $applyData['shopPhotoList'] : '';
|
|
|
- $applyData['merchantName'] = isset($applyData['merchantName']) ? $applyData['merchantName'] : '';
|
|
|
- $applyData['shopProvince'] = isset($applyData['province']) ? $applyData['province'] : '';
|
|
|
- $applyData['shopCity'] = isset($applyData['city']) ? $applyData['city'] : '';
|
|
|
- $applyData['shopDist'] = isset($applyData['dist']) ? $applyData['dist'] : '';
|
|
|
- $applyData['shopAddress'] = isset($applyData['address']) ? $applyData['address'] : '';
|
|
|
- $applyData['alipayAccount'] = isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '';
|
|
|
- $applyData['alipayAccountName'] = isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '';
|
|
|
- $applyData['agentLevel'] = 1;
|
|
|
- $applyData['parentId'] = $applyData['introSjId'] ?? 0;
|
|
|
- $merchant = self::add($applyData);
|
|
|
-
|
|
|
- $adminId = $applyData['adminId'] ?? 0;
|
|
|
- $merchantId = $merchant['id'];
|
|
|
- $mobile = $applyData['mobile'];
|
|
|
- //生成资产
|
|
|
- $assetData = [
|
|
|
- 'balance' => 0,
|
|
|
- 'totalVisit' => 0,
|
|
|
- 'totalUser' => 0,
|
|
|
- 'totalMember' => 0,
|
|
|
- 'totalFans' => 0,
|
|
|
- 'totalWeixinFans' => 0,
|
|
|
- 'totalIntegral' => 0,
|
|
|
- 'totalPoint' => 0,
|
|
|
- 'totalGoods' => 0,
|
|
|
- 'totalRecharge' => 0,
|
|
|
- 'totalOrder' => 0,
|
|
|
- 'totalDeal' => 0,
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'totalIncome' => 0,
|
|
|
- 'totalExpend' => 0,
|
|
|
- ];
|
|
|
- MerchantAssetClass::add($assetData);
|
|
|
-
|
|
|
- //生成商家拓展信息
|
|
|
- $extendData = [
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'wxAppId' => isset($applyData['wxAppId']) ? $applyData['wxAppId'] : '',
|
|
|
- 'webTitle' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
- 'webKeyword' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
- 'webDescription' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
- 'wxMenuInit' => 0,
|
|
|
- 'wxTMessageInit' => 0,
|
|
|
- 'payment' => 0,//支付功能关闭
|
|
|
- 'recharge' => 0,//充值功能关闭
|
|
|
- 'giveCoupon' => 1,//默认赠送代金劵
|
|
|
- 'giveCouponPrice' => 5,//代金劵金额5元
|
|
|
- 'couponMeetPrice' => 180,//满足金额
|
|
|
- 'couponValidity' => 30,//代金劵有效期30天
|
|
|
- 'alipayAccount' => isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '',//提现的支付宝帐号
|
|
|
- 'alipayAccountName' => isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '',//提现支付宝帐号姓名
|
|
|
- 'gradeList' => '1_2000_0.9I2_5000_0.88I3_10000_0.85I4_20000_0.8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折
|
|
|
- ];
|
|
|
- MerchantExtendClass::add($extendData);
|
|
|
-
|
|
|
- MerchantInitClass::add(['merchantId' => $merchantId]);
|
|
|
-
|
|
|
- //商家商品配置信息
|
|
|
- $setData = [
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'riseType' => 0,
|
|
|
- 'riseAmount' => 0,
|
|
|
- ];
|
|
|
- GoodsSettingClass::add($setData);
|
|
|
-
|
|
|
- //创建门店
|
|
|
- $shopData = [
|
|
|
- 'shopName' => $merchant['merchantName'],
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'openTime' => '8:00 - 23:00',
|
|
|
- 'telephone' => $mobile,
|
|
|
- 'introduction' => '欢迎光临',
|
|
|
- 'province' => isset($applyData['province']) ? $applyData['province'] : '',
|
|
|
- 'city' => isset($applyData['city']) ? $applyData['city'] : '',
|
|
|
- 'dist' => isset($applyData['dist']) ? $applyData['dist'] : '',
|
|
|
- 'default' => 1,
|
|
|
- 'address' => isset($applyData['address']) ? $applyData['address'] : '',
|
|
|
- 'fullAddress' => isset($applyData['fullAddress']) ? $applyData['fullAddress'] : '',
|
|
|
- ];
|
|
|
- $shopReturn = ShopClass::addShop($shopData);
|
|
|
- $shopId = $shopReturn['id'];
|
|
|
- //设置商家默认门店
|
|
|
- MerchantClass::updateById($merchantId, ['defaultShopId' => $shopId]);
|
|
|
-
|
|
|
- if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
|
|
|
- //创建管理员角色
|
|
|
- $roleId = 0;
|
|
|
- $hasRole = AdminRoleClass::getByCondition(['merchantId' => $merchantId]);
|
|
|
- if (empty($hasRole)) {
|
|
|
- AdminRoleClass::addAdminRole(['roleName' => '店员', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
- $roleReturn = AdminRoleClass::addAdminRole(['roleName' => '老板', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
- $roleId = $roleReturn['id'];
|
|
|
- }
|
|
|
- //创建管理员
|
|
|
- if (!empty($adminId)) {
|
|
|
- $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId]);
|
|
|
- if (empty($shopAdmin)) {
|
|
|
- $adminData = [
|
|
|
- 'password' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
- 'confirmPassword' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
- 'mobile' => $mobile
|
|
|
- ];
|
|
|
- AdminClass::updateById($adminId, $adminData);
|
|
|
- $shopData = [
|
|
|
- 'adminId' => $adminId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'remind' => 1,
|
|
|
- 'roleId' => $roleId,
|
|
|
- 'default' => 1,
|
|
|
- ];
|
|
|
- ShopAdminClass::add($shopData);
|
|
|
- }
|
|
|
- }
|
|
|
- } elseif ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
|
|
|
- //创建管理员角色
|
|
|
- $roleId = 0;
|
|
|
- $hasRole = \bizGhs\admin\classes\AdminRoleClass::getByCondition(['merchantId' => $merchantId]);
|
|
|
- if (empty($hasRole)) {
|
|
|
- \bizGhs\admin\classes\AdminRoleClass::addAdminRole(['roleName' => '店员', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
- $roleReturn = \bizGhs\admin\classes\AdminRoleClass::addAdminRole(['roleName' => '老板', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
- $roleId = $roleReturn['id'];
|
|
|
- }
|
|
|
- //创建管理员
|
|
|
- if (!empty($adminId)) {
|
|
|
-
|
|
|
- $shopAdmin = \bizGhs\shop\classes\ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId]);
|
|
|
- if (empty($shopAdmin)) {
|
|
|
- $adminData = [
|
|
|
- 'password' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
- 'confirmPassword' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
- 'mobile' => $mobile
|
|
|
- ];
|
|
|
-
|
|
|
- \bizGhs\admin\classes\AdminClass::updateById($adminId, $adminData);
|
|
|
- $shopData = [
|
|
|
- 'adminId' => $adminId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'merchantId' => $merchantId,
|
|
|
- 'remind' => 1,
|
|
|
- 'roleId' => $roleId,
|
|
|
- 'default' => 1,
|
|
|
- ];
|
|
|
- \bizGhs\shop\classes\ShopAdminClass::add($shopData);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- util::fail('商家类型有问题');
|
|
|
- }
|
|
|
-
|
|
|
- if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
|
|
|
- //商品和分类初始化
|
|
|
- CategoryClass::initCategoryGoods($merchantId);
|
|
|
- //商城和门店广告初始化
|
|
|
- AdClass::initAdd($merchantId);
|
|
|
- //优惠券资产与配置信息初始化
|
|
|
- CouponAssetClass::add(['merchantId' => $merchantId, 'switch' => 1]);
|
|
|
- }
|
|
|
-
|
|
|
- return $merchant;
|
|
|
- }
|
|
|
-
|
|
|
- //h5商城链接二维码 shish 2020.4.30
|
|
|
- public static function getH5MallQrCode($id)
|
|
|
- {
|
|
|
- $url = Yii::$app->params['mallDomain'] . "/#/?account=" . $id;
|
|
|
- //强制转成https
|
|
|
- $url = httpUtil::becomeHttps($url);
|
|
|
- $respond = qrCodeUtil::generateH5MallQrCode($url);
|
|
|
- return isset($respond['url']) ? $respond['url'] : '';
|
|
|
- }
|
|
|
-
|
|
|
- public static function getDefaultShopId($merchant)
|
|
|
- {
|
|
|
- $defaultShopId = isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
|
|
|
- return $defaultShopId;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public static $baseFile = '\bizTy\sj\models\Merchant';
|
|
|
+
|
|
|
+ //常用链接
|
|
|
+ public static $commonUrl = [
|
|
|
+ 1 => ['id' => 1, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '商城'],
|
|
|
+ 2 => ['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
|
|
|
+ 3 => ['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ //零售店
|
|
|
+ const STYLE_RETAIL = 1;
|
|
|
+ //供货商
|
|
|
+ const STYLE_SUPPLIER = 2;
|
|
|
+
|
|
|
+ //商家信息组合 shish 2019.12.20
|
|
|
+ public static function groupMerchantBaseInfo($list)
|
|
|
+ {
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getMerchantByIds($ids)
|
|
|
+ {
|
|
|
+ return self::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getMerchantById($id)
|
|
|
+ {
|
|
|
+ $merchant = self::getById($id);
|
|
|
+ if (empty($merchant)) {
|
|
|
+ return $merchant;
|
|
|
+ }
|
|
|
+ $list = self::groupBaseInfo([$merchant]);
|
|
|
+ return current($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function groupBaseInfo($list)
|
|
|
+ {
|
|
|
+ foreach ($list as $key => $val) {
|
|
|
+ $list[$key] = business::formatMerchantLogo($list[$key]);
|
|
|
+ $list[$key]['address'] = '厦门市思明区后埭溪路128号-5';
|
|
|
+ }
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建商家信息 shish 2020.2.11
|
|
|
+ public static function generateSj($applyData)
|
|
|
+ {
|
|
|
+ //生成商家
|
|
|
+ $applyData['accountStyle'] = 0;
|
|
|
+ $applyData['status'] = 1;
|
|
|
+ $applyData['shopLat'] = isset($applyData['lat']) ? $applyData['lat'] : (string)0;
|
|
|
+ $applyData['shopLong'] = isset($applyData['long']) ? $applyData['long'] : (string)0;
|
|
|
+ $applyData['shopPrecision'] = (string)0;
|
|
|
+ $applyData['wxToken'] = stringUtil::buildWxToken(0);
|
|
|
+ $applyData['shopPhotoList'] = isset($applyData['shopPhotoList']) ? $applyData['shopPhotoList'] : '';
|
|
|
+ $applyData['merchantName'] = isset($applyData['merchantName']) ? $applyData['merchantName'] : '';
|
|
|
+ $applyData['shopProvince'] = isset($applyData['province']) ? $applyData['province'] : '';
|
|
|
+ $applyData['shopCity'] = isset($applyData['city']) ? $applyData['city'] : '';
|
|
|
+ $applyData['shopDist'] = isset($applyData['dist']) ? $applyData['dist'] : '';
|
|
|
+ $applyData['shopAddress'] = isset($applyData['address']) ? $applyData['address'] : '';
|
|
|
+ $applyData['alipayAccount'] = isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '';
|
|
|
+ $applyData['alipayAccountName'] = isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '';
|
|
|
+ $applyData['agentLevel'] = 1;
|
|
|
+ $applyData['parentId'] = $applyData['introSjId'] ?? 0;
|
|
|
+ $merchant = self::add($applyData);
|
|
|
+
|
|
|
+ $adminId = $applyData['adminId'] ?? 0;
|
|
|
+ $merchantId = $merchant['id'];
|
|
|
+ $mobile = $applyData['mobile'];
|
|
|
+ //生成资产
|
|
|
+ $assetData = [
|
|
|
+ 'balance' => 0,
|
|
|
+ 'totalVisit' => 0,
|
|
|
+ 'totalUser' => 0,
|
|
|
+ 'totalMember' => 0,
|
|
|
+ 'totalFans' => 0,
|
|
|
+ 'totalWeixinFans' => 0,
|
|
|
+ 'totalIntegral' => 0,
|
|
|
+ 'totalPoint' => 0,
|
|
|
+ 'totalGoods' => 0,
|
|
|
+ 'totalRecharge' => 0,
|
|
|
+ 'totalOrder' => 0,
|
|
|
+ 'totalDeal' => 0,
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'totalIncome' => 0,
|
|
|
+ 'totalExpend' => 0,
|
|
|
+ ];
|
|
|
+ MerchantAssetClass::add($assetData);
|
|
|
+
|
|
|
+ //生成商家拓展信息
|
|
|
+ $extendData = [
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'wxAppId' => isset($applyData['wxAppId']) ? $applyData['wxAppId'] : '',
|
|
|
+ 'webTitle' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
+ 'webKeyword' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
+ 'webDescription' => isset($applyData['merchantName']) ? $applyData['merchantName'] : '',
|
|
|
+ 'wxMenuInit' => 0,
|
|
|
+ 'wxTMessageInit' => 0,
|
|
|
+ 'payment' => 0,//支付功能关闭
|
|
|
+ 'recharge' => 0,//充值功能关闭
|
|
|
+ 'giveCoupon' => 1,//默认赠送代金劵
|
|
|
+ 'giveCouponPrice' => 5,//代金劵金额5元
|
|
|
+ 'couponMeetPrice' => 180,//满足金额
|
|
|
+ 'couponValidity' => 30,//代金劵有效期30天
|
|
|
+ 'alipayAccount' => isset($applyData['alipayAccount']) ? $applyData['alipayAccount'] : '',//提现的支付宝帐号
|
|
|
+ 'alipayAccountName' => isset($applyData['alipayAccountName']) ? $applyData['alipayAccountName'] : '',//提现支付宝帐号姓名
|
|
|
+ 'gradeList' => '1_2000_0.9I2_5000_0.88I3_10000_0.85I4_20000_0.8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折
|
|
|
+ ];
|
|
|
+ MerchantExtendClass::add($extendData);
|
|
|
+
|
|
|
+ MerchantInitClass::add(['merchantId' => $merchantId]);
|
|
|
+
|
|
|
+ //商家商品配置信息
|
|
|
+ $setData = [
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'riseType' => 0,
|
|
|
+ 'riseAmount' => 0,
|
|
|
+ ];
|
|
|
+ GoodsSettingClass::add($setData);
|
|
|
+
|
|
|
+ //创建门店
|
|
|
+ $shopData = [
|
|
|
+ 'shopName' => $merchant['merchantName'],
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'openTime' => '8:00 - 23:00',
|
|
|
+ 'telephone' => $mobile,
|
|
|
+ 'introduction' => '欢迎光临',
|
|
|
+ 'province' => isset($applyData['province']) ? $applyData['province'] : '',
|
|
|
+ 'city' => isset($applyData['city']) ? $applyData['city'] : '',
|
|
|
+ 'dist' => isset($applyData['dist']) ? $applyData['dist'] : '',
|
|
|
+ 'default' => 1,
|
|
|
+ 'address' => isset($applyData['address']) ? $applyData['address'] : '',
|
|
|
+ 'fullAddress' => isset($applyData['fullAddress']) ? $applyData['fullAddress'] : '',
|
|
|
+ ];
|
|
|
+ $shopReturn = ShopClass::addShop($shopData);
|
|
|
+ $shopId = $shopReturn['id'];
|
|
|
+ //设置商家默认门店
|
|
|
+ MerchantClass::updateById($merchantId, ['defaultShopId' => $shopId]);
|
|
|
+
|
|
|
+ if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
|
|
|
+ //创建管理员角色
|
|
|
+ $roleId = 0;
|
|
|
+ $hasRole = AdminRoleClass::getByCondition(['merchantId' => $merchantId]);
|
|
|
+ if (empty($hasRole)) {
|
|
|
+ AdminRoleClass::addAdminRole(['roleName' => '店员', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleReturn = AdminRoleClass::addAdminRole(['roleName' => '老板', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleId = $roleReturn['id'];
|
|
|
+ }
|
|
|
+ //创建管理员
|
|
|
+ if (!empty($adminId)) {
|
|
|
+ $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId]);
|
|
|
+ if (empty($shopAdmin)) {
|
|
|
+ $adminData = [
|
|
|
+ 'password' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
+ 'confirmPassword' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
+ 'mobile' => $mobile
|
|
|
+ ];
|
|
|
+ AdminClass::updateById($adminId, $adminData);
|
|
|
+ $shopData = [
|
|
|
+ 'adminId' => $adminId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'remind' => 1,
|
|
|
+ 'roleId' => $roleId,
|
|
|
+ 'default' => 1,
|
|
|
+ ];
|
|
|
+ ShopAdminClass::add($shopData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($applyData['introSjId']) && !empty($applyData['introSjId'])) {
|
|
|
+ if ($applyData['introStyle'] == MerchantClass::STYLE_SUPPLIER) {
|
|
|
+ if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
|
|
|
+ $introSjId = $applyData['introSjId'];
|
|
|
+ $customData = [];
|
|
|
+ CustomClass::addCustom($customData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } elseif ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
|
|
|
+ //创建管理员角色
|
|
|
+ $roleId = 0;
|
|
|
+ $hasRole = \bizGhs\admin\classes\AdminRoleClass::getByCondition(['merchantId' => $merchantId]);
|
|
|
+ if (empty($hasRole)) {
|
|
|
+ \bizGhs\admin\classes\AdminRoleClass::addAdminRole(['roleName' => '店员', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleReturn = \bizGhs\admin\classes\AdminRoleClass::addAdminRole(['roleName' => '老板', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleId = $roleReturn['id'];
|
|
|
+ }
|
|
|
+ //创建管理员
|
|
|
+ if (!empty($adminId)) {
|
|
|
+
|
|
|
+ $shopAdmin = \bizGhs\shop\classes\ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId]);
|
|
|
+ if (empty($shopAdmin)) {
|
|
|
+ $adminData = [
|
|
|
+ 'password' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
+ 'confirmPassword' => password_hash($mobile, PASSWORD_BCRYPT),
|
|
|
+ 'mobile' => $mobile
|
|
|
+ ];
|
|
|
+
|
|
|
+ \bizGhs\admin\classes\AdminClass::updateById($adminId, $adminData);
|
|
|
+ $shopData = [
|
|
|
+ 'adminId' => $adminId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'remind' => 1,
|
|
|
+ 'roleId' => $roleId,
|
|
|
+ 'default' => 1,
|
|
|
+ ];
|
|
|
+ \bizGhs\shop\classes\ShopAdminClass::add($shopData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ util::fail('商家类型有问题');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
|
|
|
+ //商品和分类初始化
|
|
|
+ CategoryClass::initCategoryGoods($merchantId);
|
|
|
+ //商城和门店广告初始化
|
|
|
+ AdClass::initAdd($merchantId);
|
|
|
+ //优惠券资产与配置信息初始化
|
|
|
+ CouponAssetClass::add(['merchantId' => $merchantId, 'switch' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $merchant;
|
|
|
+ }
|
|
|
+
|
|
|
+ //h5商城链接二维码 shish 2020.4.30
|
|
|
+ public static function getH5MallQrCode($id)
|
|
|
+ {
|
|
|
+ $url = Yii::$app->params['mallDomain'] . "/#/?account=" . $id;
|
|
|
+ //强制转成https
|
|
|
+ $url = httpUtil::becomeHttps($url);
|
|
|
+ $respond = qrCodeUtil::generateH5MallQrCode($url);
|
|
|
+ return isset($respond['url']) ? $respond['url'] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getDefaultShopId($merchant)
|
|
|
+ {
|
|
|
+ $defaultShopId = isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
|
|
|
+ return $defaultShopId;
|
|
|
+ }
|
|
|
+
|
|
|
}
|