Browse Source

修改商家表名

shish 5 years ago
parent
commit
1db78d16d7

+ 85 - 71
app/ghs/controllers/CustomController.php

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\saas\classes\ApplyExtendClass;
 use bizTy\sj\classes\MerchantClass;
 use biz\saas\classes\ApplyClass;
 use biz\saas\services\ApplyService;
@@ -14,77 +15,90 @@ use yii\web\Controller;
 
 class CustomController extends BaseController
 {
+	
+	//客户列表 shish 2021.7.8
+	public function actionList()
+	{
+		$get = Yii::$app->request->get();
+		$type = isset($get['type']) ? $get['type'] : 0;
+		$name = isset($get['name']) ? $get['name'] : '';
+		$where = ['merchantId' => $this->sjId];
+		switch ($type) {
+			case 1:
+				//已开店
+				$where['isOpen'] = 1;
+				break;
+			default:
+		}
+		if (!empty($name)) {
+			if (stringUtil::isMobile($name)) {
+				$where['mobile'] = $name;
+			} else {
+				$where['shopName'] = ['like', $name];
+			}
+		}
+		$list = CustomService::getCustomList($where);
+		util::success($list);
+	}
+	
+	//客户详情 shish 2021.1.8
+	public function actionDetail()
+	{
+		$get = Yii::$app->request->get();
+		$customId = $get['id'] ?? 0;
+		$info = CustomService::getCustomInfo($customId);
+		CustomClass::valid($info, $this->sjId);
+		$info['sn'] = 1254358;
+		util::success($info);
+	}
+	
+	//允许月结开关 shish 2021.1.8
+	public function actionDebt()
+	{
+		$get = Yii::$app->request->get();
+		$debt = isset($get['debt']) ? $get['debt'] : 0;
+		$customId = isset($get['customId']) ? $get['customId'] : 0;
+		$custom = CustomClass::getById($customId);
+		CustomClass::valid($custom, $this->sjId);
+		CustomClass::debt($custom, $debt);
+		util::complete();
+	}
+	
+	//添加新客户 shish 2021.1.8
+	public function actionAdd()
+	{
+		$post = Yii::$app->request->post();
+		$post['style'] = MerchantClass::STYLE_RETAIL;
+		$post['from'] = ApplyClass::FROM_GHS;
+		$post['introSjId'] = $this->sjId;
+		$post['introStyle'] = MerchantClass::STYLE_SUPPLIER;
+		$post['certType'] = ApplyExtendClass::CERT_TYPE_MOBILE;
+		$mobile = $post['mobile'] ?? '';
+		$confirmMobile = $post['confirmMobile'];
+		if (stringUtil::isMobile($mobile) == false) {
+			util::fail(' 请填写正确的手机号');
+		}
+		if ($mobile != $confirmMobile) {
+			util::fail('二次号码填写不一致');
+		}
+		$extend = ApplyExtendClass::getByCondition(['certType' => ApplyExtendClass::CERT_TYPE_MOBILE, 'mobile' => $mobile]);
+		if (!empty($extend)) {
+			util::fail('此客户已存在');
+		}
+		ApplyService::addApply($post);
+		util::complete('添加成功,等待审核');
+	}
 
-    //客户列表 shish 2021.7.8
-    public function actionList()
-    {
-        $get = Yii::$app->request->get();
-        $type = isset($get['type']) ? $get['type'] : 0;
-        $name = isset($get['name']) ? $get['name'] : '';
-        $where = ['merchantId' => $this->sjId];
-        switch ($type) {
-            case 1:
-                //已开店
-                $where['isOpen'] = 1;
-                break;
-            default:
-        }
-        if (!empty($name)) {
-            if (stringUtil::isMobile($name)) {
-                $where['mobile'] = $name;
-            } else {
-                $where['shopName'] = ['like', $name];
-            }
-        }
-        $list = CustomService::getCustomList($where);
-        util::success($list);
-    }
-
-    //客户详情 shish 2021.1.8
-    public function actionDetail()
-    {
-        $get = Yii::$app->request->get();
-        $customId = $get['id'] ?? 0;
-        $info = CustomService::getCustomInfo($customId);
-        CustomClass::valid($info, $this->sjId);
-        $info['sn'] = 1254358;
-        util::success($info);
-    }
-
-    //允许月结开关 shish 2021.1.8
-    public function actionDebt()
-    {
-        $get = Yii::$app->request->get();
-        $debt = isset($get['debt']) ? $get['debt'] : 0;
-        $customId = isset($get['customId']) ? $get['customId'] : 0;
-        $custom = CustomClass::getById($customId);
-        CustomClass::valid($custom, $this->sjId);
-        CustomClass::debt($custom, $debt);
-        util::complete();
-    }
-
-    //添加新客户 shish 2021.1.8
-    public function actionAdd()
-    {
-        $post = Yii::$app->request->post();
-        $post['style'] = MerchantClass::STYLE_RETAIL;
-        $post['from'] = ApplyClass::FROM_GHS;
-        $post['introSjId'] = $this->sjId;
-        $post['introStyle'] = MerchantClass::STYLE_SUPPLIER;
-        ApplyService::addApply($post);
-        util::complete('添加成功,等待审核');
-    }
-
-    //欠款客户 shish 2021.2.4
-    public function actionDebtList()
-    {
-        $get = Yii::$app->request->get();
-        $where = ['merchantId' => $this->sjId, 'isDebt' => 1];
-        if (isset($get['name']) && !empty($get['name'])) {
-            $where['name'] = ['like', $get['name']];
-        }
-        $list = CustomService::getDebtList($where);
-        util::success($list);
-    }
+	//欠款客户 shish 2021.2.4
+	public function actionDebtList()
+	{
+		$get = Yii::$app->request->get();
+		$where = ['merchantId' => $this->sjId, 'isDebt' => 1];
+		if (isset($get['name']) && !empty($get['name'])) {
+			$where['name'] = ['like', $get['name']];
+		}
+		$list = CustomService::getDebtList($where);
+		util::success($list);
+	}
 
 }

+ 60 - 54
biz-ghs/custom/classes/CustomClass.php

@@ -11,61 +11,67 @@ use biz\base\classes\BaseClass;
 class CustomClass extends BaseClass
 {
 
-    public static $baseFile = '\bizGhs\custom\models\Custom';
+	public static $baseFile = '\bizGhs\custom\models\Custom';
 
-    //获取客户信息 shish 2021.2.4
-    public static function getCustom($id)
-    {
-        $info = self::getById($id);
-        $respond = self::groupBaseInfo([$info]);
-        return current($respond);
-    }
+	//添加客户 shish 2021.2.24
+	public static function addCustom($data)
+	{
 
-    public static function getCustomByIds($ids)
-    {
-        $list = self::getByIds($ids, null, 'id');
-        return self::groupBaseInfo($list);
-    }
-
-    //整合头像等信息 shish 2021.1.8
-    public static function groupBaseInfo($list)
-    {
-        if (empty($list)) {
-            return $list;
-        }
-        //获取客户信息
-        $downIdList = array_unique(array_filter(array_column($list, 'downId')));
-        $retailInfo = MerchantClass::getByIds($downIdList, null, 'id');
-        foreach ($list as $key => $val) {
-            $downId = $val['downId'];
-            $currentInfo = isset($retailInfo[$downId]) ? $retailInfo[$downId] : [];
-            //组合头像
-            $currentInfo = business::formatMerchantLogo($currentInfo);
-            $list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
-            $list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
-            $list[$key]['visitTime'] = '06-11 12:50';
-            $list[$key]['level'] = 0;
-        }
-        return $list;
-    }
-
-    //欠款权限开关 shish 2021.1.8
-    public static function debt($custom, $debt)
-    {
-        $id = isset($custom['id']) ? $custom['id'] : 0;
-        self::updateById($id, ['debt' => $debt]);
-        return true;
-    }
-
-    //权限判断 shish 2021.1.8
-    public static function valid($custom, $merchantId)
-    {
-        if (empty($custom)) {
-            util::fail('没有找到客户');
-        }
-        if ($custom['merchantId'] != $merchantId) {
-            util::fail('您没有权限操作此客户');
-        }
-    }
+	}
 
+	//获取客户信息 shish 2021.2.4
+	public static function getCustom($id)
+	{
+		$info = self::getById($id);
+		$respond = self::groupBaseInfo([$info]);
+		return current($respond);
+	}
+	
+	public static function getCustomByIds($ids)
+	{
+		$list = self::getByIds($ids, null, 'id');
+		return self::groupBaseInfo($list);
+	}
+	
+	//整合头像等信息 shish 2021.1.8
+	public static function groupBaseInfo($list)
+	{
+		if (empty($list)) {
+			return $list;
+		}
+		//获取客户信息
+		$downIdList = array_unique(array_filter(array_column($list, 'downId')));
+		$retailInfo = MerchantClass::getByIds($downIdList, null, 'id');
+		foreach ($list as $key => $val) {
+			$downId = $val['downId'];
+			$currentInfo = isset($retailInfo[$downId]) ? $retailInfo[$downId] : [];
+			//组合头像
+			$currentInfo = business::formatMerchantLogo($currentInfo);
+			$list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
+			$list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
+			$list[$key]['visitTime'] = '06-11 12:50';
+			$list[$key]['level'] = 0;
+		}
+		return $list;
+	}
+	
+	//欠款权限开关 shish 2021.1.8
+	public static function debt($custom, $debt)
+	{
+		$id = isset($custom['id']) ? $custom['id'] : 0;
+		self::updateById($id, ['debt' => $debt]);
+		return true;
+	}
+	
+	//权限判断 shish 2021.1.8
+	public static function valid($custom, $merchantId)
+	{
+		if (empty($custom)) {
+			util::fail('没有找到客户');
+		}
+		if ($custom['merchantId'] != $merchantId) {
+			util::fail('您没有权限操作此客户');
+		}
+	}
+	
 }

+ 1 - 1
biz-ghs/merchant/models/Merchant.php

@@ -7,7 +7,7 @@ class Merchant extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchant';
+		return 'xhSj';
 	}
 
 }

+ 1 - 1
biz-ghs/merchant/models/MerchantAsset.php

@@ -7,7 +7,7 @@ class MerchantAsset extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantAsset';
+		return 'xhSjAsset';
 	}
 
 }

+ 1 - 1
biz-ghs/merchant/models/MerchantInit.php

@@ -7,7 +7,7 @@ class MerchantInit extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantInit';
+		return 'xhSjInit';
 	}
 
 }

+ 1 - 1
biz-ghs/merchant/models/MerchantRemark.php

@@ -7,7 +7,7 @@ class MerchantRemark extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantRemark';
+		return 'xhSjRemark';
 	}
 
 }

+ 244 - 234
biz-ty/sj/classes/MerchantClass.php

@@ -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;
+	}
+	
 }

+ 1 - 1
biz-ty/sj/models/Merchant.php

@@ -7,7 +7,7 @@ class Merchant extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchant';
+		return 'xhSj';
 	}
 
 }

+ 1 - 1
biz-ty/sj/models/MerchantAsset.php

@@ -7,7 +7,7 @@ class MerchantAsset extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantAsset';
+		return 'xhSjAsset';
 	}
 
 }

+ 1 - 1
biz-ty/sj/models/MerchantInit.php

@@ -7,7 +7,7 @@ class MerchantInit extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantInit';
+		return 'xhSjInit';
 	}
 
 }

+ 1 - 1
biz-ty/sj/models/MerchantRemark.php

@@ -7,7 +7,7 @@ class MerchantRemark extends Base
 
 	public static function tableName()
 	{
-		return 'xhMerchantRemark';
+		return 'xhSjRemark';
 	}
 
 }

+ 5 - 0
biz/saas/classes/ApplyExtendClass.php

@@ -15,6 +15,11 @@ class ApplyExtendClass extends BaseClass
 
     public static $baseFile = '\biz\saas\models\ApplyExtend';
 
+	//证件类型
+    const CERT_TYPE_LICENSE = 1;
+	const CERT_TYPE_PERSON = 2;
+	const CERT_TYPE_MOBILE = 3;
+
     public static function getExtendByIds($ids)
     {
         $list = self::getAllByCondition(['applyId' => ['in', $ids]], null, '*', 'applyId');

+ 92 - 100
biz/saas/services/ApplyService.php

@@ -20,106 +20,98 @@ use common\services\xhMerchantService;
 
 class ApplyService extends BaseService
 {
+	
+	public static $baseFile = '\biz\saas\classes\ApplyClass';
+	
+	//申请列表 shish 2021.1.28
+	public static function getApplyList($where)
+	{
+		$data = ApplyClass::getList('*', $where, 'addTime DESC');
+		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+		if (empty($list)) {
+			return $data;
+		}
+		//商家信息
+		$oldList = array_column($list, 'introSjId');
+		$merchantIdList = array_column($list, 'merchantId');
+		$ids = array_merge($merchantIdList, $oldList);
+		$ids = array_unique(array_filter($ids));
+		$merchant = MerchantClass::getMerchantByIds($ids);
+		
+		$applyIds = array_unique(array_filter(array_column($list, 'id')));
+		$extend = ApplyExtendClass::getExtendByIds($applyIds);
+		
+		foreach ($list as $key => $val) {
+			$currentId = $val['id'] ?? 0;
+			$list[$key]['licenseNo'] = $extend[$currentId]['licenseNo'] ?? '';
+			$list[$key]['license'] = $extend[$currentId]['license'] ?? '';
+			$introSjId = $val['introSjId'];
+			$introSjName = $merchant[$introSjId]['merchantName'] ?? '';
+			$list[$key]['introSjName'] = $introSjName;
+		}
+		$data['list'] = $list;
+		$data['balance'] = 0.00;
+		$data['invitedNum'] = 10;
+		$data['payNum'] = 5;
+		$data['income'] = 100;
+		return $data;
+	}
+	
+	//审核通过,商家初始化 shish 2021.2.23
+	public static function pass($id)
+	{
+		$apply = ApplyClass::getById($id);
+		if (empty($apply)) {
+			util::fail('没有找到申请记录');
+		}
+		unset($apply['id']);
+		$adminId = $apply['adminId'];
+		$admin = AdminClass::getById($adminId);
+		$apply['merchantName'] = isset($apply['name']) ? $apply['name'] : '';
+		$apply['adminName'] = $admin['adminName'] ?? '';
+		return MerchantClass::generateSj($apply);
+	}
 
-    public static $baseFile = '\biz\saas\classes\ApplyClass';
-
-    //申请列表 shish 2021.1.28
-    public static function getApplyList($where)
-    {
-        $data = ApplyClass::getList('*', $where, 'addTime DESC');
-        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-        if (empty($list)) {
-            return $data;
-        }
-        //商家信息
-        $oldList = array_column($list, 'introSjId');
-        $merchantIdList = array_column($list, 'merchantId');
-        $ids = array_merge($merchantIdList, $oldList);
-        $ids = array_unique(array_filter($ids));
-        $merchant = MerchantClass::getMerchantByIds($ids);
-
-        $applyIds = array_unique(array_filter(array_column($list, 'id')));
-        $extend = ApplyExtendClass::getExtendByIds($applyIds);
-
-        foreach ($list as $key => $val) {
-            $currentId = $val['id'] ?? 0;
-            $list[$key]['licenseNo'] = $extend[$currentId]['licenseNo'] ?? '';
-            $list[$key]['license'] = $extend[$currentId]['license'] ?? '';
-            $introSjId = $val['introSjId'];
-            $introSjName = $merchant[$introSjId]['merchantName'] ?? '';
-            $list[$key]['introSjName'] = $introSjName;
-        }
-        $data['list'] = $list;
-        $data['balance'] = 0.00;
-        $data['invitedNum'] = 10;
-        $data['payNum'] = 5;
-        $data['income'] = 100;
-        return $data;
-    }
-
-    //审核通过,商家初始化 shish 2021.2.23
-    public static function pass($id)
-    {
-        $apply = ApplyClass::getById($id);
-        if (empty($apply)) {
-            util::fail('没有找到申请记录');
-        }
-        unset($apply['id']);
-        $adminId = $apply['adminId'];
-        $admin = AdminClass::getById($adminId);
-        $apply['merchantName'] = isset($apply['name']) ? $apply['name'] : '';
-        $apply['adminName'] = $admin['adminName'] ?? '';
-        return MerchantClass::generateSj($apply);
-    }
-
-    //申请开店 shish 2021.01.28
-    public static function addApply($data)
-    {
-        $style = $data['style'] ?? 0;
-        if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
-            util::fail('请确认开店资料');
-        }
-        $mobile = $data['mobile'] ?? 0;
-        if (empty($mobile)) {
-            util::fail('请填写手机号');
-        }
-        if (stringUtil::isMobile($mobile) == false) {
-            util::fail('请填写正确手机号');
-        }
-        $adminId = $data['adminId'] ?? 0;
-        $apply = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => $style]);
-        if (!empty($apply)) {
-            util::fail('手机号已被使用');
-        }
-        $from = $data['from'] ?? 0;
-        if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
-            util::fail('请确认开店资料是否完整!');
-        }
-        $apply = ApplyClass::getByCondition(['adminId' => $adminId, 'from' => $from, 'style' => $style]);
-        if (!empty($apply)) {
-            util::fail('您已经申请过了');
-        }
-        $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
-        $dist = $data['dist'] ?? '';
-        $floor = $data['floor'] ?? '';
-        $address = $data['address'] ?? '';
-        $data['fullAddress'] = $prefix . $dist . $address . $floor;
-        ApplyClass::addApply($data);
-        $mobile = $data['mobile'];
-        if ($style == MerchantClass::STYLE_RETAIL) {
-            $text = "有零售商资料提交,";
-        } else {
-            $text = "供货商申请开店,";
-        }
-        $text .= '客户(' . $mobile . ')已提交资料,';
-        $introSjId = $data['introSjId'] ?? 0;
-        if (!empty($introSjId)) {
-            $merchant = MerchantClass::getMerchantById($introSjId);
-            $name = $merchant['merchantName'] ?? '';
-            $text .= "介绍人:{$name},";
-        }
-        $text .= "请及时跟进";
-        noticeUtil::push($text, '15280215347');
-    }
+	//申请开店 shish 2021.01.28
+	public static function addApply($data)
+	{
+		$style = $data['style'] ?? 0;
+		if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
+			util::fail('请确认开店资料');
+		}
+		$mobile = $data['mobile'] ?? 0;
+		if (empty($mobile)) {
+			util::fail('请填写手机号');
+		}
+		if (stringUtil::isMobile($mobile) == false) {
+			util::fail('请填写正确手机号');
+		}
+		$adminId = $data['adminId'] ?? 0;
+		$from = $data['from'] ?? 0;
+		if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
+			util::fail('请确认开店资料是否完整!');
+		}
+		$prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
+		$dist = $data['dist'] ?? '';
+		$floor = $data['floor'] ?? '';
+		$address = $data['address'] ?? '';
+		$data['fullAddress'] = $prefix . $dist . $address . $floor;
+		ApplyClass::addApply($data);
+		$mobile = $data['mobile'];
+		if ($style == MerchantClass::STYLE_RETAIL) {
+			$text = "有零售商资料提交,";
+		} else {
+			$text = "供货商申请开店,";
+		}
+		$text .= '客户(' . $mobile . ')已提交资料,';
+		$introSjId = $data['introSjId'] ?? 0;
+		if (!empty($introSjId)) {
+			$merchant = MerchantClass::getMerchantById($introSjId);
+			$name = $merchant['merchantName'] ?? '';
+			$text .= "介绍人:{$name},";
+		}
+		$text .= "请及时跟进";
+		noticeUtil::push($text, '15280215347');
+	}
 
 }

+ 1 - 1
common/models/xhMerchant.php

@@ -7,7 +7,7 @@ class xhMerchant extends xhBaseModel
 
     public static function tableName()
     {
-        return 'xhMerchant';
+        return 'xhSj';
     }
 
 }

+ 1 - 1
common/models/xhMerchantAsset.php

@@ -6,6 +6,6 @@ class xhMerchantAsset extends xhBaseModel
 {
     public static function tableName()
     {
-        return 'xhMerchantAsset';
+        return 'xhSjAsset';
     }
 }

+ 7 - 1
sql.sql

@@ -1226,4 +1226,10 @@ ALTER TABLE xhShopAdmin DROP COLUMN `addTime`;
 ALTER TABLE xhShopAdmin ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `status`;
 ALTER TABLE xhShopAdmin ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
 ALTER TABLE xhMerchantAsset DROP COLUMN `createTime`;
-ALTER TABLE xhMerchantAsset ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `remainSmsNum`;
+ALTER TABLE xhMerchantAsset ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `remainSmsNum`;
+ALTER TABLE xhApplyExtend ADD certType TINYINT NOT NULL DEFAULT 1 COMMENT '证件类型 1营业执照 2身份证号 3手机号' AFTER licenseNo;
+ALTER TABLE xhMerchant RENAME TO xhSj;
+ALTER TABLE xhMerchantAsset RENAME TO xhSjAsset;
+ALTER TABLE xhMerchantExtend RENAME TO xhSjExtend;
+ALTER TABLE xhMerchantInit RENAME TO xhSjInit;
+ALTER TABLE xhMerchantRemark RENAME TO xhSjRemark;