|
|
@@ -243,4 +243,32 @@ class User extends UserModel
|
|
|
}
|
|
|
return $menus_arr;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取收款码
|
|
|
+ * @param $sid 门店用户ID
|
|
|
+ * @return false|string|string[]|null
|
|
|
+ * @throws BaseException
|
|
|
+ */
|
|
|
+ public static function getQrcode($sid){
|
|
|
+ $fileName = '/uploads/qrcode/'.$sid.'_'.md5($sid).'.jpg';
|
|
|
+ $cache = Cache::tag('cache')->get('caches:qrcode:'.$sid);
|
|
|
+ if($cache && file_exists(app()->getRootPath().'public'.$fileName)){
|
|
|
+ return getPreview($fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ $app = AppWx::getApp();
|
|
|
+ $data = $app->app_code->getQrCode('/pages/user/my_shop/supplier_qrcode?sid='.$sid);
|
|
|
+ if(empty($data)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ file_put_contents(app()->getRootPath().'public'.$fileName, $data);
|
|
|
+ if(file_exists(app()->getRootPath().'public'.$fileName)){
|
|
|
+ Cache::tag('cache')->set('caches:qrcode:'.$sid, $fileName, rand(300, 600));
|
|
|
+ return getPreview($fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|