feat: 完善会员资金明细与退款转账逻辑,新增支付密码组件与资金流水界面

这个提交包含在:
2026-10-24 17:55:36 +08:00
父节点 6b86177b5f
当前提交 b6c53abb84
共有 30 个文件被更改,包括 1222 次插入 和 537 次删除

查看文件

@@ -114,9 +114,11 @@ class OrderRefund
Db::name('user')->where('id', $userId)->setInc('money', $amount);
$balance = round((float)Db::name('user')->where('id', $userId)->value('money'), 2);
self::addFlow('income', '订单退款(余额)', $amount, $balance, (int)$locked['id'], '余额退款');
self::addFlow('income', '订单退款(余额)', $amount, $balance, (int)$locked['id'], '余额退款', $userId);
// 钱包流水(fa_user.money 增)→ 余额中心「余额明细」
self::addWalletFlow($userId, 'income', '订单退款(余额)', $amount, $balance, (int)$locked['id'], '余额退款');
} else {
self::addFlow('expense', '订单退款', $amount, 0, (int)$locked['id'], '微信退款 ' . $refundNo);
self::addFlow('expense', '订单退款', $amount, 0, (int)$locked['id'], '微信退款 ' . $refundNo, $userId);
}
// 3) 权益回滚
@@ -278,6 +280,11 @@ class OrderRefund
->setDec('money', $amount);
if (!$affected) {
Log::record('退款回滚余额失败(余额不足):订单 ' . $order['order_no'] . ',用户 ' . $userId, 'error');
} else {
$balance = round((float)Db::name('user')->where('id', $userId)->value('money'), 2);
self::addFlow('expense', '充值退款', $amount, $balance, (int)$order['id'], '充值订单退款扣回', $userId);
// 钱包流水(fa_user.money 减)→ 余额中心「余额明细」
self::addWalletFlow($userId, 'expense', '充值退款', $amount, $balance, (int)$order['id'], '充值订单退款扣回');
}
return;
}
@@ -369,9 +376,10 @@ class OrderRefund
}
/** 资金流水 */
protected static function addFlow($type, $scene, $amount, $balance, $relatedId, $remark)
protected static function addFlow($type, $scene, $amount, $balance, $relatedId, $remark, $userId = 0)
{
Db::name('fc_finance_flow')->insert([
'user_id' => (int)$userId,
'flow_no' => 'F' . date('YmdHis') . bin2hex(random_bytes(3)),
'type' => $type,
'scene' => $scene,
@@ -382,4 +390,20 @@ class OrderRefund
'createtime' => time(),
]);
}
/** 用户钱包流水(fa_user.money 增减)→ 余额中心「余额明细」 */
protected static function addWalletFlow($userId, $type, $scene, $amount, $balance, $relatedId, $remark)
{
Db::name('fc_wallet_flow')->insert([
'user_id' => (int)$userId,
'flow_no' => 'W' . date('YmdHis') . bin2hex(random_bytes(4)),
'type' => $type,
'scene' => $scene,
'amount' => $amount,
'balance' => $balance,
'related_id' => (int)$relatedId,
'remark' => (string)$remark,
'createtime' => time(),
]);
}
}