转账修改

This commit is contained in:
2026-06-05 14:49:11 +08:00
parent 7d41bdfbec
commit 5033a225e9
3 changed files with 14 additions and 4 deletions

View File

@@ -171,7 +171,7 @@ class Dashboard extends Backend
$logFrom = new UserMoneyLog();
$logFrom->save([
'user_id' => 0,
'money' => -$money,
'money' => $money,
'before' => $bankFrom->current_balance + $money,
'after' => $bankFrom->current_balance,
'type' => 4,
@@ -224,9 +224,18 @@ class Dashboard extends Backend
$result = false;
$data = $this->excludeFields($data);
if ($data['type'] == 2) {
$data['money'] = -$data['money'];
$bank = Bank::where('id', $data['bank_id'])->where('status', 1)->lock(true)->find();
if (!$bank) {
throw new ValidateException('银行账户不存在或已被禁用');
}
if (in_array($data['type'], [2,4])) {
$bank->current_balance -= $data['money'];
} else {
$bank->current_balance += $data['money'];
}
$bank->save();
$user_id = User::where('jk_username', $data['user_name'])->value('id');
if (!$user_id) {
$this->error(__("The user can't find it", ['']));

View File

@@ -78,6 +78,7 @@ class MoneyLog extends Backend
*/
public function add(int $userId = 0): void
{
$this->error(__('No rows were added'));
if ($this->request->isPost()) {
$data = $this->request->post();
if (!$data) {