shish пре 5 година
родитељ
комит
6d61c267f6
2 измењених фајлова са 226 додато и 224 уклоњено
  1. 225 224
      app/saas/controllers/MerchantController.php
  2. 1 0
      biz-ghs/shop/services/ShopAdminService.php

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

@@ -15,228 +15,229 @@ 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) {
-			$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()
+    {
+        $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]);
+    }
+
 }

+ 1 - 0
biz-ghs/shop/services/ShopAdminService.php

@@ -86,6 +86,7 @@ class ShopAdminService extends BaseService
             'remind' => $remind,
             'status' => $status,
             'ghsId' => $ghsId,
+            'currentShopId' => $shopId,
         ];
         ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
         return ShopAdminClass::add($addData);