feat(tenant): 按租户隔离用户身份与后台权限
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/wallet"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
@@ -16,6 +17,9 @@ import (
|
||||
// 管理员查询提现列表
|
||||
func (r *Repository) AdminList(ctx context.Context, query AdminListQuery) (*AdminPaginatedResult, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.WithdrawalRequest{})
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
db = db.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
|
||||
if query.Status != "" {
|
||||
db = db.Where("status = ?", query.Status)
|
||||
@@ -55,7 +59,11 @@ func (r *Repository) AdminList(ctx context.Context, query AdminListQuery) (*Admi
|
||||
// 管理员查询提现详情
|
||||
func (r *Repository) AdminFindByID(ctx context.Context, id uint64) (*WithdrawalDetailDTO, error) {
|
||||
var withdrawal model.WithdrawalRequest
|
||||
if err := r.db.WithContext(ctx).First(&withdrawal, id).Error; err != nil {
|
||||
query := r.db.WithContext(ctx).Where("id = ?", id)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := query.First(&withdrawal).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrWithdrawalNotFound
|
||||
}
|
||||
@@ -70,7 +78,11 @@ func (r *Repository) AdminFindByID(ctx context.Context, id uint64) (*WithdrawalD
|
||||
func (r *Repository) Review(ctx context.Context, adminID, id uint64, req ReviewWithdrawalRequest) (*WithdrawalDetailDTO, error) {
|
||||
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
var withdrawal model.WithdrawalRequest
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&withdrawal, id).Error; err != nil {
|
||||
query := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ?", id)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := query.First(&withdrawal).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return ErrWithdrawalNotFound
|
||||
}
|
||||
@@ -102,6 +114,7 @@ func (r *Repository) Review(ctx context.Context, adminID, id uint64, req ReviewW
|
||||
// 如果拒绝,解冻余额
|
||||
if !approved {
|
||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||
TenantID: withdrawal.TenantID,
|
||||
UserID: withdrawal.UserID,
|
||||
DistributionSiteID: withdrawal.DistributionSiteID,
|
||||
Direction: "out",
|
||||
@@ -111,6 +124,7 @@ func (r *Repository) Review(ctx context.Context, adminID, id uint64, req ReviewW
|
||||
BizNo: withdrawal.WithdrawNo,
|
||||
Remark: fmt.Sprintf("提现被拒绝: %s", req.Remark),
|
||||
}, wallet.Entry{
|
||||
TenantID: withdrawal.TenantID,
|
||||
UserID: withdrawal.UserID,
|
||||
DistributionSiteID: withdrawal.DistributionSiteID,
|
||||
Direction: "in",
|
||||
@@ -139,7 +153,11 @@ func (r *Repository) Review(ctx context.Context, adminID, id uint64, req ReviewW
|
||||
func (r *Repository) ConfirmPayment(ctx context.Context, adminID, id uint64, req ConfirmPaymentRequest) (*WithdrawalDetailDTO, error) {
|
||||
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
var withdrawal model.WithdrawalRequest
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&withdrawal, id).Error; err != nil {
|
||||
query := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ?", id)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := query.First(&withdrawal).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return ErrWithdrawalNotFound
|
||||
}
|
||||
@@ -164,6 +182,7 @@ func (r *Repository) ConfirmPayment(ctx context.Context, adminID, id uint64, req
|
||||
|
||||
// 扣除冻结余额
|
||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||
TenantID: withdrawal.TenantID,
|
||||
UserID: withdrawal.UserID,
|
||||
DistributionSiteID: withdrawal.DistributionSiteID,
|
||||
Direction: "out",
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
)
|
||||
|
||||
// 转换为用户DTO
|
||||
@@ -58,7 +59,11 @@ func (r *Repository) toAdminListItems(ctx context.Context, withdrawals []model.W
|
||||
|
||||
usersByID := make(map[uint64]model.User, len(userIDs))
|
||||
var users []model.User
|
||||
if err := r.db.WithContext(ctx).Select("id, nickname, phone").Where("id IN ?", userIDs).Find(&users).Error; err != nil {
|
||||
userQuery := r.db.WithContext(ctx).Select("id, nickname, phone").Where("id IN ?", userIDs)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
userQuery = userQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := userQuery.Find(&users).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
@@ -106,9 +111,14 @@ func (r *Repository) toAdminListItems(ctx context.Context, withdrawals []model.W
|
||||
// 转换为管理员详细DTO
|
||||
func (r *Repository) toDetailDTO(ctx context.Context, w model.WithdrawalRequest) (*WithdrawalDetailDTO, error) {
|
||||
db := r.db.WithContext(ctx)
|
||||
tenantID := tenancy.IDFromContext(ctx)
|
||||
// 查询用户信息
|
||||
var user model.User
|
||||
db.Select("nickname, phone").First(&user, w.UserID)
|
||||
userQuery := db.Select("nickname, phone").Where("id = ?", w.UserID)
|
||||
if tenantID > 0 {
|
||||
userQuery = userQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
userQuery.First(&user)
|
||||
|
||||
// 查询审核人信息
|
||||
var reviewedByName string
|
||||
@@ -133,7 +143,11 @@ func (r *Repository) toDetailDTO(ctx context.Context, w model.WithdrawalRequest)
|
||||
var certificateURLs []string
|
||||
if w.PaymentAccountID != nil {
|
||||
var paymentAccount model.UserPaymentAccount
|
||||
if err := db.First(&paymentAccount, *w.PaymentAccountID).Error; err == nil {
|
||||
accountQuery := db.Where("id = ?", *w.PaymentAccountID)
|
||||
if tenantID > 0 {
|
||||
accountQuery = accountQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := accountQuery.First(&paymentAccount).Error; err == nil {
|
||||
// 解密账号
|
||||
decrypted, err := r.encryptor.Decrypt(paymentAccount.AccountNo)
|
||||
if err == nil {
|
||||
|
||||
@@ -9,12 +9,17 @@ import (
|
||||
"hfb_sys/backend/internal/database"
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/wallet"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
"hfb_sys/backend/pkg/crypto"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
func withdrawalTenantContext(tenantID uint64) context.Context {
|
||||
return tenancy.WithScope(context.Background(), tenancy.Scope{TenantID: tenantID})
|
||||
}
|
||||
|
||||
type withdrawalFixture struct {
|
||||
db *gorm.DB
|
||||
repo *Repository
|
||||
@@ -405,3 +410,72 @@ func TestWithdrawalDetailIncludesDistributionSiteInfo(t *testing.T) {
|
||||
t.Fatalf("unexpected detail site info: %+v", detail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithdrawalRequestsAreScopedByTenant(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
dachuiUser := model.User{TenantID: 101, Phone: "13300000001", Status: "active"}
|
||||
jieyouUser := model.User{TenantID: 202, Phone: "13300000001", Status: "active"}
|
||||
if err := db.Create(&dachuiUser).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&jieyouUser).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dachuiAccount := model.UserPaymentAccount{
|
||||
TenantID: 101, UserID: dachuiUser.ID, AccountType: "bank",
|
||||
AccountName: "张三", AccountNo: "encrypted", Status: "active",
|
||||
}
|
||||
jieyouAccount := model.UserPaymentAccount{
|
||||
TenantID: 202, UserID: jieyouUser.ID, AccountType: "bank",
|
||||
AccountName: "张三", AccountNo: "encrypted", Status: "active",
|
||||
}
|
||||
if err := db.Create(&dachuiAccount).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&jieyouAccount).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, account := range []model.WalletAccount{
|
||||
{TenantID: 101, UserID: dachuiUser.ID, AvailableBalanceCent: 10_000, Status: "active"},
|
||||
{TenantID: 202, UserID: jieyouUser.ID, AvailableBalanceCent: 10_000, Status: "active"},
|
||||
} {
|
||||
if err := db.Create(&account).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
repo := NewRepository(db, wallet.NewRepository(db), &crypto.MockEncryptor{})
|
||||
dachuiCtx := withdrawalTenantContext(101)
|
||||
jieyouCtx := withdrawalTenantContext(202)
|
||||
dachuiWithdrawal, err := repo.Create(dachuiCtx, dachuiUser.ID, CreateWithdrawalRequest{
|
||||
PaymentAccountID: dachuiAccount.ID,
|
||||
AmountCent: 1000,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create dachui withdrawal: %v", err)
|
||||
}
|
||||
if _, err := repo.Create(jieyouCtx, jieyouUser.ID, CreateWithdrawalRequest{
|
||||
PaymentAccountID: jieyouAccount.ID,
|
||||
AmountCent: 2000,
|
||||
}); err != nil {
|
||||
t.Fatalf("create jieyou withdrawal: %v", err)
|
||||
}
|
||||
|
||||
var stored model.WithdrawalRequest
|
||||
if err := db.First(&stored, dachuiWithdrawal.ID).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stored.TenantID != 101 {
|
||||
t.Fatalf("withdrawal tenant_id = %d, want 101", stored.TenantID)
|
||||
}
|
||||
if _, err := repo.FindByID(jieyouCtx, dachuiUser.ID, dachuiWithdrawal.ID); !errors.Is(err, ErrWithdrawalNotFound) {
|
||||
t.Fatalf("cross-tenant withdrawal lookup error = %v", err)
|
||||
}
|
||||
list, err := repo.AdminList(jieyouCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if list.Total != 1 || len(list.Items) != 1 || list.Items[0].UserID != jieyouUser.ID {
|
||||
t.Fatalf("jieyou withdrawal list = %+v", list)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -34,7 +35,11 @@ func (r *Repository) AdminReviewContext(ctx context.Context, id uint64, query Wi
|
||||
query = normalizeReviewContextQuery(query)
|
||||
|
||||
var current model.WithdrawalRequest
|
||||
if err := r.db.WithContext(ctx).First(¤t, id).Error; err != nil {
|
||||
currentQuery := r.db.WithContext(ctx).Where("id = ?", id)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
currentQuery = currentQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := currentQuery.First(¤t).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrWithdrawalNotFound
|
||||
}
|
||||
@@ -79,6 +84,13 @@ func scopeWithdrawalSite(db *gorm.DB, column string, siteID uint64) *gorm.DB {
|
||||
return db.Where("(" + column + " IS NULL OR " + column + " = 0)")
|
||||
}
|
||||
|
||||
func scopeWithdrawalTenant(db *gorm.DB, column string, tenantID uint64) *gorm.DB {
|
||||
if tenantID > 0 {
|
||||
return db.Where(column+" = ?", tenantID)
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func (r *Repository) withdrawalReviewSummary(ctx context.Context, userID, siteID uint64) (WithdrawalReviewSummaryDTO, error) {
|
||||
db := r.db.WithContext(ctx)
|
||||
var result WithdrawalReviewSummaryDTO
|
||||
@@ -101,6 +113,7 @@ func (r *Repository) withdrawalReviewSummary(ctx context.Context, userID, siteID
|
||||
|
||||
var walletIncome int64
|
||||
walletQuery := scopeWithdrawalSite(db.Table("wallet_ledger AS wl"), "wl.distribution_site_id", siteID)
|
||||
walletQuery = scopeWithdrawalTenant(walletQuery, "wl.tenant_id", tenancy.IDFromContext(ctx))
|
||||
if err := walletQuery.
|
||||
Select("COALESCE(SUM(wl.amount_cent), 0)").
|
||||
Joins("JOIN rental_orders AS o ON o.id = wl.order_id").
|
||||
@@ -159,6 +172,7 @@ func (r *Repository) withdrawalReviewSummary(ctx context.Context, userID, siteID
|
||||
RejectedWithdrawalCount int64
|
||||
}
|
||||
withdrawalQuery := scopeWithdrawalSite(db.Table("withdrawal_requests"), "distribution_site_id", siteID)
|
||||
withdrawalQuery = scopeWithdrawalTenant(withdrawalQuery, "tenant_id", tenancy.IDFromContext(ctx))
|
||||
if err := withdrawalQuery.
|
||||
Select(`COUNT(*) AS withdrawal_count,
|
||||
COALESCE(SUM(CASE WHEN status = 'completed' THEN actual_amount_cent ELSE 0 END), 0) AS withdrawn_amount_cent,
|
||||
@@ -224,12 +238,12 @@ func (r *Repository) withdrawalReviewOrders(ctx context.Context, userID, siteID
|
||||
OrderID uint64
|
||||
AmountCent int64
|
||||
}
|
||||
if err := r.db.WithContext(ctx).
|
||||
walletLedgerQuery := r.db.WithContext(ctx).
|
||||
Table("wallet_ledger").
|
||||
Select("order_id, COALESCE(SUM(amount_cent), 0) AS amount_cent").
|
||||
Where("order_id IN ? AND user_id = ? AND direction = ? AND biz_type IN ?", orderIDs, userID, "in", ownerIncomeBizTypes).
|
||||
Group("order_id").
|
||||
Scan(&walletRows).Error; err != nil {
|
||||
Where("order_id IN ? AND user_id = ? AND direction = ? AND biz_type IN ?", orderIDs, userID, "in", ownerIncomeBizTypes)
|
||||
walletLedgerQuery = scopeWithdrawalTenant(walletLedgerQuery, "tenant_id", tenancy.IDFromContext(ctx))
|
||||
if err := walletLedgerQuery.Group("order_id").Scan(&walletRows).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
walletIncome := make(map[uint64]int64, len(walletRows))
|
||||
@@ -343,6 +357,7 @@ func (r *Repository) withdrawalReviewHistory(ctx context.Context, userID, siteID
|
||||
var rows []model.WithdrawalRequest
|
||||
offset := (query.WithdrawalPage - 1) * query.PageSize
|
||||
historyQuery := scopeWithdrawalSite(r.db.WithContext(ctx), "distribution_site_id", siteID)
|
||||
historyQuery = scopeWithdrawalTenant(historyQuery, "tenant_id", tenancy.IDFromContext(ctx))
|
||||
if err := historyQuery.
|
||||
Where("user_id = ?", userID).
|
||||
Order("created_at DESC, id DESC").
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/wallet"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
@@ -30,9 +31,14 @@ func (r *Repository) resolveSiteID(ctx context.Context, siteCode string) (uint64
|
||||
// 用户创建提现申请
|
||||
func (r *Repository) Create(ctx context.Context, userID uint64, req CreateWithdrawalRequest, siteCode ...string) (*WithdrawalDTO, error) {
|
||||
db := r.db.WithContext(ctx)
|
||||
tenantID := tenancy.IDFromContext(ctx)
|
||||
// 验证收款账号
|
||||
var paymentAccount model.UserPaymentAccount
|
||||
if err := db.Where("id = ? AND user_id = ? AND status = ?", req.PaymentAccountID, userID, "active").
|
||||
accountQuery := db.Where("id = ? AND user_id = ? AND status = ?", req.PaymentAccountID, userID, "active")
|
||||
if tenantID > 0 {
|
||||
accountQuery = accountQuery.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := accountQuery.
|
||||
First(&paymentAccount).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, errors.New("payment account not found")
|
||||
@@ -67,6 +73,7 @@ func (r *Repository) Create(ctx context.Context, userID uint64, req CreateWithdr
|
||||
|
||||
withdrawal := model.WithdrawalRequest{
|
||||
WithdrawNo: withdrawNo,
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
DistributionSiteID: siteID,
|
||||
AmountCent: req.AmountCent,
|
||||
@@ -90,6 +97,7 @@ func (r *Repository) Create(ctx context.Context, userID uint64, req CreateWithdr
|
||||
|
||||
// 冻结用户余额
|
||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
DistributionSiteID: siteID,
|
||||
Direction: "out",
|
||||
@@ -99,6 +107,7 @@ func (r *Repository) Create(ctx context.Context, userID uint64, req CreateWithdr
|
||||
BizNo: withdrawNo,
|
||||
Remark: "提现冻结",
|
||||
}, wallet.Entry{
|
||||
TenantID: tenantID,
|
||||
UserID: userID,
|
||||
DistributionSiteID: siteID,
|
||||
Direction: "in",
|
||||
@@ -124,6 +133,7 @@ func (r *Repository) Create(ctx context.Context, userID uint64, req CreateWithdr
|
||||
// 用户查询提现列表
|
||||
func (r *Repository) List(ctx context.Context, userID uint64, page, pageSize int, siteCode ...string) (*PaginatedResult, error) {
|
||||
db := r.db.WithContext(ctx)
|
||||
tenantID := tenancy.IDFromContext(ctx)
|
||||
var code string
|
||||
if len(siteCode) > 0 {
|
||||
code = siteCode[0]
|
||||
@@ -135,6 +145,10 @@ func (r *Repository) List(ctx context.Context, userID uint64, page, pageSize int
|
||||
|
||||
countDB := db.Model(&model.WithdrawalRequest{}).Where("user_id = ?", userID)
|
||||
dataDB := db.Where("user_id = ?", userID)
|
||||
if tenantID > 0 {
|
||||
countDB = countDB.Where("tenant_id = ?", tenantID)
|
||||
dataDB = dataDB.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if siteID > 0 {
|
||||
countDB = countDB.Where("distribution_site_id = ?", siteID)
|
||||
dataDB = dataDB.Where("distribution_site_id = ?", siteID)
|
||||
@@ -174,7 +188,11 @@ func (r *Repository) List(ctx context.Context, userID uint64, page, pageSize int
|
||||
// 用户查询提现详情
|
||||
func (r *Repository) FindByID(ctx context.Context, userID, id uint64) (*WithdrawalDTO, error) {
|
||||
var withdrawal model.WithdrawalRequest
|
||||
if err := r.db.WithContext(ctx).Where("id = ? AND user_id = ?", id, userID).
|
||||
query := r.db.WithContext(ctx).Where("id = ? AND user_id = ?", id, userID)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := query.
|
||||
First(&withdrawal).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrWithdrawalNotFound
|
||||
@@ -191,8 +209,12 @@ func (r *Repository) FindByID(ctx context.Context, userID, id uint64) (*Withdraw
|
||||
func (r *Repository) Cancel(ctx context.Context, userID, id uint64) error {
|
||||
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
var withdrawal model.WithdrawalRequest
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).
|
||||
Where("id = ? AND user_id = ?", id, userID).
|
||||
query := tx.Clauses(clause.Locking{Strength: "UPDATE"}).
|
||||
Where("id = ? AND user_id = ?", id, userID)
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
if err := query.
|
||||
First(&withdrawal).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return ErrWithdrawalNotFound
|
||||
@@ -212,6 +234,7 @@ func (r *Repository) Cancel(ctx context.Context, userID, id uint64) error {
|
||||
|
||||
// 解冻余额
|
||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||
TenantID: withdrawal.TenantID,
|
||||
UserID: userID,
|
||||
DistributionSiteID: withdrawal.DistributionSiteID,
|
||||
Direction: "out",
|
||||
@@ -221,6 +244,7 @@ func (r *Repository) Cancel(ctx context.Context, userID, id uint64) error {
|
||||
BizNo: withdrawal.WithdrawNo,
|
||||
Remark: "用户取消提现",
|
||||
}, wallet.Entry{
|
||||
TenantID: withdrawal.TenantID,
|
||||
UserID: userID,
|
||||
DistributionSiteID: withdrawal.DistributionSiteID,
|
||||
Direction: "in",
|
||||
|
||||
Reference in New Issue
Block a user