shish 6 éve
szülő
commit
344831d12a

+ 21 - 13
app/saas/controllers/MerchantController.php

@@ -62,24 +62,24 @@ class MerchantController extends BaseController
 		//创建平台,并将公众号绑定到平台
 		if ($id == 1) {
 			wxUtil::createOpenAccount($wxAppId, $merchant);
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant,false);
+			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false);
 			print_r($return);
 			if ($return['errcode'] == 0) {
 				$openAppId = $return['open_appid'];
 				xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
-				MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId,'openAppBind'=>1,'wxAuth'=>1]);
+				MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
 			}
 		}
 		//将小程序绑定到平台
 		if ($id == 2) {
 			$openAppId = $merchant['openAppId'];
 			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
-			MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind'=>3,'miniAuth'=>1]);
+			MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
 			print_r($r);
 		}
 		//查询公众号 小程序的绑定情况
 		if ($id == 3) {
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant,false);
+			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false);
 			echo "公众号绑定情况:<br />";
 			print_r($return);
 			$return = wxUtil::getOpenAccount($miniAppId, $merchant, true);
@@ -149,7 +149,7 @@ class MerchantController extends BaseController
 		print_r($r);
 		echo $miniAppId . ' ' . $openAppId . ' ';
 		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant,false);
+		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false);
 		print_r($return);
 		die;
 		
@@ -157,13 +157,13 @@ class MerchantController extends BaseController
 		print_r($return);
 		die;
 		
-		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant,false);
+		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false);
 		print_r($r);
 		echo $miniAppId . ' ' . $openAppId . ' ';
 		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant,false);
+		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false);
 		print_r($return);
-		$return = wxUtil::getOpenAccount($miniAppId, $merchant,false);
+		$return = wxUtil::getOpenAccount($miniAppId, $merchant, false);
 		print_r($return);
 		die;
 		
@@ -178,26 +178,26 @@ class MerchantController extends BaseController
 		echo "<br />openAppId:" . $openAppId . "<br />";
 		if (!empty($openAppId)) {
 			xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
-			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant,false);
+			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false);
 			echo "绑定小程序结果:<br />";
 			print_r($r);
 		}
 		echo "<br /><br />";
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant,false);
+		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false);
 		echo "微信appId:{$wxAppId}<br />";
 		print_r($return);
-		$return = wxUtil::getOpenAccount($miniAppId, $merchant,false);
+		$return = wxUtil::getOpenAccount($miniAppId, $merchant, false);
 		echo "<br />小程序appId:{$miniAppId}<br />";
 		print_r($return);
 	}
-
+	
 	//平台帐号激活 shish 2020.2.15
 	public function actionAddPlatformMerchant()
 	{
 		MerchantService::initOpenMerchant();
 		echo 'ok';
 	}
-
+	
 	//注释商家 shish 2020.3.4
 	public function actionCancel()
 	{
@@ -219,4 +219,12 @@ class MerchantController extends BaseController
 		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]);
+	}
+	
 }

+ 12 - 0
biz/merchant/classes/MerchantClass.php

@@ -9,6 +9,8 @@ use biz\coupon\classes\CouponAssetClass;
 use biz\goods\classes\CategoryClass;
 use biz\goods\classes\GoodsSettingClass;
 use common\components\business;
+use common\components\httpUtil;
+use common\components\qrCodeUtil;
 use common\components\stringUtil;
 use Yii;
 use biz\base\classes\BaseClass;
@@ -206,4 +208,14 @@ class MerchantClass extends BaseClass
 		return $merchant;
 	}
 	
+	//h5商城链接二维码 shish 2020.4.30
+	public static function getH5MallQrCode($id)
+	{
+		$url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
+		//强制转成https
+		$url = httpUtil::becomeHttps($url);
+		$respond = qrCodeUtil::generateH5MallQrCode($url);
+		return isset($respond['url']) ? $respond['url'] : '';
+	}
+	
 }

+ 0 - 1
biz/merchant/classes/ShopClass.php

@@ -89,7 +89,6 @@ class ShopClass extends BaseClass
 		$url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
 		//强制转成https
 		$url = httpUtil::becomeHttps($url);
-		Yii::info('收款链接:' . $url);
 		$gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
 		return $gatheringCode;
 	}

+ 198 - 192
biz/merchant/services/MerchantService.php

@@ -25,196 +25,202 @@ 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)
-    {
-        $defaultShopId = isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
-        return $defaultShopId;
-    }
-
-    //商家基本信息,$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['wx_base_id']) && !empty($open['wx_base_id']) && isset($open['wx_mini_base_id']) && !empty($open['wx_mini_base_id'])) {
-            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;
-    }
-
+	
+	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)
+	{
+		$defaultShopId = isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
+		return $defaultShopId;
+	}
+	
+	//商家基本信息,$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['wx_base_id']) && !empty($open['wx_base_id']) && isset($open['wx_mini_base_id']) && !empty($open['wx_mini_base_id'])) {
+			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);
+	}
+	
 }

+ 38 - 14
common/components/qrCodeUtil.php

@@ -38,7 +38,8 @@ class qrCodeUtil
 		$scale = $logo_width / $logo_qr_width;
 		$logo_qr_height = $logo_height / $scale;
 		$from_width = ($QR_width - $logo_qr_width) / 2;
-		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);//重新组合图片并调整大小
+		//重新组合图片并调整大小
+		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
 		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
 		return '/qrcode/' . $random . '_combine.png';//组合logo后输出的二维码
 	}
@@ -73,7 +74,8 @@ class qrCodeUtil
 			$scale = $logo_width / $logo_qr_width;
 			$logo_qr_height = $logo_height / $scale;
 			$from_width = ($QR_width - $logo_qr_width) / 2;
-			imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);//重新组合图片并调整大小
+			//重新组合图片并调整大小
+			imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
 			imagepng($QR, $saveDir . $random . '.png');//输出图片
 		}
 		return '/qrcode/' . $random . '.png';
@@ -110,7 +112,8 @@ class qrCodeUtil
 		$scale = $logo_width / $logo_qr_width;
 		$logo_qr_height = $logo_height / $scale;
 		$from_width = ($QR_width - $logo_qr_width) / 2;
-		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);//重新组合图片并调整大小
+		//重新组合图片并调整大小
+		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
 		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
 		return '/card/' . $random . '_combine.png';//组合logo后输出的二维码
 	}
@@ -140,7 +143,8 @@ class qrCodeUtil
 		$scale = $logo_width / $logo_qr_width;
 		$logo_qr_height = $logo_height / $scale;
 		$from_width = ($QR_width - $logo_qr_width) / 2;
-		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);//重新组合图片并调整大小
+		//重新组合图片并调整大小
+		imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
 		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
 		//return '/qrcode/'.$random.'_combine.png';//组合logo后输出的二维码
 		$weixinImg = $app . '/web/images/merchant/wxPay.png';
@@ -168,21 +172,41 @@ class qrCodeUtil
 	public static function generateGatheringQrCode($url, $merchantId, $shopId, $logo = '', $size = 5)
 	{
 		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
-		
 		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
 		$errorCorrectionLevel = 'H';
 		$matrixPointSize = $size;//生成图片大小
-		
-		$behind = '/retail/qrCode/gathering/' . $merchantId . '_' . $shopId . '.png';
-		$saveFile = dirUtil::getImgDir() . $behind;
-		
-		if (file_exists($saveFile)) {
-			return $behind;
+		$prefix = dirUtil::getImgDir();
+		$middle = '/retail/qrCode/gathering/';
+		if (file_exists($prefix . $middle) == false) {
+			mkdir($prefix . $middle, 0777, true);
+		}
+		$behind = $middle . $merchantId . '_' . $shopId . '.png';
+		$saveFile = $prefix . $behind;
+		if (file_exists($saveFile) == false) {
+			\QRcode::png($url, $saveFile, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
 		}
-
-		\QRcode::png($url, $saveFile, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		
 		return $behind;
 	}
+
+	//h5商城 shish 2020.4.30
+	public static function generateH5MallQrCode($url, $logo = '', $size = 5)
+	{
+		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
+		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
+		$errorCorrectionLevel = 'H';
+		$matrixPointSize = $size;//生成图片大小
+		$prefix = dirUtil::getImgDir();
+		$middle = '/retail/qrCode/h5Mall/';
+		if (file_exists($prefix . $middle) == false) {
+			mkdir($prefix . $middle, 0777, true);
+		}
+		$behind = $middle . md5($url) . '.png';
+		$file = $prefix . $behind;
+		$imgUrl = Yii::$app->params['imgHost'] . $behind;
+		if (file_exists($file) == false) {
+			\QRcode::png($url, $file, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+		}
+		return ['shortUrl' => $behind, 'url' => $imgUrl];
+	}
 	
 }