From 7de1d315ddaf1a059388e6162b42d5144381a87c Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 15 Jan 2024 15:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=BA=E5=85=91=E6=8D=A2=E7=82=B9=E8=B4=9F?= =?UTF-8?q?=E8=B4=A3=E4=BA=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/ExchangePickupPointRepository.php | 15 +++++++++++++++ app/controller/api/Auth.php | 9 +++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/user/ExchangePickupPointRepository.php b/app/common/repositories/user/ExchangePickupPointRepository.php index 02dfb71..710fc6a 100644 --- a/app/common/repositories/user/ExchangePickupPointRepository.php +++ b/app/common/repositories/user/ExchangePickupPointRepository.php @@ -76,6 +76,21 @@ class ExchangePickupPointRepository extends BaseRepository{ ->findOrEmpty() ->toArray(); } + /** + * Common: 用户是否存在有效的兑换站点 + * Author: wu-hui + * Time: 2024/01/15 15:19 + * @param $uid + * @return int + */ + public function userIsStaff($uid):int{ + $count = $this->dao->getSearch([]) + ->where('is_show', 1) + ->where('find_in_set(' . $uid . ',`uid_list`)') + ->count(); + + return $count > 0 ? 1 : 0; + } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 4d7af3b..43aa166 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -6,9 +6,11 @@ namespace app\controller\api; +use app\common\model\user\ExchangePickupPoint; use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\order\StoreRefundOrderRepository; use app\common\repositories\system\notice\SystemNoticeConfigRepository; +use app\common\repositories\user\ExchangePickupPointRepository; use app\common\repositories\user\UserRepository; use app\common\repositories\user\UserSignRepository; use app\common\repositories\wechat\RoutineQrcodeRepository; @@ -157,6 +159,9 @@ class Auth extends BaseController Cache::set($key,true, new \DateTime($day.' 23:59:59')); } } + // 用户是否为兑换站点管理员 + $data['is_exchange_saff'] = app()->make(ExchangePickupPointRepository::class)->userIsStaff($user->uid); + return app('json')->success($data); } @@ -225,7 +230,7 @@ class Auth extends BaseController */ public function mpAuth() { - list($code, $post_cache_key) = $this->request->params([ + [$code, $post_cache_key] = $this->request->params([ 'code', 'cache_key', ], true); @@ -504,7 +509,7 @@ class Auth extends BaseController if (count($tks) != 3) { throw new ValidateException('Wrong number of segments'); } - list($headb64, $bodyb64, $cryptob64) = $tks; + [$headb64, $bodyb64, $cryptob64] = $tks; if (null === ($payload = JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64)))) { throw new ValidateException('Invalid header encoding'); }