From 10a0882129bbe7c78c472a9306fe531ec34ee126 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Tue, 2 Jan 2024 16:18:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B1=86=E8=B1=86=E5=92=8C=E7=A7=AF=E5=88=86=E6=8C=81=E6=9C=89?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LegumesLogRepository.php | 54 +++++++++++++++++++ .../store/marketing/PlatformCommission.php | 17 +++++- route/admin/marketing.php | 3 ++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/app/common/repositories/store/platformCommission/LegumesLogRepository.php b/app/common/repositories/store/platformCommission/LegumesLogRepository.php index 8995def..9f1691c 100644 --- a/app/common/repositories/store/platformCommission/LegumesLogRepository.php +++ b/app/common/repositories/store/platformCommission/LegumesLogRepository.php @@ -48,6 +48,60 @@ class LegumesLogRepository extends BaseRepository{ return compact('count','list'); } + /** + * Common: 豆豆持有信息 + * Author: wu-hui + * Time: 2024/01/02 15:57 + * @param array $params + * @param int $page + * @param int $limit + * @return array + */ + public function getHoldList(array $params,int $page,int $limit):array{ + $query = $this->dao->getSearch([]) + ->field([ + 'uid', + 'sum(order_money) as total_order_money', + 'sum(get_legumes) as total_get_legumes', + 'sum(get_integral) as total_get_integral', + 'sum(use_integral) as total_use_integral', + ]) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('uid', (int)$params['uid']); + }) + ->whereIn('status',[0,1]) + ->with([ + 'user' => function($query){ + $query->field('uid,nickname,avatar')->bind(['nickname','avatar']); + } + ]) + ->order('create_time DESC') + ->order('id DESC'); + $count = $query->count(); + $list = $query->page($page,$limit)->group('uid')->select()->toArray(); + // 获取冻结中积分 + $ids = array_column($list,'uid'); + $freeze = $this->dao->getSearch([]) + ->field('uid,sum(get_integral) as total_get_integral') + ->whereIn('uid',$ids) + ->where('status',0) + ->group('uid') + ->select() + ->toArray(); + $freeze = array_column($freeze,'total_get_integral','uid'); + foreach($list as &$singleInfo){ + // 总冻结积分 + $singleInfo['total_freeze_integral'] = $freeze[$singleInfo['uid']]; + // 可使用积分 + $reduce = (float)sprintf("%.2f",$singleInfo['total_freeze_integral'] + $singleInfo['total_use_integral']);// 冻结 + 已使用积分 + $singleInfo['surplus_use_integral'] = (float)sprintf("%.2f",$singleInfo['total_get_integral'] - $reduce); + } + + return compact('count','list'); + } + + + /** * Common: 查询需要使用的分配信息 尽可能仅查询需要使用的信息 * Author: wu-hui diff --git a/app/controller/admin/store/marketing/PlatformCommission.php b/app/controller/admin/store/marketing/PlatformCommission.php index 1b8f2bc..4eaa920 100644 --- a/app/controller/admin/store/marketing/PlatformCommission.php +++ b/app/controller/admin/store/marketing/PlatformCommission.php @@ -126,8 +126,10 @@ class PlatformCommission extends BaseController{ return app('json')->success($data); } + + /** - * Common: 豆豆统计明细 + * Common: 豆豆 - 统计明细 * Author: wu-hui * Time: 2023/12/29 14:45 * @return mixed @@ -178,6 +180,19 @@ class PlatformCommission extends BaseController{ return app('json')->success($data); } + /** + * Common: 豆豆 - 豆豆持有信息 + * Author: wu-hui + * Time: 2024/01/02 15:25 + * @return mixed + */ + public function holdList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['uid']); + $data = app()->make(LegumesLogRepository::class)->getHoldList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } } diff --git a/route/admin/marketing.php b/route/admin/marketing.php index 0c1d0c6..add1d18 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -464,6 +464,9 @@ Route::group(function () { Route::get('legumes_list', '.platformCommission/legumesList')->name('platformCommissionLegumesList')->option([ '_alias' => '豆豆结算周期明细', ]); + Route::get('legumes_hold_list', '.platformCommission/holdList')->name('platformCommissionHoldList')->option([ + '_alias' => '豆豆持有信息', + ]);