This commit is contained in:
2026-07-18 11:49:51 +08:00
parent 0f32d5d79a
commit ff21ec785f
4 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
package yysy
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/haiyuapi"
)
// ProcessYYSYS98ARequest YYSYS98A API处理方法 - 移动手机号易诉分(转发海宇 YYSYS7Y1
func ProcessYYSYS98ARequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.YYSYS98AReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
reqParams := map[string]interface{}{
"mobile_no": paramsDto.MobileNo,
}
if paramsDto.Name != "" {
reqParams["name"] = paramsDto.Name
}
if paramsDto.IDCard != "" {
reqParams["id_card"] = paramsDto.IDCard
}
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "YYSYS7Y1", reqParams)
if err != nil {
if errors.Is(err, haiyuapi.ErrNotFound) {
return nil, errors.Join(processors.ErrNotFound, err)
}
if errors.Is(err, haiyuapi.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
}
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}