From 1683db123593c125e6abfc8c3b4b904d353f8a59 Mon Sep 17 00:00:00 2001 From: "home.fengxinyhyl" Date: Sat, 20 Apr 2024 20:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E5=AD=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/user/DepositRecordDao.php | 9 ++ app/common/model/user/DepositRecord.php | 10 ++ .../user/DepositRecordRepository.php | 9 +- app/controller/admin/system/Deposit.php | 32 ++++++- route/admin/system.php | 6 ++ view/admin/src/api/user.js | 9 +- view/admin/src/router/modules/user.js | 2 +- view/admin/src/views/user/deposit/list.vue | 93 ++++++++++++------- 8 files changed, 131 insertions(+), 39 deletions(-) diff --git a/app/common/dao/user/DepositRecordDao.php b/app/common/dao/user/DepositRecordDao.php index 02b6fda..9080177 100644 --- a/app/common/dao/user/DepositRecordDao.php +++ b/app/common/dao/user/DepositRecordDao.php @@ -15,6 +15,7 @@ use app\common\model\user\DepositRecord; use app\common\model\user\UserAssets; use app\common\model\user\UserRecharge; use app\common\repositories\store\order\StoreOrderRepository; +use think\db\BaseQuery; class DepositRecordDao extends BaseDao { @@ -32,4 +33,12 @@ class DepositRecordDao extends BaseDao public function getSum($uid, $field){ return DepositRecord::where('uid', $uid)->where('status','in', [1,2])->sum($field); } + + public function search($where){ + $query = DepositRecord::when(isset($where['uid']) && $where['uid'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('uid', $where['uid']); + }) + ->where('status', 'in', [1,3]); + return $query; + } } diff --git a/app/common/model/user/DepositRecord.php b/app/common/model/user/DepositRecord.php index 8100408..6fc546c 100644 --- a/app/common/model/user/DepositRecord.php +++ b/app/common/model/user/DepositRecord.php @@ -11,6 +11,7 @@ namespace app\common\model\user; use app\common\model\BaseModel; +use app\common\model\store\Deposit; class DepositRecord extends BaseModel @@ -40,5 +41,14 @@ class DepositRecord extends BaseModel return $params; } + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } + + public function deposit() + { + return $this->hasOne(Deposit::class, 'id', 'deposit_id'); + } } diff --git a/app/common/repositories/user/DepositRecordRepository.php b/app/common/repositories/user/DepositRecordRepository.php index 07ee3a2..0ef0b01 100644 --- a/app/common/repositories/user/DepositRecordRepository.php +++ b/app/common/repositories/user/DepositRecordRepository.php @@ -56,9 +56,16 @@ class DepositRecordRepository extends BaseRepository public function getList($where, $page, $limit) { - $query = $this->dao->searchJoinQuery($where)->order('a.pay_time DESC,a.create_time DESC'); + $query = $this->dao->search($where)->with(['user', 'deposit'])->order('create_time DESC'); $count = $query->count(); $list = $query->page($page, $limit)->select(); + + $dailyRepository = app(DepositRecordDailyRepository::class); + foreach ($list as &$item){ + $daily = $dailyRepository->getWhere(['record_id' =>$item['id']]); + $item['diamond_current'] = $daily? $daily['diamond'] : 0; + } + return compact('count', 'list'); } diff --git a/app/controller/admin/system/Deposit.php b/app/controller/admin/system/Deposit.php index 7891685..1dfebaa 100644 --- a/app/controller/admin/system/Deposit.php +++ b/app/controller/admin/system/Deposit.php @@ -15,6 +15,8 @@ namespace app\controller\admin\system; use app\common\repositories\store\DepositRepository; +use app\common\repositories\user\DepositRecordRepository; +use app\common\repositories\user\UserAssetsRepository; use app\validate\admin\DepositValidate; use crmeb\basic\BaseController; use FormBuilder\Exception\FormBuilderException; @@ -22,6 +24,7 @@ use think\App; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; +use think\facade\Request; /** * Class UserGroup @@ -36,15 +39,21 @@ class Deposit extends BaseController */ protected $repository; + /** + * @var DepositRecordRepository + */ + protected $recordRepository; + /** * UserGroup constructor. * @param App $app * @param DepositRepository $repository */ - public function __construct(App $app, DepositRepository $repository) + public function __construct(App $app, DepositRepository $repository, DepositRecordRepository $recordRepository) { parent::__construct($app); $this->repository = $repository; + $this->recordRepository = $recordRepository; } /** @@ -61,6 +70,27 @@ class Deposit extends BaseController return app('json')->success($this->repository->getList(['status' => 1], $page, $limit)); } + public function userList() + { + [$page, $limit] = $this->getPage(); + $uid = Request::get('uid'); + + return app('json')->success($this->recordRepository->getList(['uid' =>$uid], $page, $limit)); + } + + public function userFree($id) + { + $item = $this->recordRepository->get($id); + if(empty($item)){ + \app('json')->fail('查找不到记录'); + } + $item->status = 3; + $item->save(); + app(UserAssetsRepository::class)->updateAssets($item['uid'], array('deposit' => $item['price'])); + + return app('json')->success([1]); + } + /** * @return mixed * @throws FormBuilderException diff --git a/route/admin/system.php b/route/admin/system.php index 5321972..80755e1 100755 --- a/route/admin/system.php +++ b/route/admin/system.php @@ -37,6 +37,12 @@ Route::group(function () { Route::get('lst', '/lst')->name('systemDepositLst')->option([ '_alias' => '预存管理', ]); + Route::get('user/lst', '/userList')->name('systemDepositLst')->option([ + '_alias' => '用户预存列表', + ]); + Route::post('user/free/:id', '/userFree')->name('systemDepositLst')->option([ + '_alias' => '用户预存解冻', + ]); Route::post('create/deposit', '/create')->name('systemDepositCreate')->option([ '_alias' => '预存添加', ]); diff --git a/view/admin/src/api/user.js b/view/admin/src/api/user.js index 85ed5cf..1a2a96d 100644 --- a/view/admin/src/api/user.js +++ b/view/admin/src/api/user.js @@ -107,6 +107,13 @@ export function depositFormApi() { export function depositLstApi(data) { return request.get('deposit/lst', data) } +export function depositUserLstApi(data) { + return request.get('deposit/user/lst', data) +} + +export function depositUserFreeApi(id) { + return request.post(`deposit/user/free/${id}`) +} /** * @description 预存管理 -- 删除 */ @@ -522,4 +529,4 @@ export function getLotteryData(data) { // 保存抽奖 export function setLotteryData(data) { return request.post('lottery/save', data) -} \ No newline at end of file +} diff --git a/view/admin/src/router/modules/user.js b/view/admin/src/router/modules/user.js index d53ebb0..2c2d253 100644 --- a/view/admin/src/router/modules/user.js +++ b/view/admin/src/router/modules/user.js @@ -51,7 +51,7 @@ const userRouter = }, { path: 'deposit/list', - component: () => import('@/views/user/list'), + component: () => import('@/views/user/deposit/list'), name: 'depositList', meta: { title: '预存列表', noCache: true } }, diff --git a/view/admin/src/views/user/deposit/list.vue b/view/admin/src/views/user/deposit/list.vue index e3da8d1..624484d 100644 --- a/view/admin/src/views/user/deposit/list.vue +++ b/view/admin/src/views/user/deposit/list.vue @@ -1,9 +1,23 @@