From 44366db5f6f65140fb90a5372a00ed652eed6074 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 3 Jul 2024 15:52:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E6=83=A0=E6=B0=91?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E4=BF=A1=E6=81=AF=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/user/ExchangeQuotaRecordDao.php | 3 ++ .../user/ExchangeQuotaRepository.php | 25 +++++++++++++++ app/controller/api/Auth.php | 2 +- app/controller/api/user/Exchange.php | 31 +++++++++++++++++-- route/api.php | 3 ++ 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/app/common/dao/user/ExchangeQuotaRecordDao.php b/app/common/dao/user/ExchangeQuotaRecordDao.php index 2b89960..cc5aae0 100644 --- a/app/common/dao/user/ExchangeQuotaRecordDao.php +++ b/app/common/dao/user/ExchangeQuotaRecordDao.php @@ -44,6 +44,9 @@ class ExchangeQuotaRecordDao extends BaseDao{ ->when(isset($params['order_product_id']) && $params['order_product_id'] !== '',function($query) use ($params){ $query->where('order_product_id', (int)$params['order_product_id']); }) + ->when(isset($params['mer_id']) && $params['mer_id'] !== '',function($query) use ($params){ + $query->where('mer_id', (int)$params['mer_id']); + }) ->with([ 'user' => function($query){ $query->field('uid,nickname,avatar')->bind(['nickname','avatar']); diff --git a/app/common/repositories/user/ExchangeQuotaRepository.php b/app/common/repositories/user/ExchangeQuotaRepository.php index 03e7114..fa94d5c 100644 --- a/app/common/repositories/user/ExchangeQuotaRepository.php +++ b/app/common/repositories/user/ExchangeQuotaRepository.php @@ -185,7 +185,32 @@ class ExchangeQuotaRepository extends BaseRepository{ return $holdInfo; } + /** + * Common: 获取全部惠民积分(不区分商户) + * Author: wu-hui + * Time: 2024/07/03 14:51 + * @param int $uid + * @return mixed + */ + public function getIntegralAll(int $uid){ + $info = $this->searchModel(['uid' => $uid,'quota_type' => 5]) + ->field([ + 'uid', + 'SUM(total_quota) as total_quota', + 'SUM(use_quota) as use_quota', + 'SUM(surplus_quota) as surplus_quota', + 'SUM(freeze_quota) as freeze_quota', + 'quota_type' + ]) + ->findOrEmpty() + ->toArray(); + if($info){ + // 计算可用额度 + $info['available_quota'] = (float)sprintf("%.2f", $info['surplus_quota'] - $info['freeze_quota']); + } + return $info; + } /** * Common: 设置获取 diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index ccc239c..efe5849 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -225,7 +225,7 @@ class Auth extends BaseController $data['oil_available'] = $oilQuotaInfo['surplus_quota'] ?? '0.00'; $data['oil_available_quota'] = $oilQuotaInfo['available_quota'] ?? '0.00'; - $quotaIntegralInfo = app()->make(ExchangeQuotaRepository::class)->getInfo((int)$user->uid, (int)5); + $quotaIntegralInfo = app()->make(ExchangeQuotaRepository::class)->getIntegralAll((int)$user->uid); $data['quota_integral'] = $quotaIntegralInfo['surplus_quota'] ?? '0.00';// 剩余额度 $data['quota_integral_available'] = $quotaIntegralInfo['available_quota'] ?? '0.00';// 可用额度 diff --git a/app/controller/api/user/Exchange.php b/app/controller/api/user/Exchange.php index af7ed92..66f4bf1 100644 --- a/app/controller/api/user/Exchange.php +++ b/app/controller/api/user/Exchange.php @@ -415,7 +415,7 @@ class Exchange extends BaseController{ * @return mixed */ public function recordQuota(){ - $params = $this->request->params(['quota_type']); + $params = $this->request->params(['quota_type', ['mer_id', 0]]); $params['uid'] =$this->request->uid(); $statistics = app()->make(ExchangeQuotaRepository::class) @@ -446,7 +446,7 @@ class Exchange extends BaseController{ */ public function recordQuotaList(){ [$page, $limit] = $this->getPage(); - $params = $this->request->params(['quota_type']); + $params = $this->request->params(['quota_type',['mer_id', 0]]); $params['uid'] = $this->request->uid(); $data = app()->make(ExchangeQuotaRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit); @@ -514,6 +514,33 @@ class Exchange extends BaseController{ return app('json')->success($bindShop); } + /** + * Common: 惠民积分 - 统计 + * Author: wu-hui + * Time: 2024/07/03 15:18 + * @return mixed + */ + public function quotaIntegralStatistics(){ + $uid = $this->request->uid(); + $info = app()->make(ExchangeQuotaRepository::class)->getIntegralAll((int)$uid); + + return app('json')->success($info); + } + /** + * Common: 惠民积分 - 各商户持有信息列表 + * Author: wu-hui + * Time: 2024/07/03 15:40 + * @return mixed + */ + public function quotaIntegralHoldList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['quota_type']); + $params['uid'] = $this->request->uid(); + $data = app()->make(ExchangeQuotaRepository::class)->getList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + diff --git a/route/api.php b/route/api.php index c08c6bd..1a87942 100644 --- a/route/api.php +++ b/route/api.php @@ -385,6 +385,9 @@ Route::group('api/', function () { Route::get('quota_transfer', 'Exchange/quotaTransfer'); // 获取 商户绑定的酒道馆信息 Route::get('mer_bind_shop/:merId', 'Exchange/merBindShop'); + // 惠民积分 + Route::get('quota_integral_statistics', 'Exchange/quotaIntegralStatistics'); + Route::get('quota_integral_hold_list', 'Exchange/quotaIntegralHoldList'); })->prefix('api.user.');