|
|
@@ -1414,10 +1414,15 @@ class wxUtil
|
|
|
//申请会员的小程序码
|
|
|
public static function generateMemberCode($merchant, $shopId, $isOpen = 0)
|
|
|
{
|
|
|
- $behind = '/retail/mimiMemberCode/' . $merchant['id'] . '_' . $shopId . '_apply_member.jpg';
|
|
|
- $file = dirUtil::getImgDir() . $behind;
|
|
|
+ $fileName = $merchant['id'] . '_' . $shopId . '_apply_member.jpg';
|
|
|
+ $behind = '/retail/mimiMemberCode/';
|
|
|
+ $filePath = dirUtil::getImgDir() . $behind;
|
|
|
+ if (!file_exists($filePath)) {
|
|
|
+ mkdir($filePath, 0777, true);
|
|
|
+ }
|
|
|
+ $file = $filePath . $fileName;
|
|
|
if (file_exists($file)) {
|
|
|
- return $behind;
|
|
|
+ return $behind . $fileName;
|
|
|
}
|
|
|
$path = 'pages/home/user?scan=1&shopId=' . $shopId;
|
|
|
$accessToken = self::getMiniProgramAccessToken($merchant);
|
|
|
@@ -1429,18 +1434,22 @@ class wxUtil
|
|
|
];
|
|
|
$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
file_put_contents($file, $result);
|
|
|
- return $behind;
|
|
|
+ return $behind . $fileName;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//临时小程序码生成 shish 2020.4.17
|
|
|
public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $isOpen = 0)
|
|
|
{
|
|
|
$id = isset($merchant['id']) ? $merchant['id'] : 0;
|
|
|
- $shortPrefix = stringUtil::shortUniqueId($id);
|
|
|
- $behind = '/retail/mimiCode/' . date("Ym") . '/' . date("d") . '/' . $id . '/' . $shortPrefix . '.jpg';
|
|
|
- $file = dirUtil::getImgDir() . $behind;
|
|
|
+ $fileName = stringUtil::shortUniqueId($id) . '.jpg';
|
|
|
+ $behind = '/retail/mimiCode/' . date("Ym") . '/' . date("d") . '/' . $id . '/';
|
|
|
+ $filePath = dirUtil::getImgDir() . $behind;
|
|
|
+ if (!file_exists($filePath)) {
|
|
|
+ mkdir($filePath, 0777, true);
|
|
|
+ }
|
|
|
+ $file = $filePath . $fileName;
|
|
|
if (file_exists($file)) {
|
|
|
- return $behind;
|
|
|
+ return $behind . $fileName;
|
|
|
}
|
|
|
$accessToken = self::getMiniProgramAccessToken($merchant);
|
|
|
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$accessToken}";
|
|
|
@@ -1450,7 +1459,7 @@ class wxUtil
|
|
|
$data["scene"] = $scene;
|
|
|
$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
file_put_contents($file, $result);
|
|
|
- return $behind;
|
|
|
+ return $behind . $fileName;
|
|
|
}
|
|
|
|
|
|
//微信开放平台获取component_access_token
|