add sms authorization

This commit is contained in:
2025-06-03 12:24:15 +08:00
parent bebabce346
commit acd0dd5b9c
13 changed files with 252 additions and 90 deletions

View File

@@ -135,7 +135,6 @@ func (l *AlipayCallbackLogic) handleQueryOrderPayment(w http.ResponseWriter, not
UserId: order.UserId,
TargetName: encryptName,
TargetIdcard: encryptIdcard,
GrantType: model.GrantTypeFace,
Status: model.AuthorizationStatusPending,
})
if err != nil {

View File

@@ -205,7 +205,6 @@ func (l *PaymentLogic) QueryOrderPayment(req *types.PaymentReq, session sqlx.Ses
UserId: order.UserId,
TargetName: encryptName,
TargetIdcard: encryptIdcard,
GrantType: model.GrantTypeFace,
Status: model.AuthorizationStatusPending,
})
if err != nil {

View File

@@ -132,7 +132,6 @@ func (l *WechatPayCallbackLogic) handleQueryOrderPayment(w http.ResponseWriter,
UserId: order.UserId,
TargetName: encryptName,
TargetIdcard: encryptIdcard,
GrantType: model.GrantTypeFace,
Status: model.AuthorizationStatusPending,
})
if err != nil {
@@ -233,51 +232,6 @@ func (l *WechatPayCallbackLogic) handleRefund(order *model.AgentMembershipRechar
if refundErr != nil {
return refundErr
}
} else {
refund, refundErr := l.svcCtx.AlipayService.AliRefund(ctx, order.OrderNo, order.Amount)
if refundErr != nil {
return refundErr
}
if refund.IsSuccess() {
redisKey := fmt.Sprintf(types.QueryCacheKey, order.UserId, order.OrderNo)
cache, cacheErr := l.svcCtx.Redis.Get(redisKey)
if cacheErr != nil {
return fmt.Errorf("获取缓存内容失败: %+v", cacheErr)
}
var data types.QueryCacheLoad
err := json.Unmarshal([]byte(cache), &data)
if err != nil {
return fmt.Errorf("解析缓存内容失败: %+v", err)
}
secretKey := l.svcCtx.Config.Encrypt.SecretKey
key, decodeErr := hex.DecodeString(secretKey)
if decodeErr != nil {
return fmt.Errorf("获取AES密钥失败: %+v", decodeErr)
}
decryptData, aesdecryptErr := crypto.AesDecrypt(data.Params, key)
if aesdecryptErr != nil {
return fmt.Errorf("解密参数失败: %+v", aesdecryptErr)
}
var paramsMap map[string]string
if err := json.Unmarshal([]byte(decryptData), &paramsMap); err != nil {
return fmt.Errorf("解析参数失败: %+v", err)
}
_, err = l.svcCtx.AuthorizationModel.Insert(l.ctx, nil, &model.Authorization{
OrderId: order.Id,
UserId: order.UserId,
TargetName: paramsMap["name"],
TargetIdcard: paramsMap["id_card"],
GrantType: model.GrantTypeFace,
Status: model.AuthorizationStatusPending,
})
if err != nil {
logx.Errorf("支付宝支付回调,插入授权信息失败: %+v", err)
return fmt.Errorf("插入授权信息失败: %+v", err)
}
} else {
logx.Errorf("支付宝退款失败:%v", refundErr)
return refundErr
}
}
return nil
}