diff --git a/app/common/repositories/system/groupData/GroupDataRepository.php b/app/common/repositories/system/groupData/GroupDataRepository.php index 0db6c9f..79fd226 100644 --- a/app/common/repositories/system/groupData/GroupDataRepository.php +++ b/app/common/repositories/system/groupData/GroupDataRepository.php @@ -375,6 +375,7 @@ class GroupDataRepository extends BaseRepository Elm::number('cost_price', '原价')->required(), Elm::number('price', '优惠价')->required(), Elm::number('sort', '排序'), + Elm::number('quota', '赠送酒卡额度')->required(), Elm::switches('status', '是否显示')->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开'), ]; $form->setRule($rules); diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 43aa166..f86463f 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -11,6 +11,7 @@ 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\ExchangeQuotaRepository; use app\common\repositories\user\UserRepository; use app\common\repositories\user\UserSignRepository; use app\common\repositories\wechat\RoutineQrcodeRepository; @@ -161,6 +162,17 @@ class Auth extends BaseController } // 用户是否为兑换站点管理员 $data['is_exchange_saff'] = app()->make(ExchangePickupPointRepository::class)->userIsStaff($user->uid); + // 用户持有可用酒卡额度及积分 + $info = app()->make(ExchangeQuotaRepository::class) + ->getSearch([]) + ->field([ + 'uid', + // 可用额度=剩余额度-冻结额度 + '(surplus_quota - freeze_quota) as available' + ]) + ->where('uid',$user->uid) + ->findOrEmpty(); + $data['available'] = (float)$info->available; return app('json')->success($data); } diff --git a/app/controller/api/user/Exchange.php b/app/controller/api/user/Exchange.php index 2fc52c2..1039119 100644 --- a/app/controller/api/user/Exchange.php +++ b/app/controller/api/user/Exchange.php @@ -8,8 +8,10 @@ use app\common\model\user\ExchangePickupRecord; use app\common\model\user\ExchangeQuota; use app\common\model\user\ExchangeQuotaRecord; use app\common\model\user\User; +use app\common\repositories\user\ExchangeIntegralRecordRepository; use app\common\repositories\user\ExchangePickupPointRepository; use app\common\repositories\user\ExchangePickupRecordRepository; +use app\common\repositories\user\ExchangeQuotaRecordRepository; use app\common\repositories\user\ExchangeQuotaRepository; use app\common\repositories\user\UserRepository; use crmeb\basic\BaseController; @@ -274,4 +276,63 @@ class Exchange extends BaseController{ } + /** + * Common: 额度记录 - 统计 + * Author: wu-hui + * Time: 2024/01/17 17:00 + * @return mixed + */ + public function recordQuota(){ + $uid = $this->request->uid(); + $statistics = app()->make(ExchangeQuotaRepository::class) + ->getSearch([]) + ->field([ + '*', + // 可用额度=剩余额度-冻结额度 + '(surplus_quota - freeze_quota) as available' + ]) + ->where('uid',$uid) + ->findOrEmpty() + ->toArray(); + + $statisticsList = [ + ['title' => '总额度','value' => $statistics['total_quota']], + ['title' => '已使用额度','value' => $statistics['use_quota']], + ['title' => '剩余额度','value' => $statistics['surplus_quota']], + ['title' => '冻结额度','value' => $statistics['freeze_quota']], + ['title' => '可用额度','value' => $statistics['available']], + ]; + + return app('json')->success($statisticsList); + } + /** + * Common: 额度记录 - 记录列表 + * Author: wu-hui + * Time: 2024/01/17 17:01 + * @return mixed + */ + public function recordQuotaList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['uid']); + $params['uid'] = $this->request->uid(); + $data = app()->make(ExchangeQuotaRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + /** + * Common: 积分记录 - 记录列表 + * Author: wu-hui + * Time: 2024/01/17 17:02 + * @return mixed + */ + public function recordIntegralList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['uid']); + $params['uid'] = $this->request->uid(); + $data = app()->make(ExchangeIntegralRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + + } diff --git a/route/api.php b/route/api.php index b28f8ed..2ca7be2 100644 --- a/route/api.php +++ b/route/api.php @@ -358,6 +358,12 @@ Route::group('api/', function () { Route::get('site_exchange_record', 'Exchange/siteExchangeRecord'); Route::get('site_qr_code', 'Exchange/siteQrCode'); Route::get('user_qr_code', 'Exchange/userQrCode'); + // 变更记录 + Route::get('record_quota', 'Exchange/recordQuota'); + Route::get('record_quota_list', 'Exchange/recordQuotaList'); + Route::get('record_integral_list', 'Exchange/recordIntegralList'); + + })->prefix('api.user.');