save stripe custome id

Signed-off-by: wozulong <>
This commit is contained in:
wozulong
2024-03-23 21:59:15 +08:00
parent 71d60eeef7
commit 8537f10412
5 changed files with 19 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ func GetTopUpByTradeNo(tradeNo string) *TopUp {
return topUp
}
func Recharge(referenceId string) (err error) {
func Recharge(referenceId string, customerId string) (err error) {
if referenceId == "" {
return errors.New("未提供支付单号")
}
@@ -81,7 +81,7 @@ func Recharge(referenceId string) (err error) {
}
quota = topUp.Money * common.QuotaPerUnit
err = tx.Model(&User{}).Where("id = ?", topUp.UserId).Update("quota", gorm.Expr("quota + ?", quota)).Error
err = tx.Model(&User{}).Where("id = ?", topUp.UserId).Updates(map[string]interface{}{"stripe_customer": customerId, "quota": gorm.Expr("quota + ?", quota)}).Error
if err != nil {
return err
}