转账修改

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 = new UserMoneyLog();
$logFrom->save([ $logFrom->save([
'user_id' => 0, 'user_id' => 0,
'money' => -$money, 'money' => $money,
'before' => $bankFrom->current_balance + $money, 'before' => $bankFrom->current_balance + $money,
'after' => $bankFrom->current_balance, 'after' => $bankFrom->current_balance,
'type' => 4, 'type' => 4,
@@ -224,9 +224,18 @@ class Dashboard extends Backend
$result = false; $result = false;
$data = $this->excludeFields($data); $data = $this->excludeFields($data);
if ($data['type'] == 2) { $bank = Bank::where('id', $data['bank_id'])->where('status', 1)->lock(true)->find();
$data['money'] = -$data['money']; 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'); $user_id = User::where('jk_username', $data['user_name'])->value('id');
if (!$user_id) { if (!$user_id) {
$this->error(__("The user can't find it", [''])); $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 public function add(int $userId = 0): void
{ {
$this->error(__('No rows were added'));
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->post(); $data = $this->request->post();
if (!$data) { if (!$data) {

View File

@@ -15,7 +15,7 @@ export default {
User: 'User', User: 'User',
'Transaction id': 'Transaction id', 'Transaction id': 'Transaction id',
'Created by': 'Created by', 'Created by': 'Created by',
'type': '类型', 'type': 'Type',
'type_list': { 'type_list': {
1 : 'Deposit', 1 : 'Deposit',
2 : 'Withdraw', 2 : 'Withdraw',