fix general token
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user