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.');