Jelajahi Sumber

收款码问题

shish 5 tahun lalu
induk
melakukan
df9709b0f5
2 mengubah file dengan 219 tambahan dan 214 penghapusan
  1. 16 12
      app-hd/controllers/ShopController.php
  2. 203 202
      common/components/qrCodeUtil.php

+ 16 - 12
app-hd/controllers/ShopController.php

@@ -87,20 +87,24 @@ class ShopController extends BaseController
     public function actionGatheringCode()
     {
         $id = Yii::$app->request->get('id', 0);
-        $shop = ShopService::getById($id);
-        ShopService::valid($shop, $this->sjId);
+        $shop = ShopService::getById($id, true);
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        ShopService::valid($shop->attributes, $this->sjId);
         $gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
-        $file = dirUtil::getImgDir() . $gatheringCode;
-        if (file_exists($file) == false) {
-            util::fail('没有找到收款码');
+        $filename = 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';
+        $shopName = $shop->shopName ?? '';
+        $file = fopen($filename, "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);
         }
-        $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);
+        echo $contents;
+        fclose($file);
     }
 
     //获取小程序的收款码 ssh

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