diff --git a/app/main/api/internal/service/apirequestService.go b/app/main/api/internal/service/apirequestService.go index 8d84b8d..d854f78 100644 --- a/app/main/api/internal/service/apirequestService.go +++ b/app/main/api/internal/service/apirequestService.go @@ -24,6 +24,14 @@ func convertTianyuanResponse(resp *tianyuanapi.Response) ([]byte, error) { return json.Marshal(resp.Data) } +// 生成认证时间范围:当前时间前后两天的YYYYMMDD-YYMMDD格式 +func generateAuthDateRange() string { + now := time.Now() + start := now.AddDate(0, 0, -2).Format("20060102") + end := now.AddDate(0, 0, 2).Format("20060102") + return fmt.Sprintf("%s-%s", start, end) +} + type ApiRequestService struct { config config.Config featureModel model.FeatureModel @@ -538,19 +546,12 @@ func (a *ApiRequestService) ProcesFLXG0V4BRequest(params []byte) ([]byte, error) return nil, errors.New("api请求, BehaviorRiskScan, 获取相关参数失败") } - authDate := func() string { - now := time.Now() - start := now.AddDate(0, 0, -2).Format("20060201") - end := now.AddDate(0, 0, 2).Format("20060201") - return fmt.Sprintf("%s-%s", start, end) - } resp, err := a.tianyuanapi.CallInterface("FLXG0V4B", map[string]interface{}{ "name": name.String(), "id_card": idCard.String(), "mobile": mobile.String(), - "auth_date": authDate(), + "auth_date": generateAuthDateRange(), }) - if err != nil { return nil, err } @@ -1069,17 +1070,10 @@ func (a *ApiRequestService) ProcessFLXG0V4BRequest(params []byte) ([]byte, error return nil, errors.New("api请求, FLXG0V4B, 获取相关参数失败") } - authDate := func() string { - now := time.Now() - start := now.AddDate(0, 0, -2).Format("20060201") - end := now.AddDate(0, 0, 2).Format("20060201") - return fmt.Sprintf("%s-%s", start, end) - } - resp, err := a.tianyuanapi.CallInterface("FLXG0V4B", map[string]interface{}{ "name": name.String(), "id_card": idCard.String(), - "auth_date": authDate(), + "auth_date": generateAuthDateRange(), }, &tianyuanapi.ApiCallOptions{ Json: true, })