新增会员和单项0元支付

This commit is contained in:
wucongxing8150 2024-09-09 14:18:49 +08:00
parent a0b6ffce91
commit d6dde2d5d3
2 changed files with 34 additions and 23 deletions

View File

@ -126,9 +126,20 @@ func (r *OrderMemberService) AddOrderMember(tx *gorm.DB, UserId, SystemMemberId
return nil, errors.New("价格异常")
}
orderStatus = 1 // 订单状态1:待支付 2:已完成 3:已取消)
payStatus = 1 // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
payTime = nil // 支付时间
if paymentAmountTotal == 0 {
paymentAmountTotal = 0 // 实际付款金额
orderStatus = 2 // 订单状态1:待支付 2:已完成 3:已取消)
payStatus = 2 // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
now := model.LocalTime(time.Now())
payTime = &now // 支付时间
escrowTradeNo = "GD" + global.Snowflake.Generate().String() // 第三方支付流水号
} else {
orderStatus = 1 // 订单状态1:待支付 2:已完成 3:已取消)
payStatus = 1 // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
payTime = nil // 支付时间
}
// 生成订单号
orderNo := "M" + global.Snowflake.Generate().String()
@ -189,7 +200,7 @@ func (r *OrderMemberService) AddOrderMember(tx *gorm.DB, UserId, SystemMemberId
}
// 增加未支付取消订单延迟队列
if payChannel == 1 || payChannel == 2 {
if paymentAmountTotal != 0 {
delay := 30 * time.Minute
if config.C.Env == "dev" {

View File

@ -114,8 +114,23 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
couponAmountTotal = userCoupon.Coupon.CouponPrice
}
// 会员支付
if payChannel == 3 {
if orderPrice == nil {
return nil, errors.New("价格异常")
}
// 实际付款金额
paymentAmountTotal = amountTotal - couponAmountTotal
paymentAmountTotal = math.Round(paymentAmountTotal*100) / 100
if paymentAmountTotal < 0 {
paymentAmountTotal = 0
}
if *orderPrice != paymentAmountTotal {
return nil, errors.New("价格异常")
}
// 会员支付/0元支付
if payChannel == 3 || paymentAmountTotal == 0 {
paymentAmountTotal = 0 // 实际付款金额
orderStatus = 2 // 订单状态1:待支付 2:已完成 3:已取消)
payStatus = 2 // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
@ -137,21 +152,6 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
singleValidDate := model.LocalTime(time.Now().Add(time.Duration(systemSingle.ValidDays) * 24 * time.Hour))
validDate = &singleValidDate
} else {
if orderPrice == nil {
return nil, errors.New("价格异常")
}
// 实际付款金额
paymentAmountTotal = amountTotal - couponAmountTotal
paymentAmountTotal = math.Round(paymentAmountTotal*100) / 100
if paymentAmountTotal < 0 {
paymentAmountTotal = 0
}
if *orderPrice != paymentAmountTotal {
return nil, errors.New("价格异常")
}
orderStatus = 1 // 订单状态1:待支付 2:已完成 3:已取消)
payStatus = 1 // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
payTime = nil // 支付时间
@ -217,7 +217,7 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
}
// 增加未支付取消订单延迟队列
if payChannel == 1 || payChannel == 2 {
if (payChannel == 1 || payChannel == 2) && paymentAmountTotal != 0 {
delay := 30 * time.Minute
if config.C.Env == "dev" {
@ -247,7 +247,7 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
}
// 会员支付
if payChannel == 3 {
if payChannel == 3 || paymentAmountTotal == 0 {
// 增加单项支付次数
questionService := QuestionService{}
res, err := questionService.AddQuestionPayCount(tx, orderSingle.QuestionId)