重构支付接口,以动态支持多种产品类型,整合长短效套餐的购买支付逻辑;引入 decimal 类型的金额计算;
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
q "platform/web/queries"
|
||||
)
|
||||
|
||||
@@ -9,12 +8,12 @@ var User = &userService{}
|
||||
|
||||
type userService struct{}
|
||||
|
||||
func (s *userService) RechargeConfirm(ctx context.Context, tradeNo string, verified *TransactionVerifyResult) error {
|
||||
func (s *userService) RechargeConfirm(tradeNo string, verified *TransactionVerifyResult) error {
|
||||
|
||||
err := q.Q.Transaction(func(tx *q.Query) error {
|
||||
|
||||
// 更新交易状态
|
||||
result, err := Transaction.CompleteTransaction(ctx, tx, &TransactionCompleteData{
|
||||
result, err := Transaction.CompleteTransaction(tx, &TransactionCompleteData{
|
||||
TradeNo: tradeNo,
|
||||
TransactionVerifyResult: *verified,
|
||||
})
|
||||
@@ -31,7 +30,7 @@ func (s *userService) RechargeConfirm(ctx context.Context, tradeNo string, verif
|
||||
|
||||
_, err = tx.User.
|
||||
Where(tx.User.ID.Eq(user.ID)).
|
||||
UpdateSimple(tx.User.Balance.Add(result.Trade.Amount))
|
||||
UpdateSimple(tx.User.Balance.Value(user.Balance.Add(result.Trade.Amount)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user