From ca85d5d751074e72945e5926ace2782ebec6da87 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 29 Dec 2023 15:00:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E8=B1=86=E8=B1=86?= =?UTF-8?q?=E5=88=86=E9=85=8D=E8=AE=B0=E5=BD=95=E6=9F=A5=E7=9C=8B=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/platformCommission/LegumesLog.php | 10 ++++ .../LegumesLogRepository.php | 32 ++++++++++ .../platformCommission/LegumesRepository.php | 21 +++++++ .../PartnerSettlementCycleRepository.php | 2 +- .../PartnerSettlementRepository.php | 3 +- .../platformCommission/RecordRepository.php | 3 +- .../store/marketing/PlatformCommission.php | 59 ++++++++++++++++++- .../platformCommission/SparateLegumesJob.php | 1 + route/admin/marketing.php | 10 ++++ 9 files changed, 136 insertions(+), 5 deletions(-) diff --git a/app/common/model/store/platformCommission/LegumesLog.php b/app/common/model/store/platformCommission/LegumesLog.php index 65d9b96..b297382 100644 --- a/app/common/model/store/platformCommission/LegumesLog.php +++ b/app/common/model/store/platformCommission/LegumesLog.php @@ -5,6 +5,7 @@ namespace app\common\model\store\platformCommission; use app\common\model\BaseModel; +use app\common\model\user\User; class LegumesLog extends BaseModel{ @@ -16,5 +17,14 @@ class LegumesLog extends BaseModel{ } + /** + * Common: 关联用户表 + * Author: wu-hui + * Time: 2023/12/29 14:00 + * @return \think\model\relation\HasOne + */ + public function user(){ + return $this->hasOne(User::class, 'uid', 'uid'); + } } diff --git a/app/common/repositories/store/platformCommission/LegumesLogRepository.php b/app/common/repositories/store/platformCommission/LegumesLogRepository.php index 08750ab..f665ae6 100644 --- a/app/common/repositories/store/platformCommission/LegumesLogRepository.php +++ b/app/common/repositories/store/platformCommission/LegumesLogRepository.php @@ -13,6 +13,38 @@ class LegumesLogRepository extends BaseRepository{ $this->dao = $dao; } + /** + * Common: 豆豆分配记录 + * Author: wu-hui + * Time: 2023/12/29 13:58 + * @param array $params + * @param int $page + * @param int $limit + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getRecordList(array $params,int $page,int $limit):array{ + $query = $this->dao->getSearch([]) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('uid', (int)$params['uid']); + }) + ->when((int)$params['legumes_id'] > 0,function($query) use ($params){ + $query->where('legumes_id', (int)$params['legumes_id']); + }) + ->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)->select(); + + return compact('count','list'); + } diff --git a/app/common/repositories/store/platformCommission/LegumesRepository.php b/app/common/repositories/store/platformCommission/LegumesRepository.php index 3554b78..aea9ff3 100644 --- a/app/common/repositories/store/platformCommission/LegumesRepository.php +++ b/app/common/repositories/store/platformCommission/LegumesRepository.php @@ -80,7 +80,28 @@ class LegumesRepository extends BaseRepository{ $info = $this->dao->get($id); return $info ? $info->toArray() : []; } + /** + * Common: 周期结算记录 + * Author: wu-hui + * Time: 2023/12/29 13:37 + * @param int $page + * @param int $limit + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getRecordList(int $page,int $limit){ + $query = $this->dao->getSearch([])->order('create_time DESC')->order('id DESC'); + $count = $query->count(); + $list = $query->page($page,$limit)->select(); + foreach($list as &$item){ + $item['start_time'] = date("Y-m-d H:i:s",$item['start_time']); + $item['end_time'] = date("Y-m-d H:i:s",$item['end_time']); + } + return compact('count','list'); + } } diff --git a/app/common/repositories/store/platformCommission/PartnerSettlementCycleRepository.php b/app/common/repositories/store/platformCommission/PartnerSettlementCycleRepository.php index 3ad298d..9820b34 100644 --- a/app/common/repositories/store/platformCommission/PartnerSettlementCycleRepository.php +++ b/app/common/repositories/store/platformCommission/PartnerSettlementCycleRepository.php @@ -34,7 +34,7 @@ class PartnerSettlementCycleRepository extends BaseRepository{ * @throws \think\db\exception\ModelNotFoundException */ public function getRecordList(int $page,int $limit):array{ - $query = $this->dao->getSearch([])->order('create_time DESC'); + $query = $this->dao->getSearch([])->order('create_time DESC')->order('id DESC'); $count = $query->count(); $list = $query->page($page,$limit)->select(); foreach($list as &$item){ diff --git a/app/common/repositories/store/platformCommission/PartnerSettlementRepository.php b/app/common/repositories/store/platformCommission/PartnerSettlementRepository.php index 595a93e..d6b7312 100644 --- a/app/common/repositories/store/platformCommission/PartnerSettlementRepository.php +++ b/app/common/repositories/store/platformCommission/PartnerSettlementRepository.php @@ -37,7 +37,8 @@ class PartnerSettlementRepository extends BaseRepository{ $query->field('uid,nickname,avatar')->bind(['nickname','avatar']); }, ]) - ->order('create_time DESC'); + ->order('create_time DESC') + ->order('id DESC'); $count = $query->count(); $list = $query->page($page,$limit)->select(); diff --git a/app/common/repositories/store/platformCommission/RecordRepository.php b/app/common/repositories/store/platformCommission/RecordRepository.php index b680140..d998afd 100644 --- a/app/common/repositories/store/platformCommission/RecordRepository.php +++ b/app/common/repositories/store/platformCommission/RecordRepository.php @@ -95,7 +95,8 @@ class RecordRepository extends BaseRepository{ $query->field('order_id,order_sn'); } ]) - ->order('create_time DESC'); + ->order('create_time DESC') + ->order('id DESC'); $count = $query->count(); $list = $query->page($page,$limit)->select(); diff --git a/app/controller/admin/store/marketing/PlatformCommission.php b/app/controller/admin/store/marketing/PlatformCommission.php index b846bd6..4f3e55f 100644 --- a/app/controller/admin/store/marketing/PlatformCommission.php +++ b/app/controller/admin/store/marketing/PlatformCommission.php @@ -4,6 +4,9 @@ namespace app\controller\admin\store\marketing; +use app\common\model\store\platformCommission\LegumesLog; +use app\common\repositories\store\platformCommission\LegumesLogRepository; +use app\common\repositories\store\platformCommission\LegumesRepository; use app\common\repositories\store\platformCommission\PartnerSettlementCycleRepository; use app\common\repositories\store\platformCommission\PartnerSettlementRepository; use app\common\repositories\store\platformCommission\RecordRepository; @@ -99,7 +102,7 @@ class PlatformCommission extends BaseController{ /** - * Common: 合伙人佣金结算记录 - 周期记录 + * Common: 合伙人佣金结算记录 - 周期记录 * Author: wu-hui * Time: 2023/12/28 16:09 * @return mixed @@ -110,7 +113,12 @@ class PlatformCommission extends BaseController{ return app('json')->success($data); } - // 合伙人佣金结算记录 - 明细记录 + /** + * Common: 合伙人佣金结算记录 - 明细记录 + * Author: wu-hui + * Time: 2023/12/28 16:41 + * @return mixed + */ public function partnerList(){ [$page, $limit] = $this->getPage(); $params = $this->request->params(['uid', 'cycle_id']); @@ -118,8 +126,55 @@ class PlatformCommission extends BaseController{ return app('json')->success($data); } + /** + * Common: 豆豆统计明细 + * Author: wu-hui + * Time: 2023/12/29 14:45 + * @return mixed + */ + public function legumesTitle(){ + $params = $this->request->params(['uid','legumes_id']); + $legumesModel = app()->make(LegumesRepository::class)->getSearch([]); + $legumesLogModel = (new LegumesLog()) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('uid', (int)$params['uid']); + }) + ->whereIn('status', [0,1]); + return app('json')->success([ + ['className' => 'el-icon-coin','count' => $legumesModel->sum('total_platform_commission_money'),'name' => '基金池总数'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('get_legumes'),'name' => '已产生豆豆'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('order_money'),'name' => '订单总金额(积分上限)'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('get_integral'),'name' => '已产生积分'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->sum('use_integral'),'name' => '已使用积分'], + ['className' => 'el-icon-coin','count' => $legumesLogModel->where('status',0)->sum('use_integral'),'name' => '冻结中积分'], + ]); + } + /** + * Common: 豆豆 - 周期结算记录 + * Author: wu-hui + * Time: 2023/12/29 13:38 + * @return mixed + */ + public function legumesCycleList(){ + [$page, $limit] = $this->getPage(); + $data = app()->make(LegumesRepository::class)->getRecordList((int)$page,(int)$limit); + return app('json')->success($data); + } + /** + * Common: 豆豆 - 豆豆分配记录 + * Author: wu-hui + * Time: 2023/12/29 14:00 + * @return mixed + */ + public function legumesList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['uid','legumes_id']); + $data = app()->make(LegumesLogRepository::class)->getRecordList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } } diff --git a/app/jobs/store/platformCommission/SparateLegumesJob.php b/app/jobs/store/platformCommission/SparateLegumesJob.php index b7ff160..6f794b5 100644 --- a/app/jobs/store/platformCommission/SparateLegumesJob.php +++ b/app/jobs/store/platformCommission/SparateLegumesJob.php @@ -41,6 +41,7 @@ class SparateLegumesJob implements JobInterface{ $getLegumes = sprintf("%.3f",$cycleLegumes['legumes_num'] * $rate / 100); // 信息记录 $insertData[] = [ + 'uid' => $orderInfo['uid'], 'legumes_id' => $data['legumes_id'], 'order_id' => $orderInfo['order_id'], 'cycle_total_legumes' => $cycleLegumes['legumes_num'], diff --git a/route/admin/marketing.php b/route/admin/marketing.php index 08a82ac..0c1d0c6 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -454,6 +454,16 @@ Route::group(function () { Route::get('partner_list', '.platformCommission/partnerList')->name('platformCommissionPartnerList')->option([ '_alias' => '结算周期明细', ]); + // 豆豆和积分 + Route::get('legumes_title', '.platformCommission/legumesTitle')->name('platformCommissionLegumesTitle')->option([ + '_alias' => '豆豆统计', + ]); + Route::get('legumes_cycle_list', '.platformCommission/legumesCycleList')->name('platformCommissionLegumesCycleList')->option([ + '_alias' => '豆豆结算周期', + ]); + Route::get('legumes_list', '.platformCommission/legumesList')->name('platformCommissionLegumesList')->option([ + '_alias' => '豆豆结算周期明细', + ]);