123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- // Copyright 2019 gentensh.com. All rights reserved.
- // Use of this source code is governed by gentensh.com.
- package vehicle
- import (
- "context"
- "gd_vehicle/apis"
- "gd_vehicle/consts"
- "gd_vehicle/errors"
- "gd_vehicle/impl/thirdparty_impl"
- dutils "gd_vehicle/utils"
- "math/rand"
- )
- // 二要素验证,返回车档
- func V002(ctx context.Context, req *apis.CommonReq, reply *apis.CommonReply) error {
- rData := req.Data.(map[string]interface{})
- plateNo := dutils.GetStringParams(rData,"plate_no")
- plateType := dutils.GetStringParams(rData,"plate_type")
- owner := dutils.GetStringParams(rData,"owner")
- respData := make(map[string]interface{})
- reply.Data = respData
- tReq := &apis.ThirdpartRequest{
- Ctx: ctx,
- Params: map[string]interface{}{
- "plate_no": plateNo,
- "plate_type": plateType,
- "owner": owner,
- },
- ProviderApiCode: dutils.ADMA04,
- ProviderMap: req.ProviderMap,
- RangeNo: consts.RANGEONE,
- Req: req,
- Reply: reply,
- }
- if !req.IsForceUpdate{
- tReq.Params["merchant_tag"] = "1"
- }
- err := thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- return errors.NoRecord
- }
- tReq.ProviderApiCode = dutils.ADMV01
- err = thirdparty_impl.CallThirdparty(tReq,respData)
- if err != nil {
- if req.IsForceUpdate{
- return errors.NoRecord
- }else{
- if err == errors.NoRecordCannotConfirm{
- return errors.NoRecord
- }else if err == errors.NoRecord{
- // 大于3个字的认为是公司名,查无表示公司名已通过校验
- if len(owner) > 9 {
- respData["is_match"] = "1"
- }else {
- return errors.NoRecord
- }
- } else {
- return errors.NoRecord
- }
- }
- }else{
- if req.RandomPercentage > 0 {
- randInt := rand.Intn(100)
- if randInt <= req.RandomPercentage{
- return errors.NoRecord
- }
- }
- }
- return nil
- }
|