From 3671c40c464c09a8034b96b7f7fa75bae360d8aa Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Thu, 24 Apr 2025 13:59:33 +0800 Subject: [PATCH] new feature --- .../cmd/api/internal/queue/cleanQueryData.go | 8 ++-- .../api/internal/service/apirequestService.go | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/user/cmd/api/internal/queue/cleanQueryData.go b/app/user/cmd/api/internal/queue/cleanQueryData.go index 957fb02..df47b0f 100644 --- a/app/user/cmd/api/internal/queue/cleanQueryData.go +++ b/app/user/cmd/api/internal/queue/cleanQueryData.go @@ -25,14 +25,14 @@ func (l *CleanQueryDataHandler) ProcessTask(ctx context.Context, t *asynq.Task) now := time.Now().Format("2006-01-02 15:04:05") logx.Infof("%s - 开始执行查询数据清理任务", now) - // 计算3天前的时间 - threeDaysAgo := time.Now().AddDate(0, 0, -3) + // 计算7天前的时间 + sevenDaysAgo := time.Now().AddDate(0, 0, -7) // 创建查询条件,排除product_id为4的记录 conditions := l.svcCtx.QueryModel.SelectBuilder().Where("product_id != ?", 4) - // 调用QueryModel删除3天前的数据,排除product_id为4的记录 - result, err := l.svcCtx.QueryModel.DeleteBefore(ctx, threeDaysAgo, conditions) + // 调用QueryModel删除7天前的数据,排除product_id为4的记录 + result, err := l.svcCtx.QueryModel.DeleteBefore(ctx, sevenDaysAgo, conditions) if err != nil { logx.Errorf("%s - 清理查询数据失败: %v", time.Now().Format("2006-01-02 15:04:05"), err) return err diff --git a/app/user/cmd/api/internal/service/apirequestService.go b/app/user/cmd/api/internal/service/apirequestService.go index 919bff4..638b807 100644 --- a/app/user/cmd/api/internal/service/apirequestService.go +++ b/app/user/cmd/api/internal/service/apirequestService.go @@ -243,6 +243,7 @@ var requestProcessors = map[string]func(*ApiRequestService, context.Context, []b "G09XM02": (*ApiRequestService).ProcessG09XM02Request, "G10XM02": (*ApiRequestService).ProcessG10XM02Request, "G11BJ06": (*ApiRequestService).ProcessG11BJ06Request, + "G29BJ05": (*ApiRequestService).ProcessG29BJ05Request, } // PreprocessRequestApi 调用指定的请求处理函数 @@ -2518,3 +2519,48 @@ func (a *ApiRequestService) ProcessG11BJ06Request(ctx context.Context, params [] Data: jsonResult, }, nil } +func (a *ApiRequestService) ProcessG29BJ05Request(ctx context.Context, params []byte) (*APIInternalResult, error) { + + idCard := gjson.GetBytes(params, "id_card") + name := gjson.GetBytes(params, "name") + mobile := gjson.GetBytes(params, "mobile") + if !idCard.Exists() || !name.Exists() || !mobile.Exists() { + return nil, errors.New("api请求, G29BJ05, 获取相关参数失败") + } + request := map[string]interface{}{ + "data": map[string]interface{}{ + "id": a.westDexService.Encrypt(idCard.String()), + "name": a.westDexService.Encrypt(name.String()), + "cell": a.westDexService.Encrypt(mobile.String()), + }, + } + resp, err := a.westDexService.CallAPI("G29BJ05", request) + if err != nil && resp == nil { + return nil, fmt.Errorf("偿贷压力查询失败: %v", err) + } + // 获取响应码和偿贷压力标志 + code := gjson.GetBytes(resp, "code").String() + flagDebtRepayStress := gjson.GetBytes(resp, "flag_debtrepaystress").String() + + // 判断是否成功 + if code != "00" || flagDebtRepayStress != "1" { + return nil, fmt.Errorf("偿贷压力查询失败: %+v", resp) + } + // 获取偿贷压力分数 + drsNoDebtScore := gjson.GetBytes(resp, "drs_nodebtscore").String() + + // 构建结果 + result := map[string]interface{}{ + "score": drsNoDebtScore, + } + + // 将结果转为JSON + jsonResult, err := json.Marshal(result) + if err != nil { + return nil, fmt.Errorf("处理偿贷压力查询结果失败: %v", err) + } + + return &APIInternalResult{ + Data: jsonResult, + }, nil +}