|
|
@@ -1004,7 +1004,7 @@ class Wechat
|
|
|
* @param $sceneStr 场景参数字符串或ID
|
|
|
* @param $scene 场景标识:qrcode-用户二维码
|
|
|
* @param string $qrType 二维码生成类型:QR_SCENE, QR_STR_SCENE, QR_LIMIT_SCENE, QR_LIMIT_STR_SCENE
|
|
|
- * @param int $expire 有效期,配合场景类型使用,临时二维码最长30天有效期
|
|
|
+ * @param int $expire 有效期,配合场景类型使用,临时二维码最长30天有效期,0-永久
|
|
|
* @return array|bool
|
|
|
* @throws \think\Exception
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
@@ -1012,9 +1012,9 @@ class Wechat
|
|
|
* @throws \think\exception\DbException
|
|
|
* @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- public static function makeQrcode($sourceId = 0, $sceneStr = '', $scene = 'qrcode', $qrType = 'QR_STR_SCENE', $expire = 0)
|
|
|
+ public static function makeQrcode($sourceId = 0, $sceneStr = '', $scene = 'qrcode', $qrType = 'QR_STR_SCENE', $expire = -1)
|
|
|
{
|
|
|
- $expire = $expire ? $expire : 24 * 3600 * 20;
|
|
|
+ $expire = $expire>=0 ? $expire : 24 * 3600 * 20;
|
|
|
$tokenData = Wechat::getAccessToken('', 'accessToken');
|
|
|
$token = isset($tokenData['token']) ? trim($tokenData['token']) : '';
|
|
|
|
|
|
@@ -1024,7 +1024,7 @@ class Wechat
|
|
|
->find();
|
|
|
$qrcodeId = isset($qrData['id']) ? $qrData['id'] : 0;
|
|
|
$qrcodeExpire = isset($qrData['expire_at']) ? strtotime($qrData['expire_at']) : 0;
|
|
|
- if ($qrcodeExpire > time() && $qrcodeId) {
|
|
|
+ if (($expire==0 && $qrcodeId) || $qrcodeExpire > time() && $qrcodeId) {
|
|
|
$ticket = isset($qrData['ticket']) ? $qrData['ticket'] : '';
|
|
|
$qrcode = sprintf(self::$apiUrl['getQrcodeByTicket'], $ticket);
|
|
|
$qrData['qrcode'] = Wechat::loadImage($qrcode, 'qrcode');
|
|
|
@@ -1064,7 +1064,7 @@ class Wechat
|
|
|
'scene' => $scene,
|
|
|
'scene_str' => $sceneStr,
|
|
|
'ticket' => $ticket,
|
|
|
- 'expire_at' => date('Y-m-d H:i:s', time() + $expire),
|
|
|
+ 'expire_at' => $expire>0? date('Y-m-d H:i:s', time() + $expire) : null,
|
|
|
'url' => isset($result['url']) ? $result['url'] : '',
|
|
|
];
|
|
|
|