diff --git a/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go b/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go index ce1e474..95b8d86 100644 --- a/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go +++ b/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go @@ -96,9 +96,48 @@ func (l *WechatPayCallbackLogic) handleQueryOrderPayment(w http.ResponseWriter, } if order.Status == "paid" { - if asyncErr := l.svcCtx.AsynqService.SendQueryTask(order.Id); asyncErr != nil { - logx.Errorf("异步任务调度失败: %v", asyncErr) - return asyncErr + 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), ¶msMap); err != nil { + return fmt.Errorf("解析参数失败: %+v", err) + } + encryptName, err := crypto.AesEncrypt([]byte(paramsMap["name"]), key) + if err != nil { + return fmt.Errorf("生成订单, 加密姓名失败: %+v", err) + } + encryptIdcard, err := crypto.AesEncrypt([]byte(paramsMap["id_card"]), key) + if err != nil { + return fmt.Errorf("生成订单, 加密身份证号失败: %+v", err) + } + _, err = l.svcCtx.AuthorizationModel.Insert(l.ctx, nil, &model.Authorization{ + OrderId: order.Id, + UserId: order.UserId, + TargetName: encryptName, + TargetIdcard: encryptIdcard, + GrantType: model.GrantTypeFace, + Status: model.AuthorizationStatusPending, + }) + if err != nil { + logx.Errorf("微信支付回调,插入授权信息失败: %+v", err) + return fmt.Errorf("插入授权信息失败: %+v", err) } } diff --git a/pkg/lzkit/crypto/ecb_test.go b/pkg/lzkit/crypto/ecb_test.go index a497495..6537510 100644 --- a/pkg/lzkit/crypto/ecb_test.go +++ b/pkg/lzkit/crypto/ecb_test.go @@ -9,10 +9,9 @@ import ( func TestAesEcbMobileEncryption(t *testing.T) { // 测试手机号加密 - mobile := "13800138000" - key := []byte("1234567890abcdef") // 16字节AES-128密钥 + mobile := "15008098853" - keyStr := hex.EncodeToString(key) + keyStr := "ff83609b2b24fc73196aac3d3dfb874f" // 测试加密 encrypted, err := EncryptMobile(mobile, keyStr) if err != nil {