|
|
@@ -1592,6 +1592,37 @@ class miniUtil
|
|
|
return $behind . $fileName;
|
|
|
}
|
|
|
|
|
|
+ //生成充值码,永久有效,数量暂无限制 ssh 20250307
|
|
|
+ public static function generateUnlimitedRechargeMiniCode($merchant, $page, $scene = '', $ptStyle = 0)
|
|
|
+ {
|
|
|
+ $id = isset($merchant['id']) ? $merchant['id'] : 0;
|
|
|
+ $fileName = md5($page . '_' . $scene) . '.jpg';
|
|
|
+ $behind = 'retail/rechargeCode/' . 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 . $fileName;
|
|
|
+ }
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$accessToken}";
|
|
|
+ $curl = new curl\Curl();
|
|
|
+ $data = [];
|
|
|
+ if (!empty($page)) {
|
|
|
+ $data["page"] = $page;
|
|
|
+ }
|
|
|
+ $data["scene"] = $scene;
|
|
|
+ $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
|
|
|
+ Yii::info('获取小程序图片资源:' . json_encode($result));
|
|
|
+ file_put_contents($file, $result);
|
|
|
+ //上传oss
|
|
|
+ $obj = $behind . $fileName;
|
|
|
+ $obj = ltrim($obj, "/");
|
|
|
+ oss::uploadImage($obj, $file);
|
|
|
+ return $behind . $fileName;
|
|
|
+ }
|
|
|
|
|
|
//微信开放平台获取component_access_token
|
|
|
public static function getComponentAccessToken($open)
|