From 6ac618bc0ab9311b63564e8f9faa77178a072138 Mon Sep 17 00:00:00 2001 From: zhouzp <1558048883@qq.com> Date: Thu, 4 Jun 2026 14:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E8=BD=AC=E8=B4=A6=E8=AE=B0=E5=BD=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Dashboard.php | 60 +++++++++++++++++-- app/admin/model/UserMoneyLog.php | 4 -- web/src/lang/backend/en/user/moneyLog.ts | 2 + web/src/lang/backend/zh-cn/user/moneyLog.ts | 2 + web/src/views/backend/user/moneyLog/index.vue | 6 +- 5 files changed, 64 insertions(+), 10 deletions(-) diff --git a/app/admin/controller/Dashboard.php b/app/admin/controller/Dashboard.php index 7f21365..12a3ddb 100644 --- a/app/admin/controller/Dashboard.php +++ b/app/admin/controller/Dashboard.php @@ -37,13 +37,13 @@ class Dashboard extends Backend $bankList = Bank::field([ 'id', 'bank_name', 'bank_account', 'current_balance', 'safe_alert', 'label_color', 'weigh', // 子查询:入款总额 - "(SELECT SUM(money/100) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type = 1 and create_time BETWEEN {$start} AND {$end}) AS total_fund_in", + "(SELECT SUM(money/100) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type in (1,3) and create_time BETWEEN {$start} AND {$end}) AS total_fund_in", // 子查询:出款总额 - "(SELECT SUM(money/100) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type = 2 and create_time BETWEEN {$start} AND {$end}) AS total_fund_out", + "(SELECT SUM(money/100) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type in (2,4) and create_time BETWEEN {$start} AND {$end}) AS total_fund_out", // 子查询:入款次数 - "(SELECT COUNT(*) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type = 1 and create_time BETWEEN {$start} AND {$end}) AS count_fund_in", + "(SELECT COUNT(*) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type in (1,3) and create_time BETWEEN {$start} AND {$end}) AS count_fund_in", // 子查询:出款次数 - "(SELECT COUNT(*) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type = 2 and create_time BETWEEN {$start} AND {$end}) AS count_fund_out", + "(SELECT COUNT(*) FROM ba_user_money_log WHERE bank_id = ba_bank.id AND type in (2,4) and create_time BETWEEN {$start} AND {$end}) AS count_fund_out", ]) ->where('status', 1) ->order('weigh', 'desc') @@ -268,4 +268,56 @@ class Dashboard extends Backend } $this->success('', $history); } + + public function editTransact(): void + { + $userMoneyLog = new UserMoneyLog(); + $pk = $userMoneyLog->getPk(); + $id = $this->request->param($pk); + $row = $userMoneyLog->find($id); + if (!$row) { + $this->error(__('Record not found')); + } + + if ($this->request->isPost()) { + $data = $this->request->post(); + if (!$data) { + $this->error(__('Parameter %s can not be empty', [''])); + } + + $result = false; + $userMoneyLog->startTrans(); + try { + $result = $row->save($data); + $userMoneyLog->commit(); + } catch (Throwable $e) { + $userMoneyLog->rollback(); + $this->error($e->getMessage()); + } + if ($result !== false) { + $this->success(__('Update successful')); + } else { + $this->error(__('No rows updated')); + } + return; + } + $this->success('', [ + 'row' => $row + ]); + } + + public function delTransact($id): void + { + $result = false; + try { + $result = Db::table('ba_user_money_log')->delete($id); + } catch (Throwable $e) { + $this->error(__('%d records and files have been deleted', [1]) . $e->getMessage()); + } + if ($result) { + $this->success(__('%d records and files have been deleted', [1])); + } else { + $this->error(__('No rows were deleted')); + } + } } \ No newline at end of file diff --git a/app/admin/model/UserMoneyLog.php b/app/admin/model/UserMoneyLog.php index 44e47ac..61dea68 100644 --- a/app/admin/model/UserMoneyLog.php +++ b/app/admin/model/UserMoneyLog.php @@ -45,10 +45,6 @@ class UserMoneyLog extends model $new->save(); } - public static function onBeforeDelete(): bool - { - return false; - } public function getMoneyAttr($value): string { diff --git a/web/src/lang/backend/en/user/moneyLog.ts b/web/src/lang/backend/en/user/moneyLog.ts index edebf64..7169e6a 100644 --- a/web/src/lang/backend/en/user/moneyLog.ts +++ b/web/src/lang/backend/en/user/moneyLog.ts @@ -19,6 +19,8 @@ export default { 'type_list': { 1 : 'Deposit', 2 : 'Withdraw', + 3 : 'IN', + 4 : 'OUT', }, 'Game Ticket' : 'Game Ticket', 'game_type': { diff --git a/web/src/lang/backend/zh-cn/user/moneyLog.ts b/web/src/lang/backend/zh-cn/user/moneyLog.ts index c9d81ef..e7d1a52 100644 --- a/web/src/lang/backend/zh-cn/user/moneyLog.ts +++ b/web/src/lang/backend/zh-cn/user/moneyLog.ts @@ -19,6 +19,8 @@ export default { 'type_list': { 1 : '存款', 2 : '取款', + 3 : '转入', + 4 : '转出', }, 'Game Ticket' : '游戏门票', 'game_type': { diff --git a/web/src/views/backend/user/moneyLog/index.vue b/web/src/views/backend/user/moneyLog/index.vue index 524dbe6..c1139dd 100644 --- a/web/src/views/backend/user/moneyLog/index.vue +++ b/web/src/views/backend/user/moneyLog/index.vue @@ -4,7 +4,7 @@