@@ -61,23 +61,23 @@ type APIResponseData struct {
func ( a * ApiRequestService ) ProcessRequests ( params [ ] byte , productID string ) ( [ ] byte , error ) {
func ( a * ApiRequestService ) ProcessRequests ( params [ ] byte , productID string ) ( [ ] byte , error ) {
var ctx , cancel = context . WithCancel ( context . Background ( ) )
var ctx , cancel = context . WithCancel ( context . Background ( ) )
defer cancel ( )
defer cancel ( )
build := a . productFeatureModel . SelectBuilder ( ) . Where ( squirrel . Eq {
build := a . productFeatureModel . SelectBuilder ( ) . Where ( squirrel . Eq {
"product_id" : productID ,
"product_id" : productID ,
} )
} )
productFeatureList , findProductFeatureErr := a . productFeatureModel . FindAll ( ctx , build , "" )
productFeatureList , findProductFeatureErr := a . productFeatureModel . FindAll ( ctx , build , "" )
if findProductFeatureErr != nil {
if findProductFeatureErr != nil {
return nil , findProductFeatureErr
return nil , findProductFeatureErr
}
}
var featureIDs [ ] string
var featureIDs [ ] string
isImportantMap := make ( map [ string ] int64 , len ( productFeatureList ) )
isImportantMap := make ( map [ string ] int64 , len ( productFeatureList ) )
for _ , pf := range productFeatureList {
for _ , pf := range productFeatureList {
featureIDs = append ( featureIDs , pf . FeatureId )
featureIDs = append ( featureIDs , pf . FeatureId )
isImportantMap [ pf . FeatureId ] = pf . IsImportant
isImportantMap [ pf . FeatureId ] = pf . IsImportant
}
}
if len ( featureIDs ) == 0 {
if len ( featureIDs ) == 0 {
return nil , errors . New ( "featureIDs 是空的" )
return nil , errors . New ( "featureIDs 是空的" )
}
}
builder := a . featureModel . SelectBuilder ( ) . Where ( squirrel . Eq { "id" : featureIDs } )
builder := a . featureModel . SelectBuilder ( ) . Where ( squirrel . Eq { "id" : featureIDs } )
featureList , findFeatureErr := a . featureModel . FindAll ( ctx , builder , "" )
featureList , findFeatureErr := a . featureModel . FindAll ( ctx , builder , "" )
if findFeatureErr != nil {
if findFeatureErr != nil {
return nil , findFeatureErr
return nil , findFeatureErr
@@ -114,7 +114,7 @@ func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]
preprocessErr error
preprocessErr error
)
)
// 若 isImportantMap[feature.ID] == 1, 则表示需要在出错时重试
// 若 isImportantMap[feature.ID] == 1, 则表示需要在出错时重试
isImportant := isImportantMap [ feature . Id ] == 1
isImportant := isImportantMap [ feature . Id ] == 1
tryCount := 0
tryCount := 0
for {
for {
tryCount ++
tryCount ++
@@ -207,6 +207,7 @@ var requestProcessors = map[string]func(*ApiRequestService, []byte) ([]byte, err
"IVYZ8I9J" : ( * ApiRequestService ) . ProcessIVYZ8I9JRequest ,
"IVYZ8I9J" : ( * ApiRequestService ) . ProcessIVYZ8I9JRequest ,
"JRZQ7F1A" : ( * ApiRequestService ) . ProcessJRZQ7F1ARequest ,
"JRZQ7F1A" : ( * ApiRequestService ) . ProcessJRZQ7F1ARequest ,
"IVYZ3P9M" : ( * ApiRequestService ) . ProcessIVYZ3P9MRequest ,
"IVYZ3P9M" : ( * ApiRequestService ) . ProcessIVYZ3P9MRequest ,
"JRZQ6F2A" : ( * ApiRequestService ) . ProcessJRZQ6F2ARequest ,
}
}
// PreprocessRequestApi 调用指定的请求处理函数
// PreprocessRequestApi 调用指定的请求处理函数
@@ -1577,3 +1578,26 @@ func (a *ApiRequestService) ProcessIVYZ3P9MRequest(params []byte) ([]byte, error
return convertTianyuanResponse ( resp )
return convertTianyuanResponse ( resp )
}
}
// ProcessJRZQ6F2ARequest 借贷申请
func ( a * ApiRequestService ) ProcessJRZQ6F2ARequest ( params [ ] byte ) ( [ ] byte , 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请求, JRZQ6F2A, 获取相关参数失败" )
}
resp , err := a . tianyuanapi . CallInterface ( "JRZQ6F2A" , map [ string ] interface { } {
"id_card" : idCard . String ( ) ,
"name" : name . String ( ) ,
"mobile_no" : mobile . String ( ) ,
} )
if err != nil {
return nil , err
}
return convertTianyuanResponse ( resp )
}