diff --git a/app/main/api/internal/logic/agent/applyforagentlogic.go b/app/main/api/internal/logic/agent/applyforagentlogic.go index effd75b..3b6af04 100644 --- a/app/main/api/internal/logic/agent/applyforagentlogic.go +++ b/app/main/api/internal/logic/agent/applyforagentlogic.go @@ -155,7 +155,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type if transErr != nil { return nil, transErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d", userID) } diff --git a/app/main/api/internal/logic/pay/wechatpayrefundcallbacklogic.go b/app/main/api/internal/logic/pay/wechatpayrefundcallbacklogic.go index d00af8e..21a5d1b 100644 --- a/app/main/api/internal/logic/pay/wechatpayrefundcallbacklogic.go +++ b/app/main/api/internal/logic/pay/wechatpayrefundcallbacklogic.go @@ -31,14 +31,16 @@ func NewWechatPayRefundCallbackLogic(ctx context.Context, svcCtx *svc.ServiceCon // handleQueryOrderRefund 处理查询订单退款 func (l *WechatPayRefundCallbackLogic) handleQueryOrderRefund(orderNo string, status refunddomestic.Status) error { - logx.Infof("【退款回调】开始处理查询订单退款,orderNo: %s, status: %v", orderNo, status) - order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo) if err != nil { - logx.Errorf("【退款回调】查找查询订单信息失败: orderNo=%s, err=%v", orderNo, err) return errors.Wrapf(err, "查找查询订单信息失败: %s", orderNo) } - logx.Infof("【退款回调】查找到订单信息: orderId=%d, currentStatus=%s", order.Id, order.Status) + + // 检查订单是否已经处理过退款 + if order.Status == model.OrderStatusRefunded { + logx.Infof("订单已经是退款状态,无需重复处理: orderNo=%s", orderNo) + return nil + } // 只处理成功和失败状态 var orderStatus, refundStatus string @@ -46,53 +48,46 @@ func (l *WechatPayRefundCallbackLogic) handleQueryOrderRefund(orderNo string, st case refunddomestic.STATUS_SUCCESS: orderStatus = model.OrderStatusRefunded refundStatus = model.OrderRefundStatusSuccess - logx.Infof("【退款回调】退款成功,将更新订单状态为: %s, 退款记录状态为: %s", orderStatus, refundStatus) case refunddomestic.STATUS_CLOSED: // 退款关闭,保持订单原状态,更新退款记录为失败 refundStatus = model.OrderRefundStatusFailed - logx.Infof("【退款回调】退款关闭,退款记录状态将更新为: %s", refundStatus) case refunddomestic.STATUS_ABNORMAL: // 退款异常,保持订单原状态,更新退款记录为失败 refundStatus = model.OrderRefundStatusFailed - logx.Infof("【退款回调】退款异常,退款记录状态将更新为: %s", refundStatus) default: // 其他状态暂不处理 - logx.Infof("【退款回调】状态 %v 暂不处理,直接返回", status) return nil } - logx.Infof("【退款回调】开始执行数据库事务更新") // 使用事务同时更新订单和退款记录 err = l.svcCtx.OrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error { - logx.Infof("【退款回调】进入事务处理") - // 更新订单状态(仅在退款成功时更新) if status == refunddomestic.STATUS_SUCCESS { - logx.Infof("【退款回调】准备更新订单状态,orderId: %d", order.Id) order.Status = orderStatus order.RefundTime = sql.NullTime{ Time: time.Now(), Valid: true, } if err := l.svcCtx.OrderModel.UpdateWithVersion(ctx, session, order); err != nil { - logx.Errorf("【退款回调】更新订单状态失败: orderId=%d, err=%v", order.Id, err) return errors.Wrapf(err, "更新查询订单状态失败: %s", orderNo) } - logx.Infof("【退款回调】订单状态更新成功,orderId: %d", order.Id) } // 更新退款记录状态 - logx.Infof("【退款回调】准备查找退款记录,orderId: %d", order.Id) refund, err := l.svcCtx.OrderRefundModel.FindOneByOrderId(ctx, order.Id) if err != nil { if err == model.ErrNotFound { - logx.Errorf("【退款回调】未找到订单对应的退款记录: orderNo=%s, orderId=%d", orderNo, order.Id) + logx.Errorf("未找到订单对应的退款记录: orderNo=%s, orderId=%d", orderNo, order.Id) return nil // 没有退款记录时不报错,只记录警告 } - logx.Errorf("【退款回调】查找退款记录失败: orderNo=%s, orderId=%d, err=%v", orderNo, order.Id, err) return errors.Wrapf(err, "查找退款记录失败: orderNo=%s", orderNo) } - logx.Infof("【退款回调】找到退款记录: refundId=%d, currentStatus=%s", refund.Id, refund.Status) + + // 检查退款记录是否已经处理过 + if refund.Status == model.OrderRefundStatusSuccess { + logx.Infof("退款记录已经是成功状态,无需重复处理: orderNo=%s, refundId=%d", orderNo, refund.Id) + return nil + } refund.Status = refundStatus if status == refunddomestic.STATUS_SUCCESS { @@ -100,98 +95,78 @@ func (l *WechatPayRefundCallbackLogic) handleQueryOrderRefund(orderNo string, st Time: time.Now(), Valid: true, } - logx.Infof("【退款回调】设置退款成功时间") } else if status == refunddomestic.STATUS_CLOSED { refund.CloseTime = sql.NullTime{ Time: time.Now(), Valid: true, } - logx.Infof("【退款回调】设置退款关闭时间") } - logx.Infof("【退款回调】准备更新退款记录状态,refundId: %d", refund.Id) if _, err := l.svcCtx.OrderRefundModel.Update(ctx, session, refund); err != nil { - logx.Errorf("【退款回调】更新退款记录状态失败: refundId=%d, err=%v", refund.Id, err) return errors.Wrapf(err, "更新退款记录状态失败: orderNo=%s", orderNo) } - logx.Infof("【退款回调】退款记录状态更新成功,refundId: %d", refund.Id) - logx.Infof("【退款回调】事务处理完成") return nil }) if err != nil { - logx.Errorf("【退款回调】事务执行失败: orderNo=%s, err=%v", orderNo, err) return errors.Wrapf(err, "更新订单和退款记录失败: %s", orderNo) } - logx.Infof("【退款回调】查询订单退款处理完成,orderNo: %s", orderNo) return nil } // handleAgentOrderRefund 处理代理会员订单退款 func (l *WechatPayRefundCallbackLogic) handleAgentOrderRefund(orderNo string, status refunddomestic.Status) error { - logx.Infof("【退款回调】开始处理代理会员订单退款,orderNo: %s, status: %v", orderNo, status) - order, err := l.svcCtx.AgentMembershipRechargeOrderModel.FindOneByOrderNo(l.ctx, orderNo) if err != nil { - logx.Errorf("【退款回调】查找代理会员订单信息失败: orderNo=%s, err=%v", orderNo, err) return errors.Wrapf(err, "查找代理会员订单信息失败: %s", orderNo) } - logx.Infof("【退款回调】找到代理会员订单: orderId=%d, currentStatus=%s", order.Id, order.Status) + + // 检查订单是否已经处理过退款 + if order.Status == "refunded" { + logx.Infof("代理会员订单已经是退款状态,无需重复处理: orderNo=%s", orderNo) + return nil + } if status == refunddomestic.STATUS_SUCCESS { - logx.Infof("【退款回调】代理会员订单退款成功,将更新状态为: refunded") order.Status = "refunded" } else if status == refunddomestic.STATUS_ABNORMAL { - logx.Infof("【退款回调】代理会员订单退款异常状态,直接返回") return nil // 异常状态直接返回 } else { - logx.Infof("【退款回调】代理会员订单其他状态 %v,直接返回", status) return nil // 其他状态直接返回 } - logx.Infof("【退款回调】准备更新代理会员订单状态,orderId: %d", order.Id) if err := l.svcCtx.AgentMembershipRechargeOrderModel.UpdateWithVersion(l.ctx, nil, order); err != nil { - logx.Errorf("【退款回调】更新代理会员订单状态失败: orderId=%d, err=%v", order.Id, err) return errors.Wrapf(err, "更新代理会员订单状态失败: %s", orderNo) } - logx.Infof("【退款回调】代理会员订单退款处理完成,orderNo: %s", orderNo) return nil } // sendSuccessResponse 发送成功响应 func (l *WechatPayRefundCallbackLogic) sendSuccessResponse(w http.ResponseWriter) { - logx.Infof("【退款回调】发送成功响应给微信") w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte("success")) } func (l *WechatPayRefundCallbackLogic) WechatPayRefundCallback(w http.ResponseWriter, r *http.Request) error { - logx.Infof("【退款回调】收到微信退款回调请求") - // 1. 处理微信退款通知 - logx.Infof("【退款回调】开始解析微信退款通知") notification, err := l.svcCtx.WechatPayService.HandleRefundNotification(l.ctx, r) if err != nil { - logx.Errorf("【退款回调】微信退款回调处理失败: %v", err) + logx.Errorf("微信退款回调处理失败: %v", err) l.sendSuccessResponse(w) return nil } - logx.Infof("【退款回调】微信退款通知解析成功") - logx.Infof("【退款回调】notification详细信息: %+v", notification) - // 2. 检查关键字段是否为空 if notification.OutTradeNo == nil { - logx.Errorf("【退款回调】OutTradeNo字段为空") + logx.Errorf("微信退款回调OutTradeNo字段为空") l.sendSuccessResponse(w) return nil } orderNo := *notification.OutTradeNo - logx.Infof("【退款回调】提取到订单号: %s", orderNo) // 3. 判断退款状态,优先使用Status,如果Status为nil则使用SuccessTime判断 var status refunddomestic.Status @@ -200,51 +175,41 @@ func (l *WechatPayRefundCallbackLogic) WechatPayRefundCallback(w http.ResponseWr if notification.Status != nil { status = *notification.Status statusDetermined = true - logx.Infof("【退款回调】从Status字段获取状态: %v", status) } else if notification.SuccessTime != nil && !notification.SuccessTime.IsZero() { // 如果Status为空但SuccessTime有值,说明退款成功 status = refunddomestic.STATUS_SUCCESS statusDetermined = true - logx.Infof("【退款回调】Status为空,但SuccessTime有值(%v),判断为退款成功", notification.SuccessTime) } else { - logx.Errorf("【退款回调】Status和SuccessTime都为空,无法确定退款状态") + logx.Errorf("微信退款回调Status和SuccessTime都为空,无法确定退款状态: orderNo=%s", orderNo) l.sendSuccessResponse(w) return nil } if !statusDetermined { - logx.Errorf("【退款回调】无法确定退款状态") + logx.Errorf("微信退款回调无法确定退款状态: orderNo=%s", orderNo) l.sendSuccessResponse(w) return nil } - logx.Infof("【退款回调】最终确定状态: %v", status) var processErr error // 4. 根据订单号前缀处理不同类型的订单 - logx.Infof("【退款回调】开始根据订单号前缀分发处理") switch { case strings.HasPrefix(orderNo, "Q_"): - logx.Infof("【退款回调】识别为查询订单,orderNo: %s", orderNo) processErr = l.handleQueryOrderRefund(orderNo, status) case strings.HasPrefix(orderNo, "A_"): - logx.Infof("【退款回调】识别为代理会员订单,orderNo: %s", orderNo) processErr = l.handleAgentOrderRefund(orderNo, status) default: // 兼容旧订单,假设没有前缀的是查询订单 - logx.Infof("【退款回调】无前缀订单,按查询订单处理,orderNo: %s", orderNo) processErr = l.handleQueryOrderRefund(orderNo, status) } // 5. 处理错误并响应 if processErr != nil { - logx.Errorf("【退款回调】处理退款订单失败: orderNo=%s, err=%v", orderNo, processErr) - } else { - logx.Infof("【退款回调】处理退款订单成功: orderNo=%s", orderNo) + logx.Errorf("处理退款订单失败: orderNo=%s, err=%v", orderNo, processErr) } // 无论处理是否成功,都返回成功响应给微信 l.sendSuccessResponse(w) - logx.Infof("【退款回调】退款回调处理完成") return nil } diff --git a/app/main/api/internal/logic/query/queryservicelogic.go b/app/main/api/internal/logic/query/queryservicelogic.go index 953f316..d3fb2cd 100644 --- a/app/main/api/internal/logic/query/queryservicelogic.go +++ b/app/main/api/internal/logic/query/queryservicelogic.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "qnc-server/app/main/api/internal/service" + "qnc-server/app/main/model" "qnc-server/common/ctxdata" "qnc-server/common/xerr" "qnc-server/pkg/lzkit/crypto" @@ -98,7 +99,7 @@ func (l *QueryServiceLogic) ProcessMarriageLogic(req *types.QueryServiceReq) (*t if cacheDataErr != nil { return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -152,7 +153,7 @@ func (l *QueryServiceLogic) ProcessHomeServiceLogic(req *types.QueryServiceReq) if cacheDataErr != nil { return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -207,7 +208,7 @@ func (l *QueryServiceLogic) ProcessRiskAssessmentLogic(req *types.QueryServiceRe return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -261,7 +262,7 @@ func (l *QueryServiceLogic) ProcessCompanyInfoLogic(req *types.QueryServiceReq) return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -317,7 +318,7 @@ func (l *QueryServiceLogic) ProcessRentalInfoLogic(req *types.QueryServiceReq) ( return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -373,7 +374,7 @@ func (l *QueryServiceLogic) ProcessPreLoanBackgroundCheckLogic(req *types.QueryS return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } @@ -426,7 +427,7 @@ func (l *QueryServiceLogic) ProcessBackgroundCheckLogic(req *types.QueryServiceR return nil, cacheDataErr } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID) } diff --git a/app/main/api/internal/logic/user/bindmobilelogic.go b/app/main/api/internal/logic/user/bindmobilelogic.go index b7bf6ae..d45fe16 100644 --- a/app/main/api/internal/logic/user/bindmobilelogic.go +++ b/app/main/api/internal/logic/user/bindmobilelogic.go @@ -80,7 +80,7 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind } } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 生成token失败: %+v", err) } diff --git a/app/main/api/internal/logic/user/gettokenlogic.go b/app/main/api/internal/logic/user/gettokenlogic.go index 987ec74..f456460 100644 --- a/app/main/api/internal/logic/user/gettokenlogic.go +++ b/app/main/api/internal/logic/user/gettokenlogic.go @@ -29,11 +29,11 @@ func NewGetTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetToken } func (l *GetTokenLogic) GetToken() (resp *types.MobileCodeLoginResp, err error) { - userID, err := ctxdata.GetUidFromCtx(l.ctx) + claims, err := ctxdata.GetClaimsFromCtx(l.ctx) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err) } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, claims.UserId, claims.UserType) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err) } diff --git a/app/main/api/internal/logic/user/mobilecodeloginlogic.go b/app/main/api/internal/logic/user/mobilecodeloginlogic.go index e0394f8..d992dc3 100644 --- a/app/main/api/internal/logic/user/mobilecodeloginlogic.go +++ b/app/main/api/internal/logic/user/mobilecodeloginlogic.go @@ -64,7 +64,7 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r } else { userID = user.Id } - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d", userID) } diff --git a/app/main/api/internal/logic/user/wxh5authlogic.go b/app/main/api/internal/logic/user/wxh5authlogic.go index 4931600..88f7998 100644 --- a/app/main/api/internal/logic/user/wxh5authlogic.go +++ b/app/main/api/internal/logic/user/wxh5authlogic.go @@ -47,9 +47,11 @@ func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthRe // Step 3: 处理用户信息 var userID int64 + var userType int64 if userAuth != nil { // 已存在用户,直接登录 userID = userAuth.UserId + userType = model.UserTypeNormal } else { // 检查临时用户表 userTemp, err := l.svcCtx.UserTempModel.FindOneByAuthTypeAuthKey(l.ctx, model.UserAuthTypeWxh5OpenID, accessTokenResp.Openid) @@ -74,10 +76,11 @@ func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthRe } else { userID = userTemp.Id } + userType = model.UserTypeTemp } // Step 4: 生成JWT Token - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT token失败: %v", err) } diff --git a/app/main/api/internal/logic/user/wxminiauthlogic.go b/app/main/api/internal/logic/user/wxminiauthlogic.go index 784d0f0..64562ac 100644 --- a/app/main/api/internal/logic/user/wxminiauthlogic.go +++ b/app/main/api/internal/logic/user/wxminiauthlogic.go @@ -47,9 +47,11 @@ func (l *WxMiniAuthLogic) WxMiniAuth(req *types.WXMiniAuthReq) (resp *types.WXMi // 3. 处理用户信息 var userID int64 + var userType int64 if userAuth != nil { // 已存在用户,直接登录 userID = userAuth.UserId + userType = model.UserTypeNormal } else { // 注册临时用户 userTemp, err := l.svcCtx.UserTempModel.FindOneByAuthTypeAuthKey(l.ctx, model.UserAuthTypeWxMiniOpenID, sessionKeyResp.Openid) @@ -74,10 +76,11 @@ func (l *WxMiniAuthLogic) WxMiniAuth(req *types.WXMiniAuthReq) (resp *types.WXMi // 使用已存在的临时用户ID userID = userTemp.Id } + userType = model.UserTypeTemp } // 4. 生成JWT Token - token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID) + token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType) if err != nil { return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT Token失败: %v", err) } diff --git a/app/main/api/internal/service/userService.go b/app/main/api/internal/service/userService.go index 9a4b3d3..0eabd8d 100644 --- a/app/main/api/internal/service/userService.go +++ b/app/main/api/internal/service/userService.go @@ -77,7 +77,7 @@ func (s *UserService) RegisterUUIDUser(ctx context.Context) (int64, error) { } // generalUserToken 生成用户token -func (s *UserService) GeneralUserToken(ctx context.Context, userID int64) (string, error) { +func (s *UserService) GeneralUserToken(ctx context.Context, userID int64, userType int64) (string, error) { platform, err := ctxdata.GetPlatformFromCtx(ctx) if err != nil { return "", err @@ -85,18 +85,7 @@ func (s *UserService) GeneralUserToken(ctx context.Context, userID int64) (strin var isAgent int64 var agentID int64 - var userType int64 - var user *model.User - users, err := s.userModel.FindAll(ctx, s.userModel.SelectBuilder().Where("id = ?", userID), "") - if err != nil && !errors.Is(err, model.ErrNotFound) { - return "", err - } - if len(users) > 0 { - user = users[0] - } - if user != nil { - userID = user.Id - userType = model.UserTypeNormal + if userType == model.UserTypeNormal { agent, err := s.agentModel.FindOneByUserId(ctx, userID) if err != nil && !errors.Is(err, model.ErrNotFound) { return "", err @@ -112,7 +101,6 @@ func (s *UserService) GeneralUserToken(ctx context.Context, userID int64) (strin } if userTemp != nil { userID = userTemp.Id - userType = model.UserTypeTemp } } token, generaErr := jwtx.GenerateJwtToken(jwtx.JwtClaims{ diff --git a/app/main/api/internal/service/wechatpayService.go b/app/main/api/internal/service/wechatpayService.go index 2452254..adfd2f7 100644 --- a/app/main/api/internal/service/wechatpayService.go +++ b/app/main/api/internal/service/wechatpayService.go @@ -307,6 +307,7 @@ func (w *WechatPayService) HandleWechatPayNotification(ctx context.Context, req } // HandleRefundNotification 处理微信退款回调 +// 由于SDK解析退款状态refund.status为空,可以通过判断 w.notifyHandler.ParseNotifyRequest返回的notifyReq.EventType是否为REFUND.SUCCESS来判断退款状态 func (w *WechatPayService) HandleRefundNotification(ctx context.Context, req *http.Request) (*refunddomestic.Refund, error) { refund := new(refunddomestic.Refund) _, err := w.notifyHandler.ParseNotifyRequest(ctx, req, refund) @@ -350,7 +351,7 @@ func (w *WechatPayService) WeChatRefund(ctx context.Context, outTradeNo string, Currency: core.String("CNY"), Refund: core.Int64(lzUtils.ToWechatAmount(refundAmount)), Total: core.Int64(lzUtils.ToWechatAmount(totalAmount)), - }, + }, }) if err != nil { return fmt.Errorf("微信订单申请退款错误: %v", err)