Browse Source

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

林琦海 5 years ago
parent
commit
32a0cbea6b

+ 29 - 13
app-hd/controllers/ShopController.php

@@ -87,20 +87,36 @@ class ShopController extends BaseController
     public function actionGatheringCode()
     {
         $id = Yii::$app->request->get('id', 0);
-        $shop = ShopService::getById($id);
-        ShopService::valid($shop, $this->sjId);
-        $gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
-        $file = dirUtil::getImgDir() . $gatheringCode;
-        if (file_exists($file) == false) {
-            util::fail('没有找到收款码');
+        $shop = ShopService::getById($id, true);
+        if (empty($shop)) {
+            util::fail('没有找到门店');
         }
-        $fileName = "门店({$id})收款码.jpg";
-        $contentType = 'image/jpeg';
-        header("Cache-control: private");
-        header("Content-type: $contentType"); //设置要下载的文件类型
-        header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
-        header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
-        readfile($file);
+        ShopClass::valid($shop->attributes, $this->sjId);
+        $imgUrl = ShopClass::generateGatheringCode($this->sjId, $id);
+        $shopName = $shop->shopName ?? '';
+        $file = fopen($imgUrl, "rb");
+        Header("Content-type:  application/octet-stream ");
+        Header("Accept-Ranges:  bytes ");
+        Header("Content-Disposition:  attachment;filename={$shopName}收款码.jpg");
+        $contents = "";
+        while (!feof($file)) {
+            $contents .= fread($file, 8192);
+        }
+        echo $contents;
+        fclose($file);
+    }
+
+    //获取二维码
+    public function actionGetGatheringCodeUrl()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $shop = ShopService::getById($id, true);
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        ShopClass::valid($shop->attributes, $this->sjId);
+        $imgUrl = ShopClass::generateGatheringCode($this->sjId, $id);
+        util::success(['url' => $imgUrl]);
     }
 
     //获取小程序的收款码 ssh

+ 2 - 1
biz-hd/merchant/classes/ShopClass.php

@@ -90,7 +90,8 @@ class ShopClass extends BaseClass
         //强制转成https
         $url = httpUtil::becomeHttps($url);
         $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 10);
-        return $gatheringCode;
+        $imgUrl = Yii::$app->params['hdImgHost'] . 'gathering/1.jpg?x-oss-process=image/watermark,image_' . base64_encode($gatheringCode . '?x-oss-process=image/resize,P_55') . ',g_nw,x_278,y_465/watermark,image_' . base64_encode('gathering/logo.jpg') . ',g_nw,x_510,y_685';
+        return $imgUrl;
     }
 
 }

+ 0 - 5
biz-hd/merchant/services/ShopService.php

@@ -66,10 +66,5 @@ class ShopService extends BaseService
 		return ShopClass::deleteShop($shop);
 	}
 
-	//获取收款码 ssh 2020.3.9
-	public static function generateGatheringCode($sjId, $shopId)
-	{
-		return ShopClass::generateGatheringCode($sjId, $shopId);
-	}
 
 }

+ 2 - 1
biz/shop/classes/ShopClass.php

@@ -176,7 +176,8 @@ class ShopClass extends BaseClass
         //强制转成https
         $url = httpUtil::becomeHttps($url);
         $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 10);
-        return $gatheringCode;
+        $imgUrl = Yii::$app->params['hdImgHost'] . 'gathering/1.jpg?x-oss-process=image/watermark,image_' . base64_encode($gatheringCode . '?x-oss-process=image/resize,P_55') . ',g_nw,x_278,y_465/watermark,image_' . base64_encode('gathering/logo_big.png?x-oss-process=image/resize,P_12') . ',g_nw,x_555,y_728';
+        return $imgUrl;
     }
 
     //客户使用优惠券增加余额 shish 20210601

+ 203 - 202
common/components/qrCodeUtil.php

@@ -7,206 +7,207 @@ use common\components\stringUtil;
 
 class qrCodeUtil
 {
-	
-	/**
-	 * 生成二维码
-	 * $unique 举例 userId_189 merchant_20等
-	 * $size 大小 5 195px 8 312px
-	 */
-	public static function generate($url, $unique = '', $logo = '', $size = 5)
-	{
-		$app = Yii::getAlias("@app");
-		$saveDir = $app . '/../../resource/images/qrcode/';
-		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
-		$rand = stringUtil::buildOrderNo();
-		$random = empty($unique) ? $rand : $unique . '_' . $rand;
-		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
-		$errorCorrectionLevel = 'H';
-		$matrixPointSize = $size;//生成图片大小
-		$QR = $saveDir . $random . '.png';
-		\QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		if (empty($logo) || file_exists($logo) == false) {
-			return '/qrcode/' . $random . '.png';//没有logo输出的二维码
-		}
-		$QR = imagecreatefromstring(file_get_contents($QR));
-		$logo = imagecreatefromstring(file_get_contents($logo));
-		$QR_width = imagesx($QR);//二维码图片宽度
-		$QR_height = imagesy($QR);//二维码图片高度
-		$logo_width = imagesx($logo);//logo图片宽度
-		$logo_height = imagesy($logo);//logo图片高度
-		$logo_qr_width = $QR_width / 5;
-		$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);
-		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
-		return '/qrcode/' . $random . '_combine.png';//组合logo后输出的二维码
-	}
-	
-	/**
-	 * 生成固定名称的图片二维码
-	 * $unique 举例 userId_189 merchant_20等
-	 * $size 大小 5 195px 8 312px
-	 */
-	public static function generateFixQrCode($url, $unique, $logo = '', $size = 5)
-	{
-		$app = Yii::getAlias("@app");
-		$saveDir = $app . '/../resource/images/qrcode/';
-		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
-		$random = $unique;
-		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
-		$errorCorrectionLevel = 'H';
-		$matrixPointSize = $size;//生成图片大小
-		$QR = $saveDir . $random . '.png';
-		if (file_exists($QR)) {
-			return '/qrcode/' . $random . '.png';
-		}
-		\QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		if (!empty($logo) && file_exists($logo)) {
-			$QR = imagecreatefromstring(file_get_contents($QR));
-			$logo = imagecreatefromstring(file_get_contents($logo));
-			$QR_width = imagesx($QR);//二维码图片宽度
-			$QR_height = imagesy($QR);//二维码图片高度
-			$logo_width = imagesx($logo);//logo图片宽度
-			$logo_height = imagesy($logo);//logo图片高度
-			$logo_qr_width = $QR_width / 5;
-			$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);
-			imagepng($QR, $saveDir . $random . '.png');//输出图片
-		}
-		return '/qrcode/' . $random . '.png';
-	}
-	
-	/**
-	 * 生成会员二维码
-	 * $unique 举例 userId_189 merchant_20等
-	 * $size 大小 5 195px 8 312px
-	 */
-	public static function card($url, $unique = '', $logo = '', $size = 5)
-	{
-		$app = Yii::getAlias("@app");
-		$saveDir = $app . '/../../resource/images/card/';
-		
-		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
-		$rand = stringUtil::buildOrderNo();
-		$random = empty($unique) ? $rand : $unique . '_' . $rand;
-		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
-		$errorCorrectionLevel = 'H';
-		$matrixPointSize = $size;//生成图片大小
-		$QR = $saveDir . $random . '.png';
-		\QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		if (empty($logo) || file_exists($logo) == false) {
-			return '/card/' . $random . '.png';//没有logo输出的二维码
-		}
-		$QR = imagecreatefromstring(file_get_contents($QR));
-		$logo = imagecreatefromstring(file_get_contents($logo));
-		$QR_width = imagesx($QR);//二维码图片宽度
-		$QR_height = imagesy($QR);//二维码图片高度
-		$logo_width = imagesx($logo);//logo图片宽度
-		$logo_height = imagesy($logo);//logo图片高度
-		$logo_qr_width = $QR_width / 5;
-		$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);
-		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
-		return '/card/' . $random . '_combine.png';//组合logo后输出的二维码
-	}
-	
-	public static function generatePayQrCode($url, $unique = '', $logo = '', $size = 5)
-	{
-		$app = Yii::getAlias("@app");
-		$saveDir = $app . '/../resource/images/qrcode/';
-		include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
-		$rand = stringUtil::buildOrderNo();
-		$random = empty($unique) ? $rand : $unique . '_' . $rand;
-		//表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
-		$errorCorrectionLevel = 'H';
-		$matrixPointSize = $size;//生成图片大小
-		$QR = $saveDir . $random . '.png';
-		\QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		if (empty($logo) || file_exists($logo) == false) {
-			return '/qrcode/' . $random . '.png';//没有logo输出的二维码
-		}
-		$QR = imagecreatefromstring(file_get_contents($QR));
-		$logo = imagecreatefromstring(file_get_contents($logo));
-		$QR_width = imagesx($QR);//二维码图片宽度
-		$QR_height = imagesy($QR);//二维码图片高度
-		$logo_width = imagesx($logo);//logo图片宽度
-		$logo_height = imagesy($logo);//logo图片高度
-		$logo_qr_width = $QR_width / 5;
-		$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);
-		imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
-		//return '/qrcode/'.$random.'_combine.png';//组合logo后输出的二维码
-		$weixinImg = $app . '/web/images/merchant/wxPay.png';
-		$combineQR = $saveDir . $random . '_combine.png';
-		
-		$weixinImgSource = imagecreatefromstring(file_get_contents($weixinImg));
-		$combineQRSource = imagecreatefromstring(file_get_contents($combineQR));
-		
-		$weixinWidth = imagesx($weixinImgSource);
-		$weixinHeight = imagesy($weixinImgSource);
-		
-		$combineQRWidth = imagesx($combineQRSource);
-		$combineQRHeight = imagesy($combineQRSource);
-		$combineQRQRWidth = $weixinWidth / 5;
-		$scale = $combineQRWidth / $combineQRQRHeight;
-		$combineQRQRWidth = '';
-		
-	}
-	
-	/**
-	 * 生成收款二维码
-	 * $unique 举例 userId_189 merchant_20等
-	 * $size 大小 5 195px 8 312px
-	 */
-	public static function generateGatheringQrCode($url, $sjId, $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;//生成图片大小
-		$prefix = dirUtil::getImgDir();
-		$middle = 'retail/qrCode/gathering/';
-		if (file_exists($prefix . $middle) == false) {
-			mkdir($prefix . $middle, 0777, true);
-		}
-		$behind = $middle . $sjId . '_' . $shopId . '.png';
-		$saveFile = $prefix . $behind;
-		if (file_exists($saveFile) == false) {
-			\QRcode::png($url, $saveFile, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		}
-		return $behind;
-	}
-	
-	//h5商城 ssh 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 = imgUtil::getPrefix() . $behind;
-		if (file_exists($file) == false) {
-			\QRcode::png($url, $file, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
-		}
-		return ['shortUrl' => $behind, 'url' => $imgUrl];
-	}
-	
+
+    /**
+     * 生成二维码
+     * $unique 举例 userId_189 merchant_20等
+     * $size 大小 5 195px 8 312px
+     */
+    public static function generate($url, $unique = '', $logo = '', $size = 5)
+    {
+        $app = Yii::getAlias("@app");
+        $saveDir = $app . '/../../resource/images/qrcode/';
+        include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
+        $rand = stringUtil::buildOrderNo();
+        $random = empty($unique) ? $rand : $unique . '_' . $rand;
+        //表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
+        $errorCorrectionLevel = 'H';
+        $matrixPointSize = $size;//生成图片大小
+        $QR = $saveDir . $random . '.png';
+        \QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+        if (empty($logo) || file_exists($logo) == false) {
+            return '/qrcode/' . $random . '.png';//没有logo输出的二维码
+        }
+        $QR = imagecreatefromstring(file_get_contents($QR));
+        $logo = imagecreatefromstring(file_get_contents($logo));
+        $QR_width = imagesx($QR);//二维码图片宽度
+        $QR_height = imagesy($QR);//二维码图片高度
+        $logo_width = imagesx($logo);//logo图片宽度
+        $logo_height = imagesy($logo);//logo图片高度
+        $logo_qr_width = $QR_width / 5;
+        $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);
+        imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
+        return '/qrcode/' . $random . '_combine.png';//组合logo后输出的二维码
+    }
+
+    /**
+     * 生成固定名称的图片二维码
+     * $unique 举例 userId_189 merchant_20等
+     * $size 大小 5 195px 8 312px
+     */
+    public static function generateFixQrCode($url, $unique, $logo = '', $size = 5)
+    {
+        $app = Yii::getAlias("@app");
+        $saveDir = $app . '/../resource/images/qrcode/';
+        include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
+        $random = $unique;
+        //表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
+        $errorCorrectionLevel = 'H';
+        $matrixPointSize = $size;//生成图片大小
+        $QR = $saveDir . $random . '.png';
+        if (file_exists($QR)) {
+            return '/qrcode/' . $random . '.png';
+        }
+        \QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+        if (!empty($logo) && file_exists($logo)) {
+            $QR = imagecreatefromstring(file_get_contents($QR));
+            $logo = imagecreatefromstring(file_get_contents($logo));
+            $QR_width = imagesx($QR);//二维码图片宽度
+            $QR_height = imagesy($QR);//二维码图片高度
+            $logo_width = imagesx($logo);//logo图片宽度
+            $logo_height = imagesy($logo);//logo图片高度
+            $logo_qr_width = $QR_width / 5;
+            $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);
+            imagepng($QR, $saveDir . $random . '.png');//输出图片
+        }
+        return '/qrcode/' . $random . '.png';
+    }
+
+    /**
+     * 生成会员二维码
+     * $unique 举例 userId_189 merchant_20等
+     * $size 大小 5 195px 8 312px
+     */
+    public static function card($url, $unique = '', $logo = '', $size = 5)
+    {
+        $app = Yii::getAlias("@app");
+        $saveDir = $app . '/../../resource/images/card/';
+
+        include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
+        $rand = stringUtil::buildOrderNo();
+        $random = empty($unique) ? $rand : $unique . '_' . $rand;
+        //表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
+        $errorCorrectionLevel = 'H';
+        $matrixPointSize = $size;//生成图片大小
+        $QR = $saveDir . $random . '.png';
+        \QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+        if (empty($logo) || file_exists($logo) == false) {
+            return '/card/' . $random . '.png';//没有logo输出的二维码
+        }
+        $QR = imagecreatefromstring(file_get_contents($QR));
+        $logo = imagecreatefromstring(file_get_contents($logo));
+        $QR_width = imagesx($QR);//二维码图片宽度
+        $QR_height = imagesy($QR);//二维码图片高度
+        $logo_width = imagesx($logo);//logo图片宽度
+        $logo_height = imagesy($logo);//logo图片高度
+        $logo_qr_width = $QR_width / 5;
+        $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);
+        imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
+        return '/card/' . $random . '_combine.png';//组合logo后输出的二维码
+    }
+
+    public static function generatePayQrCode($url, $unique = '', $logo = '', $size = 5)
+    {
+        $app = Yii::getAlias("@app");
+        $saveDir = $app . '/../resource/images/qrcode/';
+        include_once Yii::getAlias("@vendor/qrcode") . '/phpqrcode.php';
+        $rand = stringUtil::buildOrderNo();
+        $random = empty($unique) ? $rand : $unique . '_' . $rand;
+        //表示容错率,也就是有被覆盖的区域还能识别,分别是 L(QR_ECLEVEL_L,7%),M(QR_ECLEVEL_M,15%),Q(QR_ECLEVEL_Q,25%),H(QR_ECLEVEL_H,30%)
+        $errorCorrectionLevel = 'H';
+        $matrixPointSize = $size;//生成图片大小
+        $QR = $saveDir . $random . '.png';
+        \QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+        if (empty($logo) || file_exists($logo) == false) {
+            return '/qrcode/' . $random . '.png';//没有logo输出的二维码
+        }
+        $QR = imagecreatefromstring(file_get_contents($QR));
+        $logo = imagecreatefromstring(file_get_contents($logo));
+        $QR_width = imagesx($QR);//二维码图片宽度
+        $QR_height = imagesy($QR);//二维码图片高度
+        $logo_width = imagesx($logo);//logo图片宽度
+        $logo_height = imagesy($logo);//logo图片高度
+        $logo_qr_width = $QR_width / 5;
+        $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);
+        imagepng($QR, $saveDir . $random . '_combine.png');//输出图片
+        //return '/qrcode/'.$random.'_combine.png';//组合logo后输出的二维码
+        $weixinImg = $app . '/web/images/merchant/wxPay.png';
+        $combineQR = $saveDir . $random . '_combine.png';
+
+        $weixinImgSource = imagecreatefromstring(file_get_contents($weixinImg));
+        $combineQRSource = imagecreatefromstring(file_get_contents($combineQR));
+
+        $weixinWidth = imagesx($weixinImgSource);
+        $weixinHeight = imagesy($weixinImgSource);
+
+        $combineQRWidth = imagesx($combineQRSource);
+        $combineQRHeight = imagesy($combineQRSource);
+        $combineQRQRWidth = $weixinWidth / 5;
+        $scale = $combineQRWidth / $combineQRQRHeight;
+        $combineQRQRWidth = '';
+
+    }
+
+    /**
+     * 生成收款二维码
+     * $unique 举例 userId_189 merchant_20等
+     * $size 大小 5 195px 8 312px
+     */
+    public static function generateGatheringQrCode($url, $sjId, $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;//生成图片大小
+        $prefix = dirUtil::getImgDir();
+        $middle = 'retail/qrCode/gathering/';
+        if (file_exists($prefix . $middle) == false) {
+            mkdir($prefix . $middle, 0777, true);
+        }
+        $behind = $middle . $sjId . '_' . $shopId . '.png';
+        $saveFile = $prefix . $behind;
+        if (file_exists($saveFile) == false) {
+            \QRcode::png($url, $saveFile, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+            oss::uploadImage($behind, $saveFile);
+        }
+        return $behind;
+    }
+
+    //h5商城 ssh 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 = imgUtil::getPrefix() . $behind;
+        if (file_exists($file) == false) {
+            \QRcode::png($url, $file, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
+        }
+        return ['shortUrl' => $behind, 'url' => $imgUrl];
+    }
+
 }

+ 10 - 3
common/components/wxUtil.php

@@ -1386,16 +1386,23 @@ class wxUtil
     public static function getExperienceQrCode($merchant, $page, $isOpen = 0)
     {
         $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
+
+        $sjId = $merchant['id'] ?? 0;
+        $middle = $sjId . '_' . $isOpen;
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $middle .= '_production';
+        }
+
         $path = urlencode($page);
         $url = "https://api.weixin.qq.com/wxa/get_qrcode?access_token={$accessToken}&path=" . $path;
         $curl = new curl\Curl();
         $result = $curl->get($url);
-        $file = dirUtil::getImgDir() . 'retail/miniExperience/' . $merchant['id'] . '.jpg';
+        $file = dirUtil::getImgDir() . 'retail/miniExperience/' . $middle . '.jpg';
         file_put_contents($file, $result);
+        $obj = 'retail/miniExperience/' . $middle . '.jpg';
         //上传oss
-        $obj = 'retail/miniExperience/' . $merchant['id'] . '.jpg';
         oss::uploadImage($obj, $file);
-        echo "<b /><img src='" . imgUtil::getPrefix() . "/retail/miniExperience/" . $merchant['id'] . ".jpg' />";
+        echo "<b /><img src='" . imgUtil::getPrefix() . "/retail/miniExperience/" . $middle . ".jpg' />";
     }
 
     //获取授权小程序帐号已设置的类目

+ 4 - 4
common/config/params.php

@@ -50,9 +50,9 @@ $config = [
     'dadaAppSecret' => '8ed3b159f64021003aa73f7233118fe6',
 
     //百度语音配置
-    'baiduAipAppId'=>'24236063',
-    'baiduAipAppKey'=>'WLp9xP7GG1FFSz6UNGaNeuSv',
-    'baiduAipAppSecret'=>'7gxpGeWzI2dpBVWbe8ffb11lvbtGfLOC',
+    'baiduAipAppId' => '24236063',
+    'baiduAipAppKey' => 'WLp9xP7GG1FFSz6UNGaNeuSv',
+    'baiduAipAppSecret' => '7gxpGeWzI2dpBVWbe8ffb11lvbtGfLOC',
 
 ];
 
@@ -157,7 +157,7 @@ if (getenv('YII_ENV') == 'production') {
     $config['mallShortHost'] = 'zhiguanhua.cn';
     $config['mallImgHost'] = $prefixHttp . 'img.zhiguanhua.cn/';
 
-    $config['ossBucket'] = 'pic-hhb-cs';
+    $config['ossBucket'] = 'pic-hhb-online';
 
 }