new feature

This commit is contained in:
liangzai 2025-04-24 13:59:33 +08:00
parent bb79a92176
commit 3671c40c46
2 changed files with 50 additions and 4 deletions

View File

@ -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

View File

@ -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
}