Parcourir la source

申请开店列表 商家列表

shish il y a 5 ans
Parent
commit
4719d1c4bd

+ 8 - 5
app/ghs/controllers/ApplyController.php

@@ -17,20 +17,23 @@ use yii\web\Controller;
 
 class ApplyController extends BaseController
 {
-	
-	//我的代理 shish 2019.12.26
+
+	//邀请开店列表 shish 2021.1.28
 	public function actionList()
 	{
-		$status = Yii::$app->request->get('status', 0);
+		$get = Yii::$app->request->get();
 		$where = [];
 		$where['introSjId'] = $this->sjId;
-		if ($status != -1) {
+		$status = $get['status'] ?? 0;
+		$style = $get['style'] ?? MerchantClass::STYLE_SUPPLIER;
+		if (!empty($status)) {
 			$where['status'] = $status;
 		}
+		$where['style'] = $style;
 		$data = ApplyService::getApplyList($where);
 		util::success($data);
 	}
-	
+
 	//审核
 	public function actionCheck()
 	{

+ 4 - 5
app/mall/controllers/MerchantController.php

@@ -26,7 +26,7 @@ class MerchantController extends BaseController
 		$merchant = MerchantService::getInfo($this->merchant, $this->merchantExtend);
 		util::success($merchant);
 	}
-
+	
 	//客户的会员等级 shish 2020.1.2
 	public function actionUserGrade()
 	{
@@ -39,9 +39,8 @@ class MerchantController extends BaseController
 	{
 		$id = Yii::$app->request->get('merchantId');
 		$merchant = MerchantService::getById($id);
-		$deadline = $merchant['setDeadline'];
-		$date = date("Y-m-d H:i", $deadline);
-		util::success(['date' => $date]);
+		$deadline = $merchant['deadline'];
+		util::success(['date' => $deadline]);
 	}
-
+	
 }

+ 0 - 1
app/saas/controllers/ApplyController.php

@@ -54,7 +54,6 @@ class ApplyController extends BaseController
 	//申请状态
 	public function actionApplyStatus()
 	{
-		//-1申请试用 0审核中 1审核通过、试用中 2审核未通过 3已付费,立即订购 4试用到期失效,待付款,立即订购,价格不显示
 		$status = rand(0, 4);
 		util::success(['status' => $status]);
 	}

+ 231 - 225
app/saas/controllers/MerchantController.php

@@ -2,6 +2,7 @@
 
 namespace saas\controllers;
 
+use biz\merchant\classes\MerchantClass;
 use biz\merchant\services\MerchantExtendService;
 use biz\wx\classes\WxBaseClass;
 use biz\wx\classes\WxMiniBaseClass;
@@ -15,229 +16,234 @@ use common\services\xhMerchantService;
 
 class MerchantController extends BaseController
 {
-
-    public $withoutLogin = ['bind-open'];
-
-    //商家列表 shish 2019.12.20
-    public function actionList()
-    {
-        $where = [];
-        $list = MerchantService::getSaasMerchant($where);
-        util::success($list);
-    }
-
-    //获取当前登陆老板的帐号详情,官网购买套餐时使用 shish 2020.1.11
-    public function actionLoginAccount()
-    {
-        $userId = $this->userId;
-        $admin = AdminService::getByCondition(['platUserId' => $userId]);
-        if (empty($admin)) {
-            util::fail('没有找到注册信息');
-        }
-        $merchantId = $admin['merchantId'];
-        $merchant = MerchantService::getMerchantById($merchantId);
-        util::success($merchant);
-    }
-
-    //商家信息 shish 2020.1.11
-    public function actionDetail()
-    {
-        $id = Yii::$app->request->get('id');
-        $merchant = MerchantService::getMerchantById(12358);
-        util::success($merchant);
-    }
-
-    //开放平台设置相关操作 shish 2020.1.18
-    public function actionBindOpen()
-    {
-        $isOpen = Yii::$app->request->get('isOpen', 1);
-
-        $merchantId = 0;
-        if ($isOpen == 0) {
-            //其它
-            $merchantId = Yii::$app->request->get('account', 0);
-            $merchant = MerchantService::getById($merchantId);
-            if (empty($merchant)) {
-                util::fail('没有找到商家');
-            }
-            $wxAppId = $merchant['wxAppId'];
-            $miniAppId = $merchant['miniAppId'];
-            $openAppId = $merchant['openAppId'];
-        } elseif ($isOpen == 1) {
-            //零售
-            $merchant = WxOpenClass::getWxInfo();
-            $miniAppId = $merchant['miniAppId'];
-            $wxAppId = $merchant['wxAppId'];
-            $openAppId = $merchant['openAppId'];
-        } elseif ($isOpen == 2) {
-            //供货商
-            $merchant = WxOpenClass::getGhsWxInfo();
-            $miniAppId = $merchant['miniAppId'];
-            $wxAppId = $merchant['wxAppId'];
-            $openAppId = $merchant['openAppId'];
-        }
-        echo "<pre>";
-
-        $id = Yii::$app->request->get('id', 0);
-
-        //创建平台,并将公众号绑定到平台
-        if ($id == 1) {
-            wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
-            $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-            print_r($return);
-            if ($return['errcode'] == 0) {
-                $openAppId = $return['open_appid'];
-                if ($isOpen == 0) {
-                    xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
-                    MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
-                } elseif ($isOpen == 1) {
-                    $open = WxOpenClass::getOpen();
-                    $wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
-                    $wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
-                    WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
-                    WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
-                } elseif ($isOpen == 2) {
-                    $open = WxOpenClass::getOpen();
-                    $wxMiniBaseId = isset($open['wxGhsMiniBaseId']) ? $open['wxGhsMiniBaseId'] : 0;
-                    $wxBaseId = isset($open['wxGhsBaseId']) ? $open['wxGhsBaseId'] : 0;
-                    WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
-                    WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
-                }
-            }
-        }
-        //将小程序绑定到平台
-        if ($id == 2) {
-            $openAppId = $merchant['openAppId'];
-            $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
-            //MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
-            print_r($r);
-        }
-        //查询公众号 小程序的绑定情况
-        if ($id == 3) {
-            Yii::info("查询公众号 小程序的绑定情况 wxAppId:{$wxAppId} isOpen:{$isOpen}");
-            $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-            echo "公众号绑定情况:<br />";
-            print_r($return);
-            $return = wxUtil::getOpenAccount($miniAppId, $merchant, true, $isOpen);
-            echo "小程序绑定情况:<br />";
-            print_r($return);
-        }
-
-        //设置小程序服务器域名
-        if ($id == 4) {
-            wxUtil::setDomain($merchant, $isOpen);
-            wxUtil::setWebViewDomain($merchant, $isOpen);
-        }
-
-        //为授权的小程序帐号上传小程序代码
-        if ($id == 5) {
-            //模板id
-            $tId = Yii::$app->request->get('tId');
-            wxUtil::miniCommit($merchant, $tId, $isOpen);
-        }
-
-        //获取小程序体验码
-        if ($id == 6) {
-            wxUtil::getExperienceQrCode($merchant, '', $isOpen);
-        }
-
-        //获取授权小程序帐号已设置的类目
-        if ($id == 7) {
-            wxUtil::getMiniCategory($merchant, $isOpen);
-        }
-
-        //获取小程序的第三方提交代码的页面配置
-        if ($id == 8) {
-            wxUtil::getMiniPage($merchant, $isOpen);
-        }
-
-        //将第三方提交的代码包提交审核
-        if ($id == 9) {
-            wxUtil::miniSubmitAudit($merchant, '', $isOpen);
-        }
-
-        //查询最新一次提交的审核状态
-        if ($id == 10) {
-            wxUtil::miniGetLatestAuditStatus($merchant, $isOpen);
-        }
-
-        //发布已通过审核的小程序
-        if ($id == 11) {
-            $respond = wxUtil::miniRelease($merchant, $isOpen);
-            dd($respond);
-        }
-
-        //撤回审核
-        if ($id == 12) {
-            wxUtil::rollbackCheck($merchant, $isOpen);
-        }
-        //生成 申请会员页 的小程序码
-        if ($id == 13) {
-            wxUtil::generateMemberCode($merchant, $isOpen);
-        }
-        //解绑小程序和公众号绑定的平台
-        if ($id == 14) {
-            wxUtil::unbindAccount($merchant, $isOpen);
-            wxUtil::unbindMiniProgram($merchant, $isOpen);
-        }
-        Yii::$app->end();
-
-        $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
-        print_r($r);
-        echo $miniAppId . ' ' . $openAppId . ' ';
-
-        $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-        print_r($return);
-        die;
-
-        $return = wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
-        print_r($return);
-        die;
-
-        $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false, $isOpen);
-        print_r($r);
-        echo $miniAppId . ' ' . $openAppId . ' ';
-
-        $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-        print_r($return);
-        $return = wxUtil::getOpenAccount($miniAppId, $merchant, false, $isOpen);
-        print_r($return);
-    }
-
-    //平台帐号激活 shish 2020.2.15
-    public function actionAddPlatformMerchant()
-    {
-        MerchantService::initOpenMerchant();
-        echo 'ok';
-    }
-
-    //注释商家 shish 2020.3.4
-    public function actionCancel()
-    {
-        if (getenv('YII_ENV') != 'test') {
-            util::fail('只有测试环境才能操作');
-        }
-        $id = Yii::$app->request->get('id', 0);
-        $merchant = MerchantService::getById($id, true);
-        if (isset($merchant->wxAppId) && empty($merchant->wxAppId)) {
-            util::fail('已注销/未授权');
-        }
-        $merchant->wxAppId = '';
-        $merchant->miniAppId = '';
-        $merchant->save();
-        $extend = MerchantExtendService::getByMerchantId($id, true);
-        $extend->miniAppId = '';
-        $extend->wxAppId = '';
-        $extend->save();
-        util::complete();
-    }
-
-    //商家h5商城二维码 shish 2020.4.30
-    public function actionGetH5MallQrCode()
-    {
-        $id = Yii::$app->request->get('id', 0);
-        $imgUrl = MerchantService::getH5MallQrCode($id);
-        util::success(['imgUrl' => $imgUrl]);
-    }
-
+	
+	public $withoutLogin = ['bind-open'];
+	
+	//商家列表 shish 2019.12.20
+	public function actionList()
+	{
+		$get = Yii::$app->request->get();
+		$style = $get['style'] ?? MerchantClass::STYLE_RETAIL;
+		$where = [];
+		if (!empty($style)) {
+			$where['style'] = $style;
+		}
+		$list = MerchantService::getMerchantList($where);
+		util::success($list);
+	}
+
+	//获取当前登陆老板的帐号详情,官网购买套餐时使用 shish 2020.1.11
+	public function actionLoginAccount()
+	{
+		$userId = $this->userId;
+		$admin = AdminService::getByCondition(['platUserId' => $userId]);
+		if (empty($admin)) {
+			util::fail('没有找到注册信息');
+		}
+		$merchantId = $admin['merchantId'];
+		$merchant = MerchantService::getMerchantById($merchantId);
+		util::success($merchant);
+	}
+	
+	//商家信息 shish 2020.1.11
+	public function actionDetail()
+	{
+		$id = Yii::$app->request->get('id');
+		$merchant = MerchantService::getMerchantById(12358);
+		util::success($merchant);
+	}
+	
+	//开放平台设置相关操作 shish 2020.1.18
+	public function actionBindOpen()
+	{
+		$isOpen = Yii::$app->request->get('isOpen', 1);
+		
+		$merchantId = 0;
+		if ($isOpen == 0) {
+			//其它
+			$merchantId = Yii::$app->request->get('account', 0);
+			$merchant = MerchantService::getById($merchantId);
+			if (empty($merchant)) {
+				util::fail('没有找到商家');
+			}
+			$wxAppId = $merchant['wxAppId'];
+			$miniAppId = $merchant['miniAppId'];
+			$openAppId = $merchant['openAppId'];
+		} elseif ($isOpen == 1) {
+			//零售
+			$merchant = WxOpenClass::getWxInfo();
+			$miniAppId = $merchant['miniAppId'];
+			$wxAppId = $merchant['wxAppId'];
+			$openAppId = $merchant['openAppId'];
+		} elseif ($isOpen == 2) {
+			//供货商
+			$merchant = WxOpenClass::getGhsWxInfo();
+			$miniAppId = $merchant['miniAppId'];
+			$wxAppId = $merchant['wxAppId'];
+			$openAppId = $merchant['openAppId'];
+		}
+		echo "<pre>";
+		
+		$id = Yii::$app->request->get('id', 0);
+		
+		//创建平台,并将公众号绑定到平台
+		if ($id == 1) {
+			wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
+			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+			print_r($return);
+			if ($return['errcode'] == 0) {
+				$openAppId = $return['open_appid'];
+				if ($isOpen == 0) {
+					xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
+					MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
+				} elseif ($isOpen == 1) {
+					$open = WxOpenClass::getOpen();
+					$wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
+					$wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
+					WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
+					WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
+				} elseif ($isOpen == 2) {
+					$open = WxOpenClass::getOpen();
+					$wxMiniBaseId = isset($open['wxGhsMiniBaseId']) ? $open['wxGhsMiniBaseId'] : 0;
+					$wxBaseId = isset($open['wxGhsBaseId']) ? $open['wxGhsBaseId'] : 0;
+					WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
+					WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
+				}
+			}
+		}
+		//将小程序绑定到平台
+		if ($id == 2) {
+			$openAppId = $merchant['openAppId'];
+			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
+			//MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
+			print_r($r);
+		}
+		//查询公众号 小程序的绑定情况
+		if ($id == 3) {
+			Yii::info("查询公众号 小程序的绑定情况 wxAppId:{$wxAppId} isOpen:{$isOpen}");
+			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+			echo "公众号绑定情况:<br />";
+			print_r($return);
+			$return = wxUtil::getOpenAccount($miniAppId, $merchant, true, $isOpen);
+			echo "小程序绑定情况:<br />";
+			print_r($return);
+		}
+		
+		//设置小程序服务器域名
+		if ($id == 4) {
+			wxUtil::setDomain($merchant, $isOpen);
+			wxUtil::setWebViewDomain($merchant, $isOpen);
+		}
+		
+		//为授权的小程序帐号上传小程序代码
+		if ($id == 5) {
+			//模板id
+			$tId = Yii::$app->request->get('tId');
+			wxUtil::miniCommit($merchant, $tId, $isOpen);
+		}
+		
+		//获取小程序体验码
+		if ($id == 6) {
+			wxUtil::getExperienceQrCode($merchant, '', $isOpen);
+		}
+		
+		//获取授权小程序帐号已设置的类目
+		if ($id == 7) {
+			wxUtil::getMiniCategory($merchant, $isOpen);
+		}
+		
+		//获取小程序的第三方提交代码的页面配置
+		if ($id == 8) {
+			wxUtil::getMiniPage($merchant, $isOpen);
+		}
+		
+		//将第三方提交的代码包提交审核
+		if ($id == 9) {
+			wxUtil::miniSubmitAudit($merchant, '', $isOpen);
+		}
+		
+		//查询最新一次提交的审核状态
+		if ($id == 10) {
+			wxUtil::miniGetLatestAuditStatus($merchant, $isOpen);
+		}
+		
+		//发布已通过审核的小程序
+		if ($id == 11) {
+			$respond = wxUtil::miniRelease($merchant, $isOpen);
+			dd($respond);
+		}
+		
+		//撤回审核
+		if ($id == 12) {
+			wxUtil::rollbackCheck($merchant, $isOpen);
+		}
+		//生成 申请会员页 的小程序码
+		if ($id == 13) {
+			wxUtil::generateMemberCode($merchant, $isOpen);
+		}
+		//解绑小程序和公众号绑定的平台
+		if ($id == 14) {
+			wxUtil::unbindAccount($merchant, $isOpen);
+			wxUtil::unbindMiniProgram($merchant, $isOpen);
+		}
+		Yii::$app->end();
+		
+		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
+		print_r($r);
+		echo $miniAppId . ' ' . $openAppId . ' ';
+		
+		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+		print_r($return);
+		die;
+		
+		$return = wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
+		print_r($return);
+		die;
+		
+		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false, $isOpen);
+		print_r($r);
+		echo $miniAppId . ' ' . $openAppId . ' ';
+		
+		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+		print_r($return);
+		$return = wxUtil::getOpenAccount($miniAppId, $merchant, false, $isOpen);
+		print_r($return);
+	}
+	
+	//平台帐号激活 shish 2020.2.15
+	public function actionAddPlatformMerchant()
+	{
+		MerchantService::initOpenMerchant();
+		echo 'ok';
+	}
+	
+	//注释商家 shish 2020.3.4
+	public function actionCancel()
+	{
+		if (getenv('YII_ENV') != 'test') {
+			util::fail('只有测试环境才能操作');
+		}
+		$id = Yii::$app->request->get('id', 0);
+		$merchant = MerchantService::getById($id, true);
+		if (isset($merchant->wxAppId) && empty($merchant->wxAppId)) {
+			util::fail('已注销/未授权');
+		}
+		$merchant->wxAppId = '';
+		$merchant->miniAppId = '';
+		$merchant->save();
+		$extend = MerchantExtendService::getByMerchantId($id, true);
+		$extend->miniAppId = '';
+		$extend->wxAppId = '';
+		$extend->save();
+		util::complete();
+	}
+	
+	//商家h5商城二维码 shish 2020.4.30
+	public function actionGetH5MallQrCode()
+	{
+		$id = Yii::$app->request->get('id', 0);
+		$imgUrl = MerchantService::getH5MallQrCode($id);
+		util::success(['imgUrl' => $imgUrl]);
+	}
+	
 }

+ 6 - 2
app/shop/controllers/ApplyController.php

@@ -3,6 +3,7 @@
 namespace shop\controllers;
 
 use biz\admin\services\ShopAdminService;
+use biz\merchant\classes\MerchantClass;
 use biz\saas\services\ApplyService;
 use biz\wx\services\WxBaseService;
 use biz\wx\services\WxOpenService;
@@ -20,12 +21,15 @@ class ApplyController extends BaseController
 	//我的代理 shish 2019.12.26
 	public function actionList()
 	{
-		$status = Yii::$app->request->get('status', 0);
+		$get = Yii::$app->request->get();
 		$where = [];
 		$where['introSjId'] = $this->sjId;
-		if ($status != -1) {
+		$status = $get['status'] ?? 0;
+		$style = $get['style'] ?? MerchantClass::STYLE_RETAIL;
+		if (!empty($status)) {
 			$where['status'] = $status;
 		}
+		$where['style'] = $style;
 		$data = ApplyService::getApplyList($where);
 		util::success($data);
 	}

+ 2 - 3
app/shop/controllers/MallMerchantController.php

@@ -39,9 +39,8 @@ class MallMerchantController extends BaseController
 	{
 		$id = Yii::$app->request->get('merchantId');
 		$merchant = MerchantService::getById($id);
-		$deadline = $merchant['setDeadline'];
-		$date = date("Y-m-d H:i", $deadline);
-		util::success(['date' => $date]);
+		$deadline = $merchant['deadline'];
+		util::success(['date' => $deadline]);
 	}
 
 }

+ 205 - 197
biz/merchant/services/MerchantService.php

@@ -25,201 +25,209 @@ use Yii;
 
 class MerchantService extends BaseService
 {
-
-    public static $baseFile = '\biz\merchant\classes\MerchantClass';
-
-    //商家在业务端的权限 shish 2019.11.25
-    public static function getAuthIdList($merchantId, $endId)
-    {
-        $merchant = self::getById($merchantId);
-        $setId = $merchant['setId'];
-        if (empty($setId)) {
-            util::fail('没有找到商家的套餐');
-        }
-
-        //业务端总共有哪些权限
-        $idList = AuthService::getListId($endId);
-
-        //套餐在业务端有哪些权限
-        $setIdList = SetAuthService::getAuthIdList($setId, $endId);
-
-        //有*号表示有所有的权限
-        $commonIdList = in_array('*', $setIdList) ? $idList : array_intersect($idList, $setIdList);
-
-        return $commonIdList;
-
-    }
-
-    //获取默认门店
-    public static function getDefaultShopId($merchant)
-    {
-        return MerchantClass::getDefaultShopId($merchant);
-    }
-
-    //商家基本信息,$sensitive true 除敏感信息 shish 2019.12.8
-    public static function getInfo($merchant, $extend, $sensitive = true)
-    {
-        if ($sensitive) {
-            $delete = ['miniAppId', 'miniAppSecret', 'wxAppId', 'wxAppSecret', 'openAppId', 'wxToken', 'wxJsApiTicket', 'wxAccessToken', 'wxRefreshToken'];
-            foreach ($delete as $del) {
-                unset($merchant[$del]);
-            }
-            $deleteExtend = ['miniAppId', 'miniAccessToken', 'miniRefreshToken', 'wxPayKey', 'wxPayMerchantId', 'wxAppId'];
-            foreach ($deleteExtend as $delExtend) {
-                unset($extend[$delExtend]);
-            }
-        }
-        $merchant['extend'] = $extend;
-        return $merchant;
-    }
-
-    //常用链接 shish 2019.12.19
-    public static function getCommonUrlList()
-    {
-        $list = MerchantClass::$commonUrl;
-        return array_values($list);
-    }
-
-    //取指定常用链接 shish 2019.12.28
-    public static function getCommonUrl($id)
-    {
-        $list = MerchantClass::$commonUrl;
-        return isset($list[$id]) ? $list[$id] : [];
-    }
-
-    //取平台下的商家 shish 2019.12.20
-    public static function getSaasMerchant($where)
-    {
-        $data = MerchantClass::getList('*', $where, 'addTime DESC');
-        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-        if (empty($list)) {
-            return $data;
-        }
-
-        //管理员
-        $adminIdList = array_column($list, 'adminId');
-        $admin = AdminService::getAdminByIds($adminIdList, null, 'id');
-        //商家资产
-        $merchantIdList = array_column($list, 'id');
-        $asset = MerchantAssetService::getAssetByMerchantIds($merchantIdList);
-        //套餐
-        $setIdList = array_column($list, 'setId');
-        $set = SetMealService::getSetByIds($setIdList);
-        //拓展
-        $ext = MerchantExtendService::getExtendByMerchantIds($merchantIdList);
-        foreach ($list as $key => $val) {
-            $adminId = $val['adminId'];
-            $merchantId = $val['id'];
-            $setId = $val['setId'];
-            $val['adminName'] = isset($admin[$adminId]['adminName']) ? $admin[$adminId]['adminName'] : '';
-            $val['merchantAsset'] = isset($asset[$merchantId]) ? $asset[$merchantId] : [];
-            $val['setMealName'] = isset($set[$setId]) ? $set[$setId]['name'] : '';
-            $val['extend'] = isset($ext[$merchantId]) ? $ext[$merchantId] : [];
-            $list[$key] = business::formatMerchantLogo($val);
-        }
-        $data['list'] = $list;
-        return $data;
-    }
-
-    //根据id批量取商家 shish 2019.12.20
-    public static function getMerchantByIds($ids)
-    {
-        return MerchantClass::getMerchantByIds($ids);
-    }
-
-    //获取商家 shish 2019.12.30
-    public static function getMerchantById($id)
-    {
-        return MerchantClass::getMerchantById($id);
-    }
-
-    public static function getCurrentSetId($id)
-    {
-        return MerchantClass::getCurrentSetId($id);
-    }
-
-    //开店公众号授权之后初始化 shish 2020.2.7
-    public static function openShopInit($data)
-    {
-        $merchantId = $data['merchantId'];
-        $merchant = MerchantClass::getMerchantById($merchantId);
-        if (empty($merchant)) {
-            return false;
-        }
-        $extend = MerchantExtendClass::getByMerchantId($merchantId);
-        if (isset($extend['init']) && $extend['init'] == 1) {
-            return true;
-        }
-        //事务处理
-        $connection = Yii::$app->db;
-        $transaction = $connection->beginTransaction();
-        try {
-
-            //初始化微信菜单
-            $hasMenu = WxMenuService::getByCondition(['merchantId' => $merchantId]);
-            if (empty($hasMenu)) {
-                xhWxMenuService::applyInit($merchant);
-            }
-
-            //微信客户初始化
-            $hasUser = UserService::getByCondition(['merchantId' => $merchantId]);
-            if (empty($hasUser)) {
-                $return = UserService::syncWxAllUser($merchantId);
-                $totalNum = isset($return['total']) ? $return['total'] : 0;
-                MerchantAssetClass::updateByCondition(['merchantId' => $merchantId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]);
-            }
-
-            //模板消息
-            $hasMessage = TMessageService::getByCondition(['merchantId' => $merchantId]);
-            if (empty($hasMessage)) {
-                xhTMessageService::init($merchant);
-            }
-
-            //完成初始化标识
-            MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
-
-            //代理资产
-            AgentAssetClass::add(['merchantId' => $merchantId]);
-
-            $transaction->commit();
-            return true;
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return false;
-        }
-    }
-
-    //初始化平台的商家 shish 2020.2.11
-    public static function initOpenMerchant()
-    {
-        $open = WxOpenClass::getOpen();
-        if (isset($open['wxBaseId']) && !empty($open['wxBaseId']) && isset($open['wxMiniBaseId']) && !empty($open['wxMiniBaseId'])) {
-            util::stop('已初始化,无需重复操作');
-        }
-        $env = getenv('YII_ENV');
-        switch ($env) {
-            case 'local':
-                $merchantName = '花美灵';
-                break;
-            case 'dev':
-                $merchantName = '花美灵';
-                break;
-            case 'test':
-                $merchantName = '花掌柜';
-                break;
-            case 'production':
-                $merchantName = '花卉宝';
-                break;
-            default:
-                $merchantName = '花卉宝';
-        }
-        echo $merchantName;
-    }
-
-    //获取商家的h5商城二维码 shish 2020.4.30
-    public static function getH5MallQrCode($id)
-    {
-        return MerchantClass::getH5MallQrCode($id);
-    }
-
+	
+	public static $baseFile = '\biz\merchant\classes\MerchantClass';
+	
+	//商家在业务端的权限 shish 2019.11.25
+	public static function getAuthIdList($merchantId, $endId)
+	{
+		$merchant = self::getById($merchantId);
+		$setId = $merchant['setId'];
+		if (empty($setId)) {
+			util::fail('没有找到商家的套餐');
+		}
+		
+		//业务端总共有哪些权限
+		$idList = AuthService::getListId($endId);
+		
+		//套餐在业务端有哪些权限
+		$setIdList = SetAuthService::getAuthIdList($setId, $endId);
+		
+		//有*号表示有所有的权限
+		$commonIdList = in_array('*', $setIdList) ? $idList : array_intersect($idList, $setIdList);
+		
+		return $commonIdList;
+		
+	}
+	
+	//获取默认门店
+	public static function getDefaultShopId($merchant)
+	{
+		return MerchantClass::getDefaultShopId($merchant);
+	}
+	
+	//商家基本信息,$sensitive true 除敏感信息 shish 2019.12.8
+	public static function getInfo($merchant, $extend, $sensitive = true)
+	{
+		if ($sensitive) {
+			$delete = ['miniAppId', 'miniAppSecret', 'wxAppId', 'wxAppSecret', 'openAppId', 'wxToken', 'wxJsApiTicket', 'wxAccessToken', 'wxRefreshToken'];
+			foreach ($delete as $del) {
+				unset($merchant[$del]);
+			}
+			$deleteExtend = ['miniAppId', 'miniAccessToken', 'miniRefreshToken', 'wxPayKey', 'wxPayMerchantId', 'wxAppId'];
+			foreach ($deleteExtend as $delExtend) {
+				unset($extend[$delExtend]);
+			}
+		}
+		$merchant['extend'] = $extend;
+		return $merchant;
+	}
+	
+	//常用链接 shish 2019.12.19
+	public static function getCommonUrlList()
+	{
+		$list = MerchantClass::$commonUrl;
+		return array_values($list);
+	}
+	
+	//取指定常用链接 shish 2019.12.28
+	public static function getCommonUrl($id)
+	{
+		$list = MerchantClass::$commonUrl;
+		return isset($list[$id]) ? $list[$id] : [];
+	}
+	
+	//商家列表 shish 2019.12.20
+	public static function getMerchantList($where)
+	{
+		$data = MerchantClass::getList(['merchantName'], $where, 'addTime DESC');
+		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+		if (empty($list)) {
+			return $data;
+		}
+		
+		//商家资产
+		$merchantIdList = array_column($list, 'id');
+		$asset = MerchantAssetService::getAssetByMerchantIds($merchantIdList);
+		
+		//套餐
+		$setIdList = array_column($list, 'setId');
+		$set = SetMealService::getSetByIds($setIdList);
+		
+		//拓展
+		$ext = MerchantExtendService::getExtendByMerchantIds($merchantIdList);
+		
+		foreach ($list as $key => $val) {
+			$adminId = $val['adminId'];
+			$merchantId = $val['id'];
+			$setId = $val['setId'];
+			$val['adminName'] = '';
+			$val['city'] = '厦门';
+			$val['credit'] = '良好';
+			$val['totalIncome'] = 100;
+			$val['totalExpend'] = 10;
+			$val['totalUser'] = 500;
+			$val['totalView'] = 100;
+			$val['shopNum'] = 2;
+			$val['main'] = '零售';
+			$val['setName'] = '标准版';
+			$val['deadline'] = date("Y-m-d H:i:s");
+			$val['status'] = '正常';
+			$list[$key] = business::formatMerchantLogo($val);
+		}
+		$data['list'] = $list;
+		return $data;
+	}
+	
+	//根据id批量取商家 shish 2019.12.20
+	public static function getMerchantByIds($ids)
+	{
+		return MerchantClass::getMerchantByIds($ids);
+	}
+	
+	//获取商家 shish 2019.12.30
+	public static function getMerchantById($id)
+	{
+		return MerchantClass::getMerchantById($id);
+	}
+	
+	public static function getCurrentSetId($id)
+	{
+		return MerchantClass::getCurrentSetId($id);
+	}
+	
+	//开店公众号授权之后初始化 shish 2020.2.7
+	public static function openShopInit($data)
+	{
+		$merchantId = $data['merchantId'];
+		$merchant = MerchantClass::getMerchantById($merchantId);
+		if (empty($merchant)) {
+			return false;
+		}
+		$extend = MerchantExtendClass::getByMerchantId($merchantId);
+		if (isset($extend['init']) && $extend['init'] == 1) {
+			return true;
+		}
+		//事务处理
+		$connection = Yii::$app->db;
+		$transaction = $connection->beginTransaction();
+		try {
+			
+			//初始化微信菜单
+			$hasMenu = WxMenuService::getByCondition(['merchantId' => $merchantId]);
+			if (empty($hasMenu)) {
+				xhWxMenuService::applyInit($merchant);
+			}
+			
+			//微信客户初始化
+			$hasUser = UserService::getByCondition(['merchantId' => $merchantId]);
+			if (empty($hasUser)) {
+				$return = UserService::syncWxAllUser($merchantId);
+				$totalNum = isset($return['total']) ? $return['total'] : 0;
+				MerchantAssetClass::updateByCondition(['merchantId' => $merchantId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]);
+			}
+			
+			//模板消息
+			$hasMessage = TMessageService::getByCondition(['merchantId' => $merchantId]);
+			if (empty($hasMessage)) {
+				xhTMessageService::init($merchant);
+			}
+			
+			//完成初始化标识
+			MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
+			
+			//代理资产
+			AgentAssetClass::add(['merchantId' => $merchantId]);
+			
+			$transaction->commit();
+			return true;
+		} catch (Exception $e) {
+			$transaction->rollBack();
+			return false;
+		}
+	}
+	
+	//初始化平台的商家 shish 2020.2.11
+	public static function initOpenMerchant()
+	{
+		$open = WxOpenClass::getOpen();
+		if (isset($open['wxBaseId']) && !empty($open['wxBaseId']) && isset($open['wxMiniBaseId']) && !empty($open['wxMiniBaseId'])) {
+			util::stop('已初始化,无需重复操作');
+		}
+		$env = getenv('YII_ENV');
+		switch ($env) {
+			case 'local':
+				$merchantName = '花美灵';
+				break;
+			case 'dev':
+				$merchantName = '花美灵';
+				break;
+			case 'test':
+				$merchantName = '花掌柜';
+				break;
+			case 'production':
+				$merchantName = '花卉宝';
+				break;
+			default:
+				$merchantName = '花卉宝';
+		}
+		echo $merchantName;
+	}
+	
+	//获取商家的h5商城二维码 shish 2020.4.30
+	public static function getH5MallQrCode($id)
+	{
+		return MerchantClass::getH5MallQrCode($id);
+	}
+	
 }

+ 12 - 12
biz/saas/services/ApplyService.php

@@ -22,6 +22,7 @@ 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');
@@ -29,23 +30,22 @@ class ApplyService extends BaseService
 		if (empty($list)) {
 			return $data;
 		}
-		//用户信息
-		$adminIdList = array_column($list, 'adminId');
-		$adminList = AdminService::getByIds($adminIdList, null, 'id');
 		//商家信息
 		$oldList = array_column($list, 'introSjId');
 		$merchantIdList = array_column($list, 'merchantId');
 		$idList = array_merge($merchantIdList, $oldList);
 		$idList = array_unique(array_filter($idList));
 		$merchant = [];
-		if (!empty($idList)) {
-			$merchant = MerchantService::getMerchantByIds($idList);
-		}
+		$merchant = MerchantService::getMerchantByIds($idList);
 		foreach ($list as $key => $val) {
 			$adminId = $val['adminId'];
 			$introSjId = $val['introSjId'];
 		}
 		$data['list'] = $list;
+		$data['balance'] = 0.00;
+		$data['invitedNum'] = 10;
+		$data['payNum'] = 5;
+		$data['income'] = 100;
 		return $data;
 	}
 	
@@ -66,6 +66,10 @@ class ApplyService extends BaseService
 	//申请开店 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('请填写手机号');
@@ -74,14 +78,10 @@ class ApplyService extends BaseService
 			util::fail('请填写正确手机号');
 		}
 		$adminId = $data['adminId'] ?? 0;
-		$apply = ApplyClass::getByCondition(['mobile' => $mobile]);
+		$apply = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => $style]);
 		if (!empty($apply)) {
 			util::fail('手机号已被使用');
 		}
-		$style = $data['style'] ?? 0;
-		if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
-			util::fail('请确认开店资料');
-		}
 		$from = $data['from'] ?? 0;
 		if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
 			util::fail('请确认开店资料是否完整!');
@@ -112,5 +112,5 @@ class ApplyService extends BaseService
 		$text .= "请及时跟进";
 		noticeUtil::push($text, '15280215347');
 	}
-
+	
 }

+ 7 - 1
sql.sql

@@ -1005,4 +1005,10 @@ ALTER TABLE `xhUnionUser` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TI
 将 销花宝 花卉宝 花掌柜 花美玲 的公众号和小程序 绑定到同一个开放平台下
 
 ALTER TABLE `xhApply` MODIFY `from` TINYINT NOT NULL DEFAULT 1 COMMENT '来源平台 1零售平台 2供货商平台';
-ALTER TABLE `xhApplyExtend` ADD applyId INT NOT NULL DEFAULT 0 COMMENT '申请id' AFTER `id`;
+ALTER TABLE `xhApplyExtend` ADD applyId INT NOT NULL DEFAULT 0 COMMENT '申请id' AFTER `id`;
+ALTER TABLE `xhApply` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1审核中 2审核通过,试用中 3审核未通过 4已付费,使用中 5试用到期失效';
+UPDATE `xhApply` SET `status`=1;
+ALTER TABLE `xhMerchant` DROP COLUMN `setDeadline`;
+ALTER TABLE `xhMerchant` DROP COLUMN `deadline`;
+ALTER TABLE `xhMerchant` ADD `deadline` DATETIME NOT NULL DEFAULT '00000-00-00 00:00:00' COMMENT '帐号过期时间' AFTER setId;
+UPDATE `xhMerchant` SET deadline='2022-07-09 12:00:00';