feat(distribution): 通道费改主站承担,并按冷却期自动释放结算
利润不再扣支付通道费;站点可配置结算冷却期,到期自动入账,已释放后退款从收款站钱包回冲。同时修复当日自动批次无法追加、三方回冲打错钱包,以及测试库自增重置被 MySQL 统计缓存跳过的问题。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,9 @@ type Entry struct {
|
||||
BizType string
|
||||
BizNo string
|
||||
Remark string
|
||||
// AllowNegative 仅用于结算回冲等追偿场景:余额不足时允许扣成负数,
|
||||
// 由后续收益抵扣,避免回冲失败导致账实不一致。
|
||||
AllowNegative bool
|
||||
}
|
||||
|
||||
func NewRepository(db *gorm.DB) *Repository {
|
||||
@@ -240,7 +243,7 @@ func applyEntry(account *model.WalletAccount, entry Entry) (int64, error) {
|
||||
if entry.Direction == "in" {
|
||||
account.AvailableBalanceCent += entry.AmountCent
|
||||
} else {
|
||||
if account.AvailableBalanceCent < entry.AmountCent {
|
||||
if account.AvailableBalanceCent < entry.AmountCent && !entry.AllowNegative {
|
||||
return 0, ErrInsufficientBalance
|
||||
}
|
||||
account.AvailableBalanceCent -= entry.AmountCent
|
||||
|
||||
Reference in New Issue
Block a user