feat: 完善商品筛选、发布配置与优质号主流程
This commit is contained in:
@@ -121,13 +121,31 @@ func (r *Repository) PaymentAmount(ctx context.Context, userID uint64) (int64, b
|
||||
// ConfirmQualityOwnerDepositPaidTx 在支付回调事务内完成在线保证金入账并开通资格。
|
||||
// 外部支付已经由渠道完成,因此这里只增加冻结余额,不再扣减可用余额。
|
||||
func (r *Repository) ConfirmQualityOwnerDepositPaidTx(tx *gorm.DB, userID uint64, amountCent int64, paymentNo string) error {
|
||||
if tx == nil || userID == 0 || amountCent <= 0 {
|
||||
paymentNo = strings.TrimSpace(paymentNo)
|
||||
if tx == nil || userID == 0 || amountCent <= 0 || paymentNo == "" {
|
||||
return ErrInvalidUser
|
||||
}
|
||||
var user model.User
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&user, userID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
var appliedCount int64
|
||||
if err := tx.Model(&model.WalletLedger{}).
|
||||
Where(
|
||||
"user_id = ? AND distribution_site_id = 0 AND biz_type = ? AND biz_no = ? AND direction = ? AND balance_type = ?",
|
||||
userID,
|
||||
"quality_owner_deposit",
|
||||
paymentNo,
|
||||
"in",
|
||||
"frozen",
|
||||
).
|
||||
Count(&appliedCount).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
// 同一支付单已消费过时保持幂等。即使资格后来被取消,也不能让旧支付回调重新开通。
|
||||
if appliedCount > 0 {
|
||||
return nil
|
||||
}
|
||||
// 同一支付回调可能重复到达;已经是优质号主时保持幂等。
|
||||
if user.QualityOwnerStatus == StatusActive {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user