add count easypay
This commit is contained in:
@@ -96,7 +96,19 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
if l.svcCtx.EasyPayService == nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "易支付服务未启用")
|
||||
}
|
||||
prepayData, createOrderErr = l.svcCtx.EasyPayService.CreateEasyPayOrder(l.ctx, paymentTypeResp.amount, paymentTypeResp.description, paymentTypeResp.outTradeNo)
|
||||
// 获取用户ID用于次数轮询模式
|
||||
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if getUidErr != nil {
|
||||
// 如果获取用户ID失败,使用空字符串(会回退到天数轮询)
|
||||
userID = ""
|
||||
}
|
||||
easyPayResult, createOrderErr := l.svcCtx.EasyPayService.CreateEasyPayOrder(l.ctx, paymentTypeResp.amount, paymentTypeResp.description, paymentTypeResp.outTradeNo, userID)
|
||||
if createOrderErr == nil && easyPayResult != nil {
|
||||
prepayData = easyPayResult.PayURL
|
||||
// 将渠道ID存储到context中,后续创建订单时使用
|
||||
ctx = context.WithValue(ctx, "easypay_cid", easyPayResult.CID)
|
||||
l.ctx = ctx
|
||||
}
|
||||
} else if req.PayMethod == "appleiap" {
|
||||
prepayData = l.svcCtx.ApplePayService.GetIappayAppID(paymentTypeResp.outTradeNo)
|
||||
}
|
||||
@@ -228,6 +240,12 @@ func (l *PaymentLogic) QueryOrderPayment(req *types.PaymentReq, session sqlx.Ses
|
||||
Amount: amount,
|
||||
Status: "pending",
|
||||
}
|
||||
// 如果是易支付,记录使用的渠道ID到备注字段
|
||||
if req.PayMethod == "easypay_alipay" {
|
||||
if cid, ok := l.ctx.Value("easypay_cid").(string); ok && cid != "" {
|
||||
order.Remark = sql.NullString{String: fmt.Sprintf("易支付渠道号: %s", cid), Valid: true}
|
||||
}
|
||||
}
|
||||
_, insertOrderErr := l.svcCtx.OrderModel.Insert(l.ctx, session, &order)
|
||||
if insertOrderErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成订单, 保存订单失败: %+v", insertOrderErr)
|
||||
|
||||
Reference in New Issue
Block a user