123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- // Copyright 2019 gentensh.com. All rights reserved.
- // Use of this source code is governed by gentensh.com.
- package vehicle
- import (
- "context"
- "gd_vehicle/apis"
- gutils "gd_vehicle/common.in/utils"
- "gd_vehicle/errors"
- "gd_vehicle/impl/thirdparty_impl"
- "gd_vehicle/utils"
- dutils "gd_vehicle/utils"
- //"strings"
- )
- // 所有人验证组
- func ownerVerifyGroup(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply, reqData map[string]interface{}, respData map[string]interface{}, providerMap map[string]apis.MerchantProviderLimitInfo, group []string, rangeNo int)error {
- plateNo := dutils.GetStringParams(reqData,"plate_no")
- plateType := dutils.GetStringParams(reqData,"plate_type")
- owner := dutils.GetStringParams(reqData,"owner")
- for _, v := range group {
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- ProviderApiCode: v,
- ProviderMap: providerMap,
- RangeNo: rangeNo,
- Req: req,
- Reply: reply,
- }
- switch v {
- case utils.ADMV01:
- tReq.Params = map[string]interface{}{
- "owner": owner,
- "plate_no": plateNo,
- "plate_type":plateType,
- }
- err := thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- /*case utils.ZRTWOELEMENTVERIFY:
- if !strings.HasPrefix(plateNo,"粤"){
- continue
- }
- tReq.Params = map[string]string{
- "name": owner,
- "plateNo": plateNo,
- "plateType":plateType,
- }
- ret, err := thirdparty_impl.CallThirdparty(tReq)
- if err != nil {
- continue
- }
- respData["is_match"] = ret
- return nil*/
- case utils.ZRTWOELEMENTVERIFYNATIONAL:
- tReq.Params = map[string]interface{}{
- "name": owner,
- "plateNum": plateNo,
- //"plateColor":plateType,
- }
- err := thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- }
- }
- return errors.NoRecord
- }
- // 身份验证组
- func identityVerifyGroup(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply, reqData map[string]interface{}, respData map[string]interface{}, providerMap map[string]apis.MerchantProviderLimitInfo, group []string, rangeNo int) error {
- owner := dutils.GetStringParams(reqData,"owner")
- idCard := dutils.GetStringParams(reqData,"id_card")
- var err error
- for _, v := range group {
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- ProviderApiCode: v,
- ProviderMap: providerMap,
- RangeNo: rangeNo,
- Req: req,
- Reply: reply,
- }
- switch v {
- case utils.ADMV02:
- tReq.Params = map[string]interface{}{
- "name": owner,
- "id_card": idCard,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- /*case utils.DYTWOELEMENTVERIFY:
- tReq.Params = map[string]string{
- "name": owner,
- "id_card": idCard,
- }
- ret, err = thirdparty_impl.CallThirdparty(tReq)
- if err != nil {
- continue
- }
- return nil*/
- default:
- continue
- }
- }
- return errors.NoRecord
- }
- // 所有人身份三要素核验
- /*func threeElemetVerifyGroup(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply, reqData map[string]interface{}, respData map[string]string, providerMap map[string]apis.MerchantProviderLimitInfo, group []string, rangeNo int) error {
- owner := dutils.GetStringParams(reqData,"owner")
- idCard := dutils.GetStringParams(reqData,"id_card")
- plateNo := dutils.GetStringParams(reqData,"plate_no")
- ret := ""
- var err error
- for _, v := range group {
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- ProviderApiCode: v,
- ProviderMap: providerMap,
- RangeNo: rangeNo,
- Req: req,
- Reply: reply,
- }
- switch v {
- case utils.CDBDTWOELEMENTVERIFY:
- sf, plateNum := gutils.ParsePlate(plateNo)
- if sf != "川"{
- continue
- }
- tReq.Params = map[string]string{
- "plate_num": plateNum,
- "id_card": idCard,
- "owner": owner,
- }
- ret, err = thirdparty_impl.CallThirdparty(tReq)
- if err != nil {
- continue
- }
- cdbd.GetCdbdTwoElementVerifyData(ret,respData)
- if respData["is_match"] == "-1"{
- return nil
- }
- default:
- continue
- }
- }
- return errors.NoRecord
- }
- */
- // 车牌查车档组
- func vehicleInfoByPlateGroup(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply, reqData map[string]interface{}, respData map[string]interface{}, providerMap map[string]apis.MerchantProviderLimitInfo, group []string, rangeNo int) error {
- plateNo := dutils.GetStringParams(reqData,"plate_no")
- plateType := dutils.GetStringParams(reqData,"plate_type")
- if plateNo == "" || plateType == ""{
- return errors.ArgsError
- }
- var err error
- for _, v := range group {
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- ProviderApiCode: v,
- ProviderMap: providerMap,
- RangeNo: rangeNo,
- Req: req,
- Reply: reply,
- }
- switch v {
- // 车牌查车辆信息
- case utils.ADMA04:
- tReq.Params = map[string]interface{}{
- "plate_no": plateNo,
- "plate_type":plateType,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- // 检查发动机号是否存在
- _, err := thirdparty_impl.CheckProviderApiIsAvaliable(utils.LOCALENGINENO, tReq.ProviderMap,rangeNo)
- if err == nil {
- engineNo := respData["engine_no"]
- if engineNo != ""{
- return nil
- }
- }else{
- return nil
- }
- // 车牌查vin
- case utils.ADMA01:
- tReq.Params = map[string]interface{}{
- "plate_no": plateNo,
- "plate_type":plateType,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- // 车牌查车辆信息
- case utils.ZRVEHICLEINFO:
- tReq.Params = map[string]interface{}{
- "plateNumber": plateNo,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- // 车牌查vin
- case utils.ZRVEHICLEVIN:
- tReq.Params = map[string]interface{}{
- "vinOrPlateNumber": plateNo,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- case utils.ZRVEHICLEFIVE:
- tReq.Params = map[string]interface{}{
- "vinOrPlateNumber": plateNo,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- return nil
- default:
- continue
- }
- }
- return errors.NoRecord
- }
- // vin查车档组
- func vehicleInfoByVinGroup(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply, reqData map[string]interface{}, respData map[string]interface{}, providerMap map[string]apis.MerchantProviderLimitInfo, group []string, rangeNo int) error {
- vin := dutils.GetStringParams(reqData,"vin")
- if vin == "" {
- vin = dutils.GetStringParams(respData,"vin")
- }
- if vin == "" {
- return errors.ArgsError
- }
- var err error
- for _, v := range group {
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- ProviderApiCode: v,
- ProviderMap: providerMap,
- RangeNo: rangeNo,
- Req: req,
- Reply: reply,
- }
- switch v {
- // vin查车辆信息
- case utils.ADMA05:
- tReq.Params = map[string]interface{}{
- "vin": vin,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- plateNo := gutils.GetInterfaceString(respData,"plate_no")
- if plateNo == ""{
- continue
- }
- _, err := thirdparty_impl.CheckProviderApiIsAvaliable(utils.LOCALENGINENO, tReq.ProviderMap, rangeNo)
- if err == nil {
- engineNo := gutils.GetInterfaceString(respData,"engine_no")
- if engineNo != ""{
- return nil
- }
- }else{
- return nil
- }
- // vin 查车牌
- case utils.ADMA02:
- tReq.Params = map[string]interface{}{
- "vin": vin,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- plateNo := gutils.GetInterfaceString(respData,"plate_no")
- if plateNo != ""{
- return nil
- }
- case utils.ZRVININFO:
- tReq.Params = map[string]interface{}{
- "vin": vin,
- }
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- continue
- }
- default:
- continue
- }
- }
- return errors.NoRecord
- }
- func getIsMatch(respData map[string]interface{}) string {
- return gutils.GetInterfaceString(respData,"is_match")
- return "0"
- }
- func group(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
- reqData := req.Data.(map[string]interface{})
- respData := reply.Data.(map[string]interface{})
- defer func() {
- reply.Data = respData
- }()
- var err error
- //reply.Data = respData
- for groupNum, group := range req.ProviderGroup {
- rangeNo := groupNum + 1
- for _, v := range group {
- switch v {
- // 人车核验组
- case utils.ADMV01:
- if getIsMatch(respData) == "-1"{
- continue
- }
- err = ownerVerifyGroup(ctx,req,reply,reqData,respData,req.ProviderMap,group,rangeNo)
- if err != nil{
- return errors.NoRecord
- }
- // 人身核验组
- case utils.ADMV02:
- if getIsMatch(respData) == "-1"{
- continue
- }
- err = identityVerifyGroup(ctx,req,reply,reqData,respData,req.ProviderMap,group,rangeNo)
- if err != nil {
- return errors.NoRecord
- }
- // 车牌查车辆信息组
- case utils.ADMA01,utils.ADMA04:
- if req.NeedVehicleInfo || getIsMatch(respData) == "1"{
- err = vehicleInfoByPlateGroup(ctx,req,reply,reqData,respData,req.ProviderMap,group,rangeNo)
- if err != nil {
- return errors.NoRecord
- }
- }
- // vin查车辆信息组
- case utils.ADMA02,utils.ADMA05:
- if req.NeedVehicleInfo || getIsMatch(respData) == "1"{
- err = vehicleInfoByVinGroup(ctx,req,reply,reqData,respData,req.ProviderMap,group,rangeNo)
- if err != nil {
- return errors.NoRecord
- }
- }
- }
- }
- }
- return nil
- }
|