修正实际付款金额
This commit is contained in:
parent
93328dac02
commit
2067fd6782
@ -97,7 +97,7 @@ func (b *OrderSingle) AddOrderSingle(c *gin.Context) {
|
|||||||
userCouponId = &id
|
userCouponId = &id
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.OrderPrice < 0 {
|
if *req.OrderPrice < 0 {
|
||||||
responses.FailWithMessage("价格错误", c)
|
responses.FailWithMessage("价格错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,10 +24,10 @@ type GetOrderSinglePage struct {
|
|||||||
|
|
||||||
// AddOrderSingle 创建单项订单
|
// AddOrderSingle 创建单项订单
|
||||||
type AddOrderSingle struct {
|
type AddOrderSingle struct {
|
||||||
QuestionId string `json:"question_id" form:"question_id" label:"问题" validate:"required"`
|
QuestionId string `json:"question_id" form:"question_id" label:"问题" validate:"required"`
|
||||||
UserCouponId string `json:"user_coupon_id" form:"user_coupon_id" label:"优惠卷"`
|
UserCouponId string `json:"user_coupon_id" form:"user_coupon_id" label:"优惠卷"`
|
||||||
PayChannel int `json:"pay_channel" form:"pay_channel" label:"支付渠道" validate:"required,oneof=1 2 3"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
PayChannel int `json:"pay_channel" form:"pay_channel" label:"支付渠道" validate:"required,oneof=1 2 3"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||||
OrderPrice float64 `json:"order_price" form:"order_price" label:"订单金额" validate:"required"` // 订单金额
|
OrderPrice *float64 `json:"order_price" form:"order_price" label:"订单金额"` // 订单金额
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrderSinglePay 获取单项订单支付数据
|
// GetOrderSinglePay 获取单项订单支付数据
|
||||||
|
|||||||
@ -22,7 +22,7 @@ type OrderSingleService struct {
|
|||||||
|
|
||||||
// AddOrderSingle 创建单项订单
|
// AddOrderSingle 创建单项订单
|
||||||
// payChannel:支付渠道(1:h5支付 2:app支付 3:会员支付)
|
// payChannel:支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||||
func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int64, UserCouponId *int64, payChannel int, orderPrice float64) (orderSingle *model.OrderSingle, err error) {
|
func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int64, UserCouponId *int64, payChannel int, orderPrice *float64) (orderSingle *model.OrderSingle, err error) {
|
||||||
// 检测并发请求
|
// 检测并发请求
|
||||||
redisKey := "AddOrderSingle" + fmt.Sprintf("%d", UserId) + fmt.Sprintf("%d", QuestionId)
|
redisKey := "AddOrderSingle" + fmt.Sprintf("%d", UserId) + fmt.Sprintf("%d", QuestionId)
|
||||||
res, _ := global.Redis.Get(context.Background(), redisKey).Result()
|
res, _ := global.Redis.Get(context.Background(), redisKey).Result()
|
||||||
@ -112,9 +112,13 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
|
|||||||
|
|
||||||
escrowTradeNo = "GD" + global.Snowflake.Generate().String() // 第三方支付流水号
|
escrowTradeNo = "GD" + global.Snowflake.Generate().String() // 第三方支付流水号
|
||||||
} else {
|
} else {
|
||||||
|
if orderPrice == nil {
|
||||||
|
return nil, errors.New("价格异常")
|
||||||
|
}
|
||||||
|
|
||||||
// 实际付款金额
|
// 实际付款金额
|
||||||
paymentAmountTotal = amountTotal - couponAmountTotal
|
paymentAmountTotal = amountTotal - couponAmountTotal
|
||||||
if orderPrice != paymentAmountTotal {
|
if *orderPrice != paymentAmountTotal {
|
||||||
return nil, errors.New("价格异常")
|
return nil, errors.New("价格异常")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user