fix(wallet): 保留历史分销用户零租户归属
This commit is contained in:
@@ -538,6 +538,15 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
if err := db.Create(&users).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&model.WalletAccount{
|
||||
TenantID: 0,
|
||||
UserID: users[0].ID,
|
||||
DistributionSiteID: site.ID,
|
||||
FrozenBalanceCent: 1000,
|
||||
Status: "active",
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
withdrawals := []model.WithdrawalRequest{
|
||||
{WithdrawNo: "WD-LEGACY-SITE", TenantID: 0, UserID: users[0].ID, DistributionSiteID: site.ID, AmountCent: 1000, ActualAmountCent: 1000, AccountType: "bank", AccountName: "张三", AccountNo: "****0001", Status: "pending"},
|
||||
{WithdrawNo: "WD-DACHUI", TenantID: 101, UserID: users[1].ID, AmountCent: 2000, ActualAmountCent: 2000, AccountType: "bank", AccountName: "张三", AccountNo: "****0002", Status: "pending"},
|
||||
@@ -599,4 +608,21 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
if reviewed.Status != "processing" {
|
||||
t.Fatalf("legacy withdrawal review status = %q, want processing", reviewed.Status)
|
||||
}
|
||||
paid, err := repo.ConfirmPayment(dachuiFinanceCtx, 5, withdrawals[0].ID, ConfirmPaymentRequest{
|
||||
Remark: "已通过微信转账",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("dachui legacy confirm payment: %v", err)
|
||||
}
|
||||
if paid.Status != "completed" {
|
||||
t.Fatalf("legacy withdrawal paid status = %q, want completed", paid.Status)
|
||||
}
|
||||
var walletAccount model.WalletAccount
|
||||
if err := db.Where("user_id = ? AND distribution_site_id = ?", users[0].ID, site.ID).
|
||||
First(&walletAccount).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if walletAccount.FrozenBalanceCent != 0 {
|
||||
t.Fatalf("legacy wallet frozen balance = %d, want 0", walletAccount.FrozenBalanceCent)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user