首页修改,转账记录修改

This commit is contained in:
2026-06-04 14:26:24 +08:00
parent 3ccbc9cc3b
commit 6ac618bc0a
5 changed files with 64 additions and 10 deletions

View File

@@ -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'));
}
}
}