new version qnc

This commit is contained in:
2025-04-11 13:10:17 +08:00
parent 91db6239d9
commit b0cbe2e81d
162 changed files with 1361 additions and 1556 deletions

View File

@@ -2,11 +2,9 @@ package queue
import (
"context"
"time"
"tydata-server/app/user/cmd/api/internal/svc"
"qnc-server/app/user/cmd/api/internal/svc"
"github.com/hibiken/asynq"
"github.com/zeromicro/go-zero/core/logx"
)
// TASKTIME 定义为每天凌晨3点执行
@@ -23,19 +21,19 @@ func NewCleanQueryDataHandler(svcCtx *svc.ServiceContext) *CleanQueryDataHandler
}
func (l *CleanQueryDataHandler) ProcessTask(ctx context.Context, t *asynq.Task) error {
now := time.Now().Format("2006-01-02 15:04:05")
logx.Infof("%s - 开始执行查询数据清理任务", now)
// now := time.Now().Format("2006-01-02 15:04:05")
// logx.Infof("%s - 开始执行查询数据清理任务", now)
// 计算3天前的时间
threeDaysAgo := time.Now().AddDate(0, 0, -3)
// // 计算3天前的时间
// threeDaysAgo := time.Now().AddDate(0, 0, -3)
// 调用QueryModel删除3天前的数据
result, err := l.svcCtx.QueryModel.DeleteBefore(ctx, threeDaysAgo)
if err != nil {
logx.Errorf("%s - 清理查询数据失败: %v", time.Now().Format("2006-01-02 15:04:05"), err)
return err
}
// // 调用QueryModel删除3天前的数据
// result, err := l.svcCtx.QueryModel.DeleteBefore(ctx, threeDaysAgo)
// if err != nil {
// logx.Errorf("%s - 清理查询数据失败: %v", time.Now().Format("2006-01-02 15:04:05"), err)
// return err
// }
logx.Infof("%s - 查询数据清理完成,共删除 %d 条记录", time.Now().Format("2006-01-02 15:04:05"), result)
// logx.Infof("%s - 查询数据清理完成,共删除 %d 条记录", time.Now().Format("2006-01-02 15:04:05"), result)
return nil
}

View File

@@ -6,13 +6,13 @@ import (
"encoding/json"
"fmt"
"os"
"qnc-server/app/user/cmd/api/internal/svc"
"qnc-server/app/user/cmd/api/internal/types"
"qnc-server/app/user/model"
"qnc-server/pkg/lzkit/crypto"
"qnc-server/pkg/lzkit/lzUtils"
"regexp"
"strings"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
"tydata-server/app/user/model"
"tydata-server/pkg/lzkit/crypto"
"tydata-server/pkg/lzkit/lzUtils"
"github.com/hibiken/asynq"
"github.com/zeromicro/go-zero/core/logx"
@@ -55,21 +55,21 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
redisKey := fmt.Sprintf("%d:%s", order.UserId, order.OrderNo)
cache, cacheErr := l.svcCtx.Redis.GetCtx(ctx, redisKey)
if cacheErr != nil {
return fmt.Errorf("生成订单, 获取缓存内容失败: %+v", cacheErr)
return fmt.Errorf("获取缓存内容失败: %+v", cacheErr)
}
var data types.QueryCacheLoad
err = json.Unmarshal([]byte(cache), &data)
if err != nil {
return fmt.Errorf("生成订单, 解析缓存内容失败: %+v", err)
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)
return fmt.Errorf("获取AES密钥失败: %+v", decodeErr)
}
decryptData, aesdecryptErr := crypto.AesDecrypt(data.Params, key)
if aesdecryptErr != nil {
return fmt.Errorf("生成订单, 解密参数失败: %+v", aesdecryptErr)
return fmt.Errorf("解密参数失败: %+v", aesdecryptErr)
}
// 敏感数据脱敏处理
@@ -93,7 +93,7 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
}
result, insertQueryErr := l.svcCtx.QueryModel.Insert(ctx, nil, query)
if insertQueryErr != nil {
return fmt.Errorf("生成订单, 保存查询失败: %+v", insertQueryErr)
return fmt.Errorf("保存查询失败: %+v", insertQueryErr)
}
// 获取插入后的ID

View File

@@ -3,9 +3,10 @@ package queue
import (
"context"
"fmt"
"qnc-server/app/user/cmd/api/internal/svc"
"qnc-server/app/user/cmd/api/internal/types"
"github.com/hibiken/asynq"
"tydata-server/app/user/cmd/api/internal/svc"
"tydata-server/app/user/cmd/api/internal/types"
)
type CronJob struct {