This commit is contained in:
2025-08-18 12:43:12 +08:00
parent 3403bdbb68
commit f29830c1be

View File

@@ -24,6 +24,14 @@ func convertTianyuanResponse(resp *tianyuanapi.Response) ([]byte, error) {
return json.Marshal(resp.Data) 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 { type ApiRequestService struct {
config config.Config config config.Config
featureModel model.FeatureModel featureModel model.FeatureModel
@@ -538,19 +546,12 @@ func (a *ApiRequestService) ProcesFLXG0V4BRequest(params []byte) ([]byte, error)
return nil, errors.New("api请求, BehaviorRiskScan, 获取相关参数失败") 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{}{ resp, err := a.tianyuanapi.CallInterface("FLXG0V4B", map[string]interface{}{
"name": name.String(), "name": name.String(),
"id_card": idCard.String(), "id_card": idCard.String(),
"mobile": mobile.String(), "mobile": mobile.String(),
"auth_date": authDate(), "auth_date": generateAuthDateRange(),
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -1069,17 +1070,10 @@ func (a *ApiRequestService) ProcessFLXG0V4BRequest(params []byte) ([]byte, error
return nil, errors.New("api请求, FLXG0V4B, 获取相关参数失败") 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{}{ resp, err := a.tianyuanapi.CallInterface("FLXG0V4B", map[string]interface{}{
"name": name.String(), "name": name.String(),
"id_card": idCard.String(), "id_card": idCard.String(),
"auth_date": authDate(), "auth_date": generateAuthDateRange(),
}, &tianyuanapi.ApiCallOptions{ }, &tianyuanapi.ApiCallOptions{
Json: true, Json: true,
}) })