From ccc85713f2990e207fcf9ae9c616997e6a9caa89 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Sat, 18 Nov 2023 14:21:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E6=8C=81=E6=9C=89?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E6=B7=BB=E5=8A=A0=EF=BC=9A=E5=95=86=E6=88=B7?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=81=E6=9C=89=E7=A7=AF=E5=88=86=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/user/IntegralRepository.php | 47 +++++++++++++++++-- app/controller/admin/user/UserIntegral.php | 12 +++++ app/controller/merchant/user/UserIntegral.php | 29 ++++++++++++ route/admin/marketing.php | 4 +- route/merchant/marketing.php | 7 ++- 5 files changed, 92 insertions(+), 7 deletions(-) diff --git a/app/common/repositories/user/IntegralRepository.php b/app/common/repositories/user/IntegralRepository.php index 0e9dd35..affe148 100644 --- a/app/common/repositories/user/IntegralRepository.php +++ b/app/common/repositories/user/IntegralRepository.php @@ -6,6 +6,7 @@ namespace app\common\repositories\user; use app\common\dao\user\IntegralDao; +use app\common\model\store\order\StoreOrder; use app\common\repositories\BaseRepository; use app\common\repositories\system\merchant\MerchantRepository; use think\facade\Log; @@ -158,13 +159,49 @@ class IntegralRepository extends BaseRepository return compact('count','list'); } + /** + * Common: 持有积分统计 + * Author: wu-hui + * Time: 2023/11/18 14:06 + * @param array $params + * @return array|array[] + */ + public function getStat(array $params){ + $query = $this->dao->getSearch([]) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('uid', (int)$params['uid']); + }) + ->when((int)$params['mer_id'] > 0,function($query) use ($params){ + $query->where('mer_id', (int)$params['mer_id']); + }); + $orderQuery = app()->make(StoreOrder::class) + ->when((int)$params['uid'] > 0,function($query) use ($params){ + $query->where('uid', (int)$params['uid']); + }) + ->when((int)$params['mer_id'] > 0,function($query) use ($params){ + $query->where('mer_id', (int)$params['mer_id']); + }); + // 商户信息统计 + $holdMerIntegral = (float)$query->where('mer_id','>',0)->sum('number'); + $useMerIntegral = (float)$orderQuery->sum('use_mer_integral'); + if((int)$params['mer_id'] > 0){ + return [ + ['className' => 'el-icon-coin','count' => $holdMerIntegral,'field' => '分','name' => '持有本商户积分(总)'], + ['className' => 'el-icon-coin','count' => $useMerIntegral,'field' => '分','name' => '已使用本商户积分(总)'], + ]; + } + // 平台信息统计 + $holdPlatformIntegral = (float)$query->where('mer_id','=',0)->sum('number'); + $usePlatformIntegral = (float)$orderQuery->sum('use_platform_integral'); - - - - - + return [ + ['className' => 'el-icon-coin','count' => $holdPlatformIntegral,'field' => '分','name' => '持有平台积分(总)'], + ['className' => 'el-icon-coin','count' => $usePlatformIntegral,'field' => '分','name' => '已使用平台积分(总)'], + ['className' => 'el-icon-coin','count' => $holdMerIntegral,'field' => '分','name' => '持有商户积分(总)'], + ['className' => 'el-icon-coin','count' => $useMerIntegral,'field' => '分','name' => '已使用商户积分(总)'], + ]; + } } diff --git a/app/controller/admin/user/UserIntegral.php b/app/controller/admin/user/UserIntegral.php index 9fe09e7..9fcfcfa 100644 --- a/app/controller/admin/user/UserIntegral.php +++ b/app/controller/admin/user/UserIntegral.php @@ -98,6 +98,18 @@ class UserIntegral extends BaseController return app('json')->success($data); } + /** + * Common: 持有积分统计 + * Author: wu-hui + * Time: 2023/11/18 14:16 + * @return mixed + */ + public function holdListTitle(){ + $params = $this->request->params(['uid','mer_id']); + $data = app()->make(IntegralRepository::class)->getStat((array)$params); + + return app('json')->success($data); + } /** * Common: 获取赠送积分记录 * Author: wu-hui diff --git a/app/controller/merchant/user/UserIntegral.php b/app/controller/merchant/user/UserIntegral.php index 50a94db..a1340f3 100644 --- a/app/controller/merchant/user/UserIntegral.php +++ b/app/controller/merchant/user/UserIntegral.php @@ -9,6 +9,7 @@ namespace app\controller\merchant\user; use app\common\repositories\store\coupon\StoreCouponUserRepository; use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\user\IntegralGiveRecordRepository; +use app\common\repositories\user\IntegralRepository; use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserLabelRepository; use app\common\repositories\user\UserMerchantRepository; @@ -77,6 +78,34 @@ class UserIntegral extends BaseController return app('json')->success($data); } + /** + * Common: 持有积分列表 + * Author: wu-hui + * Time: 2023/11/18 13:51 + * @return mixed + */ + public function holdList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['uid']); + $params['mer_id'] = $this->request->merId(); + $data = app()->make(IntegralRepository::class)->getAllIntegralList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + /** + * Common: 持有积分统计 + * Author: wu-hui + * Time: 2023/11/18 14:00 + * @return mixed + */ + public function holdListTitle(){ + $params = $this->request->params(['uid']); + $params['mer_id'] = $this->request->merId(); + + $data = app()->make(IntegralRepository::class)->getStat((array)$params); + + return app('json')->success($data); + } } diff --git a/route/admin/marketing.php b/route/admin/marketing.php index c67943c..ebab536 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -57,11 +57,13 @@ Route::group(function () { Route::get('hold_list', '.UserIntegral/holdIntegral')->name('systemUserIntegralHoldList')->option([ '_alias' => '持有积分', ]); + Route::get('hold_list_title','.UserIntegral/holdListTitle')->name('systemUserIntegralHoldListTitle')->option([ + '_alias' => '持有积分统计', + ]); Route::get('give_list', '.UserIntegral/giveIntegral')->name('systemUserIntegralGiveList')->option([ '_alias' => '赠送积分', ]); - })->prefix('admin.user')->option([ '_path' => '/marketing/integral/hold', '_auth' => true, diff --git a/route/merchant/marketing.php b/route/merchant/marketing.php index 80d0193..9323c0c 100644 --- a/route/merchant/marketing.php +++ b/route/merchant/marketing.php @@ -465,7 +465,12 @@ Route::group(function () { Route::get('give_list','/giveRecord')->name('merchantIntegralGiveRecord')->option([ '_alias' => '赠送记录', ]); - + Route::get('hold_list','/holdList')->name('merchantIntegralHoldList')->option([ + '_alias' => '持有积分', + ]); + Route::get('hold_list_title','/holdListTitle')->name('merchantIntegralHoldListTitle')->option([ + '_alias' => '持有积分统计', + ]); })->prefix('merchant.user.UserIntegral')->option([ '_path' => '/marketing/integral/log', '_auth' => true,