Explorar o código

查看会员申请码

shish %!s(int64=6) %!d(string=hai) anos
pai
achega
a27741a096

+ 4 - 1
app/saas/controllers/UserController.php

@@ -2,6 +2,7 @@
 
 namespace saas\controllers;
 
+use biz\merchant\classes\MerchantExtendClass;
 use biz\merchant\services\MerchantAssetService;
 use biz\retail\services\RetailAssetService;
 use biz\user\services\UserService;
@@ -60,7 +61,9 @@ class UserController extends BaseController
 	//会员申请码查看 shish 2020.2.15
 	public function actionApplyCode()
 	{
-		echo 'ok';
+		$id = Yii::$app->request->get('id');
+		$url = MerchantExtendClass::getApplyMemberCode($id);
+		echo "<img src='{$url}' />";
 	}
 
 }

+ 17 - 1
biz/merchant/classes/MerchantExtendClass.php

@@ -2,6 +2,8 @@
 
 namespace biz\merchant\classes;
 
+use common\components\dirUtil;
+use common\components\wxUtil;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -9,10 +11,24 @@ class MerchantExtendClass extends BaseClass
 {
 	
 	public static $baseFile = '\biz\merchant\models\MerchantExtend';
-
+	
 	public static function getByMerchantId($id, $returnType = false)
 	{
 		return self::getByCondition(['merchantId' => $id], $returnType);
 	}
+	
+	//获取申请会员的小程序码 shish 2020.2.19
+	public static function getApplyMemberCode($id)
+	{
+		$extend = self::getByMerchantId($id);
+		$imgUrl = isset($extend['applyMemberCode']) && !empty($extend['applyMemberCode']) ? $extend['applyMemberCode'] : '';
+		$file = dirUtil::getImgDir() . $imgUrl;
+		if (empty($img) || file_exists($file) == false) {
+			$merchant = MerchantClass::getMerchantById($id);
+			$imgUrl = wxUtil::generateMemberCode($merchant);
+			self::updateByCondition(['merchantId' => $id], ['applyMemberCode' => $imgUrl]);
+		}
+		return Yii::$app->params['imgHost'] . $imgUrl;
+	}
 
 }

+ 1 - 1
biz/user/classes/UserClass.php

@@ -576,5 +576,5 @@ class UserClass extends BaseClass
 		}
 		return ['total' => $total, 'count' => $count, 'nextOpenId' => $next_openid];
 	}
-	
+
 }

+ 6 - 6
common/components/wxUtil.php

@@ -1379,22 +1379,22 @@ class wxUtil
 		echo "<pre>";
 		print_r($respond);
 	}
-
+	
 	//申请会员的小程序码
-	public static function generateMemberCode($merchant)
+	public static function generateMemberCode($merchant, $path = 'pages/customer/my')
 	{
 		$accessToken = self::getMiniProgramAccessToken($merchant);
-		//$path = urlencode("pages/home/index");
 		$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
 		$curl = new curl\Curl();
 		$data = [
-			"path" => 'pages/customer/my',
+			"path" => $path,
 			"width" => 1000,
 		];
 		$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
-		$file = dirUtil::getImgDir() . '/retail/miniExperience/' . $merchant['id'] . '_apply_member.jpg';
+		$behind = '/retail/miniExperience/' . $merchant['id'] . '_apply_member.jpg';
+		$file = dirUtil::getImgDir() . $behind;
 		file_put_contents($file, $result);
-		echo "<img src='" . Yii::$app->params['imgHost'] . "/retail/miniExperience/" . $merchant['id'] . "_member.jpg' />";
+		return $behind;
 	}
 
 	/**

+ 6 - 1
console/controllers/UpgradeController.php

@@ -1099,7 +1099,7 @@ ALTER TABLE `xhApply` CHANGE `latitude` `lat` VARCHAR(20) NOT NULL DEFAULT '' CO
 		$sql = "ALTER TABLE `xhAd` MODIFY `endTime` BIGINT NOT NULL DEFAULT 0 COMMENT '结束时间;值4102416000(2100-01-01 00:00:00)表示永不过期情况';
 ALTER TABLE `xhAd` MODIFY `startTime` BIGINT NOT NULL DEFAULT 0 COMMENT '开始时间';";
 		Yii::$app->db->createCommand($sql)->execute();
-		
+
 		//支付相关配置修改
 		$sql = "ALTER TABLE `xhMerchantExtend` ADD wxPayInit TINYINT NOT NULL DEFAULT 0 COMMENT '0微信支付未配置 1配置' AFTER `miniVersion`;
 ALTER TABLE `xhMerchantExtend` ADD alipayInit TINYINT NOT NULL DEFAULT 0 COMMENT '0支付宝支付未配置 1配置' AFTER `wxPayKey`;
@@ -1107,6 +1107,11 @@ ALTER TABLE `xhMerchantExtend` MODIFY `alipayKey` VARCHAR(500) NOT NULL DEFAULT
 ALTER TABLE `xhMerchantExtend` ADD alipayPublicKey VARCHAR(500) NOT NULL DEFAULT '' COMMENT '支付宝公钥' AFTER `alipayKey`;";
 		Yii::$app->db->createCommand($sql)->execute();
 
+		//收款二维码和申请会员小程序码
+		$sql = "ALTER TABLE `xhMerchantExtend` ADD `applyMemberCode` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '申请会员小程序码' AFTER `alipayAccountName`;
+ALTER TABLE `xhShop` ADD `gatheringCode` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '收款的二维码' AFTER `introduction`;";
+		Yii::$app->db->createCommand($sql)->execute();
+		
 	}
 	
 	//重新拉取并保存国兰客户的头像和图片 shish 2020.1.12