|
|
@@ -2,50 +2,171 @@
|
|
|
|
|
|
namespace biz\merchant\classes;
|
|
|
|
|
|
+use biz\admin\classes\AdminRoleClass;
|
|
|
+use biz\goods\classes\GoodsSettingClass;
|
|
|
use common\components\business;
|
|
|
+use common\components\stringUtil;
|
|
|
use Yii;
|
|
|
use biz\base\classes\BaseClass;
|
|
|
|
|
|
class MerchantClass extends BaseClass
|
|
|
{
|
|
|
-
|
|
|
- public static $baseFile = '\biz\merchant\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' => '点我付款'],
|
|
|
- ];
|
|
|
-
|
|
|
- //商家信息组合 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'] = '福建省厦门市思明区上湖社1017号';
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public static $baseFile = '\biz\merchant\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' => '点我付款'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ //商家信息组合 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'] = '福建省厦门市思明区上湖社1017号';
|
|
|
+ }
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建商家信息 shish 2020.2.11
|
|
|
+ public static function generateMerchant($data)
|
|
|
+ {
|
|
|
+ //生成商家
|
|
|
+ $date = date("Y-m-d H:i:s");
|
|
|
+ $time = time();
|
|
|
+ $data['accountStyle'] = 0;//认证服务号
|
|
|
+ $data['status'] = 0;//待审核
|
|
|
+ $data['createTime'] = $date;
|
|
|
+ $data['updateTime'] = $date;
|
|
|
+ $data['shopLat'] = (string)0;
|
|
|
+ $data['shopLong'] = (string)0;
|
|
|
+ $data['shopPrecision'] = (string)0;
|
|
|
+ $data['adminId'] = 0;
|
|
|
+ $data['wxToken'] = stringUtil::buildWxToken(0);
|
|
|
+ $data['shopPhotoList'] = isset($data['shopPhotoList']) ? $data['shopPhotoList'] : '';
|
|
|
+ $data['merchantName'] = isset($data['merchantName']) ? $data['merchantName'] : '';
|
|
|
+ $data['shopProvince'] = isset($data['shopProvince']) ? $data['shopProvince'] : '';
|
|
|
+ $data['shopCity'] = isset($data['shopCity']) ? $data['shopCity'] : '';
|
|
|
+ $data['shopDist'] = isset($data['shopDist']) ? $data['shopDist'] : '';
|
|
|
+ $data['alipayAccount'] = isset($data['alipayAccount']) ? $data['alipayAccount'] : '';
|
|
|
+ $data['alipayAccountName'] = isset($data['alipayAccountName']) ? $data['alipayAccountName'] : '';
|
|
|
+ //默认设置为代理商
|
|
|
+ $data['agentLevel'] = 1;
|
|
|
+ $merchant = self::add($data);
|
|
|
+ $merchantId = $merchant['id'];
|
|
|
+ //生成商家资产
|
|
|
+ $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,
|
|
|
+ 'createTime' => $date,
|
|
|
+ 'updateTime' => $date,
|
|
|
+ ];
|
|
|
+ //商家资产表
|
|
|
+ MerchantAssetClass::add($assetData);
|
|
|
+
|
|
|
+ //生成商家拓展信息
|
|
|
+ $extendData = [
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'wxAppId' => isset($data['wxAppId']) ? $data['wxAppId'] : '',
|
|
|
+ 'webTitle' => isset($data['merchantName']) ? $data['merchantName'] : '',
|
|
|
+ 'webKeyword' => isset($data['merchantName']) ? $data['merchantName'] : '',
|
|
|
+ 'webDescription' => isset($data['merchantName']) ? $data['merchantName'] : '',
|
|
|
+ 'wxMenuInit' => 0,
|
|
|
+ 'wxTMessageInit' => 0,
|
|
|
+ 'payment' => 0,//支付功能关闭
|
|
|
+ 'recharge' => 0,//充值功能关闭
|
|
|
+ 'giveCoupon' => 1,//默认赠送代金劵
|
|
|
+ 'giveCouponPrice' => 5,//代金劵金额5元
|
|
|
+ 'couponMeetPrice' => 180,//满足金额
|
|
|
+ 'couponValidity' => 30,//代金劵有效期30天
|
|
|
+ 'alipayAccount' => isset($data['alipayAccount']) ? $data['alipayAccount'] : '',//提现的支付宝帐号
|
|
|
+ 'alipayAccountName' => isset($data['alipayAccountName']) ? $data['alipayAccountName'] : '',//提现支付宝帐号姓名
|
|
|
+ 'gradeList' => '1_2000_9I2_5000_88I3_10000_85I4_20000_8',//1 级会员需要满 2000 积分 购物享9折;2 级会员需要满 5000 积分 购物享88折
|
|
|
+ 'createTime' => $date,
|
|
|
+ 'updateTime' => $date,
|
|
|
+ ];
|
|
|
+ MerchantExtendClass::add($extendData);
|
|
|
+
|
|
|
+ //商家商品统一配置
|
|
|
+ $setData = [
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'riseType' => 0,
|
|
|
+ 'riseAmount' => 0,
|
|
|
+ 'addTime' => time(),
|
|
|
+ ];
|
|
|
+ GoodsSettingClass::add($setData);
|
|
|
+
|
|
|
+ //创建门店
|
|
|
+ $shopData = ['shopName' => $merchant['merchantName'], 'merchantName' => $merchant['merchantName'], 'merchantId' => $merchantId, 'addTime' => $time, 'createTime' => $date, 'updateTime' => $date];
|
|
|
+ $shopReturn = ShopClass::addShop($shopData);
|
|
|
+ $shopId = $shopReturn['id'];
|
|
|
+ //设置商家默认门店
|
|
|
+ MerchantClass::updateByCondition(['merchantId' => $merchantId], ['defaultShopId' => $shopId]);
|
|
|
+
|
|
|
+ //创建管理员角色
|
|
|
+ $hasRole = AdminRoleClass::getByCondition(['merchantId' => $merchantId, 'roleName' => '老板']);
|
|
|
+ if (empty($hasRole)) {
|
|
|
+ AdminRoleClass::addAdminRole(['roleName' => '店员', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleReturn = AdminRoleClass::addAdminRole(['roleName' => '老板', 'merchantId' => $merchantId, 'auth' => '*']);
|
|
|
+ $roleId = $roleReturn['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建管理员
|
|
|
+ $mobile = $data['mobile'];
|
|
|
+ $admin = AdminClass::getByCondition(['merchantId' => $merchantId, 'mobile' => $mobile]);
|
|
|
+ if (empty($admin)) {
|
|
|
+ $adminData = [
|
|
|
+ 'mobile' => 15280215347,
|
|
|
+ 'adminName' => '石少华',
|
|
|
+ 'password' => password_hash('123456', PASSWORD_BCRYPT),
|
|
|
+ 'confirmPassword' => password_hash('123456', PASSWORD_BCRYPT),
|
|
|
+ 'merchantId' => $merchantId,
|
|
|
+ 'roleId' => $roleId,
|
|
|
+ 'defaultShopId' => $shopId,
|
|
|
+ 'currentShopId' => $shopId,
|
|
|
+ 'super' => 1,
|
|
|
+ 'addTime' => $time,
|
|
|
+ ];
|
|
|
+ AdminClass::addAdmin($adminData);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $merchant;
|
|
|
+ }
|
|
|
+
|
|
|
}
|