diff --git a/app/main/api/internal/queue/paySuccessNotify.go b/app/main/api/internal/queue/paySuccessNotify.go index 259b4e6..9c987a7 100644 --- a/app/main/api/internal/queue/paySuccessNotify.go +++ b/app/main/api/internal/queue/paySuccessNotify.go @@ -96,11 +96,31 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq. return fmt.Errorf("解密参数失败: %+v", aesdecryptErr) } + // 为避免 base64 图片等大字段撑爆 query.query_params 列,这里对参数做一次瘦身: + // 删除纯 base64 图片字段(如 vlphoto_data / photo_data / image_base64),仅保留必要的文本信息。 + var originalParams map[string]interface{} + if err := json.Unmarshal(decryptData, &originalParams); err != nil { + return fmt.Errorf("解析原始参数失败: %+v", err) + } + delete(originalParams, "vlphoto_data") + delete(originalParams, "photo_data") + delete(originalParams, "image_base64") + + slimBytes, err := json.Marshal(originalParams) + if err != nil { + return fmt.Errorf("序列化精简后的参数失败: %+v", err) + } + slimEncrypted, err := crypto.AesEncrypt(slimBytes, key) + if err != nil { + return fmt.Errorf("加密精简后的参数失败: %+v", err) + } + query := &model.Query{ - OrderId: order.Id, - UserId: order.UserId, - ProductId: product.Id, - QueryParams: data.Params, + OrderId: order.Id, + UserId: order.UserId, + ProductId: product.Id, + // 仅保存精简后的参数,避免 base64 图片占满列 + QueryParams: slimEncrypted, QueryState: "pending", } result, insertQueryErr := l.svcCtx.QueryModel.Insert(ctx, nil, query) @@ -120,7 +140,7 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq. return fmt.Errorf("获取插入后的查询记录失败: %+v", err) } - // 解析解密后的参数获取用户信息 + // 解析解密后的参数获取用户信息(这里依然使用完整参数,后续会在写回时再次瘦身) var userInfo map[string]interface{} if err := json.Unmarshal(decryptData, &userInfo); err != nil { return fmt.Errorf("解析用户信息失败: %+v", err) @@ -140,7 +160,12 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq. downloadURL := l.buildAuthorizationDownloadURL(authDoc.FileName) userInfo["authorization_url"] = downloadURL - // 重新序列化用户信息 + // 为避免重新写回时再次引入大字段,这里也删除 base64 图片字段 + delete(userInfo, "vlphoto_data") + delete(userInfo, "photo_data") + delete(userInfo, "image_base64") + + // 重新序列化用户信息(已去除大字段) updatedDecryptData, marshalErr := json.Marshal(userInfo) if marshalErr != nil { logx.Errorf("序列化用户信息失败: %v", marshalErr)