<?php
/**
*VIN解码
*/
class vinAction extends baseAction
{
	/**
	  * @method get  VIN解码
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @param  shopid             string [选填] 查询的店铺ID  
	  * @author soul
	  * @copyright 2020/7/23
	  * @return * @param  $vin  17位车架号
	  * @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: LS5A2ABE0CA510728
		{"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()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$vin = $Params['vin'];
		mvc::$cfg['VINSHOPID'] = isset($Params['shopid'])? (int) $Params['shopid'] : 0;
		$othcfg = [];
		if($Params['gxbcode']) $othcfg['gxbcode'] = $Params['gxbcode'];
		$res = $YpcVin->decodeVin($vin, '', $othcfg);
		$YpcVin->tongjiVin($vin, $res['data']['from']);
		LibFc::EchoJson($res);
	}


		/**
	  * @method get  VIN解码(只返回宜配车型信息)
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @author soul
	  * @copyright 2020/7/23
	  * @return * @param  $vin  17位车架号
	  * @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}
	  */
	public function decodeVinOnlyYpcModel()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$vin = $_GET['vin'];
		$res = $YpcVin->decodeVin($vin);
		$YpcVin->tongjiVin($vin, $res['data']['from']);
		$arr = [];
		if($res['data']['from'] == 'ypc')
		{
			$arr = $res['data']['model'];
		}
		LibFc::ReturnJson(true, $arr);
	}



	/**
	  * @method 查询车架号的所属品牌
	  * @http	get
	  * @param  vin               string [必填] 车架号
	  * @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()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getBrandByVin($Params['vin']);
		LibFc::EchoJson($res);
	}
	
	/**
	  * @method 获取车架号的基本信息 例如 生产日期
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号  LBELMBKC1EY570664
	  * @param  type               string [选填] 默认所有  onlydate:仅取日期
	  * @author soul
	  * @copyright 2019/10/24
	  * @return {"status":true,"data":{"vin_year":"20080827","vin_year_style":"buid","vin_year_name":"\u751f\u4ea7\u65e5\u671f"},"code":0}
	  */
	public function getVinBaseInfo()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getVinBaseInfo($Params['vin'], $Params['type']);
		LibFc::EchoJson($res);
	}

	/**
	  * @method 获取解码的ypc车型图片
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  mod3Id             int [必填] 车型ID
	  * @param  vin                string [必填] 17位车架号  LBELMBKC1EY570664
	  * @author soul
	  * @copyright 2019/10/24
	  * @return {"status":true,"data":{"vin_year":"20080827","vin_year_style":"buid","vin_year_name":"\u751f\u4ea7\u65e5\u671f"},"code":0}
	  */
	public function getYpcModelVinImg()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getYpcModelVinImg($Params['mod3Id'], $Params['vin']);
		LibFc::EchoJson($res);
	}

	/**
	  * @method get 检测此用户是否可以查询此VIN
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 检测的VIN
	  * @param  uid                int [必填]
	  * @param  ip				   string [必填]
	  * @param  from			   string [必填] 来源标识
	  * @param  max      		   int [必填] 允许查询的最大次数
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [10],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function checkCanDecodeVin()
	{
		$Params = mvc::$URL_PARAMS;
		$pass = false;
		$max = (int) $Params['max'];
		$uid = (int) $Params['uid'];
		$vin = LibFc::FormatVin($Params['vin']);
		if($max > 0 && strlen($vin) == 17 && filter_var($Params['ip'], FILTER_VALIDATE_IP) && !empty(mvc::$cfg['FROM_TAGS'][$Params['from']]))
		{
			$where = sprintf(" and v_uid=%d and v_atime >= %d and v_from ='%s'", $uid, strtotime(date('Y-m-d')), LibFc::Escape($Params['from']));
			if($uid < 1)
				$where .= sprintf(" and v_ip='%s'", LibFc::Escape($Params['ip']));

			$YpwBase = new YpwBase();
			$res = $YpwBase->get('yt_vin', ['count(distinct v_vin) count'], $where, true);
			if(!empty($res['data']) && isset($res['data']['count']))
			{
				if($res['data']['count'] < $max)
				{
					$pass = true;
				}
				else
				{
					//是否今天已经查过
					$res = $YpwBase->get('yt_vin', ['count(*) count'], $where.sprintf(" and v_vin='%s'", LibFc::Escape($vin)), true);
					if(!empty($res['data']['count']))
					{
						$pass = true;
					}
				}
			}
			LibFc::ReturnJson(true, $pass);
		}
		LibFc::ReturnJson(false, 'checkCanDecodeVin提供的参数有误！');
	}

	
	/**
	  * @method get  【停用】VIN解码 http://192.168.1.115/www/API/home/index.php/vin/decode?vin=WDDNG7KB6AA319980&token=81e8fd3d52a742593df0efb2476db7c7
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号 或者 车型代码
	  * @param  makeNo            string [选填] 整车型号
	  * @param  langId             string [选填] 解码信息语言 1:cn[默认] | 2:en ...
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function decode()
	{
		LibFc::ReturnJson(false, '此VIN解码接口已停用，请使用新接口');
	}

	/**
	  * @method 获取VIN的工信部型号
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号 或者 车型代码
	  * @author soul
	  * @copyright 2019/12/13
	  * @return 
	  */
	public function getVinGxbCode($vin)
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getVinGxbCode($Params['vin']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method get 
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function decodeVinBrand()
	{
		$Params = mvc::$URL_PARAMS;
		$arr = [];
		$YpcVin = new YpcVin();
		$res = $YpcVin->decodeVin($Params['vin'], 'm3ids');
		if(!empty($res['data']['model']))
		{
			$YpcModel = new YpcModel();
			$res = $YpcModel->getModel(3, ['b_id as brand_id', 'b_name as brand_name'], sprintf(" and m3_id in(%s) group by b_id order by b_initial", implode(',', $res['data']['model'])));
			$arr = $res['data'];
		}
		LibFc::ReturnJson(true, $arr);
	}


	/**
	  * @method get  VIN解码 大车
	  * @http  GET|POST
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  mod_id             string [必填] 车型ID编码
	  * @author soul
	  * @copyright 2019/8/1
	  * @return {"status":true,"data":{"mod_id":"236834","mod_type":"载货车","mod_make":"福田牌","mod_code":"BJ1026V3JV6-D1","mod_name":"福田国五其它撤销车型货车86马力740吨(BJ1026V3JV6-D1)","para":{"生产企业信息":[{"label":"车辆名称","val":"载货汽车"},{"label":"车辆类型","val":"货车"},{"label":"制造地","val":"中国"},{"label":"公告批次","val":"318"},{"label":"发布日期","val":"20190404"},{"label":"产品号","val":"ZL7TS6410AY"},{"label":"目录序号","val":"9"},{"label":"中文品牌","val":"福田牌"},{"label":"公告型号","val":"BJ1026V3JV6-D1"},{"label":"免征","val":"否"},{"label":"企业名称","val":"北汽福田汽车股份有限公司"},{"label":"燃油","val":"否"},{"label":"企业地址","val":"北京市昌平区沙河镇沙阳路"},{"label":"环保","val":"是"}],"免检说明":[{"label":"免检","val":"否"}],"公告状态":[{"label":"公告状态","val":"有效"},{"label":"公告状态描述","val":"扩展"}],"主要技术参数":[{"label":"外形尺寸","val":"4880,5130,5280,4805×1650,1700,1680,1730,1740,1620×1925,1910(mm)"},{"label":"货厢尺寸","val":"2800,3050,3200,2710×1560,1610,1650,1520×360,600,320(mm)"},{"label":"总质量","val":"2040(Kg)"},{"label":"整备质量","val":"1170(Kg)"},{"label":"额定载质量","val":"740(Kg)"},{"label":"前排乘客","val":"2(人)"},{"label":"接近角\/离去角","val":"39\/23(°)"},{"label":"前悬\/后悬","val":"605\/1205,605\/1355,605\/1505,605\/1130(mm)"},{"label":"轴荷","val":"700\/1340"},{"label":"轴距","val":"3070,3170(mm)"},{"label":"轴数","val":"2"},{"label":"最高车速","val":"115(km\/h)"},{"label":"油耗","val":"7.8,7.6,7.9"},{"label":"油耗(L\/100Km)","val":"7.8,7.6,7.9"}],"发动机参数":[{"label":"发动机","val":"LJ469Q-1AE9#柳州五菱柳机动力有限公司#1249ml#64\/88kw"},{"label":"发动机","val":"4W12M1#北汽福田汽车股份有限公司#1206ml#63\/86kw"}],"车辆燃料参数":[{"label":"燃料种类","val":"汽油"},{"label":"底盘排放标准","val":"GB18352.5-2013国Ⅴ"}],"其他":[{"label":"其他","val":"带OBD,选装新风格货厢,选装前格栅及雾灯座颜色.选装新前围,发动机LJ469Q-1AE9对应油耗值为7.8,发动机4W12M1对应油耗值为7.6,发动机DAM15R对应油耗值为7.9.ABS型号为YF9,生产企业为武汉元丰汽车电控系统有限公司.扩展新风格货厢.选装不带前雾灯造型"}],"反光标识参数":[{"label":"标识企业","val":"3M中国有限公司,浙江道明光学股份有限公司,诸城万安达消防器材有限公司,3M中国有限公司,道明光学股份有限公司,道明光学股份有限公司,道明光学股份有限公司,诸城万安达消防器材有限公司,诸城万安达消防器材有限公司"},{"label":"标识商标","val":"3M,DM,WAD,3M,DM,DM,DM,WAD,WAD"},{"label":"标识型号","val":"983,DMCT1800,WAD-5000,983D,DMCT1000,DMCT1800,DM9550,WAD-5000,WAD-5001"}]}},"code":0}
	  
	  */
	public function getCartInfo()
	{
		$YpcVin = new YpcVin();
		$res = $YpcVin->getCartInfo($_REQUEST['mod_id']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method get  获取行驶证的整车型号的信息
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  makeNo             string [必填] 车型代码
	  * @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":'失败原因',"code":''}
	  */
	public function getMakeNoInfo()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getMakeNoInfo($Params['makeNo']);
		LibFc::EchoJson($res);
	}

	
	/**
	  * @method get  通过行驶证的整车型号匹配车型
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  makeNo             string [必填] 整车型号
	  * @param  mod3_engine        string [选填] 发动机型号
	  * @param  mod3_kw            int [选填] 功率
	  * @param  mod3_cc            int [选填] 排量
	  * @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":'失败原因',"code":''}
	  */
	public function getMakeNoYpcModel()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getMakeNoYpcModel($Params['makeNo'], $Params);
		LibFc::EchoJson($res);
	}


	/**
	  * @method get  纠正VIN （对长度为14 - 19的VIN进行纠正）
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号 或者 车型代码
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function correctVin()
	{
		$YpcVin = new YpcVin();
		$vin = $_GET['vin'];
		$res = $YpcVin->correctVin($vin);
		echo json_encode($res);
	}

	/**
	  * @method get  解码某VIN的宜配车型
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @param  makeNo            string [选填] 整车型号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [111,222,333],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function decodeYpcModelId()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$decodeRes = $YpcVin->decodeVinMod3Id($Params['vin'], $Params['makeNo']);
		$modArr = [];
		if(isset($decodeRes['data']) &&  is_array($decodeRes['data']['model']))
		{
			$modArr = array_keys($decodeRes['data']['model']);
		}
		$decodeRes['data'] = $modArr;
		echo json_encode($decodeRes);
	}


	/**
	  * @method get  解码某VIN的宜配车型
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @param  type               string [选填] id[默认] || info
	  * @param  tj				   int [选填] 是否加入统计
	  * @param  uid                int [选填] 统计
	  * @param  ip				   string [选填] 统计
	  * @param  from			   string [选填] 统计 来源标识
	  * @param  integral		   int [选填] 积分查询
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [111,222,333]  || [['make_name'=>...].....],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function decodeYpcModel()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$decodeRes = $YpcVin->decodeVinMod3Id($Params['vin']);
		$modArr = [];
		if(isset($decodeRes['data']) &&  is_array($decodeRes['data']['model']))
		{
			$decodeRes['data']['from'] = empty($decodeRes['data']['model'])? '': 'ypc';
			$this->tongJiAndIntegral($decodeRes['data']);
			if(!empty($decodeRes['data']['model']))
			{
				if(isset($_GET['type']) && $_GET['type'] == 'info')
				{
					$base = $YpcVin->getVinBaseInfo($Params['vin']);
					$base = $base['data'];
					$Ypc2Model = new Ypc2Model();
					$filed = ['make_show_brand', 'brand_id', 'brand_name', 'make_name', 'mod1_name', 'mod2_name', 'brand_etk_id', 'bc_model3.*'];
					$where = sprintf(" and mod3_id in (%s)", implode(",", array_keys($decodeRes['data']['model'])));
					$modRes = $Ypc2Model->getModel(3, $filed, $where);
					foreach($modRes['data'] as $v)
					{
						unset($v['mod3_keyword']);
						$v['vin_year'] = $decodeRes['data']['year'];
						if(!empty($base))
						{
							$v = array_merge($v, $base);
						}
						$decodeRes['data']['model'][$v['mod3_id']] = $v;
					}
					$modArr = array_values($decodeRes['data']['model']);
				}
				else
				{
					$modArr = array_keys($decodeRes['data']['model']);
				}
			}
		}
		$decodeRes['data'] = $modArr;
		echo json_encode($decodeRes);
	}

	/**
	  * @method get  解码某VIN的宜配车型ID
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function getModelIds()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->decodeVin($Params['vin'], 'm3ids');
		$arr = $res['data']['model'];
		$this->tongJiAndIntegral(['from'=>$res['data']['from'], 'model'=>$arr]);
		LibFc::ReturnJson(true, $arr);
	}
	
	//解码后的统计已经积分等处理
	private function tongJiAndIntegral($decodeRes)
	{
		if(!isset($decodeRes['from']))
		LibFc::ReturnJson(false, 'tongJiAndIntegral提供的参数有误！');

		$Params = mvc::$URL_PARAMS;
		$Params['by'] = $decodeRes['from'];
		//解码统计
		$YpcVin = new YpcVin();
		$YpcVin->tongjiVin($Params['vin'], $Params['by']);
		
		if(!empty($decodeRes['model']))
		{
			//积分扣除
			if(!empty($Params['integral']))
			{
				$YpwUser = new YpwUser();
				$temp = [
					'uil_u_id'=>$Params['uid'],
					'uil_change'=>-5,
					'uil_des'=>'VIN查询：'.$Params['vin'],
					'uil_remark'=>$Params['from']
				];
				$YpwUser->changeIntegral($temp);
			}
		}
	}


	/**
	  * @method 通过L开头的VIN获取整车型号
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号  LBELMBKC1EY570664
	  * @author soul
	  * @copyright 2017/9/30
	  * @return  {"status":true,"data":["BH6440LAY","BH6440LAZ","BH6440LBY","BH6440LBZ","BH6442LAY","BH6442LAZ"],"code":0}
	  */
	public function getVinMakeNo()
	{
		$Params = mvc::$URL_PARAMS;
		$vin = LibFc::FormatVin($Params['vin']);
		$arr = [];
		if(strlen($vin) == 17 && substr($vin, 0, 1) === 'L')
		{
			$YpwBase = new YpwBase();
			$res = $YpwBase->Get('stand_model_any', ['distinct sma_gxb_code'], sprintf(" and sma_vin1_8='%s' and sma_vin10_12 = '%s'", substr($vin, 0, 8), substr($vin, 9, 3)));
			if(!empty($res['data']))
			{
				$arr = array_column($res['data'], 'sma_gxb_code');
				sort($arr);
			}
		}
		LibFc::ReturnJson(true, $arr);
	}




	/**
	  * @method get  RCA通过品牌ID获取所有车型
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  brandId            int [选填] 品牌ID
	  * @param  m_id               int [选填] 厂商ID
	  * @param  m1_id              int [选填] 一级车型ID
	  * @param  m3_id              int [选填] 末级车型ID
	  * @author soul
	  * @copyright 2017/10/31
	  * @return 
	    'b_id', 'b_name', 品牌
		'm_id','m_name',生产商
		'm1_id','m1_name', 一级车型
		'm2_id','m2_name', 二级车型
		'm2_start_year','m2_end_year',二级车型年份
		'm3_id','m3_name', 末级车型
		'm3_start_year','m3_end_year',末级车型年份
		'm3_kw',功率
		'm3_cc',排量
		'm3_engine'发动机,
		'pl_transmission', 变速器
		'pl_fuel', 燃料
			'pl_body', 车身形式
		'pl_front_brake',前制动器
		'pl_rear_brake',后制动器
		'pl_parking_brake', 驻车制动
		'pl_drive	驱动方式
	  {"status":true,"data": ["6491"=>{"m3_id":"6491", "b_id":"63", .....},.... ],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function rcaModelByBrandId()
	{
		if(empty(mvc::$cfg['RQTOKEN']['brandIds']))
		{
			LibFc::ReturnJson(false, '无权限查询'); exit;
		}
		$modelArr = [];
		if(!empty($_GET['brandId']) && in_array($_GET['brandId'], mvc::$cfg['RQTOKEN']['brandIds']))
		{
			$where = sprintf(" AND m1_b_id=%d", (int) $_GET['brandId']);
		}
		else if(!empty($_GET['m_id']))
		{
			$where = sprintf(" AND m1_b_id in (%s) AND m_id=%d", implode(',', mvc::$cfg['RQTOKEN']['brandIds']), (int) $_GET['m_id']);
		}
		else if(!empty($_GET['m1_id']))
		{
			$where = sprintf(" AND m1_b_id in (%s) AND m1_id=%d", implode(',', mvc::$cfg['RQTOKEN']['brandIds']), (int) $_GET['m1_id']);
		}
		else if(!empty($_GET['m3_id']))
		{
			$where = sprintf(" AND m1_b_id in (%s) AND m3_id=%d", implode(',', mvc::$cfg['RQTOKEN']['brandIds']), (int) $_GET['m3_id']);
		}
		$langId = 1;
		if($where != '')
		{
			$YpcBase = new YpcBase();
			$YpcModel = new YpcModel();
			$res = $YpcModel->getModel(3, ['*'], $where);
			if(!empty($res['data']))
			{
				$labelArr = ['m3_transmission'=>'pl_transmission', 'm3_fuel'=>'pl_fuel', 'm3_body'=>'pl_body', 'm3_front_brake'=>'pl_front_brake', 'm3_rear_brake'=>'pl_rear_brake', 'm3_parking_brake'=>'pl_parking_brake', 'm3_drive'=>'pl_drive'];
				foreach($res['data'] as $v) 
				{
					foreach($labelArr as $KK=>$vv)
					{
						$v[$vv] = $v[$KK]? $v[$KK]: '';
					}
					$modelArr[$v['m3_id']] = $v;
				}

				$returnFiledArr = ['b_id', 'b_name', 'm_id','m_name','m1_id','m1_name','m2_id','m2_name','m2_start_year','m2_end_year','m3_id','m3_name','m3_start_year','m3_end_year','m3_kw','m3_cc','m3_engine'];
				foreach($modelArr as $K=>$V)
				{
					foreach($V as $KK=>$VV)
					{
						if(!in_array($KK, $returnFiledArr) && !in_array($KK, $labelArr))
						{
							unset($V[$KK]);
						}
					}
					$modelArr[$K] = $V;
				}
			}
		}
		$arr = [];
		foreach($modelArr as $v)
		{
			$arr[] = $v;
		}
		$LibEncry = new LibEncry();
		$key = $LibEncry->getEncryKey(mvc::$cfg['RQTOKEN']['token']);
		$arr = $LibEncry->encode(json_encode($arr), $key);
		LibFc::ReturnJson(true, $arr);
	}


	/**
	  * @method get RCA软件的 VIN解码 
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  vin                string [必填] 17位车架号
	  * @author soul
	  * @copyright 2017/10/31
	  * @return 末级车型ID
	  {"status":true,"data": [6491,63,.... ],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function rcaDecodeVin()
	{
		$vin = $_GET['vin'];
		$YpcVin = new YpcVin();
		$res = $YpcVin->decodeVin($vin, 'm3ids');
		$arr = $res['data']['model'];
		$YpcVin->tongjiVin($vin, $res['data']['from']);
		$LibEncry = new LibEncry();
		$key = $LibEncry->getEncryKey(mvc::$cfg['RQTOKEN']['token']);
		$arr = $LibEncry->encode(json_encode($arr), $key);
		LibFc::ReturnJson(true, $arr);
	}

	/**
	  * @method get RCA软件的通过OE查找宜配车型库的适用车型
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  number             string [必填] OE号码，多个英文逗号分隔
	  * @author soul
	  * @copyright 2017/10/31
	  * @return  末级车型ID
	  {"status":true,"data": [{"m3_id":"6491", "b_id":"63"},.... ],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function rcaModelByNumber()
	{
		$returnArr = [];
		define ('Encry', true);

		if(empty(mvc::$cfg['RQTOKEN']['brandIds']))
		{
			LibFc::ReturnJson(false, '无权限查询此品牌车型'); exit;
		}
		
		$numArr = [];
		foreach(explode(',', $_GET['number']) as $v)
		{
			$number = LibFc::FormatNum($v);
			if (strlen($number) >= 3)
			{
				$numArr[] = $number;
			}
		}
        if (count($numArr) < 1) 
		{
            LibFc::ReturnJson(false, '请提供正确的搜索号码'); exit;
        }
		
		//通过OE反查宜配唯一产品OE
		$YpsBase = new YpsBase();
		$res = $YpsBase->get('yp_number', ['pid'], sprintf(" and format in ('%s') and fid=770 group by pid", implode("','", $numArr)));
		if(!empty($res['data']) && count($res['data']) == 1)
		{
			$res = $YpsBase->get('yp_number', ['format'], sprintf(" and pid=%d and fid=770", $res['data'][0]['pid']));
			foreach($res['data'] as $v)
			{
				$numArr[] = $v['format'];
			}
		}

		$YpcModel = new YpcModel();
		$res = $YpcModel->getM3idByNum($numArr);
		$returnArr = $res['data'];

		$LibEncry = new LibEncry();
		$key = $LibEncry->getEncryKey(mvc::$cfg['RQTOKEN']['token']);
		$returnArr = $LibEncry->encode(json_encode($returnArr), $key);
		LibFc::ReturnJson(true, $returnArr);
	}


	/**
	  * @method get  RCA通过号码查询对应的factory  part
	  * @http  GET
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  number             string [必填] GDB900
	  * @param  lang               string [选填] cn|en
	  * @author soul
	  * @copyright 2017/10/31
	  * @return 
	  {"status":true,"data": [{"factory":"OE", "part":"刹车片"}....],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function rcaGetFacPartByNumber()
	{
		$number = LibFc::FormatNum($_GET['number']);
        if (strlen($number) < 3) {
            LibFc::ReturnJson(false, '请提供正确的配件号码'); exit;
        }
		$langId = isset($_GET['lang']) && $_GET['lang'] == 'en'? 2: 1;
		$YpsBase = new YpsBase();
		$table = 'yp_number AS num 
		JOIN yp_factory AS fac ON num.fid=fac.fid
		JOIN yp_part AS pa ON num.partid=pa.partid
		JOIN yp_lng_des AS ld ON ld.desid=pa.desid AND ld.lngid='.$langId.'
		JOIN yp_lng_text AS lt ON lt.txtid=ld.txtid';
		$res = $YpsBase->get($table, ['fac.factory, lt.txt AS part'], sprintf(" and num.format='%s' GROUP BY num.fid, num.partid, num.format", LibFc::Escape($number)));
		$arr = $res['data'];
		$LibEncry = new LibEncry();
		$key = $LibEncry->getEncryKey(mvc::$cfg['RQTOKEN']['token']);
		$arr = $LibEncry->encode(json_encode($arr), $key);
		LibFc::ReturnJson(true, $arr);
	}


	/**
	  * @method 车架号扫描图
	  * @http  POST
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param  imgdata            string  [必填] 图片内容信息base64 base64_encode(file_get_contents('D:\www\ocr/ocr.jpg'))
	  * @param  vin                string [必填] 车架号
	  * @param  imgname            string  [选填] 图片名称  ocr.jpg
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function collOcrVinImg()
	{
		$YpwVin = new YpwVin();
		$res = $YpwVin->collOcrVinImg($_POST['vin'], $_POST['imgdata'], ['imgname'=>$_POST['imgname']]);
		LibFc::EchoJson($res);
	}

	/**
	  * @method get 采集环保信息随车清单
	  * @param  token       string [必填] 调用接口凭证 (post|get)
	  * @param  vin         string  [必填] 车架号
	  * @param  engine6     string  [必填] 行驶证的发动机编码后6位
	  * @param  usecache       int  [选填]  -1|1  默认图1  如果已经存在，是否直接取缓存的数据
	  * @author soul
	  * @copyright 2020/6/5
	  * @return 
	  */
	public function catchVinQingdan()
	{
		$Params = mvc::$URL_PARAMS;
		$YpwVin = new YpwVin();
		$res = $YpwVin->catchVinQingdan($Params['vin'], $Params['engine6'], 0, $Params['usecache']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method post 批量从泽达API获取车架号信息
	  * @http  POST
	  * @param  vins string [必填] 车架号 逗号分隔 [一次最好不要超过10个]
	  * @author soul
	  * @copyright 2020/9/22
	  * @return 
	  */
	public function catchAnyVinfromZdApi()
	{
		$YpwVin = new YpwVin();
		$res = $YpwVin->catchAnyVinfromZdApi(explode(',', $_POST['vins']));
		LibFc::EchoJson($res);
	}


	/**
	  * @method post 批量从外调SP获取车架号信息
	  * @http  POST
	  * @param  vins string [必填] 车架号 逗号分隔 [一次最好不要超过10个]
	  * @param  addToSma  int [必填] 默认0不纳入 是否纳入600w总表
	  * @author soul
	  * @copyright 2020/9/22
	  * @return 
	  */
	public function catchAnyVinfromWdspApi()
	{
		$YpwVin = new YpwVin();
		$arr = [];
		foreach(explode(',', $_POST['vins']) as $vin)
		{
			$res = $YpwVin->catchVinfromWdspApi($vin, $_POST['addToSma']);
			$arr[$vin] = $res['data'];
		}
		LibFc::ReturnJson(true, $arr);
	}

	/**
	  * @method 从中车网 商车网 查询工信部型号信息
	  * @param  gxbNum  string [必填] 工信部型号
	  * @param  gxbAllMatch  string [选填] 是否精准匹配 默认1
	  * @param  vin  string [选填] 车架号或者车架号前8 最好是完整车架号
	  * @param  othArr string [选填] 其它查询参数 json 	{"sma_weight":"",...}
	  * @author soul
	  * @copyright 2020/10/6
	  * @return 
	  */
	public function catchGxbcodeInfo()
	{
		$YpwVin = new YpwVin();
		$res = $YpwVin->catchGxbcodeInfo($_POST['gxbNum'], isset($_POST['gxbAllMatch'])? $_POST['gxbAllMatch']: 1, $_POST['vin'], isset($_POST['othArr'])? json_decode($_POST['othArr'], true):[]);
		LibFc::EchoJson($res);
	}
		
	public function matchAnyByVinGxbTxt()
	{
		$OthVinImg = new OthVinImg();
		$res = $OthVinImg->matchAnyByVinGxbTxt($_POST['vin'], $_POST['gxbNum'], $_POST['ocrtxt'], explode(',', $_POST['comFileds']));
		LibFc::EchoJson($res);
	}

	

	/**
	  * @method 中车网指定页面匹配信息
	  * @http  get
	  * @param  tarid  string [必填] NzgzNjQ4
	  * @author soul
	  * @copyright 2022/8/15
	  * @return 
	  */
	public function getChinacarGg()
	{
		$Params = mvc::$URL_PARAMS;
		$YpwVin = new YpwVin();
		$tarid = $Params['tarid'];
		$res = $YpwVin->getChinacarGg([$tarid], false, '');
		$arr = empty($res[$tarid])? []: $res[$tarid];
		LibFc::ReturnJson(true, $arr);
	}

	
	/**
	  * @method 商车网指定页面匹配信息
	  * @http  get
	  * @param  tarid  string [必填] notice792350_CC6473GM05
	  * @author soul
	  * @copyright 2022/8/15
	  * @return 
	  */
	public function getCn357Gg()
	{
		$Params = mvc::$URL_PARAMS;
		$YpwVin = new YpwVin();
		$tarid = $Params['tarid'];
		$res = $YpwVin->getCn357Gg([$tarid], false, '');
		$arr = empty($res[$tarid])? []: $res[$tarid];
		LibFc::ReturnJson(true, $arr);
	}
	

	/**
	  * @method 采集智配车架号信息
	  * @http  get
	  * @param  vin  string [必填] 车架号
	  * @author soul
	  * @copyright 2020/10/6
	  * @return 
	  */
	public function catchZpVin()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcZp = new YpcZp();
		$res = $YpcZp->catchVin($Params['vin']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method 车架号图片识别型号
	  * @http  get
	  * @param  vii_id  int [vii_id|vin二选一] 图片ID
	  * @param  vin  string [vii_id|vin二选一] 车架号
	  * @author soul
	  * @copyright 2022/6/22
	  * @return 
	  */
	public function vinImgSma()
	{
		$Params = mvc::$URL_PARAMS;
		$OthVinImg = new OthVinImg();
		$YpwBase = new YpwBase();
		$where = '';
		$arr = [];
		if(!empty($Params['vii_id'])) $where = sprintf(" and vii_id = '%d'", $Params['vii_id']);
		else if(!empty($Params['vin'])) $where = sprintf(" and vii_vin = '%s'", LibFc::FormatNum($Params['vin']));
		if(!empty($where))
		{
			$viires = $YpwBase->get('stand_vin_imgs', ['*'], $where, true);
			if(!empty($viires['data']))
			{
				$viiArr = $viires['data'];
				$wmi = substr($viiArr['vii_vin'], 0, 3);
				$res = $YpwBase->get('stand_ocrimg_reg', ['*'], sprintf(" and reg_status = 1 and reg_wmi like '%%%s%%'", $wmi), true);
				$reg = $res['data'];
				$res = $OthVinImg->sma($viiArr, $reg, 0, true);
				if(!empty($res['data']['sma']['sma_gxb_code'])){
					$arr = $res['data'];
				}else if($Params['ocr'] == 'all'){
					$LibHttp = new LibHttp();
					$MainOcr = new MainOcr();
					$imgurl = mvc::$cfg['urls']['vinimg_'.$viiArr['vii_imghost']].$viiArr['vii_img'];
					$image = $LibHttp->fetch($imgurl);
					$image = base64_encode($image);
					foreach([90,180,270] as $rotate){
						$res = $MainOcr->paddleOcr($image, ['rotate'=>$rotate]);
						$ocrtxt = implode("\n", $res['data']);
						$viiArr['vii_imgocr'] = $ocrtxt;
						$res = $OthVinImg->sma($viiArr, $reg);
						if(!empty($res['data']['sma']['sma_gxb_code'])){
							$arr = $res['data'];
							break;
						}
					}
				}
			}
		}
		LibFc::ReturnJson(true, $arr);
	}


	/**
	  * @method 获取wmi替换后的品牌
	  * @param  wmi  string [必填] wmi
	  * @param  brand  string [必填] 原始品牌名称
	  * @author soul
	  * @copyright 2022/6/7
	  * @return ['status'=>true, 'data'=>替换后的名称, 'code'=>'']
	  */
	public function getWmiReBrand()
	{
		$Params = mvc::$URL_PARAMS;
		$YpwVin = new YpwVin();
		$res = $YpwVin->getWmiReBrand($Params['wmi'], $Params['brand']);
		LibFc::EchoJson($res);
	}
	
	/**
	  * @method 通过VIN解析出原厂唯一标码
	  * @param  makecode 品牌代码
	  * @param  vin  至少7位车架号
	  * @author soul
	  * @copyright 2023/7/13
	  * @return 
		成功 ["status"=>true, "data"=> [唯一标码数组]] 
		失败 ["status"=>false, "data"=> 错误信息] 
	  */
	public function getOemCodeByVin()
	{
		$Params = mvc::$URL_PARAMS;
		$YpcVin = new YpcVin();
		$res = $YpcVin->getOemCodeByVin($Params['makecode'], $Params['vin']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method 智能纠错
	  * @http get
	  * @param   vin  str [必填] vin
	  * @param   u_id  int [必填] 用户ID
	  * @author soul
	  * @copyright 2023/10/12
	  * @return 
		{"status":true,"data":{"check":"1", "msg":"此车架号纠错完成，您可以查看新的解码信息！"},"code":0}
		{"status":true,"data":{"check":"0", "u_id":"149894", "u_name":"soul12", "u_nickname":"蓝宇战车"},"code":0}
	  */
	public function autoJiucuo()
	{
		$Params = mvc::$URL_PARAMS;
		$vin = LibFc::FormatNum($Params['vin']);
		if(strlen($vin) != 17) return LibFc::ReturnData(false, '请提供17位的车架号');
		$hasArr = [];
		$PjlModel = new PjlModel();
		$addFlag = false;
		$arr = ['check'=>0];
		$dataArr['ve_atime'] = time();
		$addArr = [
			've_vin'=>$vin,
			've_uid'=>$Params['u_id'],
			've_from'=>'PJL',
			've_atime'=>time()
		];
		$chk = $PjlModel->get('pl_vin_error', ['*'], sprintf(" and ve_uid='%d' and ve_vin='%s' order by ve_atime desc limit 1", $Params['u_id'], $vin), true);
		$YpwVin = new YpwVin();
		if(!empty($chk['data'])){
			$hasArr = $chk['data'];
			if($hasArr['ve_status'] != 0 || (time() - $hasArr['ve_atime'] > 60)) $addFlag = true;
			$hasArr['ve_byinfo'] = empty($hasArr['ve_byinfo'])? []:json_decode($hasArr['ve_byinfo'], true);
		}else{
			$addFlag = true;
			//车架号尚未提交过，是否能自动处理
			$res = $YpwVin->get('stand_model_any', ['sma_id'], sprintf(" and sma_vin='%s'", $vin), true);
			$has = empty($res['data'])? false: true;
			if(empty($res['data']) && LibFc::VinYear($vin) < 2022)
			{
				$res = $YpwVin->catchAnyVinfromZdApi([$vin], 3, 'jiucuo');
				if(!empty($res['data'][$vin]['viz_vin'])) $has = true;
			}
			if($has){
				$addArr['ve_status'] = 1;
				$addArr['ve_etime'] = time();
				$addArr['ve_check'] = json_encode(['uid'=>8,'remark'=>'谢谢您的建议，已处理','time'=>time()],JSON_UNESCAPED_UNICODE);
				$arr['check'] = 1;
				$arr['msg'] = "此车架号纠错完成，您可以查看新的解码信息！";
				$PjlModel->add('pl_vin_error', $addArr);
			}
		}

		if($arr['check'] != 1)
		{	
			//分配客服
			/*$arr['u_id'] = 149894;$arr['u_name'] = "soul12";$arr['u_nickname'] = "蓝宇战车";*/
			$B2cBase = new B2cBase();
			$whereArr = [];
			/*if(!empty($hasArr['ve_byinfo']['kefu_uid'])) $whereArr[] = sprintf(" and au_status = 1 and au_vinjiucuo =1 and au_uid=%d limit 1", $hasArr['ve_byinfo']['kefu_uid']);
			$whereArr[] = " and au_status = 1 and au_vinjiucuo =1 order by rand() limit 1";*/
			$whereArr[] = " and au_status = 1 and au_uid=164045 limit 1";
			foreach($whereArr as $where){
				$ures = $B2cBase->get('an_user join ypdb_write.yp_user on au_uid=u_id', ['u_id', 'u_name', 'u_nickname'], $where, true);
				if(!empty($ures['data'])){
					$arr = array_merge($arr, $ures['data']);
					break;
				}
			}
			if($addFlag){
				$addArr['ve_byinfo'] = json_encode(['kefu_uid'=>$arr['u_id']], JSON_PARTIAL_OUTPUT_ON_ERROR);
				$res = $PjlModel->add('pl_vin_error', $addArr);
				$veid = $res['data'];
				$PjlModel->noticeJiucuo($veid, $arr['u_id']);
			}else if(!empty($hasArr['ve_byinfo']['kefu_uid']) && $arr['u_id'] != $hasArr['ve_byinfo']['kefu_uid']){//变更客服
				$hasArr['ve_byinfo']['kefu_uid'] = $arr['u_id'];
				$set = ['ve_byinfo'=>json_encode($hasArr['ve_byinfo'], JSON_PARTIAL_OUTPUT_ON_ERROR)];
				$PjlModel->set('pl_vin_error', $set, sprintf(" and ve_id=%d", $hasArr['ve_id']));
			}

			//1分钟内是否有重复消息
			$msg = '车架号纠错：'.$addArr['ve_vin'];
			$res = $YpwVin->get('im_callback', ['icb_id'], sprintf(" and icb_from_uid=%d and icb_to_uid=%d and icb_json LIKE '%%\"Text\":\"%s\"%%' and icb_atime > %d limit 1", $addArr['ve_uid'], $arr['u_id'], $msg, time()-60));
			if(empty($res['data']))
			{
				$OthIm = new OthIm();
				$OthIm->sendImMsg($addArr['ve_uid'], $arr['u_id'], $msg);
				//此车架号是否有图
				$res = $YpwVin->get('stand_vin_imgs', ['vii_id'], sprintf(" and vii_vin='%s' limit 1", $addArr['ve_vin']));
				$msg = empty($res['data'])? '您好，车架号【'.$addArr['ve_vin'].'】纠错反馈已收到，发送车辆铭牌或者行驶证图可以加快处理速度哦。': '您好，车架号【'.$addArr['ve_vin'].'】纠错反馈已收到，正在快马加鞭处理中，请稍等。';
				usleep(1500000);
				$OthIm->sendImMsg($arr['u_id'], $addArr['ve_uid'], $msg);
			}
		}
		LibFc::ReturnJson(true, $arr);
	}

	/**
	  * @method 判断图片类型 0普通 1:行驶证  2:铭牌  -1无效图
	  * @http  POST
	  * @param  ocrtxt string [必填] 内容
	  * @param  vin string [选填] 车架号
	  * @author soul
	  * @copyright 2020/9/7
	  * @return 
	  */
	public function getImgType($ocrtxt, $vin = '')
	{
		$OthVinImg = new OthVinImg();
		$res = $OthVinImg->getImgType($_POST['ocrtxt'], $_POST['vin']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method 提取发动机号码
	  * @param  vin string [必填] 
	  * @param  imgType string [必填] mp|xsz
	  * @param  ocrtxt string [必填] 
	  * @param  vinYear string [选填] 
	  * @author soul
	  * @copyright 2026/4/15
	  * @return 
	  */
	public function matchEng6(){
		$OthVinImg = new OthVinImg();
		$res = $OthVinImg->matchEng6($_POST['vin'], $_POST['imgType'], $_POST['ocrtxt'], $_POST['vinYear']);
		LibFc::EchoJson($res);
	}
}