<?php
/**
  * @method 宜配VIN解码
  * @author soul
  * @copyright 2017/9/30
  */
class YpcVin extends YpcBase
{
	private $vinBase = null;
	//解码次数，泽达的需要二次解码
	private $decodeCount = 1;
	private $fullMatchEpc = null;
	//600w精准找到
	private $fullMatchFrom = null;
	private $fullMatchFromType = null;
	//600w相邻匹配到的车架号
	private $xiangLinFromAny = null;
	private $vinYearFrom = '';
	private $resType = null;
	private $fanChaArr = [
			'getYpcModelByRcVin'=>[
				'table'=>'temp_nissan_vin',
				'wmi'=>'vin1_8',
			], 
			'getYpcModelByRoeweVin'=>[
				'table'=>'temp_roewe_vin',
				'wmi'=>'vin1_8'
			],
			'getYpcModelByQrVin'=>[
				'table'=>'temp_qirui',
				'wmi'=>'tq_vin_8bit',
			],
			'getYpcModelByWlVin'=>[
				'table'=>'temp_wuling',
				'wmi'=>'tq_vin_8bit',
			],
			'getYpcModelByChanganVin'=>[
				'table'=>'temp_changan',
				'wmi'=>'vin1_8',
			],
			'getYpcModelByChanganSuzukiVin'=>[
				'table'=>'temp_changansuzuki',
				'wmi'=>'lnk_vin_8bit',
			],
			'getYpcModelByBorgwardVin'=>[
				'table'=>'temp_borgward',
				'wmi'=>'lnk_vin_18'
			],
			'getYpcModelByBjevVin'=>[
				'table'=>'temp_bjev',
				'wmi'=>'lnk_vin_18'
			],
			'getYpcModelByCALMVin'=>[
				'table'=>'da_catch_vin_7',
				'wmi'=>'dcv_vin1_8',
			],
			'getYpcModelByBsjVin'=>[
				'table'=>'temp_porsche',
				'wmi'=>'lnk_vin_8bit',
			],
			'getYpcModelByVolvoVin'=>[
				'table'=>'temp_volvo',
				'wmi'=>'lnk_vin_8bit',
			],
			'getYpcModelByToyotaVin'=>[
				'table'=>'toyota_app_series',
				'wmi'=>'ser_col_3',
			],
			'getYpcModelByVwVin'=>[
				'table'=>'vw_catch',
				'wmi'=>'cat_18'
			],
			'getYpcModelBySanlingVin'=>[
				'table'=>'temp_mitsubishi',
				'wmi'=>'lnk_vin_8bit'
			],
			'getYpcModelByHyundaiVin'=>[
				'table'=>'temp_hyundai',
				'wmi'=>'lnk_vin_8bit'
			],
			'getYpcModelByMzdVin'=>[
				'table'=>'temp_mazda_epc',
				'wmi'=>'vin1_8'
			],
			'getYpcModelBySubaruVin'=>[
				'table'=>'temp_subaru',
				'wmi'=>'vin1_8'
			],
			'getYpcModelByChrysler'=>[
				'table'=>'temp_chrysler',
				'wmi'=>'VIN_CHAR8'
			],
			'getYpcModelByBenz'=>[
				'table'=>'temp_mercedes',
				'wmi'=>'vin1_8'
			],
			'getYpcModelByFordVin'=>[
				'table'=>'temp_ford_1',
				'wmi'=>'lnk_vin1_8'
			],
			'getYpcModelByCitroenVin'=>[
				'table'=>'temp_citroen',
				'wmi'=>'lnk_vin_8bit'
			],
			'getYpcModelByBmwVin'=>[
				'table'=>'temp_bmw_catch',
				'wmi'=>'cat_18'
			],
			'getYpcModelByLandroverVin'=>[
				'table'=>'temp_landrover',
				'wmi'=>'lnk_vin_18'
			],
			'getYpcModelByJacVin'=>[
				'table'=>'temp_jac_web',
				'wmi'=>'lnk_vin_18'
			],
			'getYpcModelByAny'=>[
				'table'=>'stand_model_any',
				'wmi'=>null,
			]
		];

		public $isZdcofArr = [
			'LSGJA52U'=>'89ABC', 'LSGJA52P'=>'89', 'LSGJA52H'=>'DEFG', 'LSGJR82U'=>'8', 'LSGBC534'=>'GH', 'LSGJB842'=>'D', 'LSGJB84J'=>'EFGH', 'LSGKE52H'=>'FGH', 'LSGKE54H'=>'GH', 'LSGPB54U'=>'ABCDEF', 'LSGPB64U'=>'ABCDEF', 'LSGTB54M '=>'9AB', 'LSGTC54M'=>'9', 'LSGTC52M'=>'678', 'LSGTB54U'=>'9AB', 'LSGTC54U'=>'9', 'LSGTC52U'=>'678', 'LSGHD82H'=>'GH', 'LSGTB62M'=>'8', 'LSGTB64M'=>'9', 'LSGTC62M'=>'678', 'LSGTB62U'=>'8', 'LSGTB64U'=>'9A', 'LSGJM82J'=>'FGH', 'LSGVA54R'=>'ABCDF', 'LSGVU52Z'=>'78', 'LSGVU54Z'=>'89', 'LSGVV52Z'=>'78', 'LSGVV54Z'=>'89', 'LSGJL52M'=>'CDEF', 'LSGJL54M'=>'CDEF', 'LSGJL62M'=>'CDEF', 'LSGJL64M'=>'CDEF', 'LSGJL54U'=>'CDE', 'LSGJL64U'=>'CDE', 'LSGKB52H'=>'H', 'LSGBL544'=>'H', 'LSGBL644'=>'H', 'LSGPC52H'=>'FG', 'LSGPC52U'=>'9ACDE', 'LSGPC64U'=>'EFGH', 'LSGPC62U'=>'FG', 'LSGBE543'=>'F', 'LSGBE544'=>'FG', 'LSGSA52S'=>'ABCDE', 'LSGSA52M'=>'ABCDE', 'LSGSA62S'=>'ABCDE', 'LSGSA62M'=>'ABCDE', 'LSGHD528'=>'FGH', 'LSGHD54H'=>'F', 'LSGSJ52N'=>'567', 'LSGSJ82N'=>'568', 'LSGGG54E'=>'CDEF', 'LSGZG535'=>'H'
		];

		public $audiReArr = ['FA'=>'4E','FB'=>'4F','FC'=>'4G','FD'=>'4H','FE'=>'4L','FF'=>'8V','FG'=>'42','FH'=>'8F','FK'=>'8J','FL'=>'8K','FM'=>'8P','FP'=>'8R','FR'=>'8T','FS'=>'8U','FV'=>'8S'];
	

	
	/**
	  * @method 重新整理的 解码总入口  ypc, bigcar, oem, gxb, eur, usa, wmi
	  * @param  $vin  17位车架号
	  * @param  $resType 默认空返回所有车型解码数据   m3ids:只返回车型ID
	  * @author soul
	  * @copyright 2020/7/23
	  * @return 
		返回的label均不固定

		ypc:LFV3A28W2K3759614  LL66HAB04HB121003
		{"status":true,"data":{"from":"ypc","ads_make":"奥迪","model":[{"make_show_brand":"0","brand_id":"6","brand_name":"奥迪","make_name":"一汽奥迪","mod1_name":"A4L","mod2_name":"A4L(868,B9)","brand_etk_id":"10","mod3_id":"17026","mod3_name":"40 TFSI 进取型 国VI 19款","mod3_start_year":"2018","mod3_end_year":"2020","mod3_engine":"DKUA","mod3_kw":"140","mod3_cc":"1984","mod3_cc_name":"2.0T","mod3_transmission":"7DCT","mod3_fuel":"汽油","mod3_body":"4门5座三厢车","mod3_front_brake":"通风盘式","mod3_rear_brake":"盘式","mod3_parking_brake":"电子驻车","mod3_drive":"前置前驱","vin_year":"2019-05-09","vin_year_style":"buid","vin_year_name":"制造日期"}]},"code":0,"runtime":89}

		vinbase: LNTGE68R2XVA00280
		{"status":true,"data":{"from":"vinbase","model":[{"品牌":"依维柯","整车型号":"A3010XJJ","尺寸(mm)":"4850*2000*2490"}],"label":["品牌","整车型号","尺寸(mm)"],"ads_make":"依维柯"},"code":0,"runtime":153}

		bigcar: 调用getCartInfo($mod_id) 显示具体车型信息   
				app 第一行信息 mod_name + sma_year
				app 第二行信息优先级(空格间开，溢出...) sma_engine>sma_kw>sma_cc>mod_tran>mod_drive>size>sma_vtype

		LS4A272P3DG001529
		{"status":true,"data":{"from":"bigcar","model":[{"mod_id":"8072@280456","mod_make":"长安牌","mod_name":"长安神童 幼儿专用校车 (SC6515XAG4)","mod_code":"SC6515XAG4","sma_engine":"JM491Q-ME","mod_tran":"MT","size":"5145*1975*2410","mod_drive":"后轮驱动"}],"label":{"mod_make":"品牌","mod_name":"车型","mod_code":"整车型号","sma_engine":"发动机","mod_tran":"变速箱","size":"尺寸(mm)","mod_drive":"驱动方式"},"ads_make":"长安牌"},"code":0,"runtime":164}

		LZZ1CLXB0HA180574
	    {"status":true,"data":{"from":"bigcar","model":[{"mod_id":"9268","mod_make":"中国重汽","mod_name":"中国重汽 HOWO-T7H重卡 440马力 6×4牵引车(ZZ4257V324HD1B)","mod_code":"ZZ4257V324HD1B"},{"mod_id":"9763","mod_make":"中国重汽","mod_name":"中国重汽 HOWO-T7H重卡 540马力6×4 牵引车(ZZ4257V324HD1B)","mod_code":"ZZ4257V324HD1B"},{"mod_id":"11974","mod_make":"中国重汽","mod_name":"中国重汽 HOWO-T7H 重卡440马力 6X4 牵引车 ZZ4257V324HD1B","mod_code":"ZZ4257V324HD1B"},{"mod_id":"13610","mod_make":"中国重汽","mod_name":"中国重汽 HOWO-T7H重卡 540马力 6×4牵引车(ZZ4257W324HE1B)","mod_code":"ZZ4257W324HE1B"}],"label":{"mod_make":"品牌","mod_name":"车型","mod_code":"整车型号"},"ads_make":"中国重汽"},"code":0,"runtime":139}



		oem:WBADT61000CE53527
		{"status":true,"data":{"from":"oem","oem":"bmw","model":[{"品牌":"宝马","车系":" 5' E39","车型":" 530I","年份":"1995-2003","发动机":" M54","功率":" 170kW","驱动":" 后驱","转向":" 左方向盘","车身":" 三厢轿车","区域":" 欧洲"}],"label":["品牌","车系","车型","年份","发动机","功率","驱动","转向","车身","区域"],"ads_make":"BMW","year":0},"code":0,"runtime":142}

		gxb:LM6AFABF0KX602898
		{"status":true,"data":{"from":"gxb","model":[{"品牌":"金杯","车系":"小海狮X30","车型":"2019款 1.5L 厢货标准型国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"小海狮X30","车型":"2019款 1.5L 厢货舒适型国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"小海狮X30","车型":"2019款 1.5L 标准型国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"小海狮X30","车型":"2019款 1.5L 舒适型国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.5L厢货商务版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.5L厢货财富版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L厢货商务版国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L厢货财富版国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L商务版六座国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L商务版国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L财富版六座国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮S","车型":"2019款 1.6L财富版国VI SWD16M","前制动器":"盘式","发动机":"SWD16M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1599","功率(kW)":"85","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮X30L","车型":"2019款 1.5L厢货商务版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮X30L","车型":"2019款 1.5L厢货财富版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮X30L","车型":"2019款 1.5L商务版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"},{"品牌":"金杯","车系":"海狮X30L","车型":"2019款 1.5L财富版国VI SWC15M","前制动器":"盘式","发动机":"SWC15M","变速箱":"5挡手动","后制动器":"鼓式","排量(mL)":"1451","功率(kW)":"75","燃料":"汽油","驱动":"中置后驱"}],"label":["品牌","车系","车型","发动机","排量(mL)","功率(kW)","燃料","变速箱","驱动","前制动器","后制动器","驻车制动"],"ads_make":"金杯","year":2019},"code":0,"runtime":648}

		eur:1FALP53S3VA220419 欧洲
		{"status":true,"data":{"from":"eur","model":[{"品牌":"Ford","车系":"Taurus","车型":"DP Ghia +LT &amp; CD Sedan 4dr Auto 4sp 3.0i","车型年":"1997","座位":"5\n\t","驱动方式":"Front Wheel Drive\n\t","燃料":"Petrol - Unleaded ULP\n\t","进气方式":"Aspirated\n\t","缸数":"6\n\t","发动机":"2967\n\t"},{"品牌":"Ford","车系":"Taurus","车型":"DP Ghia Sedan 4dr Auto 4sp 3.0i","车型年":"1997","座位":"5\n\t","驱动方式":"Front Wheel Drive\n\t","燃料":"Petrol - Unleaded ULP\n\t","进气方式":"Aspirated\n\t","缸数":"6\n\t","发动机":"2967\n\t"}],"label":["品牌","车系","车型","车型年","发动机","缸数","燃料","驱动方式","进气方式","座位"],"ads_make":"Ford","year":1997},"code":0,"runtime":142}

	    usa:137PH84346E221044 北美
		{"status":true,"data":{"from":"usa","model":[{"品牌":"悍马","车型":"H1 ALPHA HMCS","年份":"2006"}],"label":["品牌","车型","年份"],"ads_make":"悍马","year":2006},"code":0,"runtime":128}
		
		wmi:1AMHATEDEC0009018
		{"status":true,"data":{"from":"wmi","model":[{"品牌":"AMERICAN MOTOR"},{"品牌":"AMC"}],"label":["品牌"],"ads_make":"AMERICAN MOTOR","year":2012},"code":0,"runtime":126}
	  */
	public function decodeVin($vin, $resType = '', $othcfg = [])
	{
		$this->resType = $resType;

		//校验VIN
		$vin = LibFc::FormatVin($vin);
		$vin1 = substr($vin, 0, 1);
		if(strlen($vin) != 17) return LibFc::ReturnData(false, '车架号【'.$vin.'】错误，请检查', 'VIN_ERR');
		$isJinkou = !in_array($vin1, ['L', 'H'])? true: false;
		if(!$isJinkou)
		{
			$v9Arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'X'];
			if(!in_array(substr($vin, 8, 1), $v9Arr))
				return LibFc::ReturnData(false, '车架号【'.$vin.'】第9位错误，不能为字母（X除外），请检查', 'VIN9_ERR');
			$check = LibFc::VinCheckCode($vin);
			if(!$check['ok'])
				return LibFc::ReturnData(false, '车架号【'.$vin.'】错误，不能通过校验，请检查', 'VIN_ERR');
		}
		//车架号截位和年份
		$this->vinBase = [
			'vin'=>$vin,
			'wmi'=>substr($vin, 0, 3),
			'v1_8'=>substr($vin, 0, 8),
			'v10'=>substr($vin, 9, 1),
			'v11'=>substr($vin, 10, 1),
			'v12'=>substr($vin, 11, 1),
			'v10_11'=>substr($vin, 9, 2),
			'v12_17'=>substr($vin, 11, 6),
			'v10_12'=>substr($vin, 9, 3),
			'v13_17'=>substr($vin, 12, 5),
			'year'=>LibFc::VinYear(substr($vin, 9, 1)),
			'isJinkou'=>$isJinkou,
			'base'=>[],
			'decodeBy'=>'',
			'decodeM3Ids'=>[]
		];

		$YpwVin = new YpwVin();
		$lvd_params = $_REQUEST;
		unset($lvd_params['image']);
		$lvd_from = $_REQUEST['from']? $_REQUEST['from']: '';
		if(!$lvd_from && $othcfg['from']) $lvd_from = $othcfg['from'];
		
		$lvd_shop_id = $_REQUEST['shop_id']? (int) $_REQUEST['shop_id']: 0;
		if(!$lvd_shop_id && mvc::$cfg['RQTOKEN']['uid']) $lvd_shop_id = mvc::$cfg['RQTOKEN']['uid'];
		if(!$lvd_shop_id && $othcfg['shop_id']) $lvd_shop_id = $othcfg['shop_id'];

		/*$collArr = [
			'lvd_vin'=>$vin,
			'lvd_byuid'=>$_REQUEST['uid']? (int) $_REQUEST['uid']: 0,
			'lvd_shop_id'=>$lvd_shop_id,
			'lvd_ip'=>$_REQUEST['ip']? $_REQUEST['ip']: LibFc::GetClientIp(),
			'lvd_token_name'=>mvc::$cfg['RQTOKEN']['comname'],
			'lvd_from'=>$lvd_from,
			'lvd_time'=>date('Y-m-d H:i:s'),
			'lvd_params'=>json_encode($lvd_params, JSON_UNESCAPED_UNICODE),
		];
		$YpwVin->add('log_vin_decode', $collArr);*/

		
		$res = $this->getVinBaseInfo($vin);
		$this->vinBase['base'] = $res['data'];
		$this->fullMatchEpc = null;
		$this->fullMatchFrom = null;
		$this->fullMatchFromType = null;
		$this->xiangLinFromAny = null;

		//600万表解码或者原厂解码  反查
		$res = $this->getFanChaWmi();
		$wmiArr = $res['data'];
		foreach($this->fanChaArr as $funName=>$val)
		{
			//600万表解码或者原厂解码
			if($funName == 'getYpcModelByAny' || (!empty($wmiArr[$funName]) && stripos($wmiArr[$funName], $this->vinBase['v1_8']) !== false) || ($funName == 'getYpcModelByToyotaVin' && in_array($this->vinBase['wmi'], ['LFM', 'LVG']) && $this->vinBase['year'] >= 2020))
			{
				$fcRes = $this->$funName($vin);
				if(!empty($fcRes['data']))
				{
					$this->vinBase['decodeBy'] = 'ypc:epc_'.$funName;
					$this->vinBase['decodeM3Ids'] = $fcRes['data'];
					break;
				}
			}
		}
		
		
		$YpcModel = new YpcModel();
		
		//商用车，样本数据有发动机，如果不符，直接不解析
		if($this->vinBase['base']['mod3_engine'] && !empty($this->vinBase['decodeM3Ids'])){
			$res = $YpcModel->getModel(3, ['m3_id,m2_cv,m3_engine'], sprintf(" and m3_id in (%s)", implode(',', $this->vinBase['decodeM3Ids'])));
			$formateng = LibFc::FormatNum($this->vinBase['base']['mod3_engine']);
			$this->vinBase['decodeM3Ids'] = [];
			foreach($res['data'] as $v){
				$engs = [];
				foreach(explode(';', $v['m3_engine']) as $e){
					$engs[] = LibFc::FormatNum($e);
				}
				if($v['m2_cv'] && !in_array($formateng, $engs)){
				}else{
					$this->vinBase['decodeM3Ids'][] = $v['m3_id'];
				}
			}
		}
	
		//无法解析车型，进行大车解码
		if(empty($this->vinBase['decodeM3Ids']))
		{
			//卡车之家数据
			$res = $this->decodeKczj();
			if(!empty($res['data']['model'])) return $res;
			
			//进口解码，有前8则不进行大车解码
			$bigCarFlag = null;
			if($this->vinBase['isJinkou'])
			{
				//找到的型号是否为平行进口
				$allTmodArr = [];
				if(!empty($this->fullMatchFrom)) $allTmodArr = array_column($this->fullMatchFrom, null, 'sma_vin');
				else if(!empty($this->xiangLinFromAny)) $allTmodArr = array_column($this->xiangLinFromAny, null, 'sma_vin');
				$YpwBase = new YpwBase();
				$ispxjk = [];
				foreach($allTmodArr as $row)
				{
					if(!empty($row['sma_brand']) && !empty($row['sma_gxb_code']))
					{
						$res = $YpwBase->get('stand_gxb_v8info', ['sgv_ispxjk'], sprintf(" and sgv_vin1_8='%s' and sgv_gxb_code='%s' and sgv_org_brand='%s'", $this->vinBase['v1_8'], LibFc::FormatNum($row['sma_gxb_code']), LibFc::Escape($row['sma_brand'])), true);
						if(!empty($res['data'])) $ispxjk[] = $res['data']['sgv_ispxjk'];
					}
				}
				$ispxjk = array_unique($ispxjk);
				if(count($ispxjk) == 1 && $ispxjk[0] == 1) $bigCarFlag = 1;
				
				if($bigCarFlag === null)
				{
					$res = $this->get('yp_vin_model3_link JOIN yp_vin ON vin_id = vm3_vin_id', ['vm3_m3_id'], sprintf(" and vin_full = '%s' limit 1", $this->vinBase['v1_8']));
					if(!empty($res['data'])) $bigCarFlag = false;
				}
			}else{
				$bigCarFlag = 1;
			}
			
			if($bigCarFlag === null || $bigCarFlag === 1)
			{
				$res = $this->decodeBigCar();
				if(!empty($res['data']['model']))
				{
					if($this->decodeCount === 1)
					{
						//多型号判断搜集
						$ares = $this->setVinImgAnyGxb($vin);
						//泽达有数据，第二次解码
						if($ares['data']['iszd'] === 1)  return $this->redecodeVin($vin);
					}
					
					if($this->resType == 'm3ids')
					{
						return LibFc::ReturnData(true, ['from'=>'', 'model'=>[]]);
					}
					else
					{	
						return $res;
					}
				}
			}
		}
	
		//国产能精准找到车架号的相关信息 终止宜配车型解码 2020/7/21  LSCABN2E1LE823019
		if(!empty($this->fullMatchFrom) && in_array($vin1, ['L', 'H']))
		{}
		else if(empty($this->vinBase['decodeM3Ids']))
		{
			//普通模式匹配 前8位
			//2022/4/9 样本量已经足够大，不再使用此规则
			$res = $this->get('yp_vin_model3_link JOIN yp_vin ON vin_id = vm3_vin_id', ['distinct vm3_m3_id as m3_id'], sprintf(" and vin_full = '%s'", $this->vinBase['v1_8']));
			if(empty($res['data']))
			{
				//奔驰数字特殊处理 WDD140033EA392475
				if(LibFc::Int(substr($vin, 3, 6)) !== false)
				{
					$MCode = substr($vin, 3, 3).'.'.substr($vin, 6, 3);
					$table = 'yp_model3 JOIN yp_vin_model3_link ON vm3_m3_id = m3_id JOIN yp_vin ON vin_id = vm3_vin_id';
					$res = $this->get($table, ['DISTINCT m3_id'], sprintf(" and vin_m_id IN (1,22,149) and m3_mcode = '%s'", LibFc::Escape($MCode)));
					if(!empty($res['data']))
					{
						//奔驰车型扩展底盘代码，第10位只有1,2，分别表示左驱动或者右驱动的
						$this->vinBase['year'] = 0;
					}
				}
			}
			$this->vinBase['decodeBy'] = 'ypc:vin8';
			$this->vinBase['decodeM3Ids'] = array_column($res['data'], 'm3_id');
		}

		if(!empty($this->vinBase['decodeM3Ids']) && $othcfg['gxbcode']){
			$res = $YpcModel->get('yp_model3_gxb_num', ['distinct mg_m3_id'], sprintf(" and mg_m3_id in (%s) and mg_code='%s'", implode(',', $this->vinBase['decodeM3Ids']), LibFc::FormatNum($othcfg['gxbcode'])));
			if($res['data']){
				$this->vinBase['decodeM3Ids'] = array_column($res['data'], 'mg_m3_id');
			}
		}

		//继续过滤
		if(!empty($this->vinBase['decodeM3Ids']))
		{
			$ypcVinArr = [];
			$filedArr = ['m3_id,b_id,m_id,m2_id,m2_start_year,m2_end_year,m3_start_year,m3_start_month,m3_end_year,m3_end_month,m3_vin10,m3_vin11,m3_vin11_ext,m3_vin12,m3_vin12_ext,m3_vin13,m3_vin13_ext,m3_evin'];
			$res = $YpcModel->getModel(3, $filedArr, sprintf(" and m3_id in (%s)", implode(',', $this->vinBase['decodeM3Ids'])));
			foreach($res['data'] as $v)
			{
				//二级车型年份限制三级年份
				$v['start_year'] = $v['m3_start_year'] > $v['m2_start_year']? $v['m3_start_year']: $v['m2_start_year'];
				$v['end_year'] = $v['m3_end_year'] < $v['m2_end_year'] || ($v['m2_end_year'] < 1 && $v['m3_end_year'] > 0) ? $v['m3_end_year']: $v['m2_end_year'];
				$ypcVinArr[$v['m3_id']] = $v;
			}
			//统一处理11位、12位
			$VExtW = [10, 11, 12, 13];
			if(!empty($ypcVinArr))
			{
				$TempArr = $ypcVinArr;
				foreach($TempArr as $K=>$V)
				{
					foreach($VExtW as $W)
					{
						if($V['m3_vin'.$W] != '' && stripos($V['m3_vin'.$W], substr($vin, $W-1, 1)) === false )
						{
							unset($TempArr[$K]);
							break;
						}
					}
				}
				if(!empty($TempArr)) $ypcVinArr = $TempArr;
				
				$VExtW = [11, 12, 13];
				//11位、12位扩展关联
				$TempArr = $ypcVinArr;
				foreach($TempArr as $K=>$V)
				{
					foreach($VExtW as $W)
					{
						$WVin = substr($vin, $W-1, 1);
						if($V['m3_vin'.$W] == '' ||
							$V['m3_vin'.$W.'_ext'] == '' ||
							stripos($WVin.':', $V['m3_vin'.$W.'_ext']) === false ||
							stripos(';'.$WVin.':', $V['m3_vin'.$W.'_ext']) === false
						)
						continue;

						//0:10:456;1:10:6789
						$VExtArr = explode(';', $V['m3_vin'.$W.'_ext']);
						$VGet = false;
						foreach($VExtArr as $VExt)
						{
							$VTArr = explode(':', $VExt);
							if(stripos($WVin, $VTArr[0]) !== false && stripos(substr($vin, $VTArr[1]-1, 1), $VTArr[2]) !== false)
							{
								$VGet = true;
							}
						}
						//12位不在扩展值里
						if(!$VGet)
						{
							unset($TempArr[$K]);
							break;
						}
					}
				}
				if(!empty($TempArr)) $ypcVinArr = $TempArr;
			}
			
			//VIN流水号  12~17
			if(count($ypcVinArr) > 1)
			{
				$lastYpcVinArr = $ypcVinArr;
				foreach($ypcVinArr as $m3Id=>$mv)
				{
					if(!empty($mv['m3_evin'])){
						$tt = explode('-', $mv['m3_evin']);
						if(count($tt) == 2 && strlen($tt[0]) == 6 && strlen($tt[1]) == 6 && ($this->vinBase['v12_17'] < $tt[0] || $this->vinBase['v12_17'] > $tt[1]))
						{
							unset($ypcVinArr[$m3Id]);
						}
					}
				}
				if(empty($ypcVinArr)) $ypcVinArr = $lastYpcVinArr;
			}

			//soul 2019/11/26 大于1条的情况下，通过工信部型号过滤  LVGDC46A0DG478722
			if(count($ypcVinArr) > 1)
			{
				$lastYpcVinArr = $ypcVinArr;
				$m3GxbArr = [];
				$res = $this->get('yp_model3_gxb_num', ['mg_m3_id', 'mg_code'], sprintf(" and mg_m3_id in (%s)", implode(',', array_keys($ypcVinArr))));
				foreach($res['data'] as $v)
				{
					$m3GxbArr[$v['mg_m3_id']][] = $v['mg_code'];
				}
				$gxbArr = [];
				$YpwBase = new YpwBase();
				if($this->fullMatchFrom === null)
				{
					$smaTables = ['stand_model_any', 'stand_model_any_ocr'];
					foreach($smaTables as $table)
					{
						$res = $YpwBase->Get($table, ['sma_gxb_code'], sprintf(" and sma_vin='%s'", $vin), true);
						if(!empty($res['data']))
						{
							$gxbArr[] = $res['data']['sma_gxb_code'];
							break;
						}
					}
				}
				else if(is_array($this->fullMatchFrom) && !empty($this->fullMatchFrom[0]['sma_gxb_code']))
				{
					$gxbArr[] = $this->fullMatchFrom[0]['sma_gxb_code'];
				}
				
				//相邻的
				if(empty($gxbArr))
				{
					if($this->xiangLinFromAny === null)
					{
						$this->getAnyXinanglinVin($vin);
					}
					
					if(is_array($this->xiangLinFromAny))
					{
						foreach($this->xiangLinFromAny as $v)
						{
							if(!empty($v['sma_gxb_code'])) $gxbArr[] = $v['sma_gxb_code'];
						}
					}
				}

				$gxbArr = array_unique($gxbArr);
				foreach($ypcVinArr as $m3Id=>$mv)
				{
					$t = empty($m3GxbArr[$m3Id])? []: array_intersect($m3GxbArr[$m3Id], $gxbArr);
					if(empty($t)) unset($ypcVinArr[$m3Id]);
				}
				if(empty($ypcVinArr)) $ypcVinArr = $lastYpcVinArr;
			}

			//年月过滤
			if(count($ypcVinArr) > 1)
			{
				$lastYpcVinArr = $ypcVinArr;
				$res = $this->filterBuildDate($ypcVinArr, [$this->vinBase['base']['vin_year']]);
				if(count($res['data']) == count($ypcVinArr))
				{
					$ypcVinArr = $this->filterYear($ypcVinArr, $this->vinBase['year']);
				}
				else
				{
					$ypcVinArr = $res['data'];
				}
				if(empty($ypcVinArr)) $ypcVinArr = $lastYpcVinArr;
			}
			$this->vinBase['decodeM3Ids'] = array_keys($ypcVinArr);
		}
	
		
		//一汽大众奥迪 销售类型 2022/11/6  合并到VW
		/*$funName = 'getYpcModelByVwVin';
		if(count($this->vinBase['decodeM3Ids']) > 1 && !empty($wmiArr[$funName]) && stripos($wmiArr[$funName], $this->vinBase['v1_8']) !== false)
		{
			$lastM3IdArr = $this->vinBase['decodeM3Ids'];
			$res = $this->get('vw_catch', ['distinct cat_modcode'], sprintf(" and cat_vin='%s' and cat_modcode != ''", $vin));
			if(!empty($res['data']))
			{
				$res = $this->get('yp_model3', ['distinct m3_id'], sprintf(" AND m3_mcode in ('%s')", implode("','", array_column($res['data'], 'cat_modcode'))));
				if(!empty($res['data']))
				{
					$tm3IdArr = array_column($res['data'], 'm3_id');
					$same = array_intersect($this->vinBase['decodeM3Ids'], $tm3IdArr);
					if(!empty($same)) $this->vinBase['decodeM3Ids'] = $same;
				}
			}
			//过滤为空时回滚操作
			if(empty($this->vinBase['decodeM3Ids'])) $this->vinBase['decodeM3Ids'] = $lastM3IdArr;
		}*/
		
		//精准找到，并且有变速箱，过滤手动自动 如 大通LSFAM11A0HA058338
		if(count($this->vinBase['decodeM3Ids']) > 1 && !empty($this->fullMatchFrom[0]['sma_tran']))
		{
			$lastM3IdArr = $this->vinBase['decodeM3Ids'];
			$tran = $this->getShortTran($this->fullMatchFrom[0]['sma_tran']);
			$res = $this->get('yp_model3', ['m3_id, m3_transmission'], sprintf(" AND m3_id IN (%s) and m3_transmission != ''", implode(',', $this->vinBase['decodeM3Ids'])));	
			$outIdArr = [];
			
			foreach($res['data'] as $vt)
			{
				$vt['m3_transmission'] = $this->getShortTran($vt['m3_transmission']);
				if($vt['m3_transmission'] !== $tran) $outIdArr[] = $vt['m3_id'];
			}
			if(!empty($outIdArr)) $this->vinBase['decodeM3Ids'] = array_diff($this->vinBase['decodeM3Ids'], $outIdArr);
			//过滤为空时回滚操作
			if(empty($this->vinBase['decodeM3Ids'])) $this->vinBase['decodeM3Ids'] = $lastM3IdArr;
		}
		
		$passenger = 0;
		if(!empty($this->vinBase['base']['passenger'])){
			$passenger = (int) $this->vinBase['base']['passenger'];
		}else if(!empty($this->fullMatchFrom[0]['sma_passenger']) && preg_match('/^[1-9]\d*$/', $this->fullMatchFrom[0]['sma_passenger'])){
			$passenger = (int) $this->fullMatchFrom[0]['sma_passenger'];
		}else if(!empty($this->xiangLinFromAny[0]['sma_passenger'])){
			$vals = array_unique(array_column($this->xiangLinFromAny, 'sma_passenger'));
			if(count($vals) == 1 && !empty($vals[0])) $passenger = (int) $vals[0];
		}
		unset($this->vinBase['base']['passenger']);

		//精准找到，并且有座位数 LVUDB21B0LB380421
		if(count($this->vinBase['decodeM3Ids']) > 1 && $passenger > 0)
		{
			$lastM3IdArr = $this->vinBase['decodeM3Ids'];
			$res = $this->get('yp_model3', ['m3_id, m3_body'], sprintf(" AND m3_id IN (%s) and m3_body != ''", implode(',', $this->vinBase['decodeM3Ids'])));	
			$outIdArr = [];
			foreach($res['data'] as $vt)
			{
				//人数范围
				$valArr = [];
				if(preg_match('/([1-9]\d*)[\-\,\/]([1-9]\d*)座/', $vt['m3_body'], $match))
				{
					for($i = $match[1]; $i <= $match[2]; $i++)
					{
						$valArr[] = $i;
					}
				}
				else if(preg_match('/([1-9]\d*)座/', $vt['m3_body'], $match))
				{
					$valArr[] =  $match[1];
				}
				if(!empty($valArr) && !in_array($passenger, $valArr)) $outIdArr[] = $vt['m3_id'];
			}
			if(!empty($outIdArr)) $this->vinBase['decodeM3Ids'] = array_diff($this->vinBase['decodeM3Ids'], $outIdArr);
			//过滤为空时回滚操作
			if(empty($this->vinBase['decodeM3Ids'])) $this->vinBase['decodeM3Ids'] = $lastM3IdArr;
		}

		//多型号判断搜集
		if($this->decodeCount === 1 && !empty($this->vinBase['decodeM3Ids']) && count($this->vinBase['decodeM3Ids']) > 1) 
		{
			$ares = $this->setVinImgAnyGxb($vin);
			//泽达有数据，第二次解码
			if($ares['data']['iszd'] === 1)  return $this->redecodeVin($vin);
		}

		if($this->resType == 'm3ids') return LibFc::ReturnData(true, ['from'=>'ypc', 'model'=>$this->vinBase['decodeM3Ids']]);
		//车型信息
		if(!empty($this->vinBase['decodeM3Ids']))
		{
			//车型大于30条直接不出解码
			if(count($this->vinBase['decodeM3Ids']) > 30) return LibFc::ReturnData(true, ['from'=>'', 'brand_id'=>0, 'modtype'=>'', 'brand_name'=>'', 'model'=>[]]);

			//返回车型信息
			$Ypc2Model = new Ypc2Model();
			$filed = ['make_show_brand', 'brand_id', 'brand_code', 'brand_name',' make_id', 'make_name', 'mod1_id', 'mod1_name', 'mod2_id', 'mod2_name', 'mod2_pc', 'mod2_cv', 'brand_etk_id', 'mod3_id, mod3_name, mod3_start_year, mod3_end_year, mod3_engine, mod3_kw, mod3_cc, mod3_cc_name, mod3_transmission, mod3_fuel, mod3_body, mod3_front_brake, mod3_rear_brake, mod3_parking_brake, mod3_start_stop, mod3_drive, mod3_chassis, mod3_imgs as pic'];
			$where = sprintf(" and mod3_id in (%s) order by brand_name, make_name, mod2_name, mod3_name, mod3_start_year", implode(",", $this->vinBase['decodeM3Ids']));
			$modRes = $Ypc2Model->getModel(3, $filed, $where);
			$modArr = [];
			$brandName = '';
			$modType = '';

			//多个发动机的，将基本信息返回的发动机置空  2023/11/3 取消 LHGFE3661P2097884
			if(!empty($this->vinBase['base']['mod3_engine']))
			{
				$engs = [];
				foreach($modRes['data'] as $v){
					foreach(explode(';', $v['mod3_engine']) as $tv){
						if(!empty($tv)) $engs[] = $tv;
					}
				}
				$engs = array_unique($engs);
				if(count($engs) > 1 && !in_array($this->vinBase['base']['mod3_engine'], $engs))
					unset($this->vinBase['base']['mod3_engine']);
			}
			foreach($modRes['data'] as $v)
			{
				if(empty($modType)) $modType = $v['mod2_cv']? 'cv': 'pc';
				$res = $this->getYpcModelVinImg($v['mod3_id'], $vin);
				$v['pic'] = $res['data'];
				foreach($this->vinBase['base'] as $kk=>$vv)
				{
					if($kk == 'mod3_engine'){
						if(stripos($v['mod3_engine'], ';')){//LHGFE3661P2097884
							if(in_array($vv, explode(';', $v['mod3_engine']))){
							}else{
								continue;
							}
						}else if(stripos($v['mod3_engine'], $vv) === 0){//发动机包含不替换
							continue;
						}
					}
					if($kk == 'param'){
						foreach($vv as $kkk=>$vvv){
							if(in_array($vvv[2], ["size", "wheel", "weight"])) unset($vv[$kkk]);
						}
						$vv = array_values($vv);
					}
					$v[$kk] = $vv;
				}
				if(!empty($v['paifang']) && !empty($v['mod3_engine'])) $v['mod3_engine'] .= ' ('.$v['paifang'].')';
				
				//L6T7944Z7FN007707
				if(!empty($this->fullMatchFrom[0]['sma_cc']) && $this->fullMatchFrom[0]['sma_cc'] != $v['mod3_cc']) $v['mod3_cc'] = $this->fullMatchFrom[0]['sma_cc'];
				//W1NFB5HE6NA604048  5门5座SUV 7座   WAURGB4H5BN010332 4门4-5座三厢车
				if(!empty($v['mod3_body']) && $passenger > 0 && stripos($v['mod3_body'], '门'.$passenger.'座') === false)
				{
					if(preg_match('/(\d*[\-\,\/]?\d+)座/', $v['mod3_body'], $match)){
						$v['mod3_body'] = str_replace($match[0], $passenger.'座', $v['mod3_body']);
					}else{
						$v['mod3_body'] = preg_replace('/门.+座/', '门'.$passenger.'座', $v['mod3_body']);
					}
				}
				$modArr[] = $v;
			}
			return LibFc::ReturnData(true, ['from'=>'ypc', 'brand_id'=>$modArr[0]['brand_id'], 'modtype'=>$modType, 'brand_name'=>$modArr[0]['brand_name'], 'model'=>$modArr]);
		}
		
		if($this->decodeCount === 1)
		{
			$ares = $this->setVinImgAnyGxb($vin);
			//泽达有数据，第二次解码
			if($ares['data']['iszd'] === 1)  return $this->redecodeVin($vin);
		}
		
		//无法解析到具体车型
		//oem
		$res = $this->decodeByOem($vin);
		if(!empty($res['data']['model'])) return $res;

		//gxb
		$res = $this->decodeByGxbWord($vin);
		if(!empty($res['data']['model'])) return $res;
		
		//欧洲 北美 wmi
		$res = $this->decodeByOBW($vin);
		if(!empty($res['data']['model'])) return $res;

		//无法解码
		return LibFc::ReturnData(true, ['from'=>'', 'brand_id'=>0, 'modtype'=>'', 'brand_name'=>'', 'model'=>[]]);
	}
	
	//泽达有数据，第二次解码	
	private function redecodeVin($vin)
	{	
		$this->vinBase = null;
		$this->fullMatchEpc = null;
		$this->fullMatchFrom = null;
		$this->fullMatchFromType = null;
		$this->xiangLinFromAny = null;
		$this->decodeCount++;
		return $this->decodeVin($vin, $this->resType);
	}


	/**
	  * @method 获取反查的wmi
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> ] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getFanChaWmi($cache = true)
	{
		set_time_limit(0);
		$arr = [];
		$file = mvc::$cfg['AUTOLOAD']['Ypc']['path'].'cache/facha_vin8.php';
		
		if(!file_exists($file) || !$cache || (filemtime($file) < (time()-3600*15) && date('H') >= 5 && date('H') <= 7))
		{
			$lockFile = mvc::$cfg['AUTOLOAD']['Ypc']['path'].'cache/getFanChaWmiLock.txt';
			//被锁超过2分钟自动解锁
			if(file_exists($lockFile) && (time() - filemtime($lockFile)) < 3600)
			{
				return LibFc::ReturnData(true, $arr);
			}
			file_put_contents($lockFile, 'lock');
			foreach($this->fanChaArr as $funName=>$val)
			{
				if(empty($val['wmi'])) continue;
				$where  = '';
				if($val['table'] == 'stand_model_any')
				{
					$YpwBase = new YpwBase();
					$res = $YpwBase->Get($val['table'], ['distinct '.$val['wmi'].' as wmi'], $where);
				}
				else
				{
					$res = $this->get($val['table'], ['distinct '.$val['wmi'].' as wmi'], $where);
				}
				$arr[$funName] = implode(',', array_column($res['data'], 'wmi'));
			}
			if(is_array($arr)) LibFc::ArraySave($arr, $file);
			@unlink($lockFile);
		}
		else
		{//括起来为了防止读取文件失败
			$arr = include($file);
		}
		return LibFc::ReturnData(true, $arr);
	}

	
	/**
	  * @method 通过VIN解码查出对应的宜配车型ID
	  * @param  $vin  17位车架号
	  * @param  $makeNo  string [选填] 整车型号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> ] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function decodeVinMod3Id($vin)
	{
		$res = $this->decodeVin($vin, 'm3ids');
		$ypcVinArr = [];
		if($res['data']['from'] == 'ypc' && !empty($res['data']['model']))
		{
			$YpcModel = new YpcModel();
			$m3Res = $YpcModel->getModel3Vin(['*'], sprintf(" and m3_id in (%s)", implode(',', $res['data']['model'])));
			foreach($m3Res['data'] as $K=>$V)
			{
				//二级车型年份限制三级年份
				$V['start_year'] = $V['m3_start_year'] > $V['m2_start_year']? $V['m3_start_year']: $V['m2_start_year'];
				$V['end_year'] = $V['m3_end_year'] < $V['m2_end_year'] || ($V['m2_end_year'] < 1 && $V['m3_end_year'] > 0) ? $V['m3_end_year']: $V['m2_end_year'];

				$V['make_name'] = $V['m_name'];
				$MIdArr[$V['m_id']] = $V['m_id'];
				$ypcVinArr[$V['m3_id']] = $V;
			}
		}
		return LibFc::ReturnData(true, ['model'=>$ypcVinArr, 'year'=>$Year]);
	}


	/**
	  * @method 通过日产的VIN反查宜配车型ID  LGBK22E78AY571994
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByRcVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		$vin10 = LibFc::Escape(substr($vin, 9, 1));
		$vin11 = LibFc::Escape(substr($vin, 10, 1));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			//EPC精准
			$twhere = sprintf(" and gv_6 != '' and vin1_8='%s' and vin10_11='%s'", $vin1_8, $vin10_11);
			$where = $twhere.sprintf(" and vin_12_17='%s'", $vin12_17);
			$res = $this->get('temp_nissan_vin', ['gv_6'], $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$codeArr = array_column($res['data'], 'gv_6');
			if(!empty($codeArr))
			{
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $codeArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
			
			//采集数据精准
			if(!empty($M3IdArr))
			{
				$Where  = sprintf(" and nas_vin_8bit = '%s' and nas_vin_10bit='%s' and nas_vin_11bit='%s' and nas_vin_127bit='%s'", $vin1_8, $vin10, $vin11, $vin12_17);
				$res = $this->get('temp_nassian', ['nas_model'], $Where);
				if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
				$TempVinArr = $res['data'];
				if(!empty($TempVinArr))
				{
					$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", array_column($TempVinArr, 'nas_model'))));
					$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
				}
			}
			//工信部600万精准查找
			if(empty($M3IdArr))
			{
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
			}
			
			//EPC找相邻
			if(empty($M3IdArr))
			{
				$vinMinArr = [];
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];

				//忽略第九位找相邻一两条
				$twhere = sprintf(" and gv_6 != '' and vin1_8='%s' and vin10_11='%s'", $vin1_8, $vin10_11);
				$res = $this->get('temp_nissan_vin', ['gv_6', 'vin_12_17 as vin_end'], $twhere.sprintf(" AND vin_12_17 <='%s'  ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_nissan_vin', ['gv_6', 'vin_12_17 as vin_end'], $twhere.sprintf(" AND vin_12_17 >'%s'  ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$codeArr = array_column($res['data']['my'], 'gv_6');

				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
				if(!empty($codeArr))
				{
					$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $codeArr)));
					$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
				}

				//采集相邻
				if(empty($M3IdArr))
				{
					$vinMinArr['my'] = [];
					//忽略第九位找相邻一两条
					$twhere  = sprintf(" and nas_vin_8bit = '%s' and nas_vin_10bit='%s' and nas_vin_11bit='%s'", $vin1_8, $vin10, $vin11);
					$res = $this->get('temp_nassian', ['nas_model', 'nas_vin_127bit as vin_end'], $twhere.sprintf(" AND nas_vin_127bit <='%s'  ORDER BY nas_vin_127bit DESC LIMIT 1", $vin12_17), true);
					$vinMinArr['my']['X'] = $res['data'];
					$res = $this->get('temp_nassian',['nas_model', 'nas_vin_127bit as vin_end'], $twhere.sprintf(" AND nas_vin_127bit >'%s'  ORDER BY nas_vin_127bit ASC LIMIT 1", $vin12_17), true);
					$vinMinArr['my']['S'] = $res['data'];

					$res = $this->filterXinanglinVin($vin, $vinMinArr);
					$TempVinArr = $res['data']['my'];
					$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
					$M3IdArr = $res['data'];
					
					if(!empty($TempVinArr))
					{
						$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", array_column($TempVinArr, 'nas_model'))));
						$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
					}
				}
			}
			
			$M3IdArr = array_unique($M3IdArr);
			if(!empty($M3IdArr))
			{
				$Where = sprintf(" AND vm3_m3_id IN (%s) AND vin_full='%s'", implode(',', $M3IdArr), LibFc::Escape(substr($vin, 0, 8)));
				$m3Res = $this->getFieldUniVal('yp_vin_model3_link JOIN yp_vin ON vm3_vin_id = vin_id', 'vm3_m3_id', $Where);
				$M3IdArr = $m3Res['data'];
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 通过奇瑞的VIN反查宜配车型ID  LVVDC24B0CD078975
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByQrVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10 = LibFc::Escape(substr($vin, 9, 1));
		$vin11 = LibFc::Escape(substr($vin, 10, 1));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$twhere = sprintf(" and tq_status =1 and tq_vin_8bit='%s' and tq_vin_10bit='%s' and tq_vin_11bit='%s'", $vin1_8, $vin10, $vin11);

			$where = $twhere.sprintf(" and tq_real_vin11_17='%s'", $vin12_17);
			$FiledArr = ['tq_real_vin', 'tq_engine', 'tq_make', 'tq_model', 'tq_model_code', 'tq_time', 'tq_real_vin11_17 as vin_end'];
			$res = $this->get('temp_qirui', $FiledArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
			
				//找相邻
				$vinMinArr = [];
				
				//忽略第九位找相邻一两条
				$res = $this->get('temp_qirui', $FiledArr, $twhere.sprintf(" AND tq_real_vin11_17 <='%s'  ORDER BY tq_real_vin11_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_qirui', $FiledArr, $twhere.sprintf(" AND tq_real_vin11_17 >'%s'  ORDER BY tq_real_vin11_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}

			//通过型号
			foreach($TempVinArr as $V)
			{
				$where = sprintf(" AND m3_etkchina = '%s'", LibFc::Escape($V['tq_model_code']) );
				$res = $this->get('yp_model3', ['m3_id', 'm3_engine', 'm3_start_year', 'm3_start_month', 'm3_end_year', 'm3_end_month'], $where);
				$temp = [];
				foreach($res['data'] as $VV)
				{
					if(stripos($V['tq_engine'], $VV['m3_engine']) !== false)
					{
						$temp[$VV['m3_id']] = $VV;
					}
				}

				//年
				if(count($temp) > 1 && !empty($V['tq_time']))
				{
					$year = date('Y', strtotime($V['tq_time']));
					$yearm = date('Ym', strtotime($V['tq_time']));
					$where = sprintf(" and m3_id in (%s) and (m3_start_year = 0 or m3_start_year <= %d)  and ( m3_end_year = 0 OR m3_end_year >= %d)", implode(',', array_keys($temp)), $year,  $year);
					$res = $this->get('yp_model3', ['m3_id'], $where);
					$temp = array_column($res['data'], null, 'm3_id');
				}
				
				//年月
				if(count($temp) > 1 && !empty($V['tq_time']))
				{
					$year = date('Y', strtotime($V['tq_time']));
					$yearm = date('Ym', strtotime($V['tq_time']));
					$where = sprintf(" and m3_id in (%s) and (
						m3_start_year = 0 or (m3_start_month ='' and m3_start_year > 1949 and m3_start_year <= %d) or (m3_start_month !='' and m3_start_year > 1949 and concat(m3_start_year, m3_start_month) <= %d)
					) and (
					 m3_end_year = 0 OR (m3_end_month ='' and m3_end_year > 1949 and m3_end_year >= %d) or (m3_end_month !='' and m3_end_year > 1949 and concat(m3_end_year, m3_end_month) >= %d)
					)", implode(',', array_keys($temp)), $year, $yearm, $year, $yearm);
					$res = $this->get('yp_model3', ['m3_id'], $where);
					if(!empty($res['data'])) $temp = array_column($res['data'], null, 'm3_id');
				}
				$M3IdArr = array_merge($M3IdArr, array_keys($temp));
			}
			$M3IdArr = array_unique($M3IdArr);
			if(!empty($M3IdArr))
			{
				$Where = sprintf(" AND vm3_m3_id IN (%s) AND vin_vin3 = '%s' AND vin_match='%s'", implode(',', $M3IdArr), substr($vin, 0, 3), substr($vin, 3, 5));
				$m3Res = $this->getFieldUniVal('yp_vin_model3_link JOIN yp_vin ON vm3_vin_id = vin_id', 'vm3_m3_id', $Where);
				$M3IdArr = $m3Res['data'];
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}

	


	/**
	  * @method 通过五菱的VIN反查宜配车型ID  LZWACAGA061054236
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByWlVin($vin)
	{
		$M3IdArr = [];
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$vin1_8 = substr($vin, 0, 8);
			$TempWhere = sprintf(" AND varieties_0_vehiclecode != '' AND varieties_0_catalogcode != '' AND tq_vin_8bit = '%s' AND tq_vin_10bit = '%s' AND tq_vin_11bit='%s'", 
				$vin1_8, substr($vin, 9, 1), substr($vin, 10, 1));
			$Where  = sprintf(" %s AND tq_vin_127bit = '%s'", $TempWhere, LibFc::Escape($vin12_17));
			$FiledArr = ['tq_vin_8bit', 'varieties_0_vehiclecode', 'varieties_0_catalogcode', 'varieties_0_modelcode', 'tq_vin_127bit as vin_end'];
			$res = $this->get('temp_wuling', $FiledArr, $Where);
			if(!empty($res['data']))
			{
				$this->fullMatchEpc = $res['data'];
				$TempVinArr = $res['data'];
			}
			else
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
			}
			if(empty($TempVinArr))
			{
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$res = $this->get('temp_wuling', $FiledArr, $TempWhere.sprintf(" AND tq_vin_127bit <='%s'  ORDER BY tq_vin_127bit DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_wuling', $FiledArr, $TempWhere.sprintf(" AND tq_vin_127bit >'%s'  ORDER BY tq_vin_127bit ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}

			//通过品牌
			$modCodeArr = [];
			foreach($TempVinArr as $V)
			{
				if(!empty($V['varieties_0_modelcode']))
					$modCodeArr[] = $V['varieties_0_modelcode'];
				$res = $this->get('yp_model3', ['distinct m3_id'], sprintf(" AND m3_etkchina = '%s' ", LibFc::Escape($V['varieties_0_catalogcode']) ) );
				if(!empty($res['data']))
				{
					$TempM3IdArr = [];
					foreach($res['data'] as $VV)
					{
						$TempM3IdArr[] = $VV['m3_id'];
					}
					$res = $this->get('yp_model3_gxb_num', ['distinct mg_m3_id'], sprintf(" AND mg_m3_id in (%s) AND mg_code = '%s' ", implode(',', $TempM3IdArr), LibFc::Escape($V['varieties_0_vehiclecode']) ) );
					foreach($res['data'] as $VV)
					{
						$M3IdArr[] = $VV['mg_m3_id'];
					}
				}
			}
			$M3IdArr = array_unique($M3IdArr);
			if(!empty($M3IdArr))
			{
				$Where = sprintf(" AND vm3_m3_id IN (%s) AND vin_full='%s'", implode(',', $M3IdArr), LibFc::Escape($vin1_8));
				$m3Res = $this->getFieldUniVal('yp_vin_model3_link JOIN yp_vin ON vm3_vin_id = vin_id', 'vm3_m3_id', $Where);
				$M3IdArr = $m3Res['data'];
			}
			
			//多条车型则通过车型代码继续过滤
			if(count($M3IdArr) > 1 && !empty($modCodeArr))
			{
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_m3_id in (%s) AND mem_code in ('%s') ", implode(',', $M3IdArr), implode("','", $modCodeArr)) );
				if(!empty($res['data']))
				{
					$M3IdArr = array_column($res['data'], 'mem_m3_id');
				}
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}



	/**
	  * @method 通过长安EPC的VIN反查宜配车型ID  LS5A3ADD2BB159766
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByChanganVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_12_17='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['cha_model', 'lnk_extend_code','vin_12_17 as vin_end'];
			$res = $this->get('temp_changan', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//第十位 
				if(!in_array(substr($vin, 9, 1), ['H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Y']))
				{
					return LibFc::ReturnData(true, $M3IdArr);
				}

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and vin1_8='%s' and vin10_11='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_changan', $filedArr, $tempWhere.sprintf(" AND vin_12_17 <='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_changan', $filedArr, $tempWhere.sprintf(" AND vin_12_17 >'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'lnk_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
			$M3IdArr = array_unique($M3IdArr);
			
			//LSCAB22E4KG168033 工信部型号直解 soul 2019/11/19
			if(empty($M3IdArr) && !empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'cha_model');
				$res = $this->get('yp_model3_gxb_num', ['distinct mg_m3_id'], sprintf(" AND mg_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mg_m3_id'));
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 通过长安铃木 EPC的VIN反查宜配车型ID  LS5A3ADD2BB159766
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByChanganSuzukiVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin10 = substr($vin, 9, 1);
		$vin11 = substr($vin, 10, 1);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{5}$/', substr($vin, 12, 5)))
		{
			$where = sprintf(" and lnk_vin_8bit='%s' and lnk_vin_10bit='%s' and lnk_vin_11bit='%s' and lnk_vin_127bit='%s' and modelCode != ''", $vin1_8, $vin10, $vin11, $vin12_17);
			$filedArr = ['modelCode as extend_code', 'right(lnk_vin_127bit, 5) as vin_end'];
			$res = $this->get('temp_changansuzuki', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_8bit='%s' and lnk_vin_10bit='%s' and lnk_vin_11bit='%s' and modelCode != ''", $vin1_8, $vin10, $vin11);
				$res = $this->get('temp_changansuzuki', $filedArr, $tempWhere.sprintf(" AND lnk_vin_127bit <='%s' ORDER BY lnk_vin_127bit DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_changansuzuki', $filedArr, $tempWhere.sprintf(" AND lnk_vin_127bit >'%s' ORDER BY lnk_vin_127bit ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}

	



	/**
	  * @method 通过长安铃木的VIN反查宜配车型ID  LS5A3ADD2BB159766
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByCALMVin($vin)
	{
		$M3IdArr = [];
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$TempWhere = sprintf(" AND dcv_vin1_8 = '%s' AND dcv_vin10_11='%s'", LibFc::Escape(substr($vin, 0, 8)), LibFc::Escape(substr($vin, 9, 2)));
			$Where  = sprintf(" %s AND dcv_vin12_17 = '%s'", $TempWhere, LibFc::Escape($vin12_17));
			$FiledArr = ['dcv_gxb', 'dcv_vin12_17 as vin_end'];
			$res = $this->get('da_catch_vin_7', $FiledArr, $Where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$res = $this->get('da_catch_vin_7', $FiledArr, $TempWhere.sprintf(" AND dcv_vin12_17 <='%s'  ORDER BY dcv_vin12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('da_catch_vin_7', $FiledArr, $TempWhere.sprintf(" AND dcv_vin12_17 >'%s'  ORDER BY dcv_vin12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			if(!empty($TempVinArr))
			{
				$GxbNumArr = [];
				foreach($TempVinArr as $V)
				{
					$GxbNumArr[] = sprintf("'%s'", LibFc::Escape($V['dcv_gxb']));
				}
				$res = $this->get('yp_model3_gxb_num', ['distinct mg_m3_id'], sprintf(" AND mg_code in (%s) ", implode(',', $GxbNumArr)));
				foreach($res['data'] as $VV)
				{
					$M3IdArr[] = $VV['mg_m3_id'];
				}
			}
			$M3IdArr = array_unique($M3IdArr);
			if(!empty($M3IdArr))
			{
				$Where = sprintf(" AND vm3_m3_id IN (%s) AND vin_full='%s'", implode(',', $M3IdArr), LibFc::Escape(substr($vin, 0, 8)));
				$m3Res = $this->getFieldUniVal('yp_vin_model3_link JOIN yp_vin ON vm3_vin_id = vin_id', 'vm3_m3_id', $Where);
				$M3IdArr = $m3Res['data'];
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 通过保时捷的VIN反查宜配车型ID  1-8 101112 xxxxx
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByBsjVin($vin)
	{
		$M3IdArr = [];
		$vin13_17 = substr($vin, 12, 5);
		if(preg_match('/^\d{5}$/', $vin13_17))
		{
			$Where  = sprintf(" AND lnk_vin LIKE '%s_%s'", LibFc::Escape(substr($vin, 0, 8)), LibFc::Escape(substr($vin, 9, 8)));
			$FiledArr = ['param_sales_type', 'param_engine_code', 'param_front_and_back_bridge_logo as bsx', 'lnk_vin_137bit as vin_end'];
			$res = $this->get('temp_porsche', $FiledArr, $Where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$Where  = sprintf(" AND lnk_vin LIKE '%s_%s%%'", LibFc::Escape(substr($vin, 0, 8)), LibFc::Escape(substr($vin, 9, 3)));
				$res = $this->get('temp_porsche', $FiledArr, $Where.sprintf(" AND lnk_vin_137bit <='%s'  ORDER BY lnk_vin_137bit DESC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_porsche', $FiledArr, $Where.sprintf(" AND lnk_vin_137bit >'%s'  ORDER BY lnk_vin_137bit ASC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = [];
				foreach($TempVinArr as $V)
				{
					//987120@9721@6S 970850@CWFA 970850@CWF  
					$code = $V['param_sales_type'].'@'.$V['param_engine_code'].'@'.$V['bsx'];
					$mcArr[0][$code] = sprintf("'%s'", LibFc::Escape($code));
					$code = $V['param_sales_type'].'@'.$V['param_engine_code'];
					$mcArr[1][$code] = sprintf("'%s'", LibFc::Escape($code));
					if(strlen($V['param_engine_code']) == 4 && !preg_match('/^\d+$/', $V['param_engine_code']))
					{
						$code = $V['param_sales_type'].'@'.substr($V['param_engine_code'], 0, 3);
						$mcArr[2][$code] = sprintf("'%s'", LibFc::Escape($code));
					}
				}
				
				foreach($mcArr as $tarr)
				{
					$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in (%s) ", implode(',', $tarr)));
					if(!empty($res['data']))
					{
						foreach($res['data'] as $VV)
						{
							$M3IdArr[] = $VV['mem_m3_id'];
						}
						break;
					}
				}
			}
			$M3IdArr = array_unique($M3IdArr);
			if(!empty($M3IdArr))
			{
				$Where = sprintf(" AND vm3_m3_id IN (%s) AND vin_full='%s'", implode(',', $M3IdArr), LibFc::Escape(substr($vin, 0, 8)));
				$m3Res = $this->getFieldUniVal('yp_vin_model3_link JOIN yp_vin ON vm3_vin_id = vin_id', 'vm3_m3_id', $Where);
				$M3IdArr = $m3Res['data'];
			}
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 通过沃尔沃的VIN反查宜配车型ID  LVSHEFAC1AF904845  VIN前8位lnk_vin_8bit 年份param_year 销售类型param_sales_no  【发动机param_engine】
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByVolvoVin($vin)
	{
		$M3IdArr = [];
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$TempWhere = sprintf(" AND lnk_state=2 AND lnk_vin_8bit = '%s' AND dcv_vin10_11='%s'", LibFc::Escape(substr($vin, 0, 8)), LibFc::Escape(substr($vin, 9, 2)));
			$Where  = sprintf(" %s AND dcv_vin12_17 = '%s'", $TempWhere, LibFc::Escape($vin12_17));
			$FiledArr = ['lnk_vin_8bit', 'param_year', 'param_sales_no', 'param_engine', 'dcv_vin12_17 as vin_end'];
			$res = $this->get('temp_volvo', $FiledArr, $Where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$res = $this->get('temp_volvo', $FiledArr, $TempWhere.sprintf(" AND dcv_vin12_17 <='%s' ORDER BY dcv_vin12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_volvo', $FiledArr, $TempWhere.sprintf(" AND dcv_vin12_17 >'%s'  ORDER BY dcv_vin12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			$tM3IdArr = [];
			foreach($TempVinArr as $V)
			{
				$table = 'yp_vin_model3_link 
					JOIN yp_model3 ON vm3_m3_id=m3_id
					JOIN yp_vin ON vm3_vin_id = vin_id
					JOIN yp_model3_modcode ON mem_m3_id=m3_id';
				$twhere = sprintf(" AND vin_full = '%s' and mem_code='%s' and (m3_start_year<=%d or m3_start_year=0) and (m3_end_year >=%d or m3_end_year = 0)",
					LibFc::Escape($V['lnk_vin_8bit']), LibFc::Escape($V['param_sales_no']), $V['param_year'], $V['param_year']);
				$whereArr = [$twhere.sprintf(" and m3_engine='%s'", LibFc::Escape($V['param_engine'])), $twhere];
				foreach($whereArr as $where)
				{
					$res = $this->get($table, ['m3_id', 'm3_evin'], $where.' group by m3_id');
					$allM3IdArr = array_column($res['data'], 'm3_id');
					if(count($allM3IdArr) > 1)
					{
						foreach($res['data'] as $VV)
						{
							$tt = explode('-', $VV['m3_evin']);
							if(count($tt) == 2 && $vin12_17 >= $tt[0] && $vin12_17 <= $tt[1])
							{
								$tM3IdArr[] = $VV['m3_id'];
							}
						}
					}
					if(empty($tM3IdArr)) $tM3IdArr = $allM3IdArr;
					if(!empty($tM3IdArr)) break;
				}
			}
			$M3IdArr = array_unique(array_merge($M3IdArr, $tM3IdArr));
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 通过丰田的VIN反查宜配车型ID   LVGBE40K29G249157
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByToyotaVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$Year = LibFc::VinYear(substr($vin, 9, 1));
			$res = $this->get('toyota_app_series', ['DISTINCT ser_col_4'], sprintf(" and ser_col_3 = '%s'", LibFc::Escape($vin1_8)));
			$TempVinArr = [];
			if(!empty($res['data'])){
				$codeArr = array_column($res['data'], 'ser_col_4');
				
				$TempWhere = sprintf(" AND vin_code in('%s') and vin_app_year=%d and vin_11bit='%s'", implode("','", $codeArr), $Year, LibFc::Escape(substr($vin, 10, 1)));
				$Where  = sprintf(" %s AND vin_127bit = '%s' group by vin_code, vin_app_year, vin_app_month", $TempWhere, LibFc::Escape($vin12_17));
				$FiledArr = ['vin_code', 'vin_app_year', 'vin_app_month', 'vin_127bit as vin_end'];
				$table = 'toyota_app_vins';
				$res = $this->get($table, $FiledArr, $Where);
				if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
				$TempVinArr = $res['data'];
			}
			if(empty($TempVinArr))
			{
				//临时编码库 辅助
				$tepcM3Ids = [];
				if(in_array($this->vinBase['wmi'], ['LFM', 'LVG']) && $this->vinBase['year'] >= 2020){
					$YpwBase = new YpwBase();
					$res = $YpwBase->get('stand_vin_epccode', ['vie_unicode'], sprintf(" and vie_vin='%s'", $vin), true);
					if(!empty($res['data'])){
						$epccode = $res['data']['vie_unicode'];
						$res = $this->get('yp_model3_modcode JOIN yp_vin_model3_link ON vm3_m3_id = mem_m3_id JOIN yp_vin ON vin_id = vm3_vin_id', ['distinct mem_m3_id'], sprintf(" AND vin_full='%s' AND (mem_code='%s' or mem_code like '%s@%%')", $vin1_8, LibFc::Escape($epccode), LibFc::Escape($epccode)));
						if(!empty($res['data'])){
							$tepcM3Ids = array_column($res['data'], 'mem_m3_id');
						}
					}
				}

				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)){
					$M3IdArr = $res['data'];
					if($tepcM3Ids){//结果取交集
						$same = array_intersect($M3IdArr, $tepcM3Ids);
						if($same) $M3IdArr = $same;
					}
					return LibFc::ReturnData(true, $M3IdArr);
				}
				$vinMinArr = [];
				if($TempWhere){
					//忽略第九位找相邻一两条
					$res = $this->get($table, $FiledArr, $TempWhere.sprintf(" AND vin_127bit <='%s' ORDER BY vin_127bit DESC LIMIT 1", $vin12_17), true);
					$vinMinArr['my']['X'] = $res['data'];
					$res = $this->get($table, $FiledArr, $TempWhere.sprintf(" AND vin_127bit >'%s' ORDER BY vin_127bit ASC LIMIT 1", $vin12_17), true);
					$vinMinArr['my']['S'] = $res['data'];
				}else{
					$vinMinArr['my']['X'] = [];
					$vinMinArr['my']['S'] = [];
				}

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
				if($tepcM3Ids){//结果取交集
					$same = array_intersect($M3IdArr, $tepcM3Ids);
					if($same) $M3IdArr = $same;
					return LibFc::ReturnData(true, $M3IdArr);
				}
			}
			
			$tM3IdArr = [];
			if(!empty($TempVinArr))
			{
				$t = [];
				foreach($TempVinArr as $V)
				{
					$t[implode('@', $V)] = $V;
				}
				$allM3Id = [];
				foreach($t as $v)
				{
					$ym = $v['vin_app_year'].sprintf('%02s', $v['vin_app_month']);
					$res = $this->get('yp_model3_modcode', ['mem_m3_id', 'mem_code'], sprintf(" AND mem_code like '%s@%%' ", LibFc::Escape($v['vin_code'])));
					foreach($res['data'] as $vv)
					{
						$allM3Id[] = $vv['mem_m3_id'];
						//GGH20L-PFTQK@06/2010-09/2011, GGH20L-PFTQKV@06/2010-09/2011
						foreach(explode(',', $vv['mem_code']) as $vvv)
						{
							$ttt = explode('@', $vvv);
							$year = explode('-', $ttt[1]);
							//开始年月 06/2010
							$sy = explode('/', $year[0]);
							$sy = $sy[1].sprintf('%02s', $sy[0]);
							if($ym < $sy) continue;
							if(strlen($year[1]) > 6)
							{
								//09/2011
								$ey = explode('/', $year[1]);
								$ey = $ey[1].sprintf('%02s', $ey[0]);
								if($ym > $ey)continue;
							}
							//无准确日期
							if(!in_array($this->vinYearFrom, ['match', 'epc']))
							{
								$this->vinBase['base']['vin_year'] = $v['vin_app_year'].sprintf('-%02s', $v['vin_app_month']);
								$this->vinBase['base']['vin_year_style'] = 'buid';
								$this->vinBase['base']['vin_year_name'] = '制造日期';
								$this->vinYearFrom = 'epc';
							}
							$tM3IdArr[] = $vv['mem_m3_id'];
						}
					}
				}
				$tM3IdArr = empty($tM3IdArr)? $allM3Id: $tM3IdArr;
			}
			$M3IdArr = array_unique(array_merge($M3IdArr, $tM3IdArr));
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过原厂网站的VIN反查宜配车型ID   原厂代码@年份@发动机
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByVwVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$tempWhere = sprintf(" and cat_18='%s' and cat_10='%s' and cat_11='%s' and cat_extend_code != ''",
			LibFc::Escape($vin1_8), LibFc::Escape(substr($vin, 9, 1)), LibFc::Escape(substr($vin, 10, 1)));
			$filedArr = ['cat_extend_code', 'cat_127 as vin_end'];
			$res = $this->get('vw_catch', $filedArr, $tempWhere.sprintf(" and cat_127='%s'", LibFc::Escape($vin12_17)));
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$where = sprintf(" %s AND cat_127 <='%s' && cat_127 >= '%s' ORDER BY cat_127 DESC LIMIT 1", $tempWhere, $vin12_17, sprintf('%06d', $vin12_17-1000));
				$res = $this->get('vw_catch', $filedArr, $where, true);
				$vinMinArr['my']['X'] = $res['data'];

				$where = sprintf(" %s AND cat_127 > '%s' && cat_127 <= '%s' ORDER BY cat_127 asc LIMIT 1", $tempWhere, $vin12_17, sprintf('%06d', $vin12_17+1000));
				$res = $this->get('vw_catch', $filedArr, $where, true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'cat_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}

			//一汽大众奥迪 销售类型
			if(empty($M3IdArr))
			{
				$res = $this->get('vw_catch', ['distinct cat_modcode'], sprintf(" and cat_vin='%s' and cat_modcode != ''", $vin));
				if(!empty($res['data']))
				{
					$res = $this->get('yp_model3', ['distinct m3_id'], sprintf(" AND m3_mcode in ('%s')", implode("','", array_column($res['data'], 'cat_modcode'))));
					if(!empty($res['data']))
					{
						$M3IdArr = array_column($res['data'], 'm3_id');
					}
				}
			}

			if(empty($M3IdArr))
			{
				$tempWhere = sprintf(" and cat_18='%s' and cat_10='%s' and cat_11='%s' and cat_modcode != ''",
				LibFc::Escape($vin1_8), LibFc::Escape(substr($vin, 9, 1)), LibFc::Escape(substr($vin, 10, 1)));
				$filedArr = ['cat_modcode', 'cat_year', 'cat_engine'];
				$res = $this->get('vw_catch', $filedArr, $tempWhere.sprintf(" and cat_127='%s'", LibFc::Escape($vin12_17)));
				$TempVinArr = $res['data'];
				if(empty($TempVinArr))
				{
					//忽略第九位找相邻一两条
					$where = sprintf(" %s AND cat_127 <'%s' && cat_127 >= '%s' ORDER BY cat_127 DESC LIMIT 1", $tempWhere, $vin12_17, sprintf('%06d', $vin12_17-1000));
					$res = $this->get('vw_catch', $filedArr, $where, true);
					$TempVinArr = empty($res['data'])? []: [$res['data']];

					$where = sprintf(" %s AND cat_127 > '%s' && cat_127 <= '%s' ORDER BY cat_127 asc LIMIT 1", $tempWhere, $vin12_17, sprintf('%06d', $vin12_17+1000));
					$res = $this->get('vw_catch', $filedArr, $where, true);
					if(!empty($res['data']))
					$TempVinArr[] = $res['data'];
				}
				
				if(!empty($TempVinArr))
				{
					$t = [];
					foreach($TempVinArr as $V)
					{
						$t[implode('@', $V)] = $V;
					}
					$allM3Id = [];
					foreach($t as $v)
					{
						$res = $this->get('yp_model3_modcode JOIN yp_model3 ON mem_m3_id = m3_id', ['m3_id, m3_start_year, m3_end_year, m3_engine'], sprintf(" AND mem_code ='%s'", LibFc::Escape($v['cat_modcode'])));
						if(empty($res['data'])) continue;
						if(count($res['data']) == 1)
						{
							$M3IdArr[] = $res['data'][0]['m3_id'];
							continue;
						}

						$yearMatch = [];
						$tMatch = array_column($res['data'], 'm3_id');
						$match = false;
						foreach($res['data'] as $vv)
						{
							$allM3Id[] = $vv['m3_id'];
							if($v['cat_year'] >= $vv['m3_start_year'] && ($v['cat_year'] <= $vv['m3_end_year'] || $vv['m3_end_year'] == 0))
							{
								$yearMatch[] = $vv['m3_id'];
								if($vv['m3_engine'] == $v['cat_engine'])
								{
									$match = true;
									$M3IdArr[] = $vv['m3_id'];
								}
							}
						}
						if(!$match) $M3IdArr = empty($yearMatch)? array_merge($M3IdArr, $tMatch): array_merge($M3IdArr, $yearMatch);
					}
					$M3IdArr = empty($M3IdArr)? $allM3Id: $M3IdArr;
				}
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}



	/**
	  * @method 通过三菱的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelBySanlingVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin13_17 = substr($vin, 12, 5);
		if(preg_match('/^\d{5}$/', $vin13_17))
		{
			$where = sprintf(" and lnk_vin like '%s_%s' and lnk_modelcode != ''", LibFc::Escape($vin1_8), LibFc::Escape(substr($vin, 9, 8)));
			$filedArr = ['lnk_modelcode', 'param_date', 'RIGHT(lnk_vin, 5) as vin_end'];
			$res = $this->get('temp_mitsubishi', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin like '%s_%s%%' and lnk_modelcode != ''", LibFc::Escape($vin1_8), LibFc::Escape(substr($vin, 9, 3)));
				$res = $this->get('temp_mitsubishi', $filedArr, $tempWhere.sprintf(" AND RIGHT(lnk_vin, 5) <='%s' ORDER BY RIGHT(lnk_vin, 5) DESC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_mitsubishi', $filedArr, $tempWhere.sprintf(" AND RIGHT(lnk_vin, 5) >'%s' ORDER BY RIGHT(lnk_vin, 5) ASC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			$tM3IdArr = [];
			if(!empty($TempVinArr))
			{
				$t = [];
				foreach($TempVinArr as $V)
				{
					$V['param_date'] = date('Ym', strtotime($V['param_date']));
					$t[implode('@', $V)] = $V;
				}
				$allM3Id = [];
				foreach($t as $v)
				{
					$res = $this->get('yp_model3_modcode JOIN yp_model3 ON mem_m3_id = m3_id', ['m3_id'], sprintf(" AND mem_code ='%s'", LibFc::Escape($v['lnk_modelcode'])));
					if(empty($res['data'])) continue;
					if(count($res['data']) == 1)
					{
						$tM3IdArr[] = $res['data'][0]['m3_id'];
						continue;
					}
					$tMatch = array_column($res['data'], 'm3_id');
					$res = $this->get('yp_model3_etk_code', ['mec_m3_id, mec_code'], sprintf(" AND mec_m3_id in(%s)", implode(',', $tMatch)));
					foreach($res['data'] as $vv)
					{
						if(!preg_match('/(\d{6})-(\d{6})/', $vv['mec_code'], $yearMatch)) continue;
						if($v['param_date'] >= $yearMatch[1] && $v['param_date'] <= $yearMatch[2])
						{
							$tM3IdArr[] = $vv['mec_m3_id'];
						}
					}
				}
				$tM3IdArr = empty($tM3IdArr)? $allM3Id: $tM3IdArr;
			}
			$M3IdArr = array_merge($M3IdArr, $tM3IdArr);
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过现代起亚的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByHyundaiVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin13_17 = substr($vin, 12, 5);
		if(preg_match('/^\d{5}$/', $vin13_17))
		{
			$where = sprintf(" and lnk_vin = '%s' and lnk_extend_code != ''", LibFc::Escape($vin));
			$filedArr = ['lnk_extend_code', 'lnk_vin13_17 as vin_end'];
			$res = $this->get('temp_hyundai', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_8bit='%s' and lnk_vin10_12='%s' and lnk_extend_code != ''", LibFc::Escape($vin1_8), LibFc::Escape(substr($vin, 9, 3)));
				$res = $this->get('temp_hyundai', $filedArr, $tempWhere.sprintf(" AND lnk_vin13_17 <='%s' ORDER BY lnk_vin13_17 DESC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_hyundai', $filedArr, $tempWhere.sprintf(" AND lnk_vin13_17 >'%s' ORDER BY lnk_vin13_17 ASC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'lnk_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过马自达的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByMzdVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_12_17='%s' and v_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['v_extend_code', 'vin_12_17 as vin_end'];
			$res = $this->get('temp_mazda_epc', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and vin1_8='%s' and vin10_11='%s' and v_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_mazda_epc', $filedArr, $tempWhere.sprintf(" AND vin_12_17 <='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_mazda_epc', $filedArr, $tempWhere.sprintf(" AND vin_12_17 >'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'v_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过MG荣威的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByRoeweVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_12_17='%s' and vin_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['vin_extend_code', 'vin_12_17 as vin_end'];
			$res = $this->get('temp_roewe_vin', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_roewe_vin', $filedArr, $tempWhere.sprintf(" AND vin_12_17 <='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_roewe_vin', $filedArr, $tempWhere.sprintf(" AND vin_12_17 >'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'vin_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过斯巴鲁的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelBySubaruVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin10_11 = substr($vin, 9, 2);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_12_17='%s' and vin_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['vin_extend_code', 'vin_12_17 as vin_end'];
			$res = $this->get('temp_subaru', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_subaru', $filedArr, $tempWhere.sprintf(" AND vin_12_17 <='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_subaru', $filedArr, $tempWhere.sprintf(" AND vin_12_17 >'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];
				
				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'vin_extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过克莱斯勒 道奇 JEEP 的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByChrysler($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$tempWhere = sprintf(" and extend_code != '' and VIN_CHAR8='%s' and VIN_CHAR2='%s'", LibFc::Escape($vin1_8),  LibFc::Escape(substr($vin, 9, 2)));
			$filedArr = ['extend_code', 'VIN_CHAR6 as vin_end'];
			$res = $this->get('temp_chrysler', $filedArr, $tempWhere.sprintf(" and VIN_CHAR6 = '%s'", LibFc::Escape($vin12_17)));
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$res = $this->get('temp_chrysler', $filedArr, $tempWhere.sprintf(" AND VIN_CHAR6 <='%s' ORDER BY VIN_CHAR6 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_chrysler', $filedArr, $tempWhere.sprintf(" AND VIN_CHAR6 >'%s' ORDER BY VIN_CHAR6 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过 奔驰 的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByBenz($vin)
	{
		$M3IdArr = [];
		$vin1 = substr($vin, 0, 1);
		$vin1_8 = substr($vin, 0, 8);
		$vin10_11 = substr($vin, 9, 2);
		$vin12_17 = substr($vin, 11, 6);
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and vin1_8='%s' and vin10_11='%s' and vin_12_17='%s' and extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['extend_code', 'vin_12_17 as vin_end'];
			$res = $this->get('temp_mercedes', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and vin1_8='%s' and vin10_11='%s' and extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_mercedes', $filedArr, $tempWhere.sprintf(" AND vin_12_17<='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_mercedes', $filedArr, $tempWhere.sprintf(" AND vin_12_17>'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}

		//etk特殊解码
		if(empty($M3IdArr) )
		{
			$res = $this->get('yp_vin_model3_link join yp_vin on vm3_vin_id = vin_id', ['*'], sprintf(" and vin_full='%s' limit 1", LibFc::Escape($vin1_8)));
			if(empty($res['data']))
			{
				$res = $this->getBenzCodeByVin($vin);
				if(!empty($res['data']))
				{
					$where = sprintf(" and mec_code in ('%s')", implode("','", $res['data']));
					$where .= in_array($vin1, ['L', 'H'])? ' AND m1_m_id != 149': ' AND m1_m_id=149';
					$table = 'yp_model3_etk_code
					JOIN yp_model3 ON mec_m3_id = m3_id
					JOIN yp_model2 ON m3_m2_id = m2_id
					JOIN yp_model1 ON m2_m1_id = m1_id';
					$res = $this->get($table, ['distinct m3_id'], $where);
					$M3IdArr = array_column($res['data'], 'm3_id');
				}
			}	
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 福特VIN反查宜配车型ID   唯一编码@年月
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByFordVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = substr($vin, 0, 8);
		$vin10_12 = substr($vin, 9, 3);
		$vin13_17 = substr($vin, 12, 5);
		if(preg_match('/^\d{5}$/', $vin13_17))
		{
			$tempWhere = sprintf(" and lnk_vin1_8='%s' and lnk_vin10_12='%s' and extend_code != ''", LibFc::Escape($vin1_8), LibFc::Escape($vin10_12));
			$filedArr = ['extend_code', 'lnk_date', 'lnk_vin13_17 as vin_end'];
			$res = $this->get('temp_ford_1', $filedArr, $tempWhere.sprintf(" and lnk_vin13_17='%s'", LibFc::Escape($vin13_17)));
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				$res = $this->get('temp_ford_1', $filedArr, $tempWhere.sprintf(" AND lnk_vin13_17 <='%s' ORDER BY lnk_vin13_17 DESC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_ford_1', $filedArr, $tempWhere.sprintf(" AND lnk_vin13_17 >'%s' ORDER BY lnk_vin13_17 ASC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			$tM3IdArr = [];
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode JOIN yp_model3 ON mem_m3_id = m3_id', ['m3_id, mem_code,m3_start_year, m3_start_month, m3_end_year,m3_end_month'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$allModel = [];
				foreach($res['data'] as $k=>$v)
				{
					$v['bym'] = empty($v['m3_start_year']) ? 194901: (int) sprintf('%04d%02d', $v['m3_start_year'], $v['m3_start_month']);
					$v['eym'] = empty($v['m3_end_year']) ? 299912: (int) sprintf('%04d%02d', $v['m3_end_year'], !empty($v['m3_end_month'])? $v['m3_end_month']: 12);
					$allModel[] = $v;
				}
				
				$tall = $allModel;
				//年份过滤
				$matchArr = [];
				foreach($TempVinArr as $v)
				{
					$v['lnk_date'] = strtotime(str_replace('\\', '-', $v['lnk_date']));
					$v['y'] = date('Y', $v['lnk_date']);
					$v['ym'] = date('Ym', $v['lnk_date']);
					foreach($allModel as $vv)
					{
						if($vv['mem_code'] == $v['extend_code'] && $vv['bym'] <= $v['ym'] && $vv['eym'] >= $v['ym'])
						{
							$matchArr[$vv['m3_id']] = $vv;
						}
					}
				}
				$tM3IdArr = !empty($matchArr)? array_column($matchArr, 'm3_id'): array_column($allModel, 'm3_id');
			}
			$M3IdArr = array_merge($M3IdArr, $tM3IdArr);
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过标致 雪铁龙的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByCitroenVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and lnk_vin_8bit='%s' and vin10_11='%s' and vin_12_17='%s' and extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['extend_code', 'vin_12_17 as vin_end'];
			$res = $this->get('temp_citroen', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_8bit='%s' and vin10_11='%s' and extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_citroen', $filedArr, $tempWhere.sprintf(" AND vin_12_17 <='%s' ORDER BY vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_citroen', $filedArr, $tempWhere.sprintf(" AND vin_12_17 >'%s' ORDER BY vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}



	/**
	  * @method 通过宝马的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByBmwVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_12 = LibFc::Escape(substr($vin, 9, 3));
		$vin13_17 = LibFc::Escape(substr($vin, 12, 5));
		if(preg_match('/^\d{5}$/', $vin13_17))
		{
			$where = sprintf(" and cat_18 = '%s' and cat10_12='%s' and cat13_17='%s' and cat_extend_code != ''", $vin1_8, $vin10_12, $vin13_17);
			$filedArr = ['cat_extend_code as extend_code', 'cat13_17 as vin_end'];
			$res = $this->get('temp_bmw_catch', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and cat_18='%s' and cat10_12='%s' and cat_extend_code != ''", $vin1_8, $vin10_12);
				$res = $this->get('temp_bmw_catch', $filedArr, $tempWhere.sprintf(" AND cat13_17 <='%s' ORDER BY cat13_17 DESC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_bmw_catch', $filedArr, $tempWhere.sprintf(" AND cat13_17 >'%s' ORDER BY cat13_17 ASC LIMIT 1", $vin13_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过路虎的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByLandroverVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_vin_12_17='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['lnk_extend_code as extend_code', 'lnk_vin_12_17 as vin_end'];
			$res = $this->get('temp_landrover', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_landrover', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 <='%s' ORDER BY lnk_vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_landrover', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 >'%s' ORDER BY lnk_vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}
	

	/**
	  * @method 通过江淮的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByJacVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_vin_12_17='%s' and lnk_img_oid != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['lnk_img_oid as extend_code', 'lnk_vin_12_17 as vin_end'];
			$res = $this->get('temp_jac_web', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_img_oid != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_jac_web', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 <='%s' ORDER BY lnk_vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_jac_web', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 >'%s' ORDER BY lnk_vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}



	/**
	  * @method 通过宝沃的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByBorgwardVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_vin_12_17='%s' and lnk_featurePackageCode != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['lnk_featurePackageCode as extend_code', 'lnk_vin_12_17 as vin_end'];
			$res = $this->get('temp_borgward', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_featurePackageCode != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_borgward', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 <='%s' ORDER BY lnk_vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_borgward', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 >'%s' ORDER BY lnk_vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 通过北汽新能源的VIN反查宜配车型ID
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByBjevVin($vin)
	{
		$M3IdArr = [];
		$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
		$vin10_11 = LibFc::Escape(substr($vin, 9, 2));
		$vin12_17 = LibFc::Escape(substr($vin, 11, 6));
		if(preg_match('/^\d{6}$/', $vin12_17))
		{
			$where = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_vin_12_17='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11, $vin12_17);
			$filedArr = ['lnk_extend_code as extend_code', 'lnk_vin_12_17 as vin_end'];
			$res = $this->get('temp_bjev', $filedArr, $where);
			if(!empty($res['data'])) $this->fullMatchEpc = $res['data'];
			$TempVinArr = $res['data'];
			if(empty($TempVinArr))
			{
				//工信部600万精准查找
				$res = $this->getYpcModelByAnyMatch($vin);
				if(!empty($this->fullMatchFrom)) return $res;
				$vinMinArr = [];

				//忽略第九位找相邻一两条
				$tempWhere = sprintf(" and lnk_vin_18='%s' and lnk_vin_10_11='%s' and lnk_extend_code != ''", $vin1_8, $vin10_11);
				$res = $this->get('temp_bjev', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 <='%s' ORDER BY lnk_vin_12_17 DESC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['X'] = $res['data'];
				$res = $this->get('temp_bjev', $filedArr, $tempWhere.sprintf(" AND lnk_vin_12_17 >'%s' ORDER BY lnk_vin_12_17 ASC LIMIT 1", $vin12_17), true);
				$vinMinArr['my']['S'] = $res['data'];

				//600万
				$res = $this->getAnyXinanglinVin($vin);
				$vinMinArr['any'] = $res['data'];
				$res = $this->filterXinanglinVin($vin, $vinMinArr);
				$TempVinArr = $res['data']['my'];
				$res = $this->getYpcModelByAnyRows($vin, $res['data']['any']);
				$M3IdArr = $res['data'];
			}
			
			if(!empty($TempVinArr))
			{
				$mcArr = array_column($TempVinArr, 'extend_code');
				$res = $this->get('yp_model3_modcode', ['distinct mem_m3_id'], sprintf(" AND mem_code in ('%s') ", implode("','", $mcArr)));
				$M3IdArr = array_merge($M3IdArr, array_column($res['data'], 'mem_m3_id'));
			}
		}
		return LibFc::ReturnData(true, array_unique($M3IdArr));
	}


	/**
	  * @method 600万表中非精准解码VIN
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByAny($vin)
	{
		//之前是否已经精准查询过？
		if($this->fullMatchFrom === null)
		{
			//能精准找到即使没有解码结果也不继续解码
			$res = $this->getYpcModelByAnyMatch($vin);
			if(!empty($this->fullMatchFrom)) return $res;
		}
		$M3IdArr = [];
		if(empty($this->fullMatchFrom))
		{
			$YpwBase = new YpwBase();
			$vin1 = substr($vin, 0, 1);
			$vin1_8 = substr($vin, 0, 8);
			$vin10_12 = substr($vin, 9, 3);
			$vin13_17 = substr($vin, 12, 5);
			//年份在2018年以前，用“600万”解码时，“V1-8”+“V10”+“V11”找不到时，提示“该车型尚未收录，或者您录入的车架号有误”
			$Year = LibFc::VinYear(substr($vin, 9, 1));
			/*暂时取消，等待解决方案 2019/7/2
			if(in_array($vin1, ['L', 'H']) && $Year < 2018)
			{
				$res = $YpwBase->Get('stand_model_any', ['sma_vin'], sprintf(" AND sma_vin1_8 ='%s' and sma_vin10_12 like '%s%%' limit 1", $vin1_8, substr($vin, 9, 2)), true);
				if(empty($res['data']))
				{
					return LibFc::ReturnData(false, '该车型尚未收录，或者您录入的车架号有误！', 'VIN_NULL');
				}
			}*/
			
			$rowArr = [];
			$res = $this->getAnyXinanglinVin($vin);
			if(!empty($res['data']['X'])) $rowArr[] = $res['data']['X'];
			if(!empty($res['data']['S'])) $rowArr[] = $res['data']['S'];
			$gxbCodeArr = array_unique(array_column($rowArr, 'sma_gxb_code'));
			$res = $this->getYpcModelByAnyRows($vin, $rowArr);
			$M3IdArr = $res['data'];
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}

	/**
	  * @method 反查接不到车型，尝试提取车架号（含大车）信息  LN3341C218B000088  LZZ1CLXB0HA180574
	  * @author soul
	  * @copyright 2020/7/25
	  * @return 
	  */
	private function decodeBigCar()
	{
		$CHCARDb = new BaseDb(mvc::$cfg['DB']['CHCAR']);
		$CartBase = new CartBase();
		$siteArr = [3,1,2];

		$labelArr = [
			'pic'=>'车型图',
			'sma_brand'=>'品牌',
			'mod_name'=>'车型',
			'sma_engine'=>'发动机',
			'mod3_jgl_kw'=>'最大净功率',
			'mod3_ed_kw'=>'额定功率',
			'sma_kw'=>'功率',
			'sma_cc'=>'排量',
			'xuhang'=>'续航',
			'dianchi'=>'电池种类',
			'sma_tran'=>'变速箱',
			'mod_drive'=>'驱动方式',
			'size'=>'尺寸',
			'sma_wheel'=>'轴距',
			'sma_vtype'=>'车辆类型',
			'sma_weight'=>'整备质量',
			'sma_passenger'=>'载客',
			'sma_year'=>'生产日期',
			'sma_jkyear'=>'进口日期',
			'jkfs'=>'进口方式',
			'country'=>'制造国',
			'company'=>'生产厂',
		];
		$unitArr = [
			'sma_kw'=>'kw',	
			'sma_cc'=>'cc',	
			'sma_wheel'=>'mm',	
			'sma_weight'=>'kg',	
			'sma_passenger'=>'人'	
		];

		$YpwBase = new YpwBase();
		$allTmodArr = [];
		if(!empty($this->fullMatchFrom)) $allTmodArr = array_column($this->fullMatchFrom, null, 'sma_vin');
		else if(!empty($this->xiangLinFromAny)) $allTmodArr = array_column($this->xiangLinFromAny, null, 'sma_vin');
		if(!empty($allTmodArr))
		{
			$bigcar = ['mod'=>[], 'label'=>[]];
			$vinbase = ['mod'=>[], 'label'=>[]];
			$LibEncry = new LibEncry();
			$modType = '';
			foreach($allTmodArr as $tmodArr)
			{
				if(count($allTmodArr) > 1){
					if(!empty($this->vinBase['base']['vin_year']) && $this->vinBase['base']['vin_year_style'] == 'buid'){
						$tmodArr['sma_year'] = $this->vinBase['base']['vin_year'];
					}else{
						unset($tmodArr['sma_year']);
					}
					if(!empty($this->vinBase['base']['vin_year']) && $this->vinBase['base']['vin_year_style'] == 'jinkou'){
						$tmodArr['sma_jkyear'] = $this->vinBase['base']['vin_year'];
					}else{
						unset($tmodArr['sma_jkyear']);
					}
				}
				if(empty($tmodArr['xuhang']) && !empty($tmodArr['sma_xuhang'])) $tmodArr['xuhang'] = $tmodArr['sma_xuhang'];
				$tres = $this->getGxbEngKw($tmodArr['sma_gxb_code'], $tmodArr['sma_engine'], $tmodArr['sma_kw'], $this->vinBase['vin'], $tmodArr['sma_brand']);
				if(!empty($tres['data']['mod3_jgl_kw']))
				{
					$tmodArr['mod3_jgl_kw'] = $tres['data']['mod3_jgl_kw'][1];
					if(!empty($tres['data']['mod3_ed_kw'])) $tmodArr['mod3_ed_kw'] = $tres['data']['mod3_ed_kw'][1];
					unset($tmodArr['sma_kw']);
				}
				if(!empty($tres['data']['dianchi'])) $tmodArr['dianchi'] = $tres['data']['dianchi'];
				if(!empty($tres['data']['paifang']) && $tmodArr['sma_engine'] != '') $tmodArr['sma_engine'] .= ' ('.$tres['data']['paifang'].')';
				if(empty($tmodArr['xuhang']) && !empty($tres['data']['xuhang'])) $tmodArr['xuhang'] = $tres['data']['xuhang'];

				if(!empty($tmodArr['sma_length']) && !empty($tmodArr['sma_width'])  && !empty($tmodArr['sma_height']))
					$tmodArr['size'] = $tmodArr['sma_length'].'mm*'.$tmodArr['sma_width'].'mm*'.$tmodArr['sma_height'].'mm';
				if(!empty($tmodArr['sma_gxb_code']))
				{
					//已经前置
					//$tmodArr = $this->fitDataFromSmaTj($tmodArr);
					if(empty($modType) && LibFc::getGxbCarType($tmodArr['sma_gxb_code']) != 7){
						$modType = 'cv';
					}

					//长安 103马力 10-18人 幼儿专用校车(SC6515XAG4)
					$res = $CHCARDb->get('all_model', ['group_concat(distinct tymc) as mod_name', 'group_concat(distinct bsqlx) as sma_tran', 'group_concat(distinct qdxs) as mod_drive'], sprintf(" and clxh != '' and clxh = '%s' group by clxh limit 1", $tmodArr['sma_gxb_code']), true);
					if(!empty($res['data']))
					{
						if(!empty($tmodArr['sma_tran']) && $tmodArr['sma_tran'] != '无') unset($res['data']['sma_tran']);
						$tmodArr = array_merge($tmodArr, $res['data']);
					}
					if(!empty($tmodArr['mod_name']))
					{
						if(!empty($tmodArr['sma_passenger'])) $tmodArr['mod_name'] .= ' '.$tmodArr['sma_passenger'].'人';
						if(!empty($tmodArr['sma_vtype'])) $tmodArr['mod_name'] .= ' '.$tmodArr['sma_vtype'];
						if(!empty($tmodArr['sma_gxb_code_show'])) $tmodArr['mod_name'] .= ' ('.$tmodArr['sma_gxb_code_show'].')';
					}

					//是否有大车信息
					foreach($siteArr as $formId)
					{
						$res = $CartBase->get('cat_model', ['mod_id, mod_label_2 AS sma_vtype, mod_make sma_brand, mod_code sma_gxb_code_show, mod_name'], sprintf(" and mod_from=%d and mod_code_format ='%s' and mod_name not like '%%撤销%%' limit 1", $formId, $tmodArr['sma_gxb_code']), true);
						if(!empty($res['data']))
						{
							foreach($res['data'] as $f=>$fv)
							{
								if(empty($tmodArr[$f])) $tmodArr[$f] = $fv;
							}
							break;
						}
					}
					$tmodArr = $this->fitSmaBaseData($tmodArr, $this->vinBase['vin']);

					//其他渠道信息
					$res = $YpwBase->get('stand_gxb_base', ['*'], sprintf(" and sgb_gxb_code='%s'", $tmodArr['sma_gxb_code']), true);
					if(!empty($res['data']))
					{
						$othArr = $res['data'];
						if(empty($tmodArr['mod_name']) && !empty($othArr['sgb_rname'])) $tmodArr['mod_name'] = $othArr['sgb_rname'];
						if(empty($tmodArr['sma_tran']) && !empty($othArr['sgb_rtran'])) $tmodArr['sma_tran'] = $othArr['sgb_rtran'];
						if(empty($tmodArr['mod_drive']) && !empty($othArr['sgb_rdrive'])) $tmodArr['mod_drive'] = $othArr['sgb_rdrive'];
						if(empty($tmodArr['xuhang']) && !empty($othArr['sgb_rxuhang'])) $tmodArr['xuhang'] = $othArr['sgb_rxuhang'];
						if(empty($tmodArr['sma_passenger']) && !empty($othArr['sgb_frontman'])) $tmodArr['sma_passenger'] = $othArr['sgb_frontman'];
					}

					if(empty($tmodArr['mod_name'])){
						$res = $this->getKczjMod1ByGxb([$tmodArr['sma_gxb_code']]);
						if($res['data'] && count($res['data']) == 1){
							$tmodArr['sma_brand'] = $res['data'][0]['b_name'];
							$tmodArr['mod_name'] = $res['data'][0]['m1_name'];
						}
					}
				}

				if(!empty($tmodArr['mod_name'])) $tmodArr['mod_name'] = trim($tmodArr['mod_name'], ',');
 
				$res = $this->getCartImg(isset($tmodArr['mod_id'])? $tmodArr['mod_id']: 0, $tmodArr['sma_gxb_code']);
				$pics = $res['data'];

				//有大车信息 LS4A272P3DG001529
				if(!empty($tmodArr['mod_id']))
				{
					$modArr = ['mod_id'=>$LibEncry->encode($tmodArr['mod_id'].'@'.$tmodArr['sma_vin']), 'pic'=>$pics];
					foreach($labelArr as $k=>$v)
					{
						if(isset($tmodArr[$k]) && !empty($tmodArr[$k]))
						{
							$bigcar['label'][$k] = $v;
							$modArr[$k] = $tmodArr[$k].(isset($unitArr[$k])? $unitArr[$k]: '');
						}
					}
					$bigcar['mod'][] = $modArr;
				}
				else
				{
					$modArr = ['pic'=>$pics];
					foreach($labelArr as $k=>$v)
					{
						if(!empty($tmodArr[$k]))
						{
							$vinbase['label'][$k] = $v;
							$modArr[$v] = $tmodArr[$k].(isset($unitArr[$k])? $unitArr[$k]: '');
						}
					}
					$vinbase['mod'][] = $modArr;
				}
			}
			$from = '';
			if(!empty($bigcar['mod']))
			{
				$endModArr = $bigcar['mod'];
				$endLabel = $bigcar['label'];
				if(count($endModArr) > 1)
				{
					$endLabel = [];
					$notSameArr = [];
					foreach($labelArr as $k=>$v)
					{
						$tval = [];
						foreach($endModArr as $kk=>$vv)
						{
							if(!empty($vv[$k]))
							{
								//pic
								$tval[] = is_array($vv[$k])? '':$vv[$k];
								$endLabel[$k] = $v;
							}
							else
							{
								$tval[] = '';
							}
						}
						$tval = array_unique($tval);
						if(count($tval) > 1 && !in_array($k, ['sma_year', 'sma_jkyear']))
						{
							$notSameArr[$k] = $tval;
						}
					}
					//除了生产日期，其他一样，取第一条
					if(empty($notSameArr) || (count($notSameArr) == 1 && !empty($notSameArr['sma_year'])))
					{
						$endModArr = [$endModArr[0]];
						//2020-01-08=>2020-01  LEFYECG26JHN36985
						if((!empty($notSameArr['sma_year']) && strlen($endModArr[0]['sma_year']) > 9))
						{
							$endModArr[0]['sma_year'] = date('Y-m', strtotime($endModArr[0]['sma_year']));
						}
					}
				}
				unset($endLabel['pic']);
				return LibFc::ReturnData(true, ['from'=>'bigcar', 'model'=>$endModArr, 'label'=>$endLabel, 'brand_id'=>$this->getBrandIdByWord($endModArr[0]['sma_brand']),'modtype'=>'cv', 'brand_name'=>$endModArr[0]['sma_brand']]);
			}
			else
			{//['品牌'=>''...]
				$endModArr = $vinbase['mod'];
				$endLabel = array_unique($vinbase['label']);
				$showSize = true;
				if(count($endModArr) > 1)
				{
					$endLabel = [];
					$notSameArr = [];
					foreach($labelArr as $k=>$v)
					{
						$tval = [];
						foreach($endModArr as $kk=>$vv)
						{
							if(!empty($vv[$v]))
							{//pic
								$tval[] = is_array($vv[$v])? '':$vv[$v];
								$endLabel[$k] = $v;
							}
							else
							{
								$tval[] = '';
							}
						}
						$tval = array_unique($tval);
						//是否有一个没有尺寸
						if($k == 'size' && in_array('', $tval)) $showSize = false;;
						if(count($tval) > 1 && !in_array($v, ['生产日期', '进口日期']))
						{
							$notSameArr[$v] = $tval;
						}
					}

					//除了生产日期，其他一样，取第一条
					if(empty($notSameArr) || (count($notSameArr) == 1 && !empty($notSameArr['生产日期'])))
					{
						$endModArr = [$endModArr[0]];
						//2020-01-08=>2020-01  LS5A2ABE0CA510728
						if((!empty($notSameArr['生产日期']) && strlen($endModArr[0]['生产日期']) > 9))
						{
							$endModArr[0]['生产日期'] = date('Y-m', strtotime($endModArr[0]['生产日期']));
						}
					}
				}
				
				foreach($endModArr as $k=>$v)
				{
					unset($v['整车型号']);
					if(!$showSize) unset($v['尺寸']);
					if(isset($v['车辆类型']) && stripos($v['车辆类型'], '乘用车') !== false) $modType = 'pc';
					$endModArr[$k] = $v;
				}
				
				unset($endLabel['pic']);
				//2022/8/27 屏蔽型号
				unset($endLabel['sma_gxb_code_show']);
				if(!$showSize) unset($endLabel['size']);
				if(empty($modType)) $modType = 'pc';
				return LibFc::ReturnData(true, ['from'=>'vinbase', 'model'=>$endModArr, 'label'=>array_values($endLabel), 'brand_id'=>$this->getBrandIdByWord($endModArr[0]['品牌']), 'modtype'=>$modType, 'brand_name'=>$endModArr[0]['品牌']]);
			}
		}
		return LibFc::ReturnData(true, ['from'=>'', 'model'=>[]]);
	}

	/**
	  * @method 卡车标准车型
	  * @author soul
	  * @copyright 2023/5/23
	  * @return 
	  */
	private function decodeKczj()
	{
		//return LibFc::ReturnData(true, ['from'=>'', 'model'=>[]]);
		$YpwBase = new YpwBase();
		$KczjBase = new BaseDb(mvc::$cfg['DB']['KCZJ']);
		$allTmodArr = [];
		if(!empty($this->fullMatchFrom)) $allTmodArr = array_column($this->fullMatchFrom, null, 'sma_vin');
		else if(!empty($this->xiangLinFromAny)) $allTmodArr = array_column($this->xiangLinFromAny, null, 'sma_vin');
		if(!empty($allTmodArr))
		{
			$endM3Arr = [];
			foreach($allTmodArr as $tmodArr)
			{
				//已经前置
				//$tmodArr = $this->fitDataFromSmaTj($tmodArr);
				$tmodArr['sma_engine_format'] = LibFc::FormatEng($tmodArr['sma_engine']);

				if(empty($tmodArr['xuhang']) && !empty($tmodArr['sma_xuhang'])) $tmodArr['xuhang'] = $tmodArr['sma_xuhang'];
				$tres = $this->getGxbEngKw($tmodArr['sma_gxb_code'], $tmodArr['sma_engine'], $tmodArr['sma_kw'], $this->vinBase['vin'], $tmodArr['sma_brand']);
				if(!empty($tres['data']['mod3_jgl_kw']))
				{
					$tmodArr['mod3_jgl_kw'] = $tres['data']['mod3_jgl_kw'][1];
					if(!empty($tres['data']['mod3_ed_kw'])) $tmodArr['mod3_ed_kw'] = $tres['data']['mod3_ed_kw'][1];
					unset($tmodArr['sma_kw']);
				}
				if(!empty($tres['data']['dianchi'])) $tmodArr['dianchi'] = $tres['data']['dianchi'];
				if(!empty($tres['data']['paifang']) && $tmodArr['sma_engine'] != '') $tmodArr['sma_engine'] .= ' ('.$tres['data']['paifang'].')';
				if(empty($tmodArr['xuhang']) && !empty($tres['data']['xuhang'])) $tmodArr['xuhang'] = $tres['data']['xuhang'];

				if(!empty($tmodArr['sma_length']) && !empty($tmodArr['sma_width'])  && !empty($tmodArr['sma_height']))
					$tmodArr['size'] = $tmodArr['sma_length'].'mm*'.$tmodArr['sma_width'].'mm*'.$tmodArr['sma_height'].'mm';
				if(!empty($tmodArr['sma_gxb_code']))
				{
					//已经前置
					//$tmodArr = $this->fitDataFromSmaTj($tmodArr);
					$tmodArr = $this->fitSmaBaseData($tmodArr, $this->vinBase['vin']);

					//其他渠道信息
					$res = $YpwBase->get('stand_gxb_base', ['*'], sprintf(" and sgb_gxb_code='%s'", $tmodArr['sma_gxb_code']), true);
					if(!empty($res['data']))
					{
						$othArr = $res['data'];
						if(empty($tmodArr['xuhang']) && !empty($othArr['sgb_rxuhang'])) $tmodArr['xuhang'] = $othArr['sgb_rxuhang'];
						if(empty($tmodArr['sma_passenger']) && !empty($othArr['sgb_frontman'])) $tmodArr['sma_passenger'] = $othArr['sgb_frontman'];
					}
				}

				$res = $this->getCartImg(@$tmodArr['mod_id'], $tmodArr['sma_gxb_code']);
				$pics = $res['data'];

				$table = 'mer_model3 m3 join mer_model3_gxb on m3_code = mmg_m3_code left join mer_model3_size on m3_code = mms_m3_code';
				$res = $KczjBase->get($table, ['m3.*, group_concat(distinct mms_length) m3s_length, group_concat(distinct mms_width) m3s_width, group_concat(distinct mms_height) m3s_height'], sprintf(" and mmg_gxb_code ='%s' group by m3_code", $tmodArr['sma_gxb_code']));
				$modArr = array_column($res['data'], null, 'm3_code');
				
				foreach($modArr as $mk=>$mv)
				{
					$mv['m3s_length'] = explode(',', $mv['m3s_length']);
					$mv['m3s_width'] = explode(',', $mv['m3s_width']);
					$mv['m3s_height'] = explode(',', $mv['m3s_height']);
					$modArr[$mk] = $mv;
				}
				
				//过滤车型 排量轴距存在则必须相同  发动机多种名称，或者大众3位和4位
				$comfileds = ['engine','cc','wheel'];
				foreach($comfileds as $comfiled)
				{
					foreach($modArr as $mk=>$mv)
					{
						if($comfiled == 'engine' && !empty($mv['m3_engine_format']) && $tmodArr['sma_engine_format'] != '' && $mv['m3_engine_format'] != $tmodArr['sma_engine_format'])
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'cc' && !empty($mv['m3_cc']) && !empty($tmodArr['sma_cc']) && $mv['m3_cc'] != $tmodArr['sma_cc'])
						{
							unset($modArr[$mk]);
							continue;
						}
						if($comfiled == 'wheel' && !empty($mv['m3_wheel']) && !empty($tmodArr['sma_wheel']) && $mv['m3_wheel'] != $tmodArr['sma_wheel'])
						{
							unset($modArr[$mk]);
							continue;
						}
					}
				}

				if(!empty($modArr))
				{
					//过滤车型保留最后一条
					$comfileds = [ 'enginekwcc', 'length', 'width', 'height', 'weight','tran'];
					foreach($comfileds as $comfiled)
					{
						if(count($modArr) == 1) break;
						$lastModArr = $modArr;
						foreach($modArr as $mk=>$mv)
						{
							//此车型是否符合其中某一条工信部信息
							if($comfiled == 'enginekwcc' && !empty($mv['m3_engine_format']) && $tmodArr['sma_engine_format'] != '' && $mv['m3_engine_format'] != $tmodArr['sma_engine_format'])
							{//发动机
								//发动机不一样但是功率排量一样，不过滤
								if(
									(!empty($mv['m3_cc']) && !empty($tmodArr['sma_cc']) && $mv['m3_cc'] == $tmodArr['sma_cc']) &&
									(!empty($mv['m3_kw']) && !empty($tmodArr['sma_kw']) && $mv['m3_kw'] != $tmodArr['sma_kw'])
								){}else
								{
									unset($modArr[$mk]);
									continue;
								}
							}

							if($comfiled == 'length' && !empty($mv['m3s_length']) && !empty($tmodArr['sma_length']) && !in_array($tmodArr['sma_length'], $mv['m3s_length']))
							{
								unset($modArr[$mk]);
								continue;
							}
							if($comfiled == 'width' && !empty($mv['m3s_width']) && !empty($tmodArr['sma_width']) && !in_array($tmodArr['sma_width'], $mv['m3s_width']))
							{
								unset($modArr[$mk]);
								continue;
							}

							if($comfiled == 'height' && !empty($mv['m3s_height']) && !empty($tmodArr['sma_height']) && !in_array($tmodArr['sma_height'], $mv['m3s_height']))
							{
								unset($modArr[$mk]);
								continue;
							}

							if($comfiled == 'tran' && !empty($mv['m3_tran']) && !empty($tmodArr['sma_tran']) && $mv['m3_tran'] != $tmodArr['sma_tran'])
							{
								unset($modArr[$mk]);
								continue;
							}
						}
						$modArr = empty($modArr)? $lastModArr : $modArr;
					}
				}
				foreach($modArr as $mk=>$mv)
				{
					$mv = array_merge($mv, $tmodArr);
					$mv['pic'] = $pics;
					$endM3Arr[$mk] = $mv;
				}
			}
			
			if(!empty($endM3Arr))
			{
				$LibEncry = new LibEncry();
				$endModArr = [];
				$endLabel = [];
				$brand = '';
				$labelArr = [
					'pic'=>'车型图',
					'sma_brand'=>'品牌',
					'm1_name'=>'车系',
					'mod_name'=>'车型',
					'sma_engine'=>'发动机',
					'sma_kw'=>'功率',
					'sma_cc'=>'排量',
					'xuhang'=>'续航',
					'dianchi'=>'电池种类',
					'sma_tran'=>'变速箱',
					'mod_drive'=>'驱动方式',
					'sma_wheel'=>'轴距',
					'sma_vtype'=>'车辆类型',
					//'sma_weight'=>'整备质量',
					'sma_passenger'=>'载客',
					'sma_year'=>'生产日期',
					'sma_jkyear'=>'进口日期'
				];
				$unitArr = [
					'sma_wheel'=>'mm',	
					'sma_weight'=>'kg',	
					'sma_passenger'=>'人'	
				];
				foreach($endM3Arr as $row)
				{
					if(empty($brand)) $brand = $row['m3_b_name'];
					$srow = ['mod_id'=>$LibEncry->encode($row['m3_code'].'@'.$this->vinBase['vin'])];
					foreach($labelArr as $kf=>$fn)
					{
						switch($kf)
						{
							case 'sma_brand': 
								$srow[$kf] = $row['m3_m_name'] != $row['m3_b_name']? $row['m3_b_name'].'('.$row['m3_m_name'].')': $row['m3_b_name'];
								$endLabel[$kf] = $fn;
							break;
							case 'm1_name':
								$srow[$kf] = $row['m3_m1_name'];
								$endLabel[$kf] = $fn;
							break;
							case 'mod_name':
								$srow[$kf] = $row['m3_name'];
								$endLabel[$kf] = $fn;
							break;
							case 'sma_engine':
								$val = $row['sma_engine'] != ''? $row['sma_engine']: $row['m3_engine'];
								if(!empty($val))
								{
									if(!empty($row['paifang'])) $val .= ' ('.$row['paifang'].')';
									$srow[$kf] = $val;
									$endLabel[$kf] = $fn;
								}
							break;
							case 'sma_kw':
								$haskw = false;
								if(!empty($row['mod3_jgl_kw'])){
									$srow['mod3_jgl_kw'] = $row['mod3_jgl_kw'];
									$endLabel['mod3_jgl_kw'] = '最大净功率';
									$haskw = true;
								}
								if(!empty($row['mod3_ed_kw'])){
									$srow['mod3_ed_kw'] = $row['mod3_ed_kw'];
									$endLabel['mod3_ed_kw'] = '额定功率';
									$haskw = true;
								}
								if(!$haskw && !empty($row['sma_kw'])){
									$srow['sma_kw'] = $row['sma_kw'].'kw';
									$endLabel['sma_kw'] = '功率';
									$haskw = true;
								}
							break;
							case 'sma_cc':
								$val = !empty($row['sma_cc'])? $row['sma_cc']: $row['m3_cc'];
								if(!empty($val) && $val != '-'){
									$srow[$kf] = $val.'cc';
									$endLabel[$kf] = $fn;
								}
							break;
							case 'mod_drive':
								$val = !empty($row['mod_drive'])? $row['mod_drive']: $row['m3_drive'];
								if(!empty($val)){
									$srow[$kf] = $val;
									$endLabel[$kf] = $fn;
								}
							break;
							case 'sma_tran':
							case 'sma_wheel':
							case 'sma_vtype':
								$val = !empty($row[$kf])? $row[$kf]: $row[str_replace('sma_', 'm3_', $kf)];
								if(!empty($val)){
									if(isset($unitArr[$kf])) $val .= $unitArr[$kf];
									$srow[$kf] = $val;
									$endLabel[$kf] = $fn;
								}
							break;
							default: 
								if(!empty($row[$kf])){
									$val = $row[$kf];
									if(isset($unitArr[$kf])) $val .= $unitArr[$kf];
									$srow[$kf] = $val;
									$endLabel[$kf] = $fn;
								}
							break;
						}
					}
					$endModArr[] = $srow;
				}
				unset($endLabel['pic']);
				return LibFc::ReturnData(true, ['from'=>'bigcar', 'model'=>$endModArr, 'label'=>$endLabel, 'brand_id'=>$this->getBrandIdByWord($brand), 'modtype'=>'cv', 'brand_name'=>$brand]);
			}
		}
		return LibFc::ReturnData(true, ['from'=>'', 'model'=>[]]);
	}
	
	/**
	  * @method 通过型号获取卡车车系
	  * @author soul
	  * @return
	  */
	private function getKczjMod1ByGxb($gxbArr)
	{
		//卡车车系
		$arr = [];
		foreach($gxbArr as $k=>$v){
			$gxbArr[$k] = LibFc::FormatNum($v);
		}
		if($gxbArr){
			$KczjBase = new BaseDb(mvc::$cfg['DB']['KCZJ']);
			$res = $KczjBase->get('mer_model3 JOIN mer_model3_gxb ON mmg_m3_code = m3_code', ['m3_b_name b_name, m3_m1_name m1_name'], sprintf(" and mmg_gxb_code in ('%s') GROUP BY m3_m1_name", implode("','", $gxbArr)));
			$arr = $res['data'];
		}
		return LibFc::ReturnData(true, $arr);
	}


	

	/**
	  * @method 根据统计表获取型号的变速箱 人数
	  * @author soul
	  * @copyrivinbaseht 2023/3/8
	  * @return
	  */
	private function fitDataFromSmaTj($tmodArr)
	{
		if(empty($tmodArr['sma_tran']) || empty($tmodArr['sma_passenger']) || empty($tmodArr['sma_vtype']))
		{
			$YpwBase = new YpwBase();
			$twhereArr = [
				sprintf(" and smt_gxb_code='%s' and smt_vin1_8='%s'", $tmodArr['sma_gxb_code'], substr($tmodArr['sma_vin'], 0, 8)),
			];
			if(in_array(substr($tmodArr['sma_vin'], 0, 1), ['L', 'H']))
				$twhereArr[] = sprintf(" and smt_gxb_code='%s'", $tmodArr['sma_gxb_code']);
			foreach($twhereArr as $twhere)
			{
				$res = $YpwBase->get('stand_model_tj', ['group_concat(distinct smt_passenger) sma_passenger, group_concat(distinct smt_tran) sma_tran, group_concat(distinct smt_vtype) sma_vtype'], $twhere, true);
				if(!empty($res['data']))
				{
					$othArr = $res['data'];
					foreach(['sma_tran', 'sma_passenger','sma_vtype'] as $tf)
					{
						if(empty($tmodArr[$tf]) && !empty($othArr[$tf]))
						{
							$tval = [];
							foreach(explode(',', $othArr[$tf]) as $tv)
							{
								if(!empty($tv)) $tval[] = $tv;
							}
							$tval = array_unique($tval);
							if(count($tval) == 1) $tmodArr[$tf] = $tval[0];
						}
					}
				}
				if(!empty($tmodArr['sma_tran']) && !empty($tmodArr['sma_passenger']) && !empty($tmodArr['sma_vtype'])) break;
			}
		}
		return $tmodArr;
	}
	

	
	/**
	  * @method 根据规则继续填补缺失信息
	  * @author soul
	  * @copyrivinbaseht 2022/9/1
	  * @return
	  */
	private function fitSmaBaseData($tmodArr, $vin)
	{
		$isJinkou = !in_array(substr($vin, 0, 1), ['L', 'H'])? true: false;
		$YpwBase = new YpwBase();
		$vin1_8 = substr($vin, 0, 8);
		$twhere = sprintf(" and sgv_vin1_8='%s' and sgv_gxb_code='%s'", $vin1_8, $tmodArr['sma_gxb_code']);
		if($isJinkou) $twhere .= sprintf(" and (sgv_org_brand='%s' or sgv_org_brand='')", LibFc::Escape($tmodArr['sma_brand']));
		$res = $YpwBase->get('stand_gxb_v8info', ['sgv_brand sma_brand, sgv_ispxjk,sgv_model mod_name,sgv_country,sgv_company,sgv_drive mod_drive'], $twhere, true);
		if(!empty($res['data']))
		{
			$othArr = $res['data'];
			if(!empty($othArr['sma_brand']))
			{
				$tmodArr['sma_brand'] = $othArr['sma_brand'];
				if($isJinkou && $othArr['sma_brand'] != $tmodArr['sma_brand'] && !empty($tmodArr['sma_brand']))
					$tmodArr['sma_brand'] .= '('.$tmodArr['sma_brand'].')';
			}
			if(!empty($othArr['mod_name'])) $tmodArr['mod_name'] = $othArr['mod_name'];
			if(!empty($othArr['mod_drive'])) $tmodArr['mod_drive'] = $othArr['mod_drive'];
			if($othArr['sgv_ispxjk'] == 1) $tmodArr['jkfs'] = '平行进口';
			if(!empty($othArr['sgv_country'])) $tmodArr['country'] = $othArr['sgv_country'];
			if(!empty($othArr['sgv_company'])) $tmodArr['company'] = $othArr['sgv_company'];
		}

		$twhere = sprintf(" and smt_vin1_8='%s' and smt_gxb_code='%s'", $vin1_8, $tmodArr['sma_gxb_code']);
		if($isJinkou) $twhere .= sprintf(" and smt_brand='%s'", LibFc::Escape($tmodArr['sma_brand']));

		$tfiled = ['GROUP_CONCAT(DISTINCT smt_cc) sma_cc', 'GROUP_CONCAT(DISTINCT smt_passenger) sma_passenger', 'GROUP_CONCAT(DISTINCT smt_tran) sma_tran'];
		//无法确认功率类型
		if(isset($tmodArr['sma_kw'])) $tfiled[] = 'GROUP_CONCAT(DISTINCT smt_kw) sma_kw';
		$renullFileds = ['sma_kw', 'sma_cc', 'sma_passenger', 'sma_tran'];
		if($tmodArr['sma_engine'] != ''){
			$twhere .= sprintf(" and smt_engine='%s'", LibFc::Escape($tmodArr['sma_engine']));
		}else{
			$renullFileds[] = 'sma_engine';
			$tfiled[] = 'GROUP_CONCAT(DISTINCT smt_engine) sma_engine';
		}
		$res = $YpwBase->get('stand_model_tj', $tfiled, $twhere.' group by smt_vin1_8, smt_gxb_code', true);
		if(!empty($res['data']))
		{
			$othArr = $res['data'];
			foreach($renullFileds as $filed)
			{
				if(empty($tmodArr[$filed]) && !empty($othArr[$filed]))
				{
					$tvals = [];
					foreach(explode(',', $othArr[$filed]) as $tvv)
					{
						if(!empty($tvv) && !in_array($tvv, ['_', '-', '/', ';', '无']))
						{
							$tvals[] = $tvv;
						}
					}
					if(!empty($tvals))
					{
						$tvals = array_unique($tvals);
						sort($tvals);
						$tmodArr[$filed] = implode(',', $tvals);
					}
				}
			}
		}
		return $tmodArr;
	}


	
	/**
	  * @method 600万表中精准解码VIN（VIN存在600中）
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyrivinbaseht 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByAnyMatch($vin)
	{
		$YpwBase = new YpwBase();
		$M3IdArr = [];
		if($this->fullMatchFrom === null) $this->getOnlyMatchVin($vin);
		
		//第一次解码 无精准数据，是否启用泽达
		if(empty($this->fullMatchFrom) && $this->decodeCount === 1)
		{
			$ares = $this->getGetZedaApi($vin);
			if($ares['data']['iszd'] === 1)
			{
				$this->decodeCount++;
				return $this->getYpcModelByAnyMatch($vin);
			}
		}
		
		if(!empty($this->fullMatchFrom))
		{
			foreach($this->fullMatchFrom as $sk=>$sv)
			{
				$res = $this->jsVinSmaNullData($sv);
				$this->fullMatchFrom[$sk] = $res['data'];
			}
		}
		if(!empty($this->fullMatchFrom))
		{
			$res = $this->getYpcModelByAnyRows($vin, $this->fullMatchFrom);
			$M3IdArr = $res['data'];
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	/**
	  * @method 600万表中找到的数据和宜配车型比较
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getYpcModelByAnyRows($vin, $rowArr)
	{
		$M3IdArr = [];
		if(empty($rowArr)) return LibFc::ReturnData(true, $M3IdArr);
		foreach($rowArr as $gv)
		{
			$gv['sma_engine_format'] = LibFc::FormatEng($gv['sma_engine']);
			$filed = ['m1_b_id b_id,m3_id, group_concat(distinct m3s_length) `length`, group_concat(distinct m3s_width) `width`, group_concat(distinct m3s_height) `height`, m3_wheel, m3_weight,m3_engine, m3_engine_format,m3_cc,m3_kw,m3_start_year, m3_start_month, m3_end_year, m3_end_month'];
			$modArr = [];
			$comfileds = ['engine', 'enginekwcc', 'length', 'width', 'height', 'weight'];
			if(!empty($gv['sma_gxb_code']))
			{//有型号
				//前8位+型号符合 
				$table = 'yp_model3_gxb_num 
				join yp_model3 on mg_m3_id = m3_id 
				join yp_model2 on m3_m2_id = m2_id
				join yp_model1 on m2_m1_id = m1_id
				left join yp_model3_size on m3s_m3_id = m3_id';
				$res = $this->get($table, $filed, sprintf(" AND (m3_id in (SELECT DISTINCT vm3_m3_id FROM yp_vin_model3_link JOIN yp_vin ON vm3_vin_id =vin_id WHERE vin_full='%s') or m3_id not in (SELECT distinct vm3_m3_id FROM yp_vin_model3_link)) AND mg_code = '%s' group by m3_id", $this->vinBase['v1_8'], $gv['sma_gxb_code']));
				if(!empty($res['data'])){
					$modArr = $res['data'];
				}else{
					$whereArr = [];
					//原始600w记录中进口型号乱，优先前8
					if($this->vinBase['isJinkou'] && $this->vinBase['year'] <= 2017 && !empty($gv['sma_vin'])){
						$YpwBase = new YpwBase();
						$chk = $YpwBase->Get('stand_model_any', ['sma_from'], sprintf(" and sma_vin = '%s' limit 1", $gv['sma_vin']), true);
						if($chk['data']['sma_from'] == 'org'){
							$whereArr['s1'] = sprintf(" AND vin_full='%s' group by m3_id", $this->vinBase['v1_8']);
						}
					}
					//前8位不符合但是只有一条车型
					$whereArr['s2'] = sprintf(" AND mg_code = '%s' group by m3_id", $gv['sma_gxb_code']);
					foreach($whereArr as $k=>$where)
					{
						if($k == 's1'){//原始600w记录中进口型号乱，优先前8
							$table = 'yp_model3
							join yp_model2 on m3_m2_id = m2_id
							join yp_model1 on m2_m1_id = m1_id
							left join yp_model3_size on m3s_m3_id = m3_id 
							join yp_vin_model3_link on vm3_m3_id = m3_id 
							join yp_vin on vm3_vin_id =vin_id';
						}else{
							$table = 'yp_model3_gxb_num 
							join yp_model3 on mg_m3_id = m3_id 
							join yp_model2 on m3_m2_id = m2_id
							join yp_model1 on m2_m1_id = m1_id
							left join yp_model3_size on m3s_m3_id = m3_id 
							join yp_vin_model3_link on vm3_m3_id = m3_id 
							join yp_vin on vm3_vin_id =vin_id';
						}

						$res = $this->get($table, $filed, $where);
						//前8位符合 或者 前8位不符合但是只有一条车型
						if(!empty($res['data']) && (
							$k == 's1' || 
							($k == 's2' && count($res['data']) == 1)
						  )
						)
						{
							$modArr = $res['data'];
							break;
						}
					}
				}

				//底盘型号反查
				if(empty($modArr))
				{
					$YpwBase = new YpwBase();
					$res = $YpwBase->Get('gxb_base JOIN gxb_dipan ON gb_id = gd_gb_id and gb_type="gxb"', ['distinct gd_dpgxb_code dpgxb_code'], sprintf(" and gb_gxb_code = '%s' and gd_dpgxb_code != '%s'", $gv['sma_gxb_code'], $gv['sma_gxb_code']));
					if(!empty($res['data']))
					{
						$res = $this->get($table, $filed, sprintf(" AND mg_code in ('%s') group by m3_id", implode("','", array_column($res['data'], 'dpgxb_code'))));
						$modArr = $res['data'];
					}
				}
			}
			
			if(empty($modArr) && $this->vinBase['isJinkou'] && $gv['sma_engine_format'] != '')
			{//进口 V8+发动机+kw+cc
				$table = 'yp_model3
				join yp_model2 on m3_m2_id = m2_id
				join yp_model1 on m2_m1_id = m1_id
				left join yp_model3_size on m3s_m3_id = m3_id 
				join yp_vin_model3_link on vm3_m3_id = m3_id 
				join yp_vin on vm3_vin_id =vin_id';
				$comfileds = ['engine', 'kw', 'cc', 'length', 'width', 'height', 'weight'];
				$where = sprintf(" AND vin_full='%s' AND m3_engine_format like '%s%%' group by m3_id", $this->vinBase['v1_8'], LibFc::Escape($gv['sma_engine_format']));
				$res = $this->get($table, $filed, $where);
				$modArr = $res['data'];
			}
			foreach($modArr as $mk=>$mv)
			{
				foreach(['length','width','height'] as $sf){
					$mv['m3s_'.$sf] = [];
					if(!empty($mv[$sf])){
						foreach(explode(',', $mv[$sf]) as $sv){
							if(!empty($sv)) $mv['m3s_'.$sf][] = $sv;
						}
					}
				}

				$mv['m3_engine_fs'] = [];
				if(stripos($mv['m3_engine'], ';')){//LHGFE3661P2097884 多发动机
					foreach(explode(';', $mv['m3_engine']) as $te){
						$te = LibFc::FormatNum($te);
						if(!empty($te)) $mv['m3_engine_fs'][] = $te;
					}
				}else if(!empty($mv['m3_engine_format'])){
					$mv['m3_engine_fs'][] = $mv['m3_engine_format'];
				}
				$modArr[$mk] = $mv;
			}
			
			//过滤车型 排量轴距存在则必须相同  发动机多种名称，或者大众3位和4位
			foreach(['cc','wheel'] as $comfiled)
			{
				foreach($modArr as $mk=>$mv)
				{
					if($comfiled == 'cc' && !empty($mv['m3_cc']) && !empty($gv['sma_cc']) && abs((int)$mv['m3_cc'] - (int)$gv['sma_cc']) > 2)
					{//L6T7944Z7FN007707 允许容差1~2
						unset($modArr[$mk]);
						continue;
					}
					if($comfiled == 'wheel' && !empty($mv['m3_wheel']) && !empty($gv['sma_wheel']) && $mv['m3_wheel'] != $gv['sma_wheel'])
					{
						unset($modArr[$mk]);
						continue;
					}
				}
			}
			
			if(!empty($modArr))
			{//过滤车型保留最后一条
				foreach($comfileds as $comfiled)
				{
					if(count($modArr) == 1) break;
					$lastModArr = $modArr;
					foreach($modArr as $mk=>$mv)
					{
						if(in_array($comfiled, ['engine', 'enginekwcc']) && !empty($mv['m3_engine']) && $gv['sma_engine'] != '')
						{
							//大众系列3位 或者4位
							if(in_array($mv['b_id'], [6,19,20,94,137]) && strlen($mv['m3_engine_format']) > 2 && strlen($gv['sma_engine_format']) > 2 && (stripos($mv['m3_engine_format'], $gv['sma_engine_format']) === 0 || stripos($gv['sma_engine_format'], $mv['m3_engine_format']) === 0) || in_array($gv['sma_engine_format'], $mv['m3_engine_fs'])){
							}else if($mv['m3_engine_format'] != $gv['sma_engine_format']){
								if($comfiled == 'enginekwcc'){
									if(//发动机不一样但是功率排量一样，不过滤
										(!empty($mv['m3_cc']) && !empty($gv['sma_cc']) && abs($mv['m3_cc'] - $gv['sma_cc']) <= 2) &&
										(!empty($mv['m3_kw']) && !empty($gv['sma_kw']) && $mv['m3_kw'] != $gv['sma_kw'])
									){}else
									{
										unset($modArr[$mk]);
										continue;
									}
								}else{
									unset($modArr[$mk]);
									continue;
								}
								
							}
						}

						if($comfiled == 'kw' && !empty($mv['m3_kw']) && !empty($gv['sma_kw']) && $mv['m3_kw'] != $gv['sma_kw'])
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'cc' && !empty($mv['m3_cc']) && !empty($gv['sma_cc']) && abs($mv['m3_cc'] - $gv['sma_cc']) > 2)
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'length' && !empty($mv['m3s_length']) && !empty($gv['sma_length']) && !in_array($gv['sma_length'], $mv['m3s_length']))
						{//LH16CHAL7DH090618
							unset($modArr[$mk]);
							continue;
						}
						if($comfiled == 'width' && !empty($mv['m3s_width']) && !empty($gv['sma_width']) && !in_array($gv['sma_width'], $mv['m3s_width']))
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'height' && !empty($mv['m3s_height']) && !empty($gv['sma_height']) && !in_array($gv['sma_height'], $mv['m3s_height']))
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'wheel' && !empty($mv['m3_wheel']) && !empty($gv['sma_wheel']) && $mv['m3_wheel'] != $gv['sma_wheel'])
						{
							unset($modArr[$mk]);
							continue;
						}

						if($comfiled == 'weight' && !empty($mv['m3_weight']) && !empty($gv['sma_weight']) && $mv['m3_weight'] != $gv['sma_weight'])
						{
							unset($modArr[$mk]);
							continue;
						}
					}
					$modArr = empty($modArr)? $lastModArr : $modArr;
				}
			}
			$M3IdArr = array_unique(array_merge($M3IdArr, array_column($modArr, 'm3_id')));
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}


	
	/**
	  * @method 原厂VIN与600万表的相邻VIN过滤，同一方向取最小
	  * @param  $modArr 宜配车型数据，必须含有年月字段  [
			['m3_id'=>1, 'm3_start_year'=>'', 'm3_end_year'=>...]...
		]
	  * @param  $hasYmArr 制造日期的数据 [2014-09, 2014...]
	  * @author soul
	  * @copyright 2016/3/30
	  * @return ['my'=>[], 'any'=>[]]
	  */
	private function filterBuildDate($modArr, $buildDateArr)
	{
		$hasYmArr = [];
		foreach($buildDateArr as $dv)
		{
			$dv = str_replace('-', '', $dv);
			if(strlen($dv) >= 4)
			{
				$ty = substr($dv, 0, 4);
				$tym = strlen($dv) >= 6? substr($dv, 0, 6): 0;
				$hasYmArr[$ty.'@'.$tym] = [
					'year'=>$ty,
					'yearm'=>$tym
				];
			}
		}
		if(empty($hasYmArr)) return LibFc::ReturnData(true, $modArr);

		$lastModArr = $modArr;
		foreach($modArr as $mk=>$mv)
		{
			$isMatch = true;
			foreach($hasYmArr as $gv)
			{
				//是否在时间范围内
				if(strlen($mv['m3_start_year']) == strlen($gv['year']))
				{
					if($gv['year'] < $mv['m3_start_year'] || ($gv['year'] > $mv['m3_end_year'] && !empty($mv['m3_end_year'])))
					{
						$isMatch = false;
						continue;
					}

					//比较月份
					if(!empty($gv['yearm']) && (!empty($mv['m3_start_month']) || !empty($mv['m3_end_month'])))
					{
						if(!empty($mv['m3_start_month']) && $gv['yearm'] < (int) $mv['m3_start_year'].$mv['m3_start_month'] )
						{
							$isMatch = false;
							continue;
						}

						if(!empty($mv['m3_end_month']) && $gv['yearm'] > (int) $mv['m3_end_year'].$mv['m3_end_month'] )
						{
							$isMatch = false;
							continue;
						}
					}
				}
				if($isMatch) break;	
			}	
			if(!$isMatch) unset($modArr[$mk]);
		}

		//过滤到最后无车型，回滚上一步结果
		if(empty($modArr))
		{
			//取距离最近的车型
			$modArr = $lastModArr;
			$minAbs = ['y'=>null, 'ym'=>null];
			foreach($modArr as $mk=>$mv)
			{
				$mv['y'] = null;	
				$mv['ym'] = null;	
				foreach($hasYmArr as $gv)
				{
					if(strlen($mv['m3_start_year']) == strlen($gv['year']))
					{
						$t = abs($gv['year']-$mv['m3_start_year']);
						$mv['y'] = $mv['y'] === null || $mv['y'] > $t? $t: $mv['y'];

						if(strlen($mv['m3_end_year']) == strlen($gv['year']))
						{
							$t = abs($gv['year']-$mv['m3_end_year']);
							$mv['y'] = $mv['y'] === null || $mv['y'] > $t? $t: $mv['y'];
						}
						
						//月份
						if(!empty($gv['yearm']))
						{
							if(!empty($mv['m3_start_month']))
							{
								$mv['yearm'] = (int) $mv['m3_start_year'].$mv['m3_start_month'];
								$t = abs($gv['yearm']-$mv['yearm']);
								$mv['ym'] = $mv['ym'] === null || $mv['ym'] > $t? $t: $mv['ym'];
							}

							if(!empty($mv['m3_end_month']))
							{
								$mv['yearm'] = (int) $mv['m3_end_year'].$mv['m3_end_month'];
								$t = abs($gv['yearm']-$mv['yearm']);
								$mv['ym'] = $mv['ym'] === null || $mv['ym'] > $t? $t: $mv['ym'];
							}
						}
					}
				}
				$minAbs['y'] = $minAbs['y'] === null || ($mv['y'] !== null && $minAbs['y'] > $mv['y'])? $mv['y']: $minAbs['y'];
				$minAbs['ym'] = $minAbs['ym'] === null || ($mv['ym'] !== null && $minAbs['ym'] > $mv['ym'])? $mv['ym']: $minAbs['ym'];
				$modArr[$mk] = $mv;
			}
			
			foreach($modArr as $mk=>$mv)
			{
				//有年月比较
				if( ($minAbs['ym'] !== null && ($minAbs['ym'] === $mv['ym'] || $mv['ym'] === null)) ||  ($minAbs['ym'] === null && ($mv['y'] === $minAbs['y'] || $mv['y'] === null))  )
				{}
				else 
				{
					unset($modArr[$mk]);
				}
			}
		}
		return LibFc::ReturnData(true, $modArr);	
	}

	/**
	  * @method 600万表中精准解码VIN（VIN存在600中）
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyrivinbaseht 2016/3/30
	  * @return 
	  */
	public function getOnlyMatchVin($vin, $type = '')
	{
		$YpwBase = new YpwBase();
		$vin1_8 = substr($vin, 0, 8);
		$vin10_12 = substr($vin, 9, 3);
		$vin13_17 = substr($vin, 12, 5);
		$filedArr = ['sma_vin,sma_brand,sma_gxb_code_show,sma_gxb_code,sma_engine,sma_kw,sma_cc,sma_length,sma_width,sma_height,sma_wheel,sma_weight,sma_passenger,sma_year,sma_vtype,sma_xuhang,sma_jkyear,sma_tran'];
		$res = $YpwBase->Get('stand_model_any', $filedArr, sprintf(" AND sma_vin='%s'", $vin));
		$this->fullMatchFrom = $res['data'];

		//第一次解码 无精准数据，是否启用VIN图片ocr
		if(empty($this->fullMatchFrom) && mvc::$cfg['DECODE_OCR']['statue'] && $this->decodeCount === 1 && $type != 'onlydate')
		{
			$res = $YpwBase->get('stand_model_any_ocr', $filedArr, sprintf(" and sma_vin='%s' and sma_etime > %d order by sma_id desc limit 1", $vin, time()-mvc::$cfg['DECODE_OCR']['cachetime']));
			if(!empty($res['data']))
			{
				$this->fullMatchFrom = $res['data'];
			}
			else
			{
				$YpwVinImg = new YpwVinImg();
				$res = $YpwVinImg->getImgOcrSma($vin, 3, true);
				if(!empty($res['data']))
				{
					$ocrSma = $res['data'];
					$row = [];
					foreach($filedArr as $filed)
					{
						if(isset($ocrSma[$filed])){
							$row[$filed] = $ocrSma[$filed];
						}else if(in_array($filed, ['sma_length','sma_width','sma_height','sma_wheel','sma_weight','sma_passenger'])) {
							$row[$filed] = 0;
						}else{
							$row[$filed] = '';
						}
					}
					$this->fullMatchFrom = [$row];
				}
			}
		}
		foreach($this->fullMatchFrom as $k=>$v){
			$this->fullMatchFrom[$k] = $this->fitDataFromSmaTj($v);
		}
		return LibFc::ReturnData(true, $this->fullMatchFrom);
	}

	
	/**
	  * @method 600万表中找相邻的VIN
	  * @param  $vin  17位车架号
	  * @param  $setImg true|false  默认true 多型号时是否设置对应图片为多型号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> [宜配车型库末级的ID数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function getAnyXinanglinVin($vin)
	{
		$arr =['S'=>[],'X'=>[]];
		$YpwBase = new YpwBase();
		$vin1_8 = substr($vin, 0, 8);
		$vin10_12 = substr($vin, 9, 3);
		$vin13_17 = substr($vin, 12, 5);
		$vin10_11 = substr($vin, 9, 2);
		$vin12_17 = substr($vin, 11, 6);
		$gxbCodeArr = [];
		$twhere = sprintf(" AND sma_vin1_8 ='%s'", $vin1_8);
		
		$filedArr = ['sma_vin,sma_brand,sma_gxb_code_show,sma_gxb_code,sma_engine,sma_kw,sma_cc,sma_length,sma_width,sma_height,sma_wheel,sma_weight,sma_passenger,sma_year,sma_vtype,sma_xuhang,sma_jkyear,sma_tran,sma_vin13_17 as vin_end'];
		$where = $twhere.sprintf(" and sma_vin10_12 ='%s' and sma_vin13_17 <= '%s' ORDER BY sma_vin13_17 DESC LIMIT 1", $vin10_12, $vin13_17);
		$res = $YpwBase->Get('stand_model_any', $filedArr, $where, true);
		$arr['X'] = $res['data'];

		$where = $twhere.sprintf(" and sma_vin10_12 ='%s' and sma_vin13_17 > '%s' ORDER BY sma_vin13_17 ASC LIMIT 1", $vin10_12, $vin13_17);
		$res = $YpwBase->Get('stand_model_any', $filedArr, $where, true);
		$arr['S'] = $res['data'];
		
		$filedArr = ['sma_vin,sma_brand,sma_gxb_code_show,sma_gxb_code,sma_engine,sma_kw,sma_cc,sma_length,sma_width,sma_height,sma_wheel,sma_weight,sma_passenger,sma_year,sma_vtype,sma_xuhang,sma_jkyear,sma_tran,sma_vin12_17 as vin_end'];
		if(empty($arr['X']))
		{
			$where = $twhere.sprintf(" and sma_vin10_11 = '%s' and sma_vin12_17 <= '%s' ORDER BY sma_vin12_17 DESC LIMIT 1", $vin10_11, $vin12_17);
			$res = $YpwBase->Get('stand_model_any', $filedArr, $where, true);
			$arr['X'] = $res['data'];
		}
		if(empty($arr['S']))
		{
			$where = $twhere.sprintf(" and sma_vin10_11 = '%s' and sma_vin12_17 > '%s' ORDER BY sma_vin12_17 ASC LIMIT 1", $vin10_11, $vin12_17);
			$res = $YpwBase->Get('stand_model_any', $filedArr, $where, true);
			$arr['S'] = $res['data'];
		}

		$isJinkou = !in_array(substr($vin, 0, 1), ['L', 'H'])? true: false;
		if(empty($this->fullMatchFrom) && $isJinkou && mvc::$cfg['DECODE_OCR']['statue'] && $this->decodeCount === 1)
		{//进口 无精准数据进行第二次OCR（发动机型号），是否启用VIN图片ocr
			$res = $YpwBase->get('stand_model_any_ocrjk', ['sma_vin', 'sma_engine', 'sma_cc', 'sma_kw', 'sma_passenger'], sprintf(" and sma_vin='%s' and sma_etime > %d order by sma_id desc limit 1", $vin, time()-mvc::$cfg['DECODE_OCR']['cachetime']), true);
			if(!empty($res['data'])){
				$this->jkocr = $res['data'];
			}else{
				$YpwVinImg = new YpwVinImg();
				$res = $YpwVinImg->getImgOcrsmaNoGxb($vin, 3);
				if(!empty($res['data'])) $this->jkocr = $res['data'];
			}
		}

		$this->xiangLinFromAny = [];
		foreach($arr as $sv)
		{
			if(!empty($sv['sma_vin']))
			{
				if(!empty($this->jkocr)){
					$ismatch = true;
					foreach($this->jkocr as $jk=>$jv){
						if($jv != ''){
							if(empty($sv[$jk])){
								$sv[$jk] = $jv;
							}else if($sv[$jk] != $jv && in_array($jk, ['sma_engine', 'sma_cc'])){
								$ismatch = false;
								break;
							}
						}
					}
					if(!$ismatch) continue;
				}
				$sv = $this->fitDataFromSmaTj($sv);
				$res = $this->jsVinSmaNullData($sv);
				$this->xiangLinFromAny[] = $res['data'];
			}
		}
		return LibFc::ReturnData(true, $arr);
	}


	/**
	  * @method 原厂VIN与600万表的相邻VIN过滤，同一方向取最小
	  * @param  $vin  17位车架号
	  * @param  $vinMinArr 相邻的vin  ['my'=>[], 'any'=>[]]
	  * @author soul
	  * @copyright 2016/3/30
	  * @return ['my'=>[], 'any'=>[]]
	  */
	private function filterXinanglinVin($vin, $vinMinArr)
	{
		$arr = ['my'=>[], 'any'=>[]];
		foreach($vinMinArr as $t=>$vArr)
		{
			foreach($vArr as $kk=>$vv)
			{
				if(isset($vv['vin_end']))
					$vinMinArr[$t][$kk]['abs'] = abs((int)substr($vin, -strlen($vv['vin_end'])) - (int) $vv['vin_end']);
			}
		}
		//取最小
		$tArr = ['X', 'S'];
		foreach($tArr as $fx)
		{
			if(!empty($vinMinArr['my'][$fx]) && !empty($vinMinArr['any'][$fx]))
			{
				if($vinMinArr['my'][$fx]['abs'] <= $vinMinArr['any'][$fx]['abs'])
				{
					$arr['my'][] = $vinMinArr['my'][$fx];
				}
				else
				{
					$arr['any'][] = $vinMinArr['any'][$fx];
				}
			}
			else if(!empty($vinMinArr['my'][$fx]))
			{
				$arr['my'][] = $vinMinArr['my'][$fx];
			}
			else if(!empty($vinMinArr['my'][$fx]))
			{
				$arr['any'][] = $vinMinArr['any'][$fx];
			}
		}
		return LibFc::ReturnData(true, $arr);
	}


	/**
	  * @method 通过VIN 行驶证整车型号 解码VIN
	  * @param  $vin               string [必填] 17位车架号 或者 车型代码
	  * @param  $makeNo            string [必填] 整车型号
	  * @author soul
	  * @copyright 2019/6/11
	  * @return 
	  */
	public function getYpcModelByVinMakeNo($vin, $makeNo)
	{
		//品牌型号 比亚迪牌BYD7150A3 || BMW7154AD
		$M3IdArr = [];
		$vin = LibFc::FormatVin($vin);
		$makeNoArr = LibFc::FormatMakeNo($makeNo);
		if(strlen($makeNoArr['makeno']) < 2) return LibFc::ReturnData(false, '请提供正确的整车型号！');
		if(strlen($vin) < 17)  return LibFc::ReturnData(false, '请提供正确的车架号！');
		
		
		$vin1_8 = substr($vin, 0, 8);
		$table = 'yp_model3_gxb_num  JOIN yp_vin_model3_link ON vm3_m3_id=mg_m3_id JOIN yp_vin ON vin_id= vm3_vin_id ';
		$res = $this->get($table, ['distinct mg_m3_id'], sprintf(" AND vin_full = '%s' AND mg_code = '%s'", LibFc::Escape($vin1_8), LibFc::Escape($makeNoArr['makeno'])));
		if(!empty($res['data']))
			$M3IdArr = array_column($res['data'], 'mg_m3_id');

		//收集数据
		$collArr = [
			'vim_vin'=>$vin,	
			'vim_makeno'=>$makeNoArr['makeno']
		];
		$YpwBase = new YpwBase();
		$where = sprintf(" and vim_vin='%s' and vim_makeno = '%s' limit 1", LibFc::Escape($vin), LibFc::Escape($makeNoArr['makeno']));
		$res = $YpwBase->Get('ypc_vin_makeno', ['vim_id'], $where, true);
		if(empty($res['data']))
		{
			$YpwBase->Add('ypc_vin_makeno', $collArr);
		}
		return LibFc::ReturnData(true, $M3IdArr);
	}
	



	
	/**
	  * @method oem解码
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> ] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function decodeByOem($vin)
	{
		$OEMCOF = include(mvc::$cfg['AUTOLOAD']['Ypc']['path'].'config/oem.config.php');
		$brandName = '';
		$Year = LibFc::VinYear(substr($vin, 9, 1));
		$vin3 = substr($vin, 0, 3);
		$vin8 = substr($vin, 0, 8);
		$vin48 = substr($vin, 3, 5);
		$vin11 = substr($vin, 10, 1);
		$vin12 = substr($vin, 11, 1);

		//原厂商
		$OemModelArr = array();
		$OemBase = new OemBase();
		$TT = array();
		foreach($OEMCOF as $K=>$V)
		{
			foreach($V['makes'] as $VV)
			{
				$OEMMAKE[strtoupper($VV)][] = $K;
				$TT[] = sprintf("'%s'", $VV);
			}
		}
		//LJ  > 2010
		$Res = $OemBase->get('vin3_make', array('vm_make', 'vm_make_cn'), sprintf(" AND vm_vin3='%s' AND vm_make IN (%s) GROUP BY vm_make", $vin3, implode(',', $TT)));
		if(empty($Res['data'])) return LibFc::ReturnData(true, $returnArr);

		//找到的品牌
		$WMIArr = array();
		$MCArr = array();
		foreach($Res['data'] as $V)
		{
			foreach($OEMMAKE[strtoupper($V['vm_make'])] as $MC)
			{
				if(isset($MCArr[$MC])) continue;
				$MCArr[$MC] = $V;
			}
		}

		foreach($MCArr as $MC=>$MArr)
		{
			$LabelArr = array();
			$OemModelArr = array();
			//去对应的原厂表取数据
			$Conf = $OEMCOF[$MC];
			$OemShowArr = $Conf['cn'];
			$Where = '';
			$GetModelArr = [];
			switch($MC)
			{
				case 'audi':
				case 'bmw':
					$Res = $this->getReplaceVin($MC, $vin);
					$CodeArr = $Res['data'];
					if(!empty($CodeArr))
					{
						foreach($CodeArr as $KT=>$BC)
						{
							$CodeArr[$KT] = sprintf("'%s'", $BC);
						}
						$Where = sprintf(" %s AND vin_code IN (%s)",$Where, implode(',', $CodeArr));
					}
				break;
				case 'benz':
					$Res = $this->getBenzCodeByVin($vin);
					$CodeArr = $Res['data'];
					if(!empty($CodeArr))
					{
						if(substr($vin, 3, 2) == 'LJ')
						{
							foreach($CodeArr as $KT=>$BC)
							{
								if($Year >= 2010 && stripos($BC, '208') === 0)
								{
									unset($CodeArr[$KT]);
								}
								else if($Year >= 1900 && $Year < 2010 && stripos($BC, '218') === 0)
								{
									unset($CodeArr[$KT]);
								}
							}
						}
						foreach($CodeArr as $KT=>$BC)
						{
							$CodeArr[$KT] = sprintf("'%s'", $BC);
						}
						$Where = sprintf(" %s AND vin_code IN (%s)",$Where, implode(',', $CodeArr));
					}
					if(strlen($vin) >= 9 && LibFc::Int(substr($vin, 3, 6)) !== false)
					{
						$Year = 0;
					}
				break;
				case 'toyota':
					$Where = !empty($Res['data']) ? sprintf(" %s AND VIN3='%s' AND vin_code IN ('%s','%s')",$Where, $vin3, substr($vin, 3, 5), substr($vin, 3, 6)) : '';
					if(strlen($vin) >= 9 && LibFc::Int(substr($vin, 3, 6)) !== false)
					{
						$Year = 0;
					}
				break;
				case 'volvo':
					//45位》78位》7位
					$Res = $this->getVolvoVds($vin);
					if(!empty($Res['data']))
					{
						$TT  = array();
						foreach($Res['data'] as $VV)
						{
							$TT[] = sprintf("'%s'", $VV);
						}
						$Where = sprintf(" AND m1_name IN (%s)  AND engine_code IN ('%s', '%s')", implode(',', $TT), substr($vin, 5, 2), substr($vin, 3, 2));
					}
				break;
				case 'land_rover':
					//逐位判断 45=>4=>5=>6=>7=>8
					$TempArr = array();
					$LocArr = array(
						45=>substr($vin, 3, 2),
						4=>substr($vin, 3, 1),
						5=>substr($vin, 4, 1),
						6=>substr($vin, 5, 1),
						7=>substr($vin, 6, 1),
						8=>substr($vin, 7, 1),
						9=>substr($vin, 8, 1)
					);
					$WhereArr = array();
					foreach($LocArr as $KK=>$VV)
					{
						$WhereArr[] = sprintf("(vin_location = '%s' AND vin_val='%s')", $KK, $VV);
					}
					$FiledArr = array('group_id', 'start_year', 'end_year', 'vin_location', 'vin_val', 'engcode','label_cn as label', 'val_cn as val');
					$Res = $OemBase->get('vin_'.$MC, $FiledArr, sprintf(" AND (%s) ORDER BY group_id, vin_location, start_year", implode(" OR ", $WhereArr)));
					foreach($Res['data'] as $VV)
					{
						$TempArr[$VV['group_id']][$VV['vin_location'].'@'.$VV['vin_val']][] = $VV;
					}

					$FitterArr = array();
					foreach($TempArr as $Gid=>$VV)
					{
						$TT = array();
						if(!empty($VV['45@'.$LocArr[45]]))
						{
							$TT[] = $VV['45@'.$LocArr[45]][0];
						}
						else if (!empty($VV['4@'.$LocArr[4]]) && !empty($VV['5@'.$LocArr[5]]))
						{
							$TT[] = $VV['4@'.$LocArr[4]][0];
							$TT[] = $VV['5@'.$LocArr[5]][0];
						}
						if(empty($TT)) continue;
						$TT['start_year'] = $TT[0]['start_year'];
						$TT['end_year'] = $TT[0]['end_year'];

						if(empty($VV['6@'.$LocArr[6]]) || empty($VV['7@'.$LocArr[7]]) || empty($VV['8@'.$LocArr[8]])) continue;

						$NotOk = array();
						for($I = 6; $I < 10; $I++)
						{
							if(is_array($VV[$I.'@'.$LocArr[$I]])){
								if(count($VV[$I.'@'.$LocArr[$I]]) == 1)
								{
									$TT[] = $VV[$I.'@'.$LocArr[$I]][0];

								}
								else if(count($VV[$I.'@'.$LocArr[$I]]) > 1)
								{
									$NotOk[$I] = $VV[$I.'@'.$LocArr[$I]];
								}
							}
						}

						//再次确认两个及以上的参数值
						foreach($NotOk as $Loc=>$VVV)
						{
							$Ok = -1;
							$Zuijin = 0;
							if($Year > 0)
							{//通过年份判断 SALVD1BG0F SALMA11406
								$I = 0;
								$Diff === null;
								foreach($VVV as $KKKK=>$VVVV)
								{
									$Bdiff = abs($VVVV['start_year']-$Year);
									$Ediff = abs($VVVV['end_year']-$Year);
									$VVVV['y_diff'] = $Bdiff > $Ediff? $Ediff: $Bdiff;
									if($Diff === null || $Diff > $VVVV['y_diff'])
									{
										$Diff =  $VVVV['y_diff'];
										$Zuijin = $KKKK;
									}

									if($Year >= $VVVV['start_year'] && ($Year <= $VVVV['end_year'] || $VVVV['end_year'] == 0))
									{
										$Ok = $KKKK;
										$I++;
									}
								}
								if($I != 1) $Ok = -1;
							}

							$EngLoc = in_array($VV['7@'.$LocArr[7]][0]['label'], array('Engine', '发动机信息')) ? 7: 8;
							if($Ok == -1)
							{//通过发动机判别 SALLMAM34  SALLMAMH3
								foreach($VVV as $KKKK=>$VVVV)
								{
									if(in_array($LocArr[$EngLoc], explode(',', $VVVV['engcode']) ) )
									{
										$Ok = $KKKK;
										break;
									}
								}
							}
							$Ok = $Ok == -1? $Zuijin: $Ok;
							$TT['start_year'] = $VVV[$Ok]['start_year'];
							$TT['end_year'] = $VVV[$Ok]['end_year'];
							$TT[] = $VVV[$Ok];
						}
						$FitterArr[] = $TT;
					}
					$FitterArr = $this->filterYear($FitterArr, $Year);

					//整理输出数据
					foreach($FitterArr as $VV)
					{
						$TT = array('品牌'=>$MArr['vm_make_cn'], '年份'=>$VV['vin_year']);
						$brandName = empty($brandName)? $MArr['vm_make']: $brandName;
						foreach($VV as $VVV)
						{
							if(!is_array($VVV)) continue;
							$TT[$VVV['label']] = $VVV['val'];
						}
						foreach($TT as $KKK=>$VVV)
						{
							$LabelArr[$KKK] = $KKK;
						}
						$TT['make_name'] = $MArr['vm_make'];
						$OemModelArr[] = $TT;

					}
				break;
				case 'cadillac':
					$Where = sprintf(" AND vin_48 ='%s'", substr($vin, 3, 5));
				break;
				case 'subaru':
					//逐位判断 1-3=>4=>5=>6=>7=>8
					$TempArr = array();
					$LocArr = array(
						4=>substr($vin, 3, 1),
						5=>substr($vin, 4, 1),
						6=>substr($vin, 5, 1),
						7=>substr($vin, 6, 1),
						8=>substr($vin, 7, 1),
						9=>substr($vin, 8, 1),
						11=>substr($vin, 10, 1),
					);
					$WhereArr = array();
					foreach($LocArr as $KK=>$VV)
					{
						$WhereArr[] = sprintf("(vin_location = '%s' AND vin_val='%s')", $KK, $VV);
					}
					$FiledArr = array('group_id', 'start_year', 'end_year', 'vin_location', 'vin_val');
					$FiledArr = $langId > 1 ? array_merge($FiledArr, array('label', 'val')):  array_merge($FiledArr, array('label_cn as label', 'val_cn as val'));
					$Res = $OemBase->get('vin_'.$MC, $FiledArr, sprintf(" AND wmi LIKE '%%%s%%' AND (%s) ORDER BY group_id, vin_location, start_year",$vin3, implode(" OR ", $WhereArr)));
					if(empty($Res['data'])) break;
					foreach($Res['data'] as $VV)
					{
						$TempArr[$VV['group_id']][$VV['vin_location']][] = $VV;
					}
					$GroupLocArr = array();
					$Res = $OemBase->get('vin_'.$MC, array('group_id', 'vin_location'), sprintf(" AND group_id IN (%s) ORDER BY group_id, vin_location", implode(',', array_keys($TempArr))));
					foreach($Res['data'] as $VV)
					{
						$GroupLocArr[$VV['group_id']][$VV['vin_location']] = $VV['vin_location'];
					}
					$FitterArr = array();
					foreach($TempArr as $Gid=>$VV)
					{
						$TT = array();
						$NotOk = array();
						$Ok = true;
						foreach($GroupLocArr[$Gid] as $Loc)
						{
							//if(empty($VV[$Loc]) && $LocArr[$Loc] != '*' && $Loc != 11)
							if(empty($VV[$Loc]) && $LocArr[$Loc] != '*')
							{
								$Ok = false;
								break;
							}
							if(count($VV[$Loc]) == 1)
							{
								$TT[] = $VV[$Loc][0];
							}
							else if(count($VV[$Loc]) > 1)
							{
								$NotOk[$Loc] = $VV[$Loc];
							}
						}
						if(!$Ok) continue;

						$TT['start_year'] = $TT[0]['start_year'];
						$TT['end_year'] = $TT[0]['end_year'];

						//再次确认两个及以上的参数值
						foreach($NotOk as $Loc=>$VVV)
						{
							$Ok = -1;
							$Zuijin = 0;
							if($Year > 0)
							{//通过年份判断 SALVD1BG0F SALMA11406
								$I = 0;
								$Diff === null;
								foreach($VVV as $KKKK=>$VVVV)
								{
									$Bdiff = abs($VVVV['start_year']-$Year);
									$Ediff = abs($VVVV['end_year']-$Year);
									$VVVV['y_diff'] = $Bdiff > $Ediff? $Ediff: $Bdiff;
									if($Diff === null || $Diff > $VVVV['y_diff'])
									{
										$Diff =  $VVVV['y_diff'];
										$Zuijin = $KKKK;
									}

									if($Year >= $VVVV['start_year'] && ($Year <= $VVVV['end_year'] || $VVVV['end_year'] == 0))
									{
										$Ok = $KKKK;
										$I++;
									}
								}
								if($I != 1) $Ok = -1;
							}
							$Ok = $Ok == -1? $Zuijin: $Ok;
							$TT['start_year'] = $VVV[$Ok]['start_year'];
							$TT['end_year'] = $VVV[$Ok]['end_year'];
							$TT[] = $VVV[$Ok];
						}

						$FitterArr[] = $TT;
					}
					//var_dump($FitterArr);
					$FitterArr = $this->filterYear($FitterArr, $Year);

					//整理输出数据
					foreach($FitterArr as $VV)
					{
						$TT = $langId > 1 ?  array('Make'=>$MArr['vm_make'], 'Year'=>$VV['vin_year']) : array('品牌'=>$MArr['vm_make_cn'], '年份'=>$VV['vin_year']);
						$brandName = empty($brandName)? $MArr['vm_make']: $brandName;
						foreach($VV as $VVV)
						{
							if(!is_array($VVV) || empty($VVV['val'])) continue;
							$TT[$VVV['label']] = !empty($TT[$VVV['label']]) ? $TT[$VVV['label']].'&nbsp;&nbsp;'.$VVV['val'] : $VVV['val'];
						}
						foreach($TT as $KKK=>$VVV)
						{
							$LabelArr[$KKK] = $KKK;
						}
						$TT['make_name'] = $MArr['vm_make'];
						$OemModelArr[] = $TT;
					}
				break;
				case 'porsche':
					$Res = $this->getReplaceVin($MC, $vin);
					$CodeArr = $Res['data'];
					if(!empty($CodeArr))
					{
						foreach($CodeArr as $KT=>$BC)
						{
							$CodeArr[$KT] = sprintf("'%s'", $BC);
						}
						$Where = sprintf(" %s AND vin_48 IN (%s)",$Where, implode(',', $CodeArr));
					}
					$vin12 = substr($vin, 11, 1);
					$Where .= $vin12 !== '' &&  $vin12 != '*'? sprintf(" AND vin_12 ='%s'", $vin12): '';
				break;
				case 'mitsubishi_fuso':
				case 'mitsubishi':
					$WhereArr = array(
						sprintf(" AND vin_wmi = '%s' AND vin_48 ='%s' ORDER BY start_year", $vin3, substr($vin, 3, 5)),
						sprintf(" AND vin_48 ='%s' ORDER BY start_year", substr($vin, 3, 5))
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'honda':
					$WhereArr = array(
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' AND vin_9 = '%s' ORDER BY start_year", $vin3, substr($vin, 3, 5), substr($vin, 8, 1)),
						sprintf(" AND vin_48 ='%s' AND vin_9 = '%s' ORDER BY start_year", substr($vin, 3, 5), substr($vin, 8, 1)),
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' AND vin_9 = '*' ORDER BY start_year",$vin3,  substr($vin, 3, 5)),
						sprintf("AND vin_48 ='%s' AND vin_9 = '*' ORDER BY start_year",substr($vin, 3, 5))
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'honda_europe':
					$WhereArr = array(
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' AND vin_9 = '%s' AND vin_11 ='%s' ORDER BY start_year", $vin3, substr($vin, 3, 5), substr($vin, 8, 1), substr($vin, 10, 1)),
						sprintf(" AND vin_48 ='%s' AND vin_9 = '%s' AND vin_11 ='%s' ORDER BY start_year", substr($vin, 3, 5), substr($vin, 8, 1), substr($vin, 10, 1)),
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' AND vin_9 = '*' AND vin_11 ='%s'  ORDER BY start_year",$vin3,  substr($vin, 3, 5), substr($vin, 10, 1)),
						sprintf(" AND vin_48 ='%s' AND vin_9 = '*' AND vin_11 ='%s'  ORDER BY start_year", substr($vin, 3, 5), substr($vin, 10, 1))
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'honda_usa':
					$WhereArr = array(
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' ORDER BY start_year", $vin3, substr($vin, 3, 5)),
						sprintf(" AND vin_48 ='%s'ORDER BY start_year", substr($vin, 3, 5))
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'acura':
					if($Year >= 2010)
					{
						$Res = $this->getReplaceVin($MC, $vin);
						$CodeArr = $Res['data'];
					}
					else
					{
						$CodeArr = array(substr($vin, 6, 1));
					}
					foreach($CodeArr as $KT=>$BC)
					{
						$CodeArr[$KT] = sprintf("'%s'", $BC);
					}
					$WhereArr = array(
						sprintf(" AND vin_wmi ='%s' AND vin_46 ='%s' AND vin_7 IN (%s) AND vin_8 ='%s' ORDER BY year", $vin3, substr($vin, 3, 3), implode(',', $CodeArr), substr($vin, 7, 1)),
						sprintf(" AND vin_46 ='%s' AND vin_7 IN (%s) AND vin_8 ='%s' ORDER BY year", substr($vin, 3, 3), implode(',', $CodeArr), substr($vin, 7, 1)),
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'chrysler_pc':
					if($Year < 1990) break;
					$OthWhere = ' AND year ='.$Year;
					if($Year < 2012)
					{
						$Res = $OemBase->get('vin_'.$MC.'_wmi', array('make_name'), sprintf(" AND wmi = '%s' AND year=%d LIMIT 1", $vin3, $Year), true);
						if(empty($Res['data']['make_name'])) break;
						$OthWhere .= sprintf(" AND make_name='%s'", LibFc::Escape($Res['data']['make_name']));
					}
					$vin6 = substr($vin, 5, 1);
					$Where = sprintf(" %s AND vin_5 ='%s' AND vin_6 LIKE '%%,%s,%%' AND vin_7 LIKE '%%,%s,%%'", $OthWhere, substr($vin, 4, 1), $vin6, substr($vin, 6, 1));
					$Res2 = $OemBase->get('vin_'.$MC, array('*'), $Where);
					$vin6_l2009 = array('B','E','N','C','F','G');
					if(empty($Res2['data']) && $Year <= 2009 && in_array($vin6, $vin6_l2009))
					{
						$Where = sprintf(" %s AND vin_5 ='%s' AND vin_7 LIKE '%%,%s,%%'", $OthWhere, substr($vin, 4, 1), substr($vin, 6, 1));
						$Res2 = $OemBase->get('vin_'.$MC, array('*'), $Where);
					}

					$GetModelArr = $Res2['data'];
					//发动机
					if(!empty($GetModelArr))
					{
						$Res = $OemBase->get('vin_'.$MC.'_engine', array('*'), sprintf(" AND vin_8 = '%s' AND year=%d LIMIT 1", substr($vin, 7, 1), $Year), true);
						foreach($GetModelArr as $K=>$V)
						{
							$V = array_merge($V, $Res['data']);
							$GetModelArr[$K] = $V;
						}
					}
				break;
				case 'chrysler_mpv':
					if($Year < 1990) break;
					$OthWhere = ' AND year ='.$Year;
					if($Year < 2012)
					{
						$Res = $OemBase->get('vin_'.$MC.'_wmi', array('make_name'), sprintf(" AND wmi = '%s' AND year=%d LIMIT 1", $vin3, $Year), true);
						if(empty($Res['data']['make_name'])) break;
						$OthWhere .= sprintf(" AND make_name='%s'", LibFc::Escape($Res['data']['make_name']));
					}
					$vin4 = substr($vin, 3, 1);
					$vin5 = substr($vin, 4, 1);
					$vin6 = substr($vin, 5, 1);
					$vin7 = substr($vin, 6, 1);
					$vin8 = substr($vin, 7, 1);
					$WhereArr = array(
						sprintf(" %s AND vin_4 ='%s' AND vin_5 ='%s' AND vin_6 LIKE '%%,%s,%%' AND vin_7 LIKE '%%,%s,%%' AND vin_8 LIKE '%%,%s,%%'", $OthWhere, $vin4, $vin5, $vin6, $vin7, $vin8),
						sprintf(" %s AND vin_5 ='%s' AND vin_6 LIKE '%%,%s,%%' AND vin_7 LIKE '%%,%s,%%' AND vin_8 LIKE '%%,%s,%%'", $OthWhere, $vin5, $vin6, $vin7, $vin8),
						sprintf(" %s AND vin_4 ='%s' AND vin_5 ='%s' AND vin_6 LIKE '%%,%s,%%' AND vin_7 LIKE '%%,%s,%%'", $OthWhere, $vin4, $vin5, $vin6, $vin7),
						sprintf(" %s AND vin_5 ='%s' AND vin_6 LIKE '%%,%s,%%' AND vin_7 LIKE '%%,%s,%%'", $OthWhere, $vin5, $vin6, $vin7),
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('*'), $Where);
						$vin6_l2009 = array('B','E','N','C','F','G');
						if(empty($Res2['data']) && $Year <= 2009 && in_array($vin6, $vin6_l2009))
						{
							$Where = str_replace("AND vin_6 LIKE '%,".$vin6.",%' ", "", $Where);
							$Res2 = $OemBase->get('vin_'.$MC, array('*'), $Where);
						}
						if(!empty($Res2['data'])) break;
					}
					$GetModelArr = $Res2['data'];
					//发动机
					if(!empty($GetModelArr))
					{
						$Res = $OemBase->get('vin_'.$MC.'_engine', array('*'), sprintf(" AND vin_8 = '%s' AND year=%d LIMIT 1", substr($vin, 7, 1), $Year), true);

						foreach($GetModelArr as $K=>$V)
						{
							$V = array_merge($V, $Res['data']);
							$GetModelArr[$K] = $V;
						}
					}
				break;
				case 'kia':
				case 'hyundai':
					$WhereArr = array(
						sprintf(" AND vin_wmi ='%s' AND vin_48 ='%s' ORDER BY year", $vin3, substr($vin, 3, 5)),
						sprintf(" AND vin_48 ='%s'ORDER BY year", substr($vin, 3, 5))
					);
					foreach($WhereArr as $Where)
					{
						$Res2 = $OemBase->get('vin_'.$MC, array('count(*) as count'), $Where, true);
						if(!empty($Res2['data']['count'])) break;
					}
				break;
				case 'ford_pc':
					if($Year < 2000) break;
					$Res = $OemBase->get('vin_'.$MC, array('*'), sprintf(" AND vin_57 ='%s' AND year=%d LIMIT 1", substr($vin, 4, 3), $Year), true);
					if(!empty($Res['data']))
					{
						$TempModelArr = $Res['data'];
						$Res2 = $OemBase->get('vin_'.$MC.'_engine', array('*'), sprintf(" AND vin_8 = '%s' AND year=%d", substr($vin, 7, 1), $Year));
						$EngArr = array();
						if(count($Res2['data']) > 1)
						{//多条通过车型过滤

							$ReStr = array(' ', "\n", "\t", "\r");
							foreach($Res2['data'] as $TT)
							{
								$TTMakeArr = explode(';', strtoupper(str_replace($ReStr, '',$TT['make'])));
								$TTModelArr = explode(';', strtoupper(str_replace($ReStr, '',$TT['model'])));
								if(
									in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['make_name'])), $TTMakeArr) &&
								   (in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['m1_name'])), $TTModelArr) ||
									in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['m2_name'])), $TTModelArr))
								)
								{
									$EngArr = $TT;
									break;
								}
							}
						}
						if(!empty($Res2['data']) && empty($EngArr))
						{
							$EngArr = $Res2['data'][0];
						}
						$GetModelArr = array(array_merge($EngArr, $TempModelArr));
					}
				break;
				case 'ford_mpv':
					if($Year < 2000) break;
					$Res = $OemBase->get('vin_'.$MC, array('*'), sprintf(" AND vin_57 ='%s' AND year=%d", substr($vin, 4, 3), $Year));
					$vin4 = substr($vin, 3, 1);
					$TempModelArr = array();

					if(count($Res['data']) > 1)
					{
						foreach($Res['data'] as $TT)
						{
							if($TT['vin_4'] == $vin4)
							{
								$TempModelArr = $TT;
								break;
							}
						}
					}

					if(!empty($Res['data']) && empty($TempModelArr))
					{
						$TempModelArr = $Res['data'][0];
					}

					if(!empty($TempModelArr))
					{

						$Res2 = $OemBase->get('vin_'.$MC.'_engine', array('*'), sprintf(" AND vin_8 = '%s' AND year=%d", substr($vin, 7, 1), $Year));
						$EngArr = array();
						if(count($Res2['data']) > 1)
						{//多条通过重量车型过滤
							$ModelGvwr = $TempModelArr['gvwr'] == '>11000' || empty($TempModelArr['gvwr'])? '': '到11000磅';
							$TTEngArr = array();
							$ReStr = array(' ', "\n", "\t", "\r");
							foreach($Res2['data'] as $TT)
							{
								if($ModelGvwr == str_replace($ReStr, '',$TT['gvwr']))
								{
									$TTEngArr[] = $TT;
								}
							}
							if(count($TTEngArr) == 1)
							{
								$EngArr= $TTEngArr[0];
							}
							else
							{
								foreach($TTEngArr as $TT)
								{
									$TTMakeArr = explode(';', strtoupper(str_replace($ReStr, '',$TT['make'])));
									$TTModelArr = explode(';', strtoupper(str_replace($ReStr, '',$TT['model'])));
									if(
										in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['make_name'])), $TTMakeArr) &&
									   (in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['m1_name'])), $TTModelArr) ||
										in_array(strtoupper(str_replace($ReStr, '', $TempModelArr['m2_name'])), $TTModelArr))
									)
									{
										$EngArr = $TT;
										break;
									}
								}
							}
						}
						if(!empty($Res2['data']) && empty($EngArr))
						{
							$EngArr = $Res2['data'][0];
						}
						$GetModelArr = array(array_merge($EngArr, $TempModelArr));
					}

				break;
			}
			//特殊处理不进来
			if(!in_array($MC, array('land_rover', 'subaru')))
			{
				if(in_array($MC, array('chrysler_pc', 'chrysler_mpv', 'ford_pc', 'ford_mpv')))
				{
					$TempAllArr = $GetModelArr;
				}
				else
				{
					if(empty($Where)) continue;
					$Res2 = $OemBase->get('vin_'.$MC, array('*'), $Where);
					$TempAllArr = $Res2['data'];
				}

				//没有开始结束年份字段
				if(in_array($MC, array('volvo', 'cadillac', 'acura', 'chrysler_pc', 'chrysler_mpv', 'kia', 'hyundai', 'ford_pc', 'ford_mpv')))
				{
					foreach($TempAllArr as $KK=>$VV)
					{
						$TempAllArr[$KK]['start_year'] = $VV['year'];
						$TempAllArr[$KK]['end_year'] = $VV['year'];
					}
				}

				$TempAllArr = $this->filterYear($TempAllArr, $Year);

				foreach($TempAllArr as $KK=>$VV)
				{
					foreach($OemShowArr as $KKK=>$VVV)
					{
						$Val = '';
						if($VVV === null)
						{
							switch($KKK)
							{
								case '品牌':
								case 'Make':
									$Val = $MArr['vm_make_cn'];
									$brandName = empty($brandName)? $MArr['vm_make']: $brandName;
								break;
								case '年份':
								case 'Year':
									$Val = $VV['vin_year'];
								break;
							}
						}
						else
						{
							foreach($VVV as $Field)
							{
								$Val .= !empty($VV[$Field]) ? ' '.$VV[$Field]: '';
							}

						}

						if(empty($LabelArr[$KK]))
						{
							$LabelArr[$KKK] = $KKK;
						}
						$OemModelArr[$KK][$KKK] = $Val;
					}
				}
			}
			if(!empty($OemModelArr))
			{
				return LibFc::ReturnData(true, ['from'=>'oem', 'oem'=>$MC, 'model'=>array_values($OemModelArr), 'label'=>array_values($LabelArr), 'brand_id'=>$this->getBrandIdByWord($brandName), 'modtype'=>'cv',  'brand_name'=>$brandName, 'year'=>$Year]);
			}
		}
		return LibFc::ReturnData(true, $returnArr);
	}

	/*
	*获取广告品牌ID
	*/
	public function getVinAdsMakeId($MakeName)
	{
		$AdsMakeId = 0;
		if(!empty($MakeName))
		{
			$MakeName = strtoupper(str_replace(' ', '', $MakeName));
			$File = mvc::$cfg['AUTOLOAD']['Oem']['path'].'config/AdsWMIMake.php';
			$TempMakeArr = include($File);
			foreach($TempMakeArr as $V)
			{
				if(strtoupper(str_replace(' ', '', $V['name'])) == $MakeName || strtoupper(str_replace(' ', '', $V['name_cn'])) == $MakeName)
				{
					$AdsMakeId = $V['id'];
					break;
				}
			}

			if($AdsMakeId < 1)
			{
				foreach($TempMakeArr as $V)
				{
					if(stripos(strtoupper(str_replace(' ', '', $V['name'])), $MakeName) !== false || stripos(strtoupper(str_replace(' ', '', $V['name_cn'])), $MakeName) !== false)
					{
						$AdsMakeId = $V['id'];
						break;
					}
				}
			}
		}
		return LibFc::ReturnData(true, $AdsMakeId);
	}


	/**
	  * @method 工信部解码
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
		成功 ["status"=>true, "data"=> ] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function decodeByGxbWord($vin)
	{
		$brandName = '';
		$ModelArr = array();
		$Year = LibFc::VinYear(substr($vin, 9, 1));
		$vin8 = substr($vin, 0, 8);
		$JdcBase = new JdcBase();
		$table = 'data_vins 
		JOIN data_model_vins ON vin_id=dmv_vin_id 
		JOIN data_weight ON dmv_jml_id = dwt_jml_id
		JOIN data_wheel ON dmv_jml_id = dwl_jml_id
		JOIN `model_qczj`.model2 ON dwt_long = m2_length AND dwt_width= m2_width AND dwt_high=m2_height AND dwl_wheel=m2_wheelbase';
		$whereArr = [
			sprintf(" AND vin_8bit = '%s' AND m2_year=%d GROUP BY m2_id, dwl_jml_id", $vin8, $Year),
			sprintf(" AND vin_8bit = '%s' GROUP BY m2_id, dwl_jml_id", $vin8),
		];
		foreach($whereArr as $where)
		{
			$res = $JdcBase->get($table, ['m2_id, dmv_jml_id'], $where);
			if(!empty($res['data']))
			{
				$JmlIdArr = array_unique(array_column($res['data'], 'dmv_jml_id'));
				$M2IdArr = array_unique(array_column($res['data'], 'm2_id'));
				break;
			}
		}
		if(empty($M2IdArr)) return LibFc::ReturnData(true, $ModelArr);

		$CarBase = new CarBase();
		//2、排量 功率
		$Res = $JdcBase->get('data_engine', array('engine_ml, engine_kw'), sprintf(' AND engine_jml_id IN (%s)', implode(',', $JmlIdArr)));
		if(!empty($Res['data']))
		{
			$MlArr = array();
			$KwArr = array();
			foreach($Res['data'] as $K=>$V)
			{
				if($V['engine_ml'] > 0) $MlArr[round($V['engine_ml'])] = round($V['engine_ml']);
				if($V['engine_kw'] > 0) $KwArr[round($V['engine_kw'])] = round($V['engine_kw']);
			}

			//排量
			if(!empty($MlArr))
			{
				$Res = $CarBase->get('para_value', array('distinct pv_m2_id'), sprintf(" AND pv_m2_id IN (%s) AND pv_pl_id = 125 AND pv_value IN (%s) ", implode(',', $M2IdArr), implode(',', $MlArr) ) );
				$MlM2Arr = array();
				foreach($Res['data'] as $V)
				{
					$MlM2Arr[] = $V['pv_m2_id'];
				}
				$M2IdArr = array_intersect($M2IdArr, $MlM2Arr);
			}

			//功率误差正负20 取最近
			if(!empty($KwArr) && !empty($M2IdArr))
			{
				$ParaValArr = array();
				$Res = $CarBase->get('para_value', array('pv_m2_id', 'pv_value'), sprintf(" AND pv_pl_id = 136 AND pv_m2_id IN (%s) ORDER BY pv_value", implode(',', $M2IdArr) ) );
				foreach($Res['data'] as $V)
				{
					$ParaValArr[$V['pv_value']][] = $V['pv_m2_id'];
				}
				$KwM2Arr = array();
				foreach($KwArr as $V)
				{
					$TempM2Arr = array();
					foreach($ParaValArr as $KK=>$VV)
					{
						$TempM2Arr[abs($V-$KK)] = isset($TempM2Arr[abs($V-$KK)])? array_merge($TempM2Arr[abs($V-$KK)], $VV): $VV;
					}
					ksort($TempM2Arr);
					foreach($TempM2Arr as $KK=>$VV)
					{
						if($KK <= 20)
						{
							$KwM2Arr = array_merge($KwM2Arr, $VV);
						}
						break;
					}
				}
				$M2IdArr = array_intersect($M2IdArr, $KwM2Arr);
			}
		}

		if(!empty($M2IdArr))
		{
			$LabelArr = [
				-3=>'品牌',
				-2=>'车系',
				-1=>'车型',
				54=>'发动机',
				125=>'排量(mL)',
				136=>'功率(kW)',
				152=>'燃料',
				57=>'变速箱',
				244=>'驱动',
				37=>'前制动器',
				62=>'后制动器',
				246=>'驻车制动'
			];
			$CarModel = new CarModel();
			$Res = $CarModel->getModel2(array('m2_id', 'b_name', 'm1_name', 'm2_name'), sprintf(" AND m1_import=0 AND m2_id IN (%s) ORDER BY b_initial, m2_year DESC, m1_name, m2_name", implode(',', $M2IdArr)));
			if(!empty($Res['data']))
			{
				foreach($Res['data'] as $V)
				{
					$brandName = empty($brandName)? $V['b_name']: $brandName;
					$V['make_name'] = $V['b_name'];
					$ModelArr[$V['m2_id']] = [
						'品牌'=>$V['make_name'],	
						'车系'=>trim($V['m1_name']),
						'车型'=>trim($V['m2_name'])
					];
				}
				$Res = $CarBase->get('para_value', array('pv_m2_id', 'pv_pl_id', 'pv_value'), sprintf(" AND pv_m2_id IN (%s) AND pv_pl_id IN (%s)", implode(',', array_keys($ModelArr)), implode(',', array_keys($LabelArr)) ) );
				foreach($Res['data'] as $V)
				{
					$ModelArr[$V['pv_m2_id']][$LabelArr[$V['pv_pl_id']]] = $V['pv_value'];
				}
			}
		}
		if(!empty($ModelArr))
		{
			return LibFc::ReturnData(true, ['from'=>'gxb', 'model'=>array_values($ModelArr), 'label'=>array_values($LabelArr), 'brand_id'=>$this->getBrandIdByWord($brandName), 'modtype'=>'pc', 'brand_name'=>$brandName, 'year'=>$Year]);
		}
		
		return LibFc::ReturnData(true, $ModelArr);
	}



	/**
	  * @method 欧洲 北美 wmi
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2020/7/23
	  * @return 
		成功 ["status"=>true, "data"=> ] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function decodeByOBW($vin)
	{
		$Year = $this->vinBase['year'];
		$OemBase = new OemBase();
		$Res = $OemBase->Get('vin3_make', array('distinct vm_make', 'vm_make_cn'), sprintf(" AND vm_vin3 = '%s'", $this->vinBase['wmi']));
		if(empty($Res['data'])) return LibFc::ReturnData(true, ['from'=>'', 'brand_id'=>0, 'brand_name'=>'', 'model'=>[]]);
		
		$MArr = array();
		$WMIArr = array();
		foreach($Res['data'] as $V)
		{
			$MArr[strtoupper(trim($V['vm_make']))] = sprintf("'%s'", $V['vm_make']);
			$WMIArr[] = ['品牌'=>$V['vm_make_cn']];
		}
		
		//欧洲VIN 	1FALP53S3VA220419
		$vinchModel = new VinChModel();
		$Where = sprintf(" AND make_name IN (%s) AND vin_48 = '%s'", implode(',', $MArr), substr($vin, 3, 5));
		$WhereArr = $Year > 1980 && $Where != ''?  array(' AND m2_year='.$Year.' '.$Where, $Where): array($Where);

		$vinM2Arr = array();
		foreach($WhereArr as $Where)
		{
			if(trim($Where) == '') continue;
			$Res = $vinchModel->getVin(array('m2_id, m2_name, make_name, m1_name, m2_year'), sprintf(" %s group by m2_id ORDER BY make_name, m1_name, m2_name, m2_year", $Where));
			if(!empty($Res['data']))
			{
				foreach($Res['data'] as $V)
				{
					$brandName = empty($brandName)? $V['make_name']: $brandName;
					$vinM2Arr[$V['m2_id']] = [
						'品牌'=>$V['make_name'],
						'车系'=>$V['m1_name'],
						'车型'=>$V['m2_name'],
						'车型年'=>$V['m2_year']
					];
				}
				$vinChBase = new VinChBase();
				$LabelArr = [
					-4=>'品牌',
					-3=>'车系',
					-2=>'车型',
					-1=>'车型年',
					5=>'发动机',
					13=>'缸数',
					6=>'燃料',
					4=>'驱动方式',
					7=>'进气方式',
					8=>'座位'
				];

				$Res = $vinChBase->get('m2_para_value', array('pv_m2_id', 'pv_pl_id', 'pv_value'), sprintf(" AND pv_m2_id IN (%s) AND pv_pl_id IN (%s)", implode(',', array_keys($vinM2Arr)), implode(',', array_keys($LabelArr)) ) );
				foreach($Res['data'] as $V)
				{
					$vinM2Arr[$V['pv_m2_id']][$LabelArr[$V['pv_pl_id']]] = $V['pv_value'];
				}
				break;
			}
		}
		if(!empty($vinM2Arr) && count($vinM2Arr) <= 10)
		{
			return LibFc::ReturnData(true, array('from'=>'eur', 'model'=>array_values($vinM2Arr), 'label'=>array_values($LabelArr), 'brand_id'=>$this->getBrandIdByWord($brandName), 'modtype'=>'pc', 'brand_name'=>$brandName, 'year'=>$Year));
		}

		//北美 1FT8W3BT191122758
		$UsaVinArr = array();
		$TempVinArr = array(sprintf("'%s'", substr($vin, 3, 5)));
		$vin78 = substr($vin, 6, 2);
		if(isset($MArr['AUDI']))
		{
			$vin46 = substr($vin, 3, 3);
			foreach($this->audiReArr as $K=>$V)
			{
				if($K == $vin78)
				{
					$TempVinArr[] = sprintf("'%s'", $vin46.$V);
				}
				else if($V == $vin78)
				{
					$TempVinArr[] = sprintf("'%s'", $vin46.$K);
				}
			}
		}
		$TempVinArr = array_unique($TempVinArr);
		$Where = sprintf(" AND vu_make IN (%s) AND vu_vin48 IN (%s) GROUP BY vu_year, vu_make, vu_model", implode(',', $MArr), implode(',', $TempVinArr));
		$WhereArr = $Year > 1980 && $Where != ''?  array(' AND vu_year='.$Year.' '.$Where, $Where): array($Where);
		foreach($WhereArr as $Where)
		{
			if(trim($Where) == '') continue;
			$Res = $OemBase->get('vin_usa LEFT JOIN vin3_make ON vu_make= vm_make', array('vu_year, vu_make, vu_model, vm_make_cn'),  $Where);
			if(!empty($Res['data']))
			{
				foreach($Res['data'] as $K=>$V)
				{
					$brandName = empty($brandName)? $V['vm_make_cn']: $brandName;
					$UsaVinArr[] = ['品牌'=>$V['vm_make_cn'], '车型'=>$V['vu_model'], '年份'=>$V['vu_year']];
				}
				break;
			}
		}

		if(!empty($UsaVinArr)) return LibFc::ReturnData(true, ['from'=>'usa', 'model'=>$UsaVinArr, 'label'=>['品牌', '车型', '年份'], 'brand_id'=>$this->getBrandIdByWord($brandName), 'modtype'=>'pc', 'brand_name'=>$brandName, 'year'=>$Year]);
		
		//2022/10/15 多品牌不再出
		if(count($WMIArr) > 1) return LibFc::ReturnData(true, ['from'=>'', 'brand_id'=>0, 'modtype'=>'', 'brand_name'=>'', 'model'=>[]]);
		
		//WMI
		foreach($WMIArr as $V)
		{
			$brandName = empty($brandName)? $V['品牌']: $brandName;
			break;
		}
		return LibFc::ReturnData(true, ['from'=>'wmi', 'model'=>$WMIArr, 'label'=>['品牌'], 'brand_id'=>$this->getBrandIdByWord($brandName), 'modtype'=>'pc', 'brand_name'=>$brandName, 'year'=>$Year]);
	}

	/**
	  * @method 有替换关系的VIN
	  * @param  $Code 品牌代码
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> [符合条件的VIN数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getReplaceVin($Code, $vin)
	{
		$BmwReArr = array(
			'A'=>'1',
			'B'=>'2',
			'C'=>'3',
			'D'=>'4',
			'E'=>'5',
			'F'=>'6',
			'G'=>'7'
		);

		$Porsche7ReArr = array(
			'A'=>'9',
			'9'=>'A'
		);

		$Acura7ReArr = array(
			'8'=>'H',
			'5'=>'E',
			'6'=>'F',
		);
		switch($Code)
		{
			case 'audi':
				if(strlen($vin) >= 8)
				{
					$vinCode = substr($vin, 3, 2).'*';
					$vin78 = substr($vin, 6, 2);
					$TempVinArr = array($vinCode.$vin78);
					foreach($this->audiReArr as $K=>$V)
					{
						if($K == $vin78)
						{
							$TempVinArr[] = $vinCode.$V;
						}
						else if($V == $vin78)
						{
							$TempVinArr[] = $vinCode.$K;
						}
					}
					$TempVinArr = array_unique($TempVinArr);
				}
			break;
			case 'bmw':
				if(strlen($vin) >= 7)
				{
					$vin7 = substr($vin, 6, 1);
					$vinCode = substr($vin, 3, 3);
					$TempVinArr = array($vinCode.$vin7);
					foreach($BmwReArr as $K=>$V)
					{
						if($K == $vin7)
						{
							$TempVinArr[] = $vinCode.$V;
						}
						else if($V == $vin7)
						{
							$TempVinArr[] = $vinCode.$K;
						}
					}
					$TempVinArr = array_unique($TempVinArr);
				}
			break;
			case 'porsche':
				if(strlen($vin) >= 8)
				{
					$vin7 = substr($vin, 6, 1);
					$TempVinArr = array(substr($vin, 3, 5));
					foreach($Porsche7ReArr as $K=>$V)
					{
						if($K == $vin7)
						{
							$TempVinArr[] = substr($vin, 3, 3).$V.substr($vin, 7, 1);
						}
						else if($V == $vin7)
						{
							$TempVinArr[] = substr($vin, 3, 3).$K.substr($vin, 7, 1);
						}
					}
					$TempVinArr = array_unique($TempVinArr);
				}
			break;
			case 'acura':
				if(strlen($vin) >= 8)
				{
					$vin7 = substr($vin, 6, 1);
					$TempVinArr = array($vin7);
					foreach($Acura7ReArr as $K=>$V)
					{
						if($K == $vin7)
						{
							$TempVinArr[] = $V;
						}
						else if($V == $vin7)
						{
							$TempVinArr[] = $K;
						}
					}
					$TempVinArr = array_unique($TempVinArr);
				}
			break;
		}
		return LibFc::ReturnData(true, $TempVinArr);
	}


	/**
	  * @method 通过VIN解析出原厂唯一标码
	  * @param  $MakeCode 品牌代码
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> [唯一标码数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function getOemCodeByVin($MakeCode, $vin)
	{
		$CodeArr = array();
		switch($MakeCode)
		{
			case 'benz':
				$Res = $this->getBenzCodeByVin($vin);
				$CodeArr = $Res['data'];
			break;
			case 'bmw':
				$Res = $this->getReplaceVin('bmw', $vin);
				$CodeArr = $Res['data'];
			break;
			case 'honda':
				$CodeArr = array(substr($vin, 0, 8));
			break;
		}
		return LibFc::ReturnData(true, $CodeArr);
	}


	/**
	  * @method 通过VIN获取奔驰的7位编码
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> [编码数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getBenzCodeByVin($vin)
	{
		$Code = array();
		if(strlen($vin) >= 7 && LibFc::Int(substr($vin, 3, 6)) !== false)
		{
			//WDB2201751A*054072
			$Code = array(substr($vin, 3, 6));
		}
		else if(strlen($vin) >= 7 && LibFc::Int(substr($vin, 3, 1)) === false)
		{
			$V45 = substr($vin, 3, 2);
			$V6 = substr($vin, 5, 1);
			$V7 = substr($vin, 6, 1);
			$OemBase = new OemBase();
			$Res = $OemBase->get('vin_benz_code', array('distinct vbc_code'), sprintf(" AND vbc_vin = '%s'", LibFc::escape($V45)));
			foreach($Res['data'] as $K=>$V)
			{
				$Code[] = str_replace('.', '', $V['vbc_code']);
			}
			$V6 = LibFc::Int($V6) === false ? '': $V6;

			$V7Arr = array('A'=>0, 'B'=>1, 'C'=>2, 'D'=>3, 'E'=>4, 'F'=>5, 'G'=>6, 'H'=>7, 'J'=>8, 'K'=>9);
			if(LibFc::Int($V7) === false)
			{
				$V7 = !empty($V7Arr[$V7])? $V7Arr[$V7]: '';
			}
			foreach($Code as $K=>$V)
			{
				$V .= $V6.$V7;
				if(strlen($V) != 6)
				{
					unset($Code[$K]);
				}
				else
				{
					$Code[$K] = $V;
				}
			}
		}
		foreach($Code as $K=>$V)
		{
			$Code[$K] = substr($V, 0, 3).'.'.substr($V, 3, 3);
		}
		return LibFc::ReturnData(true, $Code);
	}


	/**
	  * @method 通过VIN获取volvo车型
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> [车型数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function getVolvoVds($vin)
	{
		$WhereArr = array(
			sprintf(" AND vv_4='%s' AND vv_5='%s'", substr($vin, 3, 1), substr($vin, 4, 1)),
			sprintf(" AND vv_7='%s' AND vv_8='%s'", substr($vin, 6, 1), substr($vin, 7, 1)),
			sprintf(" AND vv_7='%s'", substr($vin, 6, 1))
		);
		$Arr = array();
		$OemBase = new OemBase();
		foreach($WhereArr as $Where)
		{
			$Res = $OemBase->getFieldUniVal('vin_volvo_vds', 'vv_model', $Where);
			if(!empty($Res['data']))
			{
				$Arr = $Res['data'];
				break;
			}
		}
		return LibFc::ReturnData(true, $Arr);
	}




	/**
	  * @method 过滤不符合年份的VIN
	  * @param  $vinArr  解码后的车型数组
	  * @param  $Year    VIN年份
	  * @param  $ignoreYear  如果年份过滤后，无符合车型
							 true 继续寻找最近的车型,至少有一条数据返回
							 false 否则返回空
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> [符合条件的车型数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	private function filterYear($vinArr, $Year, $ignoreYear = false)
	{
		$NoOkArr = array();
		$Diff = null;
		foreach($vinArr as $K=>$V)
		{
			if($Year > 0)
			{
				if($Year >= $V['start_year'] && ($Year <= $V['end_year'] || $V['end_year'] == 0))
				{//符合年份
					$V['vin_year'] = $Year;
				}
				else
				{//找最接近年份
					$Bdiff = abs($V['start_year']-$Year);
					$Ediff = abs($V['end_year']-$Year);
					$V['y_diff'] = $Bdiff > $Ediff? $Ediff: $Bdiff;
					$Diff = $Diff === null || $Diff>$V['y_diff']? $V['y_diff']: $Diff;
				}
			}
			else
			{//没有选择年
				$V['vin_year'] .= $V['start_year'] > 0 ? $V['start_year'].'-': '-';
				$V['vin_year'] .= $V['end_year'] > 0 ? $V['end_year']: '';
				$V['vin_year'] = $V['vin_year'] == '-'? '': $V['vin_year'];
				$V['vin_year'] = $V['start_year'] == $V['end_year']? $V['start_year']: $V['vin_year'];
			}

			if(isset($V['vin_year']))
			{
				$vinArr[$K] = $V;
			}
			else
			{
				unset($vinArr[$K]);
				$NoOkArr[$K] = $V;
			}
		}
		if(empty($vinArr))
		{
			foreach($NoOkArr as $K=>$V)
			{
				if($Diff == $V['y_diff'])
				{
					$V['vin_year'] = $Year;
					$vinArr[$K] = $V;
				}
			}
		}
		foreach($vinArr as $K=>$V)
		{
			$vinArr[$K]['vin_year'] = empty($V['vin_year']) ? '': $V['vin_year'];
		}
		return $vinArr;
	}


	/**
	  * @method 统计VIN
	  * @param  $Vin
	  * @param  $From  从哪里解码成功
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
		成功 ["status"=>true, "data"=> 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function tongjiVin($Vin, $From)
	{
		$Vin = LibFc::FormatVin($Vin);
		if(strlen($Vin) == 17 && strpos($Vin, '*') === false)
		{
			$Vin = substr($Vin, 0, 17);
			$CheckArr = LibFc::VinCheckCode($Vin);
			$YpwBase = new YpwBase();
			$Res = $YpwBase->Get('yp_vin_search', array('vs_id', 'vs_click'), sprintf(" AND vs_vin='%s'", LibFc::Escape($Vin)), true);
			if(empty($Res['data']))
			{
				$YpwBase->Add('yp_vin_search', ['vs_vin1_3'=>substr($Vin, 0, 3), 'vs_vin10'=>substr($Vin, 9, 1),'vs_checkcode'=>$CheckArr['real'], 'vs_vin9'=>$CheckArr['v9'], 'vs_vin'=>$Vin, 'vs_last_time'=>time(), 'vs_click'=>1, 'vs_from'=>$From]);
			}
			else
			{
				$YpwBase->Set('yp_vin_search', ['vs_click'=>++$Res['data']['vs_click']], ' AND vs_id='.$Res['data']['vs_id']);
			}
		}
		return LibFc::ReturnData(true);	
	}


	/**
	  * @method 纠正VIN （对长度为14 - 19的VIN进行纠正）
	  * @param  word    
	  * @author soul
	  * @copyright 2017/8/16
	  * @return
			成功：['status'=>true, 'data'=>[0=>'', 1=>''.....]]
			失败：['status'=>false, 'data'=>'xxx', 'code'=>'xxx']
	  */
	public function correctVin($word)
	{
		$word = LibFc::FormatVin($word);
		$len = strlen($word);
		if($len > 13 && $len < 17)
		{
			$min = 17-$len;
			for($begin = 0; $begin <= $min; $begin++)
			{
				$likeWord = str_pad(substr($word, 0, 8-$begin), 8, '_', STR_PAD_LEFT);
				$res = $this->Get('yp_vin', ['vin_full'], sprintf(" AND vin_full LIKE '%s'", $likeWord));
			
				if(empty($res['data'])) continue;
				if(count($res['data']) == 1)
				{
					$word = $res['data'][0]['vin_full'].substr($word, 8-$begin);
					$word = str_pad($word, 17, '_');
				}
				else
				{
					$bstr = '';
					$bstr = str_pad($bstr, $begin, '_');
					$word = str_pad($bstr.$word, 17, '_');
				}
				break;
			}
		}
		else if($len > 17 && $len < 20)
		{
			$min = $len - 17;
			for($begin = 0; $begin <= $min; $begin++)
			{
				$likeWord = substr($word, $begin, 8);
				$res = $this->Get('yp_vin', ['vin_full'], sprintf(" AND vin_full ='%s'", $likeWord), true);
				if(empty($res['data'])) continue;
				$word = substr($word, $begin, 17);
				break;
			}
		}
		return LibFc::ReturnData(true, $word);
	}


	/**
	  * @method 行驶证的整车型号解码
	  * @param  $makeNo  整车型号  GTM6491HWE
	  * @author soul
	  * @copyright 2019/3/19
	  * @return 
		{"status":true,"data":{"jml_id":"250952","jml_make":"丰田(TOYOTA)","img":"","para":[{"label":"外形尺寸","value":"4890*1925*1715","unit":"mm"},{"label":"总质量","value":"2720,2640","unit":"kg"},{"label":"整备质量","value":"2070,2040","unit":"kg"},{"label":"轮胎规格","value":"245\/55R19,245\/60R18","unit":""},{"label":"额定载客","value":"7","unit":"人"}],"engine":[{"engine_no":"8AR","engine_ml":"1998","engine_kw":"162"}]},"code":0}
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function getMakeNoInfo($makeNo)
	{
		$arr = [];
		$makeNo = LibFc::FormatNum($makeNo);
		if(strlen($makeNo) < 2) return LibFc::ReturnData(true, $arr);
		$JdcBase = new JdcBase();
		$res = $JdcBase->Get('data_model', ['jml_id', 'jml_model', 'jml_make'], sprintf(" and jml_model_format = '%s' limit 1", LibFc::Escape($makeNo)), true);
		if(!empty($res['data']))
		{
			$arr = $res['data'];
			$res = $this->Get('yp_image_gxb', ['gxb_path', 'gxb_name'], sprintf(" and gxb_code='%s' order by gxb_order limit 1", LibFc::Escape($makeNo)), true);
			$arr['img'] = !empty($res['data'])? mvc::$cfg['urls']['etkPic'].$res['data']['gxb_path'].'/'.$res['data']['gxb_name'] : '';
			$arr['para'] = [];
			$res = $JdcBase->Get('data_info', ['ino_label', 'ino_text', 'ino_value'], sprintf(" AND ino_jml_id = %d AND ino_label IN (7,8,20,21,22,23,24,16,42)", $arr['jml_id']));
			$temp = array_column($res['data'], null, 'ino_label');
			if(!empty($temp[22]['ino_value']) && !empty($temp[23]['ino_value']) && !empty($temp[24]['ino_value']))
				$arr['para'][] = ['label'=>'外形尺寸', 'value'=>$temp[22]['ino_value'].'*'.$temp[23]['ino_value'].'*'.$temp[24]['ino_value'], 'unit'=>'mm'];
			if(!empty($temp[7]['ino_value'])) $arr['para'][] = ['label'=>$temp[7]['ino_text'], 'value'=>$temp[7]['ino_value'], 'unit'=>'kg'];
			if(!empty($temp[8]['ino_value'])) $arr['para'][] = ['label'=>$temp[8]['ino_text'], 'value'=>$temp[8]['ino_value'], 'unit'=>'kg'];
			if(!empty($temp[32]['ino_value'])) $arr['para'][] = ['label'=>$temp[16]['ino_text'], 'value'=>$temp[16]['ino_value'], 'unit'=>''];
			if(!empty($temp[24]['ino_value'])) $arr['para'][] = ['label'=>$temp[42]['ino_text'], 'value'=>$temp[42]['ino_value'], 'unit'=>'人'];
			
			$res = $JdcBase->Get('data_engine', ['engine_no', 'engine_ml', 'engine_kw'], sprintf(" AND engine_jml_id =%d", $arr['jml_id']));
			$arr['engine'] = [];
			foreach($res['data'] as $V)
			{
				$arr['engine'][] = $V;
			}
		}
		return LibFc::ReturnData(true, $arr);
	}
	

	/**
	  * @method 行驶证的整车型号解码
	  * @param  $makeNo  整车型号
	  * @param  $othParamArr  ....
	  * @author soul
	  * @copyright 2019/3/19
	  * @return 
		{"status":true,"data":[{"brand_id":"62","brand_etk_id":"8","brand_code":"FENGTIAN","make_show_brand":0,"brand_name":"丰田","make_name":"广汽丰田","mod1_name":"汉兰达","mod2_name":"汉兰达(_SU5_)","mod3_id":"10117","mod3_mod2_id":"970","mod3_mod1_id":"636","mod3_brand_id":"62","mod3_make_id":"81","mod3_name":"2.0T 四驱7座至尊版","mod3_start_year":"2018","mod3_end_year":"0","mod3_kw":"162","mod3_cc":"1998","mod3_engine":"8AR-FTS","mod3_transmission":"6A\/MT","mod3_fuel":"汽油","mod3_body":"5门7座SUV","mod3_front_brake":"通风盘式","mod3_rear_brake":"盘式","mod3_parking_brake":"脚刹","mod3_drive":"前置四驱","mod3_keyword":"2.0T四驱7座至尊版","mod3_cc_name":"2.0"},{"brand_id":"62","brand_etk_id":"8","brand_code":"FENGTIAN","make_show_brand":0,"brand_name":"丰田","make_name":"广汽丰田","mod1_name":"汉兰达","mod2_name":"汉兰达(_SU5_)","mod3_id":"10118","mod3_mod2_id":"970","mod3_mod1_id":"636","mod3_brand_id":"62","mod3_make_id":"81","mod3_name":"2.0T 四驱7座豪华版","mod3_start_year":"2018","mod3_end_year":"0","mod3_kw":"162","mod3_cc":"1998","mod3_engine":"8AR-FTS","mod3_transmission":"6A\/MT","mod3_fuel":"汽油","mod3_body":"5门7座SUV","mod3_front_brake":"通风盘式","mod3_rear_brake":"盘式","mod3_parking_brake":"脚刹","mod3_drive":"前置四驱","mod3_keyword":"2.0T四驱7座豪华版","mod3_cc_name":"2.0"}],"code":0}
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function getMakeNoYpcModel($makeNo, $othParamArr)
	{
		$arr = [];
		$makeNo = LibFc::FormatNum($makeNo);
		if(strlen($makeNo) < 2) return LibFc::ReturnData(true, $arr);
		$where = sprintf(" AND mg_code = '%s'", $makeNo);

		if(!empty($othParamArr['mod3_engine'])) $where .= sprintf(" AND m3_engine = '%s'", LibFc::Escape($othParamArr['mod3_engine']));
		if(!empty($othParamArr['m3_kw'])) $where .= sprintf(" AND m3_kw = %d", (int) $othParamArr['m3_kw']);
		if(!empty($othParamArr['m3_cc'])) $where .= sprintf(" AND m3_cc = %d", (int) $othParamArr['m3_cc']);

		$res = $this->get('yp_model3_gxb_num join yp_model3 on m3_id=mg_m3_id', ['distinct m3_id'], $where);
		if(!empty($res['data']))
		{
			$where = sprintf(" and mod3_id in (%s)", implode(',', array_column($res['data'], 'm3_id') ) );
			$Ypc2Model = new Ypc2Model();
			$filed = ['brand_id', 'brand_etk_id', 'brand_code', 'make_show_brand', 'brand_name', 'make_name', 'mod1_name', 'mod2_name', 'bc_model3.*'];
			$res = $Ypc2Model->getModel(3, $filed, $where);
			$arr = $res['data'];
		}
		return LibFc::ReturnData(true, $arr);
	}


	/**
	  * @method get  VIN解码大车详细信息
	  * @http  GET
	  * @param  $mod_id             string [必填] 解码接口返回的车型ID  l40HeD9/bU1vsWVXsp9fQzwqbEbya256xpZtMMSKRD0=
	  * @author soul
	  * @copyright 2020/7/26
	  * @return {"status":true,"data":{"mod_type":"牵引汽车","mod_make":"豪沃牌","mod_code":"ZZ4257W324HE1B","mod_name":"中国重汽 HOWO-T7H 重卡 540马力6×4牵引车(ZZ4257W324HE1B)","pic":["http:\/\/3thpics.yiparts.com\/etk\/CART\/0\/256\/256818.jpg","http:\/\/3thpics.yiparts.com\/etk\/CART\/0\/256\/256819.jpg","http:\/\/3thpics.yiparts.com\/etk\/CART\/0\/288\/288259.jpg"],"para":[{"group":"车型概要","para":[{"label":"品牌","val":"豪沃牌"},{"label":"整车型号","val":"ZZ4257W324HE1B"},{"label":"尺寸(mm)","val":"6985*2496*3230"}]},{"group":"基本信息","para":[{"label":"整车公告","val":"ZZ4257W324HE1B"},{"label":"品牌","val":"中国重汽"},{"label":"车系","val":"HOWO-T7H"},{"label":"用途","val":"牵引车"},{"label":"驱动方式","val":"6×4"},{"label":"最高车速","val":"101km\/h"},{"label":"吨位级别","val":"重卡"},{"label":"生产厂家","val":"中国重汽"},{"label":"整车产地","val":"山东济南"},{"label":"备注","val":"选装驾驶室,选装保险杠,选装后轮轮罩,选装悬架布置型式,选装牵引钩。油箱可置于车辆右侧消声器后面,电瓶箱和储气筒可置于驾驶室后部车架上。选装双油箱布置结构。"}]},{"group":"整车参数","para":[{"label":"牵引总质量","val":"40000kg"},{"label":"整备质量","val":"8800kg"},{"label":"总质量","val":"25000kg"},{"label":"整车长度","val":"7315mm"},{"label":"整车宽度","val":"2496mm"},{"label":"整车高度","val":"3850mm"},{"label":"前轮距","val":"2041mm"},{"label":"后轮距","val":"1830mm"},{"label":"轴距","val":"3400+1400mm"},{"label":"前悬","val":"1540mm"},{"label":"后悬","val":"975mm"},{"label":"接近角","val":"15°"},{"label":"离去角","val":"46°"}]},{"group":"驾驶室","para":[{"label":"驾驶室类型","val":"高顶"},{"label":"座位排数","val":"排半"},{"label":"准乘人数","val":"3人"}]},{"group":"发动机","para":[{"label":"发动机型号","val":"中国重汽MC13.54-50"},{"label":"发动机形式","val":"直列6缸、水冷、四冲程、增压中冷、高压共轨"},{"label":"最大功率","val":"397Kw"},{"label":"最大功率转速","val":"1900rpm"},{"label":"最大扭矩","val":"25000N.m"},{"label":"最大扭矩转速","val":"1050-1350rpm"},{"label":"最大马力","val":"540马力"},{"label":"排量","val":"12419mL"},{"label":"燃油种类","val":"柴油"},{"label":"排放标准","val":"国五\/欧五"}]},{"group":"变速箱","para":[{"label":"变速箱型号","val":"HW25716XSTL"},{"label":"换挡方式","val":"手动"},{"label":"前进档位数","val":"16档"},{"label":"倒档档位数","val":"2个"}]},{"group":"底盘","para":[{"label":"板簧片数","val":"9\/12,3\/12,3\/5,3\/4,2\/4,9\/-,3\/-,2\/-,3\/-\/-,2\/-\/-,3\/2+-\/2+-"},{"label":"前桥描述","val":"最大允许承载重量7000kg"},{"label":"后桥描述","val":"最大允许承载重量18000kg"},{"label":"后桥速比","val":"3.36"},{"label":"油箱容量","val":"1000L"}]},{"group":"轮胎","para":[{"label":"轮胎数量","val":"10个"},{"label":"轮胎规格","val":"315\/80R22.518PR,295\/80R22.5 18PR,12R22.5 18PR,12.00R20 16PR,11.00R2018PR"}]},{"group":"其它信息","para":[{"label":"信息提供","val":"中国重汽集团济南卡车股份有限公司"}]}]},"code":0,"runtime":95}
	  */
	public function getCartInfo($modid)
	{
		$arr = [];
		$LibEncry = new LibEncry();
		$t = explode('@', $LibEncry->decode($modid));
		$mod_id = $t[0];
		$sma_vin = LibFc::FormatVin($t[1]);
		//是否在卡车标准车型，为了兼容历史版本
		$KczjBase = new BaseDb(mvc::$cfg['DB']['KCZJ']);
		$res = $KczjBase->get('mer_model3', ['m3_code'], sprintf(" and m3_code='%s'", LibFc::Escape($mod_id)), true);
		if(!empty($res['data']))
		{
			$deres = $this->decodeVin($sma_vin);
			
			if(empty($deres['data']) || $deres['data']['from'] != 'bigcar')
			{
				return LibFc::ReturnData(true, $arr);
			}
			$deres = $deres['data'];
			$labelArr = $deres['label'];
			$modInfo = [];
			foreach($deres['model'] as $mod)
			{
				if($modid == $mod['mod_id'] || strtr($modid, [' '=>'+']) == $mod['mod_id'])
				{
					$modInfo = $mod;
					break;
				}
			}
			if(empty($modInfo)) return LibFc::ReturnData(true, $arr);

			$arr['pic'] = $modInfo['pic']? $modInfo['pic']: [];
			$arr['para'] = [];
			foreach($labelArr as $k=>$v)
			{
				if(!empty($modInfo[$k])){
					$arr['para']['基本信息'][] = ['label'=>$v, 'val'=>$modInfo[$k]];
				}
			}
			$arr['mod_name'] = $modInfo['sma_brand'].' '.$modInfo['m1_name'].' '.$modInfo['mod_name'];
			$temp = $arr['para'];
			$arr['para'] = [];
			foreach($temp as $k=>$v)
			{
				$arr['para'][] = [
					'group'=>$k,
					'para'=>$v
				];
			}
			return LibFc::ReturnData(true, $arr);
		}
		$mod_id = (int) $mod_id;
		if($mod_id < 1) return LibFc::ReturnData(true, $arr);
		
		$CartBase = new CartBase();
		$res = $CartBase->get('cat_model', ['mod_id, mod_label_2 AS sma_vtype, mod_make sma_brand, mod_code sma_gxb_code_show, mod_name, mod_code_format'], sprintf(" and mod_id=%d", $mod_id), true);
		if(empty($res['data'])) return LibFc::ReturnData(true, $arr);
		$arr = $res['data'];
		$arr['pic'] = [];
		$arr['para'] = [];

		//600万表存在
		$hasLabel = [];
		if(strlen($sma_vin) == 17)
		{
			$labelArr = [
				'sma_brand'=>'品牌',
				'mod_name'=>'车型',
				'sma_engine'=>'发动机',
				'mod3_jgl_kw'=>'最大净功率',
				'mod3_ed_kw'=>'额定功率',
				'sma_kw'=>'功率',
				'sma_cc'=>'排量',
				'xuhang'=>'续航',
				'dianchi'=>'电池种类',
				'sma_tran'=>'变速箱',
				'mod_drive'=>'驱动方式',
				'size'=>'尺寸',
				'sma_wheel'=>'轴距',
				'sma_vtype'=>'车辆类型',
				'sma_weight'=>'整备质量',
				'sma_passenger'=>'载客',
				'sma_year'=>'生产日期',
				'sma_jkyear'=>'进口日期',
				'jkfs'=>'进口方式',
				'country'=>'制造国',
				'company'=>'生产厂',
			];
			$unitArr = [
				'sma_kw'=>'kw',	
				'sma_cc'=>'cc',	
				'sma_wheel'=>'mm',	
				'sma_weight'=>'kg',	
				'sma_passenger'=>'人'	
			];
			$CHCARDb = new BaseDb(mvc::$cfg['DB']['CHCAR']);
			$YpwBase = new YpwBase();
			$smafiledArr = ['sma_vin, sma_brand, sma_gxb_code_show, sma_gxb_code, sma_length, sma_width, sma_height, sma_wheel, sma_weight, sma_passenger, sma_engine,sma_kw, sma_cc,sma_tran,sma_year, sma_vtype'];

			$smaTables = ['stand_model_any', 'stand_model_any_ocr'];
			foreach($smaTables as $table)
			{
				$res = $YpwBase->get($table, $smafiledArr, sprintf(" and sma_vin = '%s' and sma_gxb_code='%s'", $sma_vin, LibFc::Escape($arr['mod_code_format'])), true);
				if(!empty($res['data'])) break;
			}
			if(!empty($res['data']))
			{
				$tmodArr = $res['data'];

				$res = $this->jsVinSmaNullData($tmodArr);
				$tmodArr = $res['data'];

				$tres = $this->getGxbEngKw($tmodArr['sma_gxb_code'], $tmodArr['sma_engine'], $tmodArr['sma_kw'], $tmodArr['sma_vin'], $tmodArr['sma_brand']);
				if(!empty($tres['data']['mod3_jgl_kw']))
				{
					$tmodArr['mod3_jgl_kw'] = $tres['data']['mod3_jgl_kw'][1];
					if(!empty($tres['data']['mod3_ed_kw'])) $tmodArr['mod3_ed_kw'] = $tres['data']['mod3_ed_kw'][1];
					unset($tmodArr['sma_kw']);
				}
				if(!empty($tres['data']['dianchi'])) $tmodArr['dianchi'] = $tres['data']['dianchi'];
				if(!empty($tres['data']['paifang']) && $tmodArr['sma_engine'] != '') $tmodArr['sma_engine'] .= ' ('.$tres['data']['paifang'].')';
				if(empty($tmodArr['xuhang']) && !empty($tres['data']['xuhang'])) $tmodArr['xuhang'] = $tres['data']['xuhang'];

				if(!empty($tmodArr['sma_length']) && !empty($tmodArr['sma_width'])  && !empty($tmodArr['sma_height']))
					$tmodArr['size'] = $tmodArr['sma_length'].'mm*'.$tmodArr['sma_width'].'mm*'.$tmodArr['sma_height'].'mm';
				if(!empty($tmodArr['sma_gxb_code']))
				{
					$tmodArr = $this->fitDataFromSmaTj($tmodArr);

					//长安 103马力 10-18人 幼儿专用校车(SC6515XAG4)
					$res = $CHCARDb->get('all_model', ['group_concat(distinct tymc) as mod_name', 'group_concat(distinct bsqlx) as sma_tran', 'group_concat(distinct qdxs) as mod_drive'], sprintf(" and clxh != '' and clxh = '%s' group by clxh limit 1", $tmodArr['sma_gxb_code']), true);
					if(!empty($res['data']))
					{
						if(!empty($tmodArr['sma_tran']) && $tmodArr['sma_tran'] != '无') unset($res['data']['sma_tran']);
						$tmodArr = array_merge($tmodArr, $res['data']);
					}
					if(!empty($tmodArr['mod_name']))
					{
						if(!empty($tmodArr['sma_passenger'])) $tmodArr['mod_name'] .= ' '.$tmodArr['sma_passenger'].'人';
						if(!empty($tmodArr['sma_vtype'])) $tmodArr['mod_name'] .= ' '.$tmodArr['sma_vtype'];
						if(!empty($tmodArr['sma_gxb_code_show'])) $tmodArr['mod_name'] .= ' ('.$tmodArr['sma_gxb_code_show'].')';
					}
					$tmodArr = $this->fitSmaBaseData($tmodArr, $tmodArr['sma_vin']);

					//其他渠道信息
					$res = $YpwBase->get('stand_gxb_base', ['*'], sprintf(" and sgb_gxb_code='%s'", $tmodArr['sma_gxb_code']), true);
					if(!empty($res['data']))
					{
						$othArr = $res['data'];
						if(empty($tmodArr['mod_name']) && !empty($othArr['sgb_rname'])) $tmodArr['mod_name'] = $othArr['sgb_rname'];
						if(empty($tmodArr['sma_tran']) && !empty($othArr['sgb_rtran'])) $tmodArr['sma_tran'] = $othArr['sgb_rtran'];
						if(empty($tmodArr['mod_drive']) && !empty($othArr['sgb_rdrive'])) $tmodArr['mod_drive'] = $othArr['sgb_rdrive'];
						if(empty($tmodArr['xuhang']) && !empty($othArr['sgb_rxuhang'])) $tmodArr['xuhang'] = $othArr['sgb_rxuhang'];
						if(empty($tmodArr['sma_passenger']) && !empty($othArr['sgb_frontman'])) $tmodArr['sma_passenger'] = $othArr['sgb_frontman'];
					}
					if(!empty($tmodArr['mod_name'])) $tmodArr['mod_name'] = trim($tmodArr['mod_name'], ',');
				}
			}
			
			foreach($labelArr as $k=>$v)
			{
				if(!empty($tmodArr[$k])){
					$arr['para']['基本信息'][] = ['label'=>$v, 'val'=>$tmodArr[$k].($unitArr[$k]? $unitArr[$k]: '')];
					$hasLabel[] = '基本信息@'.$v;
				}
			}
			foreach($tmodArr as $k=>$v)
			{
				if(!empty($v) && isset($arr[$k])) $arr[$k] = $v;
			}
		}

		$res = $this->getCartImg($mod_id, $arr['mod_code_format']);
		$arr['pic'] = $res['data'];

		unset($arr['mod_code_format']);

		$res = $CartBase->get('cat_param', ['pam_class, pam_label, pam_value'], sprintf(" and pam_mod_id=%d", $mod_id));
		foreach($res['data'] as $v)
		{
			if(trim($v['pam_value']) == '' || in_array($v['pam_class'].'@'.$v['pam_label'], $hasLabel)) continue;
			if($v['pam_label'] == '发动机参数')
			{
				$tArr = json_decode($v['pam_value'], true);
				if(is_array($tArr))
				{
					foreach($tArr as $vv)
					{
						$val = $vv['engine'].' '.$vv['ml'].'cc '.$vv['kw'].'kw '.$vv['company'];
						$arr['para'][$v['pam_class']][] = ['label'=>'发动机', 'val'=>$val];
					}
					continue;
				}
			}
			$arr['para'][$v['pam_class']][] = ['label'=>$v['pam_label'], 'val'=>$v['pam_value']];
		}
		$temp = $arr['para'];
		$arr['mod_name'] = $arr['sma_brand'].' '.$arr['mod_name'];
		$arr['para'] = [];
		foreach($temp as $k=>$v)
		{
			$arr['para'][] = [
				'group'=>$k,
				'para'=>$v
			];
		}
		unset($arr['sma_gxb_code_show']);
		unset($arr['mod_id']);
		return LibFc::ReturnData(true, $arr);
	}

	/**
	  * @method 获取卡车或者工信部图片
	   * @param  $mod_id             string [二选一] 卡车车型ID
	   * @param  $gxbNum             string [二选一] 工信部型号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return {"status":true,"data":{"vin_year":"20080827","vin_year_name":"\u751f\u4ea7\u65e5\u671f"},"code":0}
	  */
	public function getCartImg($mod_id = 0, $gxbNum = '')
	{
		$imgArr = [];
		if(!empty($mod_id))
		{
			$CartBase = new CartBase();
			$res = $CartBase->get('cat_image', ['img_path, img_name'], sprintf(" and img_mod_id=%d", $mod_id));
			foreach($res['data'] as $v)
			{
				$imgArr[] = mvc::$cfg['urls']['cartPic'].$v['img_path'].'/'.$v['img_name'];
			}
		}
		
		$gxbNum = LibFc::FormatNum($gxbNum);
		if(empty($imgArr) && !empty($gxbNum))
		{
			$CartBase = new CartBase();
			$res = $CartBase->get('cat_model JOIN cat_image ON img_mod_id = mod_id', ['img_path, img_name'], sprintf(" and mod_code_format='%s' group by img_path, img_name limit 3", LibFc::Escape($gxbNum)));
			foreach($res['data'] as $v)
			{
				$imgArr[] = mvc::$cfg['urls']['cartPic'].$v['img_path'].'/'.$v['img_name'];
			}
			
			if(empty($imgArr))
			{
				$res = $this->get('yp_image_gxb', ['gxb_path as img_path, gxb_name as img_name'], sprintf(" and gxb_code='%s' and gxb_catch =1 order by gxb_order limit 3", LibFc::Escape($gxbNum)));
				foreach($res['data'] as $v)
				{
					$imgArr[] = mvc::$cfg['urls']['cartPic'].$v['img_path'].'/'.$v['img_name'];
				}
			}
		}
		return LibFc::ReturnData(true, $imgArr);
	}


	/**
	  * @method 获取解码的ypc车型图片  自有车型图片》精准型号图片》随机型号图片
	   * @param  $mod3Id             int [必填] 车型ID
	   * @param  $vin             string [必填] 车架号
	  * @author soul
	  * @copyright 2021/1/22
	  * @return 
	  */
	public function getYpcModelVinImg($mod3Id, $vin)
	{
		$imgArr = [];
		$vin = LibFc::FormatVin($vin);
		$mod3Id = (int) $mod3Id;
		if(!empty($mod3Id) && strlen($vin) == 17)
		{
			$res = $this->get('yp_model3_img', ["m3i_img"], sprintf(" and m3i_m3_id=%d order by m3i_ismain desc, m3i_seq", $mod3Id));
			foreach($res['data'] as $v)
			{
				$imgArr[] =  mvc::$cfg['FILE_CENTER']['b2c']['url_get'].'&c=model&f='.str_replace('/small/', '/', $v['m3i_img']).mvc::$cfg['FILE_CENTER']['b2c']['get_uri'];
			}

			//通过车架号查找图片
			if(empty($imgArr))
			{
				$gxbArr = [];
				//精准
				if($this->vinBase['vin'] == $vin && !empty($this->fullMatchFrom[0]['sma_gxb_code']))
				{
					$gxbArr[] = $this->fullMatchFrom[0]['sma_gxb_code'];
				}
				else
				{
					$YpwBase = new YpwBase();
					$smaTables = ['stand_model_any', 'stand_model_any_ocr'];
					foreach($smaTables as $table)
					{
						$res = $YpwBase->Get($table, ['sma_gxb_code'], sprintf(" and sma_vin='%s'", $vin), true);
						if(!empty($res['data']))
						{
							$gxbArr[] = $res['data']['sma_gxb_code'];
							break;
						}
					}
				}
				
				//相邻的
				if(empty($gxbArr))
				{
					if($this->xiangLinFromAny === null) $this->getAnyXinanglinVin($vin);
					if(is_array($this->xiangLinFromAny))
					{
						foreach($this->xiangLinFromAny as $v)
						{
							if(!empty($v['sma_gxb_code'])) $gxbArr[] = $v['sma_gxb_code'];
						}
					}
				}

				if(empty($gxbArr))
				{
					$res = $this->get('yp_model3_gxb_num', ['mg_code'], sprintf(" and mg_m3_id=%d", $mod3Id));
					$gxbArr = array_column($res['data'], 'mg_code');
				}
				if(!empty($gxbArr))
				{
					$gxbArr = array_unique($gxbArr);
					$res = $this->get('yp_image_gxb', ['gxb_path as img_path, gxb_name as img_name'], sprintf(" and gxb_code in ('%s') and gxb_catch =1 order by gxb_order limit 3", implode("','", $gxbArr)));
					foreach($res['data'] as $v)
					{
						$imgArr[] = mvc::$cfg['urls']['cartPic'].$v['img_path'].'/'.$v['img_name'];
					}
				}
			}
		}
		return LibFc::ReturnData(true, $imgArr);
	}

	/**
	  * @method 通过工信部型号和发动机型号获取功率
	  * @param  $gxb                string [必填] 工信部型号
	  * @param  $engine             string [必填] 发动机
	  * @param  $fromkw             string [必填] 随便一个可能的功率用于校验
	  * @param  $vin             string [必填] 车架号
	  * @param  $brand             string [必填] 进口时需要
	  * @author soul
	  * @copyright 2017/9/30
	  * @return {"status":true,"data":{"mod3_kw", "mod3_jgl_kw":["最大净功率","113kw"],"mod3_ed_kw":["额定功率","123kw"]}
	  */
	public function getGxbEngKw($gxb, $engine, $fromkw, $vin, $brand = '')
	{
		$arr = [];
		$gxb = LibFc::FormatNum($gxb);
		if(!empty($gxb))
		{
			$jsJinkou = !in_array(substr($vin, 0, 1), ['L', 'H']);
			$YpwVin = new YpwVin();
			if(!empty($this->vinBase['base']['xuhang'])) $arr['xuhang'] = $this->vinBase['base']['xuhang'];
			if(stripos($gxb, 'EV') && empty($arr['xuhang']))
			{
				$xhArr = [];
				$vin1_8 = substr($vin, 0, 8);
				$vin10_12 = substr($vin, 9, 3);
				$vin13_17 = substr($vin, 12, 5);
				$twhere = sprintf(" AND sma_vin1_8 ='%s' and sma_vin10_12 ='%s' and sma_gxb_code='%s' and sma_xuhang != ''", $vin1_8, $vin10_12, $gxb);
				if($engine != '') $twhere .= sprintf(" and sma_engine='%s'", LibFc::Escape($engine));
				if($jsJinkou && !empty($brand)) $twhere .= sprintf(" and sma_brand='%s'", LibFc::Escape($brand));

				$where = $twhere.sprintf(" and sma_vin13_17 <= '%s' ORDER BY sma_vin13_17 DESC LIMIT 3", $vin13_17);
				$res = $YpwVin->Get('stand_model_any', ['sma_xuhang xuhang'], $where);
				if(!empty($res['data'])) $xhArr = array_column($res['data'], 'xuhang');

				$where = $twhere.sprintf(" and sma_vin13_17 > '%s' ORDER BY sma_vin13_17 ASC LIMIT 3", $vin13_17);
				$res = $YpwVin->Get('stand_model_any', ['sma_xuhang xuhang'], $where);
				if(!empty($res['data'])) $xhArr = array_merge($xhArr, array_column($res['data'], 'xuhang'));

				if(!empty($xhArr))
				{
					$xhArr = array_unique($xhArr);
					$xhres = $YpwVin->formatXuhang($xhArr);
					if(!empty($xhres['data']['xuhang'])) $arr['xuhang'] = $xhres['data']['xuhang'];
				}
			}
			if($engine != '')
			{
				$where = sprintf(" and ckw_gxb_format='%s' and ckw_engine ='%s'", $gxb, LibFc::Escape($engine));
				if($jsJinkou && !empty($brand)) $where .= sprintf(" and ckw_brand='%s'", LibFc::Escape($brand));
				$res = $YpwVin->get('stand_gxbengine_kw', ['ckw_ed_kw, ckw_jgl_kw, ckw_dianchi, ckw_xuhang, ckw_paifang'], $where, true);
				if(!empty($res['data']))
				{
					$kwArr = $res['data'];
					$kwArr['ckw_ed_kw'] = empty($kwArr['ckw_ed_kw'])? []: explode(',', $kwArr['ckw_ed_kw']);
					$kwArr['ckw_jgl_kw'] = empty($kwArr['ckw_jgl_kw'])? []: explode(',', $kwArr['ckw_jgl_kw']);
					//功率
					if(!empty($kwArr['ckw_jgl_kw']) && in_array($fromkw, $kwArr['ckw_jgl_kw']))
					{
						$arr['mod3_jgl_kw'] = ['最大净功率', $fromkw.'kw'];
						$arr['mod3_kw'] = $fromkw;
						if(!empty($kwArr['ckw_ed_kw']) && !in_array($fromkw, $kwArr['ckw_ed_kw'])){
							$key = count($kwArr['ckw_ed_kw']) == 1 ? 0: array_search($fromkw, $kwArr['ckw_jgl_kw']);
							if(!empty($kwArr['ckw_ed_kw'][$key])){
								$arr['mod3_ed_kw'] = ['额定功率', $kwArr['ckw_ed_kw'][$key].'kw'];
							}
						}
					}
					else if(!empty($kwArr['ckw_ed_kw']) && in_array($fromkw, $kwArr['ckw_ed_kw']))
					{
						$arr['mod3_ed_kw'] = ['额定功率', $fromkw.'kw'];
						if(!empty($kwArr['ckw_jgl_kw']) && !in_array($fromkw, $kwArr['ckw_jgl_kw'])){//LSYYBADF5EC040310
							$key = count($kwArr['ckw_jgl_kw']) == 1? 0: array_search($fromkw, $kwArr['ckw_ed_kw']);
							if(!empty($kwArr['ckw_jgl_kw'][$key])){
								$arr['mod3_jgl_kw'] = ['最大净功率', $kwArr['ckw_jgl_kw'][$key].'kw'];
								$arr['mod3_kw'] = $kwArr['ckw_jgl_kw'][$key];
							}
						}
					}

					//电池种类
					if(!empty($kwArr['ckw_dianchi'])) $arr['dianchi'] = $kwArr['ckw_dianchi'];
					if(empty($arr['xuhang']) && !empty($kwArr['ckw_xuhang'])) $arr['xuhang'] = $kwArr['ckw_xuhang'];
					if(!empty($kwArr['ckw_paifang'])) $arr['paifang'] = $kwArr['ckw_paifang'];
				}
			}
			if(stripos($gxb, 'EV'))
			{
				if(empty($arr['dianchi'])){
					$res = $YpwVin->get('stand_gxbengine_kw', ['ckw_dianchi'], sprintf(" and ckw_gxb_format='%s' and ckw_dianchi !='' limit 1", $gxb), true);
					if(!empty($res['data'])) $arr['dianchi'] = $res['data']['ckw_dianchi'];
				}
				if(empty($arr['xuhang'])){
					$res = $YpwVin->get('stand_gxbengine_kw', ['ckw_xuhang'], sprintf(" and ckw_gxb_format='%s' and ckw_engine ='' and ckw_xuhang !='' limit 1", $gxb), true);
					if(!empty($res['data'])) $arr['xuhang'] = $res['data']['ckw_xuhang'];
				}
			}
		}
		return LibFc::ReturnData(true, $arr);
	}

	/**
	  * @method 根据总表计算VIN相邻计算车架号的 发动机 排量 长 宽 高 轴距  	LZZ1BAFB5HE619835
	  * @param  $smaArr             array [必填] 已有数据['sma_vin'=>''....]
	  * @author soul
	  * @copyright 2023/2/14
	  * @return 
	  */
	public function jsVinSmaNullData($smaArr)
	{
		$vin = $smaArr['sma_vin'];
		$vin13_17 = substr($vin, 12, 5);
		$jsJinkou = !in_array(substr($vin, 0, 1), ['L', 'H']);

		$YpwVin = new YpwVin();
		$fileds = ['sma_engine', 'sma_wheel', 'sma_weight', 'sma_length', 'sma_width', 'sma_height', 'sma_cc','sma_kw', 'sma_passenger'];
		if($jsJinkou){
			if(empty($smaArr['sma_gxb_code'])) $fileds[] = 'sma_gxb_code';
			if(empty($smaArr['sma_brand'])) $fileds[] = 'sma_brand';
		}
		$gfiles = [];
		foreach($fileds as $kf=>$filed)
		{
			if(!empty($smaArr[$filed])){
				unset($fileds[$kf]);
			}else{
				if(in_array($filed, ['sma_wheel', 'sma_weight', 'sma_length', 'sma_width', 'sma_height', 'sma_passenger'])){
					$gfiles[$filed] = sprintf("group_concat(distinct %s) %s, sum(case when %s != 0 and %s != '' then 1 else 0 end)/count(*) %s_hasrate", $filed, $filed, $filed, $filed, $filed);
				}else{
					$gfiles[$filed] = sprintf("group_concat(distinct %s) %s, sum(case when %s != '0' and %s != '' then 1 else 0 end)/count(*) %s_hasrate", $filed, $filed, $filed, $filed, $filed);
				}
			}
		}
		if(empty($fileds)) return LibFc::ReturnData(true, $smaArr);
		$comwhere = sprintf(" AND sma_vin1_8='%s' and sma_vin10_12='%s'", substr($vin, 0, 8), substr($vin, 9, 3));
		if(!$jsJinkou || !empty($smaArr['sma_gxb_code'])) $comwhere .= sprintf(" and sma_gxb_code='%s'", $smaArr['sma_gxb_code']);
		if($jsJinkou && !empty($smaArr['sma_brand'])) $comwhere .= sprintf(" and sma_brand='%s'", LibFc::Escape($smaArr['sma_brand']));
	
		//这些字段是否有唯一值，且这个值占比超过10%（CC6470AH0AB 只有一条记录） 2023/5/30 	
		$res = $YpwVin->Get('stand_model_any', $gfiles, $comwhere, true);
		$tdata = $res['data'];
		foreach($gfiles as $tf=>$ts)
		{
			if(isset($tdata[$tf]))
			{
				$vals = [];
				foreach(explode(',', $tdata[$tf]) as $tval)
				{
					if(!empty($tval)) $vals[] = $tval;
				}
				$vals = array_unique($vals);
				if(count($vals) == 1 && $tdata[$tf.'_hasrate'] > 0.1){
					$smaArr[$tf] = $vals[0];
					$kf = array_search($tf, $fileds); 
					unset($fileds[$kf]);
				}else if(empty($vals)){
					//字段均无值
					$kf = array_search($tf, $fileds); 
					unset($fileds[$kf]);
				}
			}
		}
		
		if(empty($fileds)) return LibFc::ReturnData(true, $smaArr);

		//上下50条，此字段有值的最近三条，值唯一则赋值
		$count = 50;
		$valCount = 3;
		$where = $comwhere.sprintf(" and sma_vin13_17 <= '%s' ORDER BY sma_vin13_17 DESC LIMIT %s", $vin13_17, $count);
		$res = $YpwVin->Get('stand_model_any', $fileds, $where);
		$sxRowsArr = ['X'=>$res['data']];
		$where = $comwhere.sprintf(" and sma_vin13_17 > '%s' ORDER BY sma_vin13_17 ASC LIMIT %d", $vin13_17, $count);
		$res = $YpwVin->Get('stand_model_any', $fileds, $where);
		$sxRowsArr['S'] = $res['data'];
		$vals = [];
		$coutlAll = 0;
		foreach($sxRowsArr as $type=>$rows)
		{
			foreach($rows as $row)
			{
				foreach($fileds as $filed)
				{
					if(!empty($row[$filed]) && (empty($vals[$filed]['count'][$type]) || $vals[$filed]['count'][$type] < $valCount))
					{
						if(!isset($vals[$filed]['count'][$type])) $vals[$filed]['count'][$type] = 0;
						$vals[$filed]['count'][$type]++;
						$vals[$filed]['vals'][] = $row[$filed];
						$vals[$filed]['total']++;
					}
				}
			}
		}
		
		//LTA1222L4F2000843  CC6470AH0AB
		foreach($fileds as $kf=>$filed)
		{
			//上下都有值或者单向有值但是对向样例数不够最大值
			if(empty($smaArr[$filed]) && !empty($vals[$filed]['vals']) && (
				(isset($vals[$filed]['count']['X']) && isset($vals[$filed]['count']['S']) && $vals[$filed]['count']['X'] > 0 && $vals[$filed]['count']['S'] > 0 ) ||
				(isset($vals[$filed]['count']['X']) && $vals[$filed]['count']['X'] > 0 && count($sxRowsArr['S']) < $count) ||
				(isset($vals[$filed]['count']['S']) && $vals[$filed]['count']['S'] > 0 && count($sxRowsArr['X']) < $count)
			))
			{
				$vals[$filed]['vals'] = array_unique($vals[$filed]['vals']);
				//最近三条，值唯一则赋值
				if(count($vals[$filed]['vals']) == 1 && $vals[$filed]['total'] > 2){
					$smaArr[$filed] =$vals[$filed]['vals'][0];
					unset($fileds[$kf]);
				}
			}
		}

		/*
		//CC6470AH0AB区间过大
		foreach($fileds as $kf=>$filed)
		{
			if(!empty($smaArr[$filed]) || (isset($gunivals[$tf]) && empty($gunivals[$tf])))
			{
				unset($fileds[$kf]);
				continue;
			} 
			//$btime = microtime(true);
			$vals = [];
			$twhere = in_array($filed, ['sma_wheel', 'sma_weight', 'sma_length', 'sma_width', 'sma_height'])? sprintf(" and %s > 0", $filed): sprintf(" and %s != ''", $filed);
			$where = $comwhere.$twhere.sprintf(" and sma_vin13_17 <= '%s' ORDER BY sma_vin13_17 DESC LIMIT 3", $vin13_17);
			$res = $YpwVin->Get('stand_model_any', $fileds, $where);
			$rows = $res['data'];
	
			$where = $comwhere.$twhere.sprintf(" and sma_vin13_17 > '%s' ORDER BY sma_vin13_17 ASC LIMIT 3", $vin13_17);
			$res = $YpwVin->Get('stand_model_any', $fileds, $where);
			if(!empty($res['data'])) $rows = array_merge($rows, $res['data']);
			foreach($rows as $row)
			{
				foreach($row as $ttf=>$ttv)
				{
					if(!empty($ttv)) $vals[$ttf][] = $ttv;
				}
			}
			
			foreach($vals as $vk=>$vv)
			{
				$vv = array_unique($vv);
				if(count($vv) == 1)
				{
					$smaArr[$vk] = $vv[0];
				}
			}
			//echo $filed, '=>', ceil((microtime(true) - $btime)*1000), "ms\n";
		}*/
		
		return LibFc::ReturnData(true, $smaArr);
	}

	
	/**
	  * @method 获取车架号的基本信息 例如 生产日期
	  * @param  $vin                string [必填] 17位车架号  LC0CG4CG7F0004330
	  * @param  $type               string [选填] 默认所有  onlydate:仅取日期
	  * @author soul
	  * @copyright 2017/9/30
	  * @return {"status":true,"data":{"vin_year":"2015-03","vin_year_style":"buid","vin_year_name":"制造日期","mod3_jgl_kw":["最大净功率","113kw"],"mod3_ed_kw":["额定功率","123kw"],"param":[["尺寸","4820mm*1810mm*1765mm","size"],["轴距","2960mm","wheel"],["车辆类型","乘用车","vtype"],["整备质量","1790kg","weight"],["载客","7人","passenger"]]}
	  */
	public function getVinBaseInfo($vin, $type = '')
	{
		$vin = LibFc::FormatVin($vin);
		$isJinkou = !in_array(substr($vin, 0, 1), ['L', 'H'])? true: false;
		$arr = [];
		if(strlen($vin) == 17)
		{
			$arr = ['vin_year'=>(string)  LibFc::VinYear($vin), 'vin_year_style'=>'year', 'vin_year_name'=>'年份'];
			$YpwBase = new YpwBase();

			if($this->fullMatchFrom === null) $this->getOnlyMatchVin($vin, $type);
			if(!empty($this->fullMatchFrom))
			{
				$temp = $this->fullMatchFrom[0];
				if(empty($type) || $type != 'onlydate')
				{
					if(!empty($temp['sma_gxb_code']))
					{//功率问题 2022/6/27
						$res = $this->getGxbEngKw($temp['sma_gxb_code'], $temp['sma_engine'], $temp['sma_kw'], $vin, $temp['sma_brand']);
						$arr = array_merge($arr, $res['data']);
					}

					if($temp['sma_engine'] != '') $arr['mod3_engine'] = $temp['sma_engine'];
					if(!empty($temp['sma_xuhang'])) $arr['xuhang'] = $temp['sma_xuhang'];
					if(!empty($temp['sma_jkyear'])) $arr['param']['jkyear'] = ['进口日期', $temp['sma_jkyear'], 'jkyear'];
					//临时新版本发布后可取消
					if(!empty($arr['paifang'])) $arr['param']['paifang'] = ['排放标准', $arr['paifang'], 'paifang'];
					
					if(!empty($temp['sma_length']) && !empty($temp['sma_width']) && !empty($temp['sma_height'])) $arr['param']['size'] = ['尺寸', $temp['sma_length'].'mm*'.$temp['sma_width'].'mm*'.$temp['sma_height'].'mm', 'size'];
					if(!empty($temp['sma_wheel'])) $arr['param']['wheel'] = ['轴距', $temp['sma_wheel'].'mm', 'wheel'];
					if(!empty($temp['sma_vtype'])) $arr['param']['vtype'] = ['车辆类型', $temp['sma_vtype'], 'vtype'];
					if(!empty($temp['sma_weight'])) $arr['param']['weight'] = ['整备质量', $temp['sma_weight'].'kg', 'weight'];
					if(!empty($temp['sma_passenger'])){
						$arr['param']['passenger'] = ['载客', $temp['sma_passenger'].'人', 'passenger'];
						$arr['passenger'] = $temp['sma_passenger'];
					}
				}
				if(!empty($temp['sma_year']))
				{
					$arr['vin_year'] = $temp['sma_year'];
					$arr['vin_year_style'] = 'buid';
					$arr['vin_year_name'] = '制造日期';
					$this->vinYearFrom = 'match';
				}
			}
			else if(empty($type) || $type != 'onlydate')
			{
				if($this->xiangLinFromAny === null) $this->getAnyXinanglinVin($vin);
				if(!empty($this->xiangLinFromAny))
				{//相邻算法
					$uniArr = [];
					foreach($this->xiangLinFromAny as $tv)
					{
						$uniArr[$tv['sma_gxb_code'].'@'.$tv['sma_engine']]= $tv;
					}
					if(!empty($uniArr))
					{
						$lxbase = ['dianchi'=>[], 'xuhang'=>[], 'paifang'=>[]];
						foreach($uniArr as $tv)
						{
							$res = $this->getGxbEngKw($tv['sma_gxb_code'], $tv['sma_engine'], $tv['sma_kw'], $vin, $tv['sma_brand']);
							foreach($res['data'] as $fk=>$fv)
							{
								$lxbase[$fk][] = $fv;
							}
							/*if(!empty(['dianchi'])) $lxbase['dianchi'][] = $res['data']['dianchi'];
							if(!empty($res['data']['xuhang'])) $lxbase['xuhang'][] = $res['data']['xuhang'];
							if(!empty($res['data']['paifang'])) $lxbase['paifang'][] = $res['data']['paifang'];*/
						}
						foreach($lxbase as $fk=>$fv)
						{
							$fv = array_unique($fv);
							if(count($fv) == 1) $arr[$fk] = $fv[0];
						}
						/*$lxbase['dianchi'] = array_unique($lxbase['dianchi']);
						$lxbase['xuhang'] = array_unique($lxbase['xuhang']);
						$lxbase['paifang'] = array_unique($lxbase['paifang']);
						if(count($lxbase['dianchi']) == 1) $arr['dianchi'] = implode(',', array_unique($lxbase['dianchi']));
						if(count($lxbase['xuhang']) == 1)  $arr['xuhang'] = implode(',', array_unique($lxbase['xuhang']));
						if(count($lxbase['paifang']) == 1) $arr['paifang'] = implode(',', array_unique($lxbase['paifang']));*/
						//临时新版本发布后可取消
						if(!empty($arr['paifang'])) $arr['param']['paifang'] = ['排放标准', $arr['paifang'], 'paifang'];
					}
				}
			}
			if(!empty($arr['param'])) $arr['param'] = array_values($arr['param']);

			if(!empty($arr['vin_year']) && $this->vinYearFrom  == 'match')
			{
				return LibFc::ReturnData(true, $arr);
			}
			else
			{
				$res = $YpwBase->Get('yp_allvin_base', ['alb_date as vin_year'], sprintf(" and alb_vin='%s' and alb_date != '' limit 1", $vin), true);
				if(!empty($res['data']))
				{
					$arr['vin_year'] = $res['data']['vin_year'];
					$arr['vin_year_style'] = 'buid';
					$arr['vin_year_name'] = '制造日期';
					$this->vinYearFrom = 'match';
					return LibFc::ReturnData(true, $arr);
				}
			}
			
			//epc
			$res = $this->getFanChaWmi();
			$wmiArr = $res['data'];
			$vin1_8 = substr($vin, 0, 8);
			if(!empty($wmiArr['getYpcModelByToyotaVin']) && stripos($wmiArr['getYpcModelByToyotaVin'], $vin1_8) !== false)
			{
				$this->getYpcModelByToyotaVin($vin);
				if($this->vinYearFrom  == 'epc' && strlen($this->vinBase['base']['vin_year']) > 4)
				{
					$arr['vin_year'] = $this->vinBase['base']['vin_year'];
					$arr['vin_year_style'] = $this->vinBase['base']['vin_year_style'];
					$arr['vin_year_name'] = $this->vinBase['base']['vin_year_name'];
					return LibFc::ReturnData(true, $arr);
				}
			}
			
			//根据规则计算日期概率
			$vin1_3 = substr($vin, 0, 3);
			$vin12 = substr($vin, 11, 1);
			$vin12_17 = substr($vin, 11, 6);
			$vin13_17 = substr($vin, 12, 5);

			if(!preg_match('/\d{5}/', $vin13_17, $m)) return LibFc::ReturnData(true, $arr);
			$this->vinYearFrom = 'reg';
			$res = $YpwBase->Get('yp_allvin_date_reg', ['aldr_reg_use'], sprintf(" and aldr_vin1_3='%s'", $vin1_3), true);
			if(!empty($res['data']['aldr_reg_use']))
			{
				$regArr = explode(',', $res['data']['aldr_reg_use']);
				$minAbs = [];
				foreach($regArr as $rf)
				{
					$rows = [];
					switch($rf)
					{
						case 'aldr_reg1_3_10_11':
						case 'aldr_reg1_8_10_11':
							if(!preg_match('/\d/', substr($vin, 11, 1), $m)) break;
							$twhere = sprintf(" and alb_date != '' and alb_vin1_3='%s' and alb_vin10_11='%s'", $vin1_3, substr($vin, 9, 2));
							if($rf == 'aldr_reg1_8_10_11')
								$twhere = sprintf(" and alb_date != '' and alb_vin1_3='%s' and alb_vin4_8='%s' and alb_vin10_11='%s'", $vin1_3, substr($vin, 3, 5), substr($vin, 9, 2));
							$filed = ['alb_vin vin, abs(CONCAT(alb_vin12, alb_vin13_17)-'.$vin12_17.') as vin_abs, alb_date as vin_year'];
							
							//最小值
							$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and CONCAT(alb_vin12, alb_vin13_17) <'%s' order by CONCAT(alb_vin12, alb_vin13_17) desc limit 1", $vin12_17), true);
							if(!empty($res['data'])) $rows[] = $res['data'];
							
							//最大值
							$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and CONCAT(alb_vin12, alb_vin13_17) >='%s' order by CONCAT(alb_vin12, alb_vin13_17) asc limit 1", $vin12_17), true);
							if(!empty($res['data'])) $rows[] = $res['data'];
						break;

						case 'aldr_reg1_3_10_12':
						case 'aldr_reg1_8_10_12':
							$twhere = sprintf(" and alb_date != '' and alb_vin1_3='%s' and alb_vin10_11='%s' and alb_vin12='%s'", $vin1_3, substr($vin, 3, 5), substr($vin, 9, 2), substr($vin, 11, 1));
							if($rf == 'aldr_reg1_8_10_12')
								$twhere = sprintf(" and alb_date != '' and alb_vin1_3='%s' and alb_vin4_8='%s' and alb_vin10_11='%s' and alb_vin12='%s'", substr($vin, 0, 3), substr($vin, 3, 5), substr($vin, 9, 2), substr($vin, 11, 1));

							$filed = ['alb_vin vin, abs(alb_vin13_17-'.$vin13_17.') as vin_abs, alb_date as vin_year'];
							$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and alb_vin13_17 <'%s' order by alb_vin13_17 desc limit 1", $vin13_17), true);
							//最小值
							if(!empty($res['data'])) $rows[] = $res['data'];

							//最大值
							$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and alb_vin13_17 >='%s' order by alb_vin13_17 asc limit 1", $vin13_17), true);
							if(!empty($res['data'])) $rows[] = $res['data'];
						break;
					}
					if(!empty($rows)) break;
				}
			}
			else
			{
				//差值算法
				$rows = [];
				$twhere = sprintf(" and alb_vin1_3='%s' and alb_vin4_8='%s' and alb_vin10_11='%s' and alb_vin12='%s' and alb_date != ''", substr($vin, 0, 3), substr($vin, 3, 5), substr($vin, 9, 2), substr($vin, 11, 1));
				$filed = ['alb_vin vin, abs(alb_vin13_17-'.$vin13_17.') as vin_abs, alb_date as vin_year'];
				
				$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and alb_vin13_17 <'%s' order by alb_vin13_17 desc limit 1", $vin13_17), true);
				if(!empty($res['data'])){
					$rows[] = $res['data'];
				}else{
					$twhere = sprintf(" and alb_vin1_3='%s' and alb_vin4_8='%s' and alb_vin10_11='%s' and alb_date != ''", substr($vin, 0, 3), substr($vin, 3, 5), substr($vin, 9, 2));
					$filed = ['alb_vin vin, alb_vin12, alb_vin13_17, alb_date as vin_year'];
					$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and concat(alb_vin12, alb_vin13_17) <'%s' order by alb_vin12 desc, alb_vin13_17 desc limit 1", $vin12_17), true);
					if(!empty($res['data'])){
						$row = $res['data'];
						if($row['alb_vin12'] < $vin12){
							$row['vin_abs'] = ((int) '1'.$vin13_17) - ((int) '0'.$row['alb_vin13_17']);
						}else{
							$row['vin_abs'] = abs($vin13_17 - $row['alb_vin13_17']);
						}
						$rows[] = $row;
					}
				}
				
				$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and alb_vin13_17 >='%s' order by alb_vin13_17 asc limit 1", $vin13_17), true);
				if(!empty($res['data'])){
					$rows[] = $res['data'];
				}else{
					$twhere = sprintf(" and alb_vin1_3='%s' and alb_vin4_8='%s' and alb_vin10_11='%s' and alb_date != ''", substr($vin, 0, 3), substr($vin, 3, 5), substr($vin, 9, 2));
					$filed = ['alb_vin vin, alb_vin12, alb_vin13_17, alb_date as vin_year'];
					$res = $YpwBase->Get('yp_allvin_base', $filed, $twhere.sprintf(" and concat(alb_vin12, alb_vin13_17) >='%s' order by alb_vin12 asc, alb_vin13_17 asc limit 1", $vin12_17), true);
					if(!empty($res['data'])){
						$row = $res['data'];
						if($row['alb_vin12'] > $vin12){
							$row['vin_abs'] = ((int) '1'.$row['alb_vin13_17']) - ((int) '0'.$vin13_17);
						}else{
							$row['vin_abs'] = abs($row['alb_vin13_17'] - $vin13_17);
						}
						$rows[] = $row;
					}
				}
			}

			if(!empty($rows[0]['vin_year'])) $rows[0]['vin_year'] = preg_replace('/[^0-9]/', '', $rows[0]['vin_year']);
			if(!empty($rows[1]['vin_year'])) $rows[1]['vin_year'] = preg_replace('/[^0-9]/', '', $rows[1]['vin_year']);
			
			//只有单侧数据时，如果相差不大，则直接取当前时间 获取两个时间一样时取第一个
			if(
				count($rows) == 1 && $rows[0]['vin_abs'] < 3000 ||
				(count($rows) == 2 && $rows[0]['vin_year'] == $rows[1]['vin_year'])
			)
			{
				$arr['vin_year'] = $rows[0]['vin_year'];
				//区间太大时只取月份 20210606
				if($rows[0]['vin_abs'] > 100 && strlen($arr['vin_year']) > 6)
					$arr['vin_year'] = substr($rows[0]['vin_year'], 0, 6);
			}
			else if(count($rows) == 2 && strlen($rows[0]['vin_year']) > 4 &&  strlen($rows[1]['vin_year']) > 4)
			{
				//精准到日
				if(strlen($rows[0]['vin_year']) > 6 &&  strlen($rows[1]['vin_year']) > 6)
				{
					$xcDate = ceil(abs(strtotime($rows[0]['vin_year']) - strtotime($rows[1]['vin_year']))/3600/24);
					if($xcDate <= 7)
					{//相差小于7天就近取日
						if($rows[0]['vin_abs'] <= $rows[1]['vin_abs'])
						{
							$arr['vin_year'] = $rows[0]['vin_year'];
						}
						else if($rows[0]['vin_abs'] > $rows[1]['vin_abs'])
						{
							$arr['vin_year'] = $rows[1]['vin_year'];
						}
					}
				}

				if(strlen($arr['vin_year']) < 6)
				{
					$rows[0]['vin_yearm'] = substr($rows[0]['vin_year'], 0, 6);
					$rows[1]['vin_yearm'] = substr($rows[1]['vin_year'], 0, 6);

					//转到1号计算相差天数
					$xcDate = ceil(abs(strtotime($rows[0]['vin_yearm'].'01') - strtotime($rows[1]['vin_yearm'].'01'))/3600/24);
					//相差少于31天
					if($xcDate <= 31)
					{
						if($rows[0]['vin_abs'] <= $rows[1]['vin_abs'])
						{
							$arr['vin_year'] = $rows[0]['vin_yearm'];
						}
						else if($rows[0]['vin_abs'] > $rows[1]['vin_abs'])
						{
							$arr['vin_year'] = $rows[1]['vin_yearm'];
						}
					}
					else if($rows[0]['vin_abs'] <= 1000 && $rows[0]['vin_abs'] < $rows[1]['vin_abs'])
					{//第一个最小绝对值小于1000
						$arr['vin_year'] = $rows[0]['vin_yearm'];
					}
					else if($rows[1]['vin_abs'] <= 1000 && $rows[1]['vin_abs'] < $rows[0]['vin_abs'])
					{//第二个最小绝对值小于1000
						$arr['vin_year'] = $rows[1]['vin_yearm'];
					}
				}
			}

			$arr['vin_year'] = preg_replace('/[^0-9]/', '', $arr['vin_year']);
			if(strlen($arr['vin_year']) == 6)
			{
				$arr['vin_year'] = date('Y-m', strtotime($arr['vin_year'].'01'));
			}
			else if(strlen($arr['vin_year']) > 6)
			{
				$arr['vin_year'] = date('Y-m-d', strtotime($arr['vin_year']));
			}
			if(strlen($arr['vin_year']) >= 6)
			{
				$arr['vin_year_style'] = 'buid';
				$arr['vin_year_name'] = '制造日期';
			}
			else if($isJinkou)
			{
				//进口日期
				$res = $YpwBase->Get('stand_model_any', ['sma_jkyear as vin_year'], sprintf(" and sma_vin='%s' and sma_jkyear != '' limit 1", $vin), true);
				if(!empty($res['data']))
				{
					$arr['vin_year'] = $res['data']['vin_year'];
					$arr['vin_year_style'] = 'jinkou';
					$arr['vin_year_name'] = '进口日期';
					unset($arr['param']['jkyear']);
					if(!empty($arr['param'])) $arr['param'] = array_values($arr['param']);
					return LibFc::ReturnData(true, $arr);
				}
			}
		}
		if(!empty($arr['param'])) $arr['param'] = array_values($arr['param']);
		return LibFc::ReturnData(true, $arr);
	}



	/**
	  * @method 获取VIN的工信部型号
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2019/12/13
	  * @return 
	  */
	public function getVinGxbCode($vin)
	{
		$vin = LibFc::FormatVin($vin);
		if(strlen($vin) < 17) return LibFc::ReturnData(true, []);
		
		$vin1_8 = substr($vin, 0, 8);
		$res = $this->getFanChaWmi();
		$wmiArr = $res['data'];
		$arr = [];
		foreach($this->fanChaArr as $funName=>$val)
		{
			if(!empty($wmiArr[$funName] && stripos($wmiArr[$funName], $vin1_8) !== false))
			{
				switch($val['table'])
				{
					case 'temp_changan':
						$res = $this->get('temp_changan',  ['cha_model as gxb, 1 as islike, cha_vin as sma_vin'], sprintf(" and cha_vin='%s' and cha_model != ''", $vin), true);
						if(!empty($res['data'])) $arr[] = $res['data'];
					break;
					case 'da_catch_vin_7':
						$res = $this->get('da_catch_vin_7',  ['dcv_gxb as gxb, 1 as islike, dcv_vin as sma_vin'], sprintf(" and dcv_vin='%s' and dcv_gxb != ''", $vin), true);
						if(!empty($res['data'])) $arr[] = $res['data'];
					break;
				}
			}
			if(!empty($arr)) break;
		}
		return LibFc::ReturnData(true, $arr);
	}


	/**
	  * @method 查询车架号的所属品牌
	  * @param  $vin  17位车架号
	  * @author soul
	  * @copyright 2020/5/15
	  * @return {"status":true,"data":{"brand_id":"62","brand_name":"\u4e30\u7530","brand_code":"FENGTIAN"},"code":0}
	  */
	public function getBrandByVin($vin)
	{
		$arr = ['brand_id'=>0, 'brand_name'=>'', 'brand_code'=>''];
		$vin = LibFc::FormatVin($vin);
		if(strlen($vin) == 17)
		{
			$vin1_8 = LibFc::Escape(substr($vin, 0, 8));
			$vin10_12 = LibFc::Escape(substr($vin, 9, 3));
			$YpwBase = new YpwBase();
			$whereArr = [
				sprintf(" and vbd_brand_id > 0 and vbd_vin1_8='%s' and vbd_vin10_12='%s' limit 1", $vin1_8, $vin10_12),
				sprintf(" and vbd_brand_id > 0 and vbd_vin1_8='%s' limit 1", $vin1_8),
			];
			$brandId = 0;
			foreach($whereArr as $where)
			{
				$res = $YpwBase->get('ypc_vin_brand_demo', ['vbd_brand_id'], $where, true);
				if(!empty($res['data']))
				{
					$brandId = $res['data']['vbd_brand_id'];
					break;
				}
			}

			//品牌信息
			if($brandId > 0)
			{
				$res = $this->get('yp_brand', ['b_id as brand_id', 'b_name as brand_name', 'b_code as brand_code'], sprintf(" and b_id=%d", $brandId), true);
				if(!empty($res['data']))
				{
					$arr = $res['data'];
				}
			}
		}
		return LibFc::ReturnData(true, $arr);
	}
	

	/**
	  * @method 通过关键字查询品牌ID
	  * @param  $word
	  * @author soul
	  */
	public function getBrandIdByWord($word)
	{
		$brand_id = 0;
		if(!empty($word))
		{
			$re = ['牌'=>''];
			$word = LibFc::Escape(strtr($word, $re));
			$res = $this->get('yp_brand', ['b_id'], sprintf(" and (b_name='%s' or b_keyword like '%%%s%%') order by length(b_name) limit 1", $word, $word), true);
			$brand_id = (int) $res['data']['b_id'];
		}
		return $brand_id;
	}
	

	/**
	  * @method 根据$this->xiangLinFromAny判断VIN是否属于多型号，并设置图片状态
	  * @author soul
	  * @return {"status":true,"data":{"isany":"0|1"},"code":0}
	  */
	private function setVinImgAnyGxb($vin)
	{
		$arr = ['isany'=>0, 'iszd'=>0];
		if(!empty($this->xiangLinFromAny))
		{
			$gxbs = array_unique(array_column($this->xiangLinFromAny, 'sma_gxb_code'));
			if(count($gxbs) > 1)
			{
				LibFc::useMainDb();//主库，读库有时间差
				$YpwVin = new YpwVin();
				$arr['isany'] = 1;
				
				//是否需要采集泽达
				$vin1 = substr($vin, 0, 1);
				$wmi = substr($vin, 0, 3);
				$ignorWmiArr = ['LCU','LFB','LFM','LFP','LTV','LVG','LHG','LVH','LSJ','LNP','LSJ','LBE','LNB','LS1','LJD'];
				if(in_array($vin1, ['L','H']) && !in_array($wmi, $ignorWmiArr))
				{
					$vinYear = LibFc::VinYear(substr($vin, 9, 1));
					//if($vinYear >= 2000 && $vinYear <= 2020)
					if($vinYear >= 2000)
					{
						$zdres = $YpwVin->catchAnyVinfromZdApi([$vin], 3, 'anygxb');
						$arr['iszd'] = !empty($zdres['data'][$vin]['viz_gxb_code'])? 1: -1;
					}
				}
				$YpwVin->set('stand_vin_imgs', ['vii_anygxb'=>1], sprintf(" and vii_status != 1 and vii_vin='%s'  and vii_anygxb != 1", $vin));
			}
		}
		return LibFc::ReturnData(true, $arr);
	}
	

	/**
	  * @method 根据token和车架号配置 判断是否可以直接取泽达数据
	  * @author soul
	  * @return {"status":true,"data":{"iszd":"-1无数据|0|1"},"code":0}
	  */
	private function getGetZedaApi($vin)
	{
		$arr = ['iszd'=>0];
		
		if(empty($this->fullMatchFrom))
		{	
			$from = '';
			if(!empty(mvc::$cfg['RQTOKEN']['decodeVinZd'])){
				$from = mvc::$cfg['RQTOKEN']['user'];
			}else if(!empty(mvc::$cfg['VINSHOPID']) && in_array(mvc::$cfg['VINSHOPID'], mvc::$cfg['DECODEVINZD']['shopid'])){
				$from = 'shop_'.mvc::$cfg['VINSHOPID'];
			}
			if(!empty($from))
			{
				$vin1_8 = substr($vin, 0, 8);
				$vin10 = substr($vin, 9, 1);
				//是否需要采集泽达
				if(!empty($this->isZdcofArr[$vin1_8]) && stripos($this->isZdcofArr[$vin1_8], $vin10) !== false)
				{
					LibFc::useMainDb();//主库，读库有时间差
					$YpwVin = new YpwVin();
					$zdres = $YpwVin->catchAnyVinfromZdApi([$vin], 3, $from);
						
					$arr['iszd'] = !empty($zdres['data'][$vin]['viz_gxb_code'])? 1: -1;
				}
			}
		}
		return LibFc::ReturnData(true, $arr);
	}
	 
	//获取驱动的端名 手自一体 手动 自动
	public function getShortTran($tran)
	{
		if(stripos($tran, 'AMT') !== false || stripos($tran, 'A/MT') !== false || stripos($tran, '手自') !== false){
			$tran = '手自一体';
		}else if(stripos($tran, 'MT') !== false || stripos($tran, '手动') !== false){
			$tran = '手动';
		}else if(stripos($tran, 'AT') !== false || stripos($tran, 'CVT') !== false || stripos($tran, '电机') !== false || stripos($tran, '自动') !== false || stripos($tran, 'DCT') !== false){
			$tran = '自动';
		}
		return $tran;
	}
}