// 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 }