| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801 | 
							- <?php defined('BASEPATH') or exit('No direct script access allowed');
 
- class Boss extends Start_Controller
 
- {
 
- 	public function __construct()
 
- 	{
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_api', 'api');
 
- 		$this->load->_model('Model_apismt', 'apismt');
 
- 		$this->load->_model('Model_shop', 'shop');
 
- 		$this->load->_model('Model_fullorder', 'fullorder');
 
- 		$this->load->_model('Model_fullordertt', 'fullordertt');
 
- 		$this->load->_model('Model_fedex_cby', 'fedex_cby');
 
- 		$this->load->_model('Model_fullorder_smt', 'fullorder_smt');
 
- 		$this->load->_model('Model_fullordersmt', 'fullordersmt');
 
- 		$this->load->_model('Model_fullorderxw', 'fullorderxw');
 
- 		$this->load->_model('Model_fullorderamz', 'fullorderamz');
 
- 		$this->load->_model('Model_customersmt', 'customersmt');
 
- 		$this->load->_model('Model_logic_order', 'logic_order');
 
- 		$this->load->_model('Model_country', 'country');
 
- 		$this->load->_model('Model_hl', 'hl');
 
- 		$this->load->_model('Model_is', 'is');
 
- 		$this->load->_model('Model_kdniao', 'kdniao');
 
- 		$this->load->_model('Model_typeclass', 'typeclass');
 
- 		$this->load->_model('Model_warehouse', 'warehouse');
 
- 		$this->load->_model('Model_fullorderexcel', 'fullorderexcel');
 
- 		$this->load->_model('Model_dhl', 'dhl');
 
- 		$this->load->_model('Model_usps', 'usps');
 
- 		$this->load->_model('Model_dhltest', 'dhltest');
 
- 		$this->load->_model('Model_customer', 'customer');
 
- 		$this->load->_model('Model_express', 'express');
 
- 		$this->load->_model('Model_notice', 'notice');
 
- 		$this->load->_model('Model_whlabel', 'whlabel');
 
- 		$this->load->_model('Model_productdescribe', 'productdescribe');
 
- 		$this->load->_model('Model_ljg', 'ljg');
 
- 		$this->load->_model('Model_commodityread', 'commodityread');
 
- 		$this->load->_model('Model_service', 'service');
 
- 		$this->load->_model('Model_fedex', 'fedex');
 
- 		$this->load->_model('Model_commodity', 'commodity');
 
- 		$this->load->_model('Model_fullordersmtorder', 'fullordersmtorder');
 
- 		$this->load->_model('Model_ali', 'ali');
 
- 		$this->load->_model('Model_fullordersmthb', 'fullordersmthb');
 
- 		$this->load->_model('Model_fullordersmtbf', 'fullordersmtbf');
 
- 		$this->load->_model('Model_taxzhengzhou', 'taxzhengzhou');
 
- 		$this->load->_model('Model_taxshanghai', 'taxshanghai');
 
- 		$this->load->_model('Model_excel', 'excel');
 
- 		$this->load->_model('Model_ups', 'ups');
 
- 		$this->load->_model('Model_dpd', 'dpd');
 
- 		$this->load->_model('Model_cne', 'cne');
 
- 		$this->load->_model('Model_outbound', 'outbound');
 
- 		$this->load->_model('Model_specialstock', 'specialstock');
 
- 		$this->load->_model('Model_setting', 'setting');
 
- 		$this->load->_model('Model_pay', 'pay');
 
- 		$this->load->_model('Model_shopsku', 'shopsku');
 
- 		$this->load->_model('Model_classid', 'classid');
 
- 		$this->load->_model('Model_weight', 'weight');
 
- 		$this->load->_model('Model_country', 'country');
 
- 		$this->load->_model("Model_zzquque_u9", "zzquque_u9");
 
- 		$this->load->_model("Model_customsdeclaration", "customsdeclaration");
 
- 		$this->load->_model("Model_logic_u9tools","logic_u9tools");
 
- 	}
 
- 	//定义方法的调用规则 获取URI第二段值
 
- 	public function _remap($arg, $arg_array)
 
- 	{
 
- 		if ($arg == 'out') {
 
- 			$this->_out($arg_array);
 
- 		} else if ($arg == 'sku') {
 
- 			$this->_sku();
 
- 		} else if ($arg == 'spexcel') {
 
- 			$this->_spexcel();
 
- 		} else if ($arg == 'qczd') {
 
- 			$this->_qczd();
 
- 		} else if ($arg == 'setting') {
 
- 			$this->_setting();
 
- 		} else if ($arg == 'sctime') {
 
- 			$this->_sctime();
 
- 		} else if ($arg == 'dpex') {
 
- 			$this->_dpex();
 
- 		} else if ($arg == 'dpay') {
 
- 			$this->_dpay();
 
- 		} else if ($arg == 'excellkh') {
 
- 			$this->_excellkh();
 
- 		} else if ($arg == 'excelshop') {
 
- 			$this->_excelshop();
 
- 		} else if ($arg == 'ggdd') {
 
- 			$this->_ggdd();
 
- 		} else if ($arg == 'qt') {
 
- 			$this->_qt();
 
- 		} else {
 
- 			$this->_index();
 
- 		}
 
- 	}
 
- 	public function _index()
 
- 	{
 
- 		$setting = $this->setting->get_settings();
 
- 		$this->data['excelpass'] = $setting['excelpass'];
 
- 		$this->data['excelusernum'] = $setting['excelusernum'];
 
- 		$this->data['exceljmnum'] = $setting['exceljmnum'];
 
- 		$this->data['sctime'] = $setting['sctime'];
 
- 		$this->_Template('boss', $this->data);
 
- 	}
 
- 	public function _qt()
 
- 	{
 
- 		$setting = $this->setting->get_settings();
 
- 		$this->data['excelpass'] = $setting['excelpass'];
 
- 		$this->data['excelusernum'] = $setting['excelusernum'];
 
- 		$this->data['exceljmnum'] = $setting['exceljmnum'];
 
- 		$this->data['sctime'] = $setting['sctime'];
 
- 		$wh = $this->warehouse->find_all('1=1', 'id,title');
 
- 		$this->data['wh'] = $wh;
 
- 		$this->_Template('boss_qt', $this->data);
 
- 	}
 
- 	public function _out($arg_array)
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['order'])) {
 
- 			$time = $this->input->post('time', true);
 
- 			$time = strtotime($time);
 
- 			$order = $this->input->post('order', true);
 
- 			$weight = $this->input->post('weight', true);
 
- 			if (!isset($weight)) //测试没问题后可以删
 
- 			{
 
- 				$weight = '';
 
- 			}
 
- 			if (substr($order, 0, 3) == '788' && substr($order, -4, 4) == '0430') //Fedex联邦
 
- 			{
 
- 				$order = substr($order, 0, 12);
 
- 			}
 
- 			if (strlen($order) == '34') //联邦杭州超长运单截取
 
- 			{
 
- 				$order = substr($order, 22, 12);
 
- 			}
 
- 			if (!$order) {
 
- 				echo json_encode(array('msg' => '出库信息不能为空!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			// $fullorder_name = 'fullorder';$outtype = 1;
 
- 			// $y = $this->fullorder->get_waybill($order);
 
- 			// if(!$y)
 
- 			// {
 
- 			// 	$y = $this->fullorder->get_number($order);
 
- 			// 	$outtype = 2;
 
- 			// 	if(!$y)
 
- 			// 	{
 
- 			// 		$fullorder_name = 'fullordersmt';$outtype = 1;
 
- 			// 		$y = $this->fullordersmt->get_waybill($order);
 
- 			// 		if(!$y)
 
- 			// 	    {
 
- 			// 			$y = $this->fullordersmt->get_number($order);
 
- 			// 			$outtype = 2;
 
- 			// 			if(!$y)
 
- 			// 			{
 
- 			// 				$fullorder_name = 'fullordertt';$outtype = 1;
 
- 			// 				$y = $this->fullordertt->get_waybill($order);
 
- 			// 				if(!$y)
 
- 			// 	    		{
 
- 			// 					$y = $this->fullordertt->get_number($order);
 
- 			// 					$outtype = 2;
 
- 			// 					if(!$y)
 
- 			// 					{
 
- 			// 						$fullorder_name = 'fullorderamz';$outtype = 1;
 
- 			// 						$y = $this->fullorderamz->get_waybill($order);
 
- 			// 						if(!$y)
 
- 			// 	    				{
 
- 			// 							$y = $this->fullorderamz->get_number($order);
 
- 			// 							$outtype = 2;
 
- 			// 							if(!$y)
 
- 			// 							{
 
- 			// 								$fullorder_name = 'fullorderxw';$outtype = 1;
 
- 			// 								$y = $this->fullorderxw->get_waybill($order);
 
- 			// 								if(!$y)
 
- 			// 								{
 
- 			// 									$y = $this->fullorderxw->get_number($order);
 
- 			// 									$outtype = 2;
 
- 			// 									if(!$y)
 
- 			// 									{
 
- 			// 										echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
 
- 			// 									}
 
- 			// 								}
 
- 			// 							}
 
- 			// 						}
 
- 			// 					}
 
- 			// 				}
 
- 			// 			}
 
- 			// 		}
 
- 			// 	}
 
- 			// }
 
- 			$outtype = 1;
 
- 			$y = $this->logic_order->getInfo("waybill = '" . $order . "'");
 
- 			if (empty($y)) {
 
- 				$outtype = 2;
 
- 				$y = $this->logic_order->getInfo("number = '" . $order . "'");
 
- 			}
 
- 			$fullorder_name = $y['lv_platform'];
 
- 			if ($y['mergeid'] == '1') {
 
- 				$y = $this->$fullorder_name->read($y['merge']);
 
- 			}
 
- 			$express = $this->express->read($y['express']);
 
- 			if ($y['state'] == 216 && $fullorder_name == 'fullordersmt') {
 
- 				$y['librarynot'] = '客户已取消!';
 
- 			}
 
- 			if (($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt')) && $y['type'] != 3) //独立站216先关了
 
- 			{
 
- 				echo json_encode(array('msg' => '禁止出库!' . $y['librarynot'], 'success' => false));
 
- 				exit;
 
- 			}
 
- 			if ($y['library'] > 1) {
 
- 				echo json_encode(array('msg' => '此数据 ' . date('Y-m-d H:i:s', $y['librarytime']) . ' 已操作', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			if ($express['out'] != 3) {
 
- 				if ($express['out'] != $outtype) {
 
- 					$smlx = ($express['out'] == '1') ? '运单' : '发货单';
 
- 					echo json_encode(array('msg' => '扫描类型错误!此单需要扫描' . $smlx, 'success' => false));
 
- 					exit;
 
- 				}
 
- 			}
 
- 			if ($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1') {
 
- 				$y['waybill'] = trim($y['waybill'], ' ');
 
- 				if (strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 71 && $y['express'] != 73 && $y['express'] != 75 && $y['express'] != 78 && $y['express'] != 79) {
 
- 					echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-1', 'success' => false));
 
- 					exit;
 
- 				} else if (strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42  && $y['express'] != 78  && $y['express'] != 79) {
 
- 					echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-2', 'success' => false));
 
- 					exit;
 
- 				} else if (strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67 && $y['express'] != 72 ) {
 
- 					echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-3', 'success' => false));
 
- 					exit;
 
- 				}
 
- 				else if(strlen($y['waybill']) == 16 && $y['express'] != 76 && $y['express'] != 77)
 
- 				{
 
- 					echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-4','success'=>false));exit;
 
- 				}
 
- 			}
 
- 			// 			if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
 
- 			// 			{
 
- 			// 				$numweight = str_replace('kg','',$weight);
 
- 			// 				if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
 
- 			// 				{
 
- 			// 					echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
 
- 			// 				}
 
- 			// 				$yzweight = explode('.',$numweight);
 
- 			// 				if($yzweight[0] == '')
 
- 			// 				{
 
- 			// 					echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
 
- 			// 				}
 
- 			// 				if($numweight > '0.98' &&  $y['express'] == '3')
 
- 			// 				{
 
- 			// 					echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
 
- 			// 				}
 
- 			// 				if($numweight > '2' &&  $y['express'] == '37')
 
- 			// 				{
 
- 			// 					echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
 
- 			// 				}
 
- 			// 				if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
 
- 			// 				{
 
- 			// 					echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
 
- 			// 				}
 
- 			// 			}
 
- 			$numweight = str_replace('kg', '', $weight);
 
- 			//根据要求 USPS-USA  FEDEX-US2  USPS-US2  这三个快递方式除外的所有快递都需要称重再发货  或者说是【国内发货】的都需要称重
 
- 			$express_info = $this->express->read($y['express']);
 
- 			if (empty($express_info)) {
 
- 				echo json_encode(array('msg' => '该快递信息异常,请联系技术!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$weight_limit = $express_info['weight_limit'] * 1;
 
- 			if ($weight_limit  > 0) {
 
- 				if ($weight == '' || $numweight < '0.1' || !is_numeric($numweight)) {
 
- 					echo json_encode(array('msg' => '此单需要称重!', 'success' => false));
 
- 					exit;
 
- 				}
 
- 				$yzweight = explode('.', $numweight);
 
- 				if ($yzweight[0] == '') {
 
- 					echo json_encode(array('msg' => '重量错误,请重新称重!', 'success' => false));
 
- 					exit;
 
- 				}
 
- 				if ($numweight < (($y['jweight'] * 1) / 1000)) {
 
- 					echo	json_encode(array('msg' => '重量小于净重,请重新称重!', 'success' => false));
 
- 					exit;
 
- 				}
 
- 				//Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
 
- 				if (in_array($y['express'], [3, 24, 42])) {
 
- 					//规定实际重量不允许超过 净重为1kg
 
- 					if ($numweight - (($y['jweight'] * 1) / 1000) > 1) {
 
- 						echo json_encode(array('msg' => '称重重量和净重相差过大,请找成会或梦体处理!', 'success' => false));
 
- 						exit;
 
- 					}
 
- 				}
 
- 				if ($weight_limit < $numweight) {
 
- 					echo json_encode(array('msg' => $express['servicename'] . '大于' . $weight_limit . '公斤需要拆包!', 'success' => false));
 
- 					exit;
 
- 				}
 
- 			}
 
- 			if (((time() - $y['printtime']) > (15 * 24 * 3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6) //杭州店铺除外
 
- 			{
 
- 				echo json_encode(array('yd' => 1, 'id' => $y['id'], 'express' => $y['express'], 'name' => $fullorder_name, 'success' => true));
 
- 				exit;
 
- 			}
 
- 			if ((time() - $y['printtime']) > (4 * 24 * 3600) && $y['express'] == '3' && $y['type'] != 6) //杭州店铺除外
 
- 			{
 
- 				//echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
 
- 				echo json_encode(array('msg' => '此运单过期无法出库,请联系成会处理!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			if ((time() - $y['printtime']) > (7 * 24 * 3600) && $y['express'] == '37' && $y['type'] != 6) //杭州店铺除外
 
- 			{
 
- 				echo json_encode(array('yd' => 1, 'id' => $y['id'], 'express' => $y['express'], 'name' => $fullorder_name, 'success' => true));
 
- 				exit;
 
- 			}
 
- 			$this->db->trans_begin();
 
- 			$warehouse = $this->warehouse->read($y['type']);
 
- 			if ($warehouse['zd'] == '1') {
 
- 				if ($warehouse['bdck'] == '') {
 
- 					echo json_encode(array('msg' => '仓库设置错误!', 'success' => false));
 
- 					exit;
 
- 				}
 
- 				$bdck = $warehouse['bdck'];
 
- 				$wh = $this->_fout_db($y, $warehouse, $bdck);
 
- 				if ($wh['fh'] == 2) {
 
- 					$kcyz = $this->ck->get_kc($y['state'], $warehouse, $y['shop'], $y['number'], $y['whlabel'], $y['fpdata']);
 
- 					if ($kcyz['fpdata'] != '' && $kcyz['t'] == '0') {
 
- 						$x['whlabel'] = $kcyz['whlabel'];
 
- 						$x['fpdata'] = $kcyz['fpdata'];
 
- 						$y['whlabel'] = $x['whlabel'];
 
- 						$this->$fullorder_name->save($x, $y['id']);
 
- 					}
 
- 					$wh = $this->_fout_db($y, $warehouse, $bdck);
 
- 					if ($wh['fh'] == 2) {
 
- 						echo json_encode(array('msg' => '库存占用量与实际出库量不符!', 'success' => false));
 
- 						exit;
 
- 					}
 
- 				}
 
- 				foreach ($wh['sj'] as $v) {
 
- 					$this->$bdck->save(array('state' => 1, 'cktype' => 1, 'orderinfo' => $y['orderinfo'], 'waybill' => $y['waybill'], 'outk' => $time, 'time' => $time), $v['id']);
 
- 				}
 
- 			}
 
- 			if ($fullorder_name == 'fullordersmt') {
 
- 				$stt = ($y['waybill'] != '') ? 209 : $y['state'];
 
- 				$this->$fullorder_name->save(array('library' => 2, 'state' => $stt, 'librarytime' => $time, 'weight' => $weight), $y['id']);
 
- 			} else {
 
- 				if ($y['type'] == 3) {
 
- 					$this->$fullorder_name->save(array('print' => 3, 'printtime' => $time, 'printnumber' => 1, 'state' => 216, 'libraryconfirm' => 2, 'library' => 2, 'librarytime' => $time, 'weight' => $weight), $y['id']);
 
- 				} else {
 
- 					$this->$fullorder_name->save(array('library' => 2, 'librarytime' => $time, 'weight' => $weight), $y['id']);
 
- 				}
 
- 			}
 
- 			$queue_u9_list = [];
 
- 			$queue_u9_list[] = [
 
- 				'platform' => $fullorder_name,
 
- 				'warehouse' => $y['type'],
 
- 				'type' => ($y['type'] == 5) ? 11 : 10,   //5代表美仓  
 
- 				'order_no' => $y['number'],
 
- 				'status' => 0,
 
- 				'create_time' => time(),
 
- 				'update_time' => time(),
 
- 			];
 
- 			//将要执行的队列数据添加进去
 
- 			foreach ($queue_u9_list as $item) {
 
- 				if ($item['platform'] != 'fullorderxw') {
 
- 					if ($item['warehouse'] != 5) {
 
- 						$this->zzquque_u9->insert($item);
 
- 					}
 
- 				}
 
- 			}
 
- 			if ($this->db->trans_status() === TRUE) {
 
- 				$this->db->trans_commit();
 
- 				echo json_encode(array('msg' => '操作成功!', 'success' => true));
 
- 				exit;
 
- 			} else {
 
- 				$this->db->trans_rollback();
 
- 				echo json_encode(array('msg' => '出库失败,请重试', 'success' => false));
 
- 			}
 
- 		}
 
- 	}
 
- 	public function _fout_db($y, $warehouse, $bdck) //对比占单是否正确
 
- 	{
 
- 		$wh = $this->$bdck->find_all("zd = '" . $y['number'] . "' and warehouse = '" . $y['type'] . "' and (state = '0' or state = '9')");
 
- 		$cpsl = 0;
 
- 		$pp = explode('|', trim($y['whlabel'], '|'));
 
- 		foreach ($pp as $va) {
 
- 			$num = explode('-', $va);
 
- 			if (isset($num[2])) {
 
- 				if (stripos($num[2], $warehouse['hz']) !== false) {
 
- 					$cpsl += $num[1];
 
- 				}
 
- 			}
 
- 		}
 
- 		if (count($wh) == $cpsl) {
 
- 			return array('fh' => 1, 'sj' => $wh);
 
- 		} else {
 
- 			return array('fh' => 2);
 
- 		}
 
- 	}
 
- 	public function _sku() //测试SKU
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['sku'])) {
 
- 			$sku = $this->input->post('sku', true);
 
- 			if ($sku == '') {
 
- 				echo json_encode(array('msg' => 'SKU不能为空!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$gethl = $this->hl->get_hl(); //获取即时汇率
 
- 			$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
 
- 			$dtc = array();
 
- 			foreach ($dictionaries as $v) {
 
- 				if (stripos($v['spare'], '|') !== false) //如果有多个值
 
- 				{
 
- 					$v['spare'] = explode('|', $v['spare']);
 
- 					foreach ($v['spare'] as $k => $vs) {
 
- 						if (stripos($v['zh'], '|') !== false) {
 
- 							$vzh = explode('|', $v['zh']);
 
- 							$dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $vzh[$k], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
 
- 						} else {
 
- 							$dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
 
- 						}
 
- 					}
 
- 				} else {
 
- 					$dtc[strtolower($v['spare'])] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $v['spare']);
 
- 				}
 
- 			}
 
- 			$dictionaries2 = $this->typeclass->find_all();
 
- 			foreach ($dictionaries2 as $v) {
 
- 				$dtctitle[$v['id']] = $v['title'];
 
- 			}
 
- 			/*  匹配结束  */
 
- 			/*  价格加入  */
 
- 			$money = array();
 
- 			$productdescribe = $this->productdescribe->find_all('1=1');
 
- 			foreach ($productdescribe as $v) {
 
- 				$money[$v['number']] = array();
 
- 			}
 
- 			/*  价格加入  */
 
- 			/*  匹配ID加入  */
 
- 			$int = array();
 
- 			$intdata = $this->typeclass->find_all('classid=14', 'id,spare');
 
- 			foreach ($intdata as $v) {
 
- 				$v['spare'] = explode('|', $v['spare']);
 
- 				$int[$v['id']] = $v['spare'][0];
 
- 			}
 
- 			/*  匹配ID加入  */
 
- 			$zjsku = array();
 
- 			$shopsku = $this->shopsku->find_all();
 
- 			foreach ($shopsku as $val) {
 
- 				$ss = explode(',', trim($val['shop'], ','));
 
- 				foreach ($ss as $v) {
 
- 					if (isset($zjsku[$v])) {
 
- 						$zjsku[$v] .= ',' . trim($val['sku'], ',');
 
- 					} else {
 
- 						$zjsku[$v] = trim($val['sku'], ',');
 
- 					}
 
- 				}
 
- 			}
 
- 			/*  匹配ID结束  */
 
- 			$q = '';
 
- 			$quantity = explode(',', trim($sku, ','));
 
- 			foreach ($quantity as $v) {
 
- 				$q .= '1;';
 
- 			}
 
- 			$is = $this->is->find_all('1=1', '*', 'number asc'); //获取仓库平匹配表
 
- 			$shop = $this->shop->read(19);
 
- 			if (isset($zjsku[$shop['id']])) //判断是否找到店铺SKU
 
- 			{
 
- 				$sku = rtrim($sku, ',') . ',' . $zjsku[$shop['id']];
 
- 			}
 
- 			$r = $this->api->matching(trim($q, ';'), $sku, $dtc, $money, $int, $dtctitle, $shop);
 
- 			$p = '';
 
- 			$product = explode(';', trim($r['product'], ';'));
 
- 			if ($r['title'] != '' && $product) {
 
- 				foreach ($product as $v) {
 
- 					$vc = explode('|', $v);
 
- 					if(isset($vc[1])){
 
- 						$p .= $vc[1] . '<br>';
 
- 					}
 
- 					
 
- 				}
 
- 				$tmp_str = $r['product']; 
 
- 				
 
- 				$tmp_arr = explode(";",$tmp_str);
 
- 				$list = [];
 
- 				foreach($tmp_arr as $k=>$v){
 
- 					$tmp_str1 = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
 
- 					$tmp_arr1 = explode('|',trim($tmp_str1,'|'));
 
- 					if(stripos($tmp_arr1[0],',') !== false){
 
- 						$ft = explode(',',$tmp_arr1[0]);
 
- 						$features = explode('-',trim($ft[1],'-'));
 
- 						$features[] = $ft[0];
 
- 					}else{
 
- 						$features = explode('-',trim($tmp_arr1[0],'-'));
 
- 					}
 
- 					$sku = implode("-",$features);
 
- 					if(!empty($sku)){
 
- 						$list[] = [
 
- 							'sku2'=>$sku
 
- 						];
 
- 					}
 
- 					
 
- 				}
 
- 				
 
- 				
 
- 				$u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
 
- 				$jm = $u9_data[0]['jm'];
 
- 				$r['title'] = str_replace(array('<', '>'), array('<', '>'), $r['title']);
 
- 				echo json_encode(array('msg' => '仓库品名:' . $r['title'] . '<br>商品名称:' . $p ."<br>用友料号:".$jm, 'success' => true, 'r' => $r));
 
- 				exit;
 
- 			} else {
 
- 				echo json_encode(array('msg' => 'SKU错误', 'success' => false));
 
- 				exit;
 
- 			}
 
- 		}
 
- 	}
 
- 	public function matching($quantity, $issku, $dtc, $money, $int, $dtctitle)
 
- 	{
 
- 		$sl =  explode(';', $quantity);
 
- 		$x = 0;
 
- 		$product = ''; //product 每单多产品链接组合
 
- 		$purchase = 0;
 
- 		$cost = 0; //每单所有产品总成本价格;
 
- 		$whlabel = '|'; //库存产品码
 
- 		$cscs = array();
 
- 		$cscs = $issku;
 
- 		$nr = '';
 
- 		$cs = array();
 
- 		$t = array('/\-\-/', '/\+/', '/\#Color/', '/\#Long/', '/-[1-4]-/', '/(\w+)~(\w+)-/');
 
- 		$h = array('-', '-', '', '', '-', '');
 
- 		$issku = str_replace(array('(', ')'), array('(', ')'), $issku);
 
- 		$issku = str_replace(array(' <', '> '), array('<', '>'), $issku);
 
- 		$issku = strtolower($issku);
 
- 		$varsku = preg_replace($t, $h, $issku); ////转大写、匹配更改和删除
 
- 		$varsku = strtolower($varsku); //转小写
 
- 		$sku = explode(',', $varsku); //多产品分割为多数组
 
- 		$pd = explode(',', $issku);
 
- 		$slpx = array();
 
- 		$tqjcskua = array(); //先检测是否只匹配品名
 
- 		$tqjcskub = array();
 
- 		$tqjcqda = array();
 
- 		$tqjcqdb = array();
 
- 		$tqjcgit = array(); //礼物类放SKU顺序中间
 
- 		$tqjcgitpd = array(); //礼物类放SKU顺序中间
 
- 		foreach ($sku as $k => $value) {
 
- 			//查找是否有头套和HD开始
 
- 			$cid = array();
 
- 			$cf = explode('-', trim($value, '-'));
 
- 			$cf = array_filter($cf);
 
- 			foreach ($cf as $v) {
 
- 				if (isset($dtc[$v]['id']) && isset($dtc[$v]['jm'])) {
 
- 					$cid[$dtc[$v]['classid']] = array('id' => $dtc[$v]['id'], 'spare' => $v, 'jm' => $dtc[$v]['jm']);
 
- 				}
 
- 			}
 
- 			if (isset($cid['44']) && isset($cid['18'])) {
 
- 				if (isset($dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['id'])) {
 
- 					$value = '-' . $value . '-';
 
- 					$sku[$k] = '-' . $sku[$k] . '-';
 
- 					$pd[$k] = '-' . $pd[$k] . '-';
 
- 					$value = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $value);
 
- 					$value = str_replace('-' . $cid['44']['spare'], '-', $value);
 
- 					$sku[$k] = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $sku[$k]);
 
- 					$sku[$k] = str_replace('-' . $cid['44']['spare'], '-', $sku[$k]);
 
- 					$pd[$k] = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $pd[$k]);
 
- 					$pd[$k] = str_replace('-' . $cid['44']['spare'], '-', $pd[$k]);
 
- 					$value = strtolower(trim($value, '-'));
 
- 					$pd[$k] = strtolower(trim($pd[$k], '-'));
 
- 					$sku[$k] = strtolower(trim($sku[$k], '-'));
 
- 				} else if (stripos($value, '-transparent') !== false || stripos($value, '-tr') === false) {
 
- 					$value = str_replace(array('-transparent', '-tr'), '', $value);
 
- 					$sku[$k] = str_replace(array('-transparent', '-tr'), '', $sku[$k]);
 
- 					$pd[$k] = str_replace(array('-transparent', '-tr'), '', $pd[$k]);
 
- 				}
 
- 			}
 
- 			//查找是否有头套和HD结束
 
- 			if (isset($dtc[$value]['classid'])) {
 
- 				if ($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999') {
 
- 					$tqjcskua[$k] = $value;
 
- 					$tqjcqda[$k] = $pd[$k];
 
- 					continue;
 
- 				}
 
- 			}
 
- 			if (stripos($value, 'gift') !== false) {
 
- 				$tqjcgit[$k] = $value;
 
- 				$tqjcgitpd[$k] = $pd[$k];
 
- 				continue;
 
- 			}
 
- 			$tqjcskub[$k] = $value;
 
- 			$tqjcqdb[$k] = $pd[$k];
 
- 		}
 
- 		$sku = $tqjcskub + $tqjcgit + $tqjcskua;
 
- 		$newsl = array();
 
- 		foreach ($sku as $k => $value) {
 
- 			if (!isset($sl[$k])) {
 
- 				$sl[$k] = 1;
 
- 			}
 
- 			$newsl[] = $sl[$k];
 
- 		}
 
- 		$sl = array_values($newsl);
 
- 		$pd = $tqjcqdb + $tqjcgitpd + $tqjcqda;
 
- 		$sku = array_values($sku); //按照现有顺序键值重新由0开始
 
- 		$pd = array_values($pd);
 
- 		/**
 
- 		$tqjcskua = array();//先检测是否只匹配品名
 
- 		$tqjcskub = array();
 
- 		foreach ($sku as $k=>$value) 
 
- 		{
 
- 			if(isset($dtc[$value]['classid']))
 
- 			{
 
- 			    if($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999')
 
- 			    {
 
- 				    $tqjcskua[$k] = $value;
 
- 					continue;
 
- 			    }
 
- 			}
 
- 			$tqjcskub[$k] = $value;
 
- 				
 
- 		}
 
- 		$sku = $tqjcskub+$tqjcskua;
 
- 		$sku = array_values($sku);//按照现有顺序键值重新由0开始
 
- 		 **/
 
- 		foreach ($sku as $value) {
 
- 			$bmsku = '';
 
- 			if (stripos($value, '-<') !== false && stripos($value, '>-') === false) {
 
- 				$isskufg = explode('-<', $value);
 
- 				$bmsku = '<' . strtoupper($isskufg[1]);
 
- 			}
 
- 			if (stripos($value, '-<') !== false && stripos($value, '>-') !== false) {
 
- 				$isskufg = explode('-<', $value);
 
- 				$isskufgh = explode('>-', $isskufg[1]);
 
- 				$bmsku = '<' . strtoupper($isskufgh[0]) . '>';
 
- 			}
 
- 			if (stripos($value, '-<') === false && stripos($value, '>-') !== false) {
 
- 				$isskufg = explode('>-', $value);
 
- 				$bmsku = strtoupper($isskufg[0]) . '>';
 
- 			}
 
- 			if (stripos($value, '-<') !== false && stripos($value, '>-') === false) {
 
- 				$isskufg = explode('-<', $value);
 
- 				$bmsku = '<' . strtoupper($isskufg[1]);
 
- 			}
 
- 			if (stripos($value, '-<') !== false && stripos($value, '>-') !== false) {
 
- 				$isskufg = explode('-<', $value);
 
- 				$isskufgh = explode('>-', $isskufg[1]);
 
- 				$bmsku = '<' . strtoupper($isskufgh[0]) . '>';
 
- 			}
 
- 			if (stripos($value, '-<') === false && stripos($value, '>-') !== false) {
 
- 				$isskufg = explode('>-', $value);
 
- 				$bmsku = strtoupper($isskufg[0]) . '>';
 
- 			}
 
- 			$value = trim($value, ' ');
 
- 			$cpson = array();
 
- 			$cplf = array();
 
- 			$thisid = '';
 
- 			$tha = array();
 
- 			$thb = array();
 
- 			$purchasemy = 0;
 
- 			$costmy = 0;
 
- 			$salespricemy = 0;
 
- 			$djay = array(); //每单单个产品公司销售价格
 
- 			$ptitlea = '';
 
- 			$ptitleb = ''; //每单产品名称
 
- 			$cpa = '';
 
- 			$cpb = '';
 
- 			$fc = 0;
 
- 			$number = array('dc' => '', 'c' => '');
 
- 			$classid = $this->classid->sku();
 
- 			$pm = $classid; //品名顺序
 
- 			//等级-真人发类型-化纤发编号-颜色-花型-蕾丝头套种类-化纤头套类型-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-化纤其它属性-头套其它属性-头套属性 100为头套额外附加
 
- 			$cp = array(16 => 126, 22 => '', 13 => 80, 14 => '', 43 => '', 8 => 57, 15 => ''); //产品默认ID内容
 
- 			//16->类目、22->真人发类型、13->等级、14->长度、8->颜色、15->曲度(花型)
 
- 			$cptt = array(16 => 128, 13 => 80, 43 => '', 8 => '57', 15 => '', 18 => '', 6 => 30, 10 => 72, 9 => '', 44 => '', 39 => ''); //头套
 
- 			$cpcp = array(16 => 130, 13 => 80, 14 => '', 33 => '', 8 => 57, 15 => '', 38 => '', 7 => ''); //卡子发,7=>33重量
 
- 			$cpgi = array(16 => 131, 34 => ''); //礼物
 
- 			$cpac = array(16 => 133, 35 => ''); //配件
 
- 			$cphxtt = array(16 => 1297, 13 => 80, 14 => '', 40 => '', 8 => 57, 15 => '', 41 => '', 42 => '');
 
- 			$cphxhair = array(16 => 1702, 13 => 80, 14 => '', 47 => '', 46 => '', 8 => 57, 15 => '', 38 => '', 48 => '');
 
- 			if ((preg_match('/\d\*\df/', $pd[$x]) ||  preg_match('/\df/', $pd[$x]) ||  stripos($pd[$x], '+F') !== false || stripos($pd[$x], 'Frontal') !== false) && stripos($pd[$x], 'wig') === false && stripos($pd[$x], 'Bob') === false) {
 
- 				$u27 = (stripos($pd[$x], 'SilkBaseFrontal') !== false) ? 199 : 197;
 
- 				$cplf = array(16 => 127, 27 => $u27, 12 => 75, 10 => 72, 26 => 191, 9 => '', 44 => ''); //蕾丝发块
 
- 				$fc = 1;
 
- 			} else if ((preg_match('/\d\*\dc/', $pd[$x]) || preg_match('/\dc/', $pd[$x]) || stripos($pd[$x], '+C') !== false || stripos($pd[$x], 'Closure') !== false) && stripos($pd[$x], 'wig') === false && stripos($pd[$x], 'Bob') === false) {
 
- 				$u27 = (stripos($pd[$x], 'SilkBaseClosure') !== false) ? 196 : 195;
 
- 				$cplf = array(16 => 127, 27 => $u27, 12 => 75, 10 => 72, 25 => 182, 9 => '', 44 => ''); //蕾丝发块
 
- 				if (stripos($pd[$x], '2*6') !== false) {
 
- 					$cplf[12] = 76;
 
- 				}
 
- 				$fc = 1;
 
- 			}
 
- 			$ceshi = array();
 
- 			$cpcppd = 0;
 
- 			$cpcptype = $this->typeclass->find_all("classid = 33");
 
- 			foreach ($cpcptype as $v) {
 
- 				$val = explode('|', trim($v['spare'], '|'));
 
- 				foreach ($val as $vv) {
 
- 					if (stripos('-' . $pd[$x] . '-', '-' . $vv . '-') !== false) {
 
- 						$cpcppd++;
 
- 					}
 
- 				}
 
- 			}
 
- 			if ($fc == 1) {
 
- 				$cpson = $cplf;
 
- 			} else if ((stripos($pd[$x], 'wig') !== false || stripos($pd[$x], 'Bob') !== false) && stripos($pd[$x], 'Syn') === false && stripos($pd[$x], 'Gift') === false) //
 
- 			{
 
- 				$cpson = $cptt;
 
- 			} else if ((stripos($pd[$x], 'SyHair') !== false || (stripos($pd[$x], 'SyHair') !== false && stripos($pd[$x], 'Syn') !== false)) && $cpcppd == 0) {
 
- 				$cpson = $cphxhair;
 
- 				$cp = $cpson;
 
- 			} else if (stripos($pd[$x], 'Syn') !== false && $cpcppd == 0) {
 
- 				$cpson = $cphxtt;
 
- 				$cp = $cpson;
 
- 			} else if ($cpcppd > 0) {
 
- 				$cpson = $cpcp;
 
- 				$cp = $cpcp;
 
- 			} else if (stripos($pd[$x], 'Gift') !== false) {
 
- 				$cpson = $cpgi;
 
- 			} else if (stripos($pd[$x], 'Accs') !== false) {
 
- 				$cpson = $cpac;
 
- 			} else {
 
- 				$cpson = $cp;
 
- 			}
 
- 			//$cpson = $fc==1?$cplf:((stripos($pd[$x],'wig') !== false || stripos($pd[$x],'Bob') !== false)?$cptt:(stripos($pd[$x],'Clip') !== false?$cpcp:array()));//是否是类似发块或头套产品
 
- 			$cs[$x] = $cpson;
 
- 			$son = explode('-', $value); //字符串转数组
 
- 			$snum = 0;
 
- 			$cpsl = 0;
 
- 			foreach ($son as $val) {
 
- 				if (stripos($val, '^') !== false) {
 
- 					$snum += str_replace('^', '', $val);
 
- 				}
 
- 				if (isset($dtc[$val])) //如果能匹配到
 
- 				{
 
- 					if (is_numeric($val) || $dtc[$val]['classid'] == '14') //如果是组合产品
 
- 					{
 
- 						$cpsl++;
 
- 						if (!is_numeric($val)) {
 
- 							$pm['c'] = $dtc[$val]['zh'];
 
- 						} else {
 
- 							$pm['c'] = $val . '寸'; //尺寸不匹配,并且准备写入到+号后面
 
- 						}
 
- 						$number['c'] = $val;
 
- 					} else {
 
- 						if (isset($cp[$dtc[$val]['classid']])) //判断匹配ID属于头部还是尾部
 
- 						{
 
- 							$cp[$dtc[$val]['classid']] = $dtc[$val]['id'];
 
- 						}
 
- 						if (isset($cpson[$dtc[$val]['classid']])) {
 
- 							if ($dtc[$val]['id'] != 66) //按要求暂时不匹配中棕颜色
 
- 							{
 
- 								$cpson[$dtc[$val]['classid']] = $dtc[$val]['id'];
 
- 							}
 
- 						}
 
- 						/**
 
- 						if($pm[15] == '卡子发卡子发' || $dtc[$val]['zh'] == '卡子发卡子发')
 
- 						{
 
- 							$slpx[] = 1;
 
- 							$pm[$dtc[$val]['classid']] = $pm[$dtc[$val]['classid']].' '.$dtc[$val]['zh'];
 
- 						}
 
- 					    else 
 
- 						 **/
 
- 						if ($dtc[$val]['classid'] == '999') {
 
- 							$pm[$dtc[$val]['classid']] .= $dtc[$val]['zh']; //其它正常匹配
 
- 						} else {
 
- 							$pm[$dtc[$val]['classid']] = $dtc[$val]['zh']; //其它正常匹配
 
- 						}
 
- 					}
 
- 				} else if (preg_match('/((\d+)\s+(\d+))/', $val) && stripos($val, 'NO') === false) //如果不能匹配是多尺寸字符串
 
- 				{
 
- 					$j = (stripos($pd[$x], '+') !== false) ? ' +' : ''; //判断sku是否是+号类型
 
- 					if (isset($cpson[16])) {
 
- 						if ($cpson[16] != 128) {
 
- 							$cpslnum = explode(' ', trim($val, ' '));
 
- 							$cpsl += count($cpslnum);
 
- 							$pm['dc'] = $val . $j; //写入多尺寸字符串
 
- 						}
 
- 					} else {
 
- 						$cpslnum = explode(' ', trim($val, ' '));
 
- 						$cpsl += count($cpslnum);
 
- 						$pm['dc'] = $val . $j;
 
- 					}
 
- 					$number['dc'] = $val;
 
- 				}
 
- 			}
 
- 			if ($sl[$x] > 1 || $snum > 1) {
 
- 				$slx = $sl[$x];
 
- 				if ($snum > 1) {
 
- 					$slx = ($slx > 1) ? $slx : 1;
 
- 					$slx *= $snum;
 
- 				}
 
- 				$slpx[] = $cpsl;
 
- 				$nr .= '[' . $bmsku . implode(" ", $pm) . ']*' . $slx . '包' . ';'; //数组转字符串
 
- 			} else {
 
- 				if ($cpsl > 0) {
 
- 					$slpx[] = $cpsl;
 
- 				}
 
- 				$slx = 1;
 
- 				$pdpm = $bmsku . implode("", $pm);
 
- 				if ($pdpm != '') {
 
- 					$nr .= $bmsku . implode(" ", $pm) . ';'; //数组转字符串
 
- 				}
 
- 			}
 
- 			//以下是特殊类型的匹配
 
- 			if (stripos($nr, '带绒布内衬半蕾丝头套') !== false && stripos($nr, '#') !== false) {
 
- 				$nr = preg_replace('/\#(\d+)/', '内衬颜色$1号色', $nr);
 
- 			}
 
- 			$weightsku = array();
 
- 			$weightdata = $this->weight->find_all();
 
- 			foreach ($weightdata as $w) {
 
- 				$weightsku[$w['features']] = $w['weight'];
 
- 			}
 
- 			if ($number['dc'] != '') {
 
- 				if (stripos($pd[$x], '+') !== false) {
 
- 					foreach ($cp as $v) {
 
- 						$ptitlea .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
 
- 					}
 
- 				} else {
 
- 					foreach ($cpson as $v) {
 
- 						$ptitlea .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
 
- 					}
 
- 				}
 
- 				$dc = explode(' ', trim($number['dc'], ' '));
 
- 				for ($i = 0; $i < count($dc); $i++) {
 
- 					if (isset($dtc[$dc[$i]]['id'])) {
 
- 						$thisid = $dtc[$dc[$i]]['id'];
 
- 						/**
 
- 					    $tha[$dc[$i]] = isset($tha[$dc[$i]])?array('zh'=>$tha[$dc[$i]]['zh'],'id'=>$tha[$dc[$i]]['id'],'count'=>$tha[$dc[$i]]['count']+1):array('zh'=>$dc[$i],'id'=>$thisid,'count'=>1);
 
- 						 **/
 
- 						//一样的不再合并
 
- 						$tha[] = array('zh' => $dc[$i], 'id' => $thisid, 'count' => 1);
 
- 					}
 
- 				}
 
- 				foreach ($tha as $v) {
 
- 					$item = array_merge($cp);
 
- 					$weight = 0;
 
- 					if ($cp['16'] == '126') {
 
- 						$weight = $weightsku['126'];
 
- 					} else if ($cp['16'] == '127') {
 
- 						if (isset($item[9])) {
 
- 							$sku127a = $item[0] . '-' . $v['id'] . '-' . $item[3] . '-' . $item[6] . '-' . $item[9];
 
- 							$sku127b = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[9];
 
- 							if (isset($weightsku[$sku127a])) {
 
- 								$weight = $weightsku[$sku127a];
 
- 							} else if (isset($weightsku[$sku127b])) {
 
- 								$weight = $weightsku[$sku127b];
 
- 							}
 
- 						}
 
- 					} else if ($cp['16'] == '128') {
 
- 						if (isset($item[8])) {
 
- 							$sku128 = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[8];
 
- 							if (isset($weightsku[$sku128])) {
 
- 								$weight = $weightsku[$sku128];
 
- 							}
 
- 						}
 
- 					}
 
- 					$cpa = $cp;
 
- 					$cpa[14] = $v['id'];
 
- 					$cpa[22] = ''; //增加长度ID、去除真人发类型
 
- 					$whlabel .= implode("", $cpa) . '-' . $slx * $v['count'] . '-0|';
 
- 					$pdcc = (is_numeric($v['zh'])) ? $v['zh'] . 'inch |' : strtoupper($v['zh']) . '|';
 
- 					$product .= $v['id'] . ',-' . rtrim(implode("-", $cp), '-') . '-|' . $ptitlea . $pdcc . $slx * $v['count'] . '|0|0|' . $v['zh'] . '|0|0|' . $slx * $v['count'] * $weight . '|0;';
 
- 				}
 
- 			}
 
- 			if ($number['c'] != '') {
 
- 				$fk = $cp;
 
- 				foreach ($cpson as $k => $v) {
 
- 					$fk[$k] = $v; //+号左右ID合并右完整ID
 
- 				}
 
- 				foreach ($fk as $v) {
 
- 					$ptitleb .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
 
- 				}
 
- 				$c = explode(' ', trim($number['c'], ' '));
 
- 				for ($i = 0; $i < count($c); $i++) {
 
- 					$thisid = $dtc[$c[$i]]['id'];
 
- 					/**
 
- 					$thb[$c[$i]] = isset($thb[$c[$i]])?array('zh'=>$thb[$c[$i]]['zh'],'id'=>$thb[$c[$i]]['id'],'count'=>$thb[$c[$i]]['count']+1):array('zh'=>$c[$i],'id'=>$thisid,'count'=>1);
 
- 					 **/
 
- 					//一样的不再合并
 
- 					$thb[] = array('zh' => $c[$i], 'id' => $thisid, 'count' => 1);
 
- 				}
 
- 				foreach ($thb as $v) {
 
- 					$item = array_merge($fk);
 
- 					$weight = 0;
 
- 					if ($fk['16'] == '126') {
 
- 						$weight = $weightsku[$item[0]];
 
- 					} else if ($fk['16'] == '127') {
 
- 						if (isset($item[9])) {
 
- 							$sku127a = $item[0] . '-' . $v['id'] . '-' . $item[3] . '-' . $item[6] . '-' . $item[9];
 
- 							$sku127b = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[9];
 
- 							if (isset($weightsku[$sku127a])) {
 
- 								$weight = $weightsku[$sku127a];
 
- 							} else if (isset($weightsku[$sku127b])) {
 
- 								$weight = $weightsku[$sku127b];
 
- 							}
 
- 						}
 
- 					} else if ($fk['16'] == '128') {
 
- 						if (isset($item[8])) {
 
- 							$sku128 = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[8];
 
- 							if (isset($weightsku[$sku128])) {
 
- 								$weight = $weightsku[$sku128];
 
- 							}
 
- 						}
 
- 					}
 
- 					$cpb = $fk;
 
- 					$cpb[14] = $v['id'];
 
- 					$cpb[22] = ''; //增加长度ID、去除真人发类型
 
- 					$whlabel .= implode("", $cpb) . '-' . $slx * $v['count'] . '-0|';
 
- 					$pdcc = (is_numeric($v['zh'])) ? $v['zh'] . 'inch |' : strtoupper($v['zh']) . '|';
 
- 					$product .= $v['id'] . ',-' . rtrim(implode("-", $fk), '-') . '-|' . $ptitleb . $pdcc . $slx * $v['count'] . '|0|0|' . $v['zh'] . '|0|0|' . $slx * $v['count'] * $weight . '|0;';
 
- 				}
 
- 			}
 
- 			if (stripos($pd[$x], 'Gift-') !== false) {
 
- 				$ptitleg = '';
 
- 				foreach ($cpson as $v) {
 
- 					$ptitleg .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
 
- 				}
 
- 				$whlabel .= implode("", $cpson) . '-' . $slx . '-0|';
 
- 				$product .= '-' . rtrim(implode("-", $cpson), '-') . '-|' . $ptitleg . '|' . $slx . '|0|0||0|0|0|0;';
 
- 			}
 
- 			$x++;
 
- 			$purchase += $purchasemy;
 
- 			$cost += $costmy;
 
- 		}
 
- 		$product = str_replace('--', '-', $product);
 
- 		$qbslpx = 0;
 
- 		$wcslpx = '';
 
- 		foreach ($slpx as $v) {
 
- 			$wcslpx .= $qbslpx . '-' . ($qbslpx + $v) . '|';
 
- 			$qbslpx += $v;
 
- 		}
 
- 		$nr = str_replace(array('(', ')'), array('(', ')'), $nr);
 
- 		if (stripos($whlabel, '|--|') !== false) {
 
- 			$whlabel = '';
 
- 			$product = '';
 
- 		}
 
- 		return array('title' => preg_replace(array('/(\s+)/', '/分\s/u'), array(' ', '分'), trim($nr, ';')), 'purchase' => $purchase, 'cost' => $cost, 'product' => str_replace(array('---', '--'), array('-', '-'), $product), 'whlabel' => $whlabel, 'wcslpx' => trim($wcslpx, '|'), 'cs' => $cscs);
 
- 	}
 
- 	public function _spexcel()
 
- 	{
 
- 		$tc = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v) {
 
- 			$tc[$v['id']] = $v;
 
- 		}
 
- 		if (isset($_SESSION['api'])) {
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 			$fgshop = "";
 
- 			$sid = "";
 
- 			$excelshop = "";
 
- 			$usersp = explode('|', trim($user['shop'], '|'));
 
- 			foreach ($usersp as $value) {
 
- 				$fgshop .= " shop = " . $value . " or";
 
- 				$sid .= " id = " . $value . " or";
 
- 			}
 
- 			$userexcel = explode('|', trim($user['excelshop'], '|'));
 
- 			foreach ($userexcel as $value) {
 
- 				$excelshop .= " shop =  " . $value . " or";
 
- 			}
 
- 			if ($excelshop != "") {
 
- 				$excelshop = "(" . rtrim($excelshop, 'or') . ")";
 
- 			}
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		$tcall = $this->typeclass->find_all();
 
- 		$typeclass = array();
 
- 		foreach ($tcall as $v) {
 
- 			$tcjm[$v['id']] = array($v['jm'], $v['classid']);
 
- 			$typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
 
- 		}
 
- 		$classid = $this->classid->sku();
 
- 		if (isset($_GET['category'])) {
 
- 			$timetk = $this->input->get('timetk', true);
 
- 			$timetj = $this->input->get('timetj', true);
 
- 			$color = $this->input->get('color', true);
 
- 			$lowe = $this->input->get('lowe', true);
 
- 			$size = $this->input->get('size', true);
 
- 			$grade = $this->input->get('grade', true);
 
- 			$lacetype = $this->input->get('lacetype', true);
 
- 			$category = $this->input->get('category', true);
 
- 			$shop = $this->input->get('shop', true);
 
- 			$density = $this->input->get('density', true);
 
- 			$warehouse = $this->input->get('warehouse', true);
 
- 			$time = $this->input->get('time', true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			$where = "";
 
- 			if ($warehouse) {
 
- 				$where .= " type = " . $warehouse . " and  ";
 
- 			}
 
- 			if ($category) {
 
- 				$where  .= "fpdata like '%-" . $category . "-%' and ";
 
- 			}
 
- 			if ($color) {
 
- 				$where  .= "fpdata like '%-" . $color . "-%' and ";
 
- 			}
 
- 			if ($size) {
 
- 				$where  .= "fpdata like '%-" . $size . "-%' and ";
 
- 			}
 
- 			if ($grade) {
 
- 				$where  .= "fpdata like '%-" . $grade . "-%' and ";
 
- 			}
 
- 			if ($shop) {
 
- 				$where  .= "shop = '$shop' and ";
 
- 			} else {
 
- 				$where  .= $excelshop . " and ";
 
- 			}
 
- 			if ($lowe) {
 
- 				$where  .= "fpdata like '%-" . $lowe . "-%' and ";
 
- 			}
 
- 			if ($density) {
 
- 				$where  .= "fpdata like '%-" . $density . "-%' and ";
 
- 			}
 
- 			if ($lacetype) {
 
- 				$where  .= "fpdata like '%-" . $lacetype . "-%' and ";
 
- 			}
 
- 			$dataa = $this->fullorder->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
 
- 			$datab = $this->fullordersmt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj' and shop != '9'", 'fpdata,number,whlabel,type', 'id desc');
 
- 			$datac = $this->fullordertt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
 
- 			$data = array_merge($dataa, $datab, $datac);
 
- 			$sp = array();
 
- 			$cs = array();
 
- 			$warehouses = $this->warehouse->find_all('1=1', 'id,title');
 
- 			$warehouses = array_column($warehouses, 'title', 'id');
 
- 			foreach ($data as $val) {
 
- 				$f = explode(';', trim($val['fpdata'], ';'));
 
- 				$w = explode('|', trim($val['whlabel'], '|'));
 
- 				foreach ($f as $k => $v) {
 
- 					if ($category) {
 
- 						if (stripos($v, '-' . $category . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($color) {
 
- 						if (stripos($v, '-' . $color . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($lowe) {
 
- 						if (stripos($v, '-' . $lowe . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($size) {
 
- 						if (stripos($v, $size . ',') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($grade) {
 
- 						if (stripos($v, '-' . $grade . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($lacetype) {
 
- 						if (stripos($v, '-' . $lacetype . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					if ($density) {
 
- 						if (stripos($v, '-' . $density . '-') === false) {
 
- 							continue;
 
- 						}
 
- 					}
 
- 					$title = explode('|', $v);
 
- 					$fg = str_replace(array('-163-', '-164-', '-165-', '-166-', '-0-', '-126-', '-127-', '-128-', '-197-', '-195-'), '-', $title[0]);
 
- 					$fg = explode(',', $fg);
 
- 					$tmp_c = $this->getCate($title[0]);
 
- 					//$fg = explode('-',trim($fg[1].$fg[0],'-'));
 
- 					if (isset($fg[1])) {
 
- 						$fg = explode('-', trim($fg[1] . $fg[0], '-'));
 
- 					} else {
 
- 						$fg = [];
 
- 					}
 
- 					$pm = array();
 
- 					//$pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'','dc'=>'','c'=>'',12=>'',25=>'',26=>'',14=>'',27=>'',10=>'',6=>'',9=>'',39=>'',999=>'',9999=>'');//品名顺序
 
- 					foreach ($fg as $vv) {
 
- 						if (isset($tc[$vv]['zh'])) {
 
- 							$zh = explode('|', trim($tc[$vv]['zh'], '|'));
 
- 							$pm[$tc[$vv]['classid']] = $zh[0];
 
- 						}
 
- 					}
 
- 					$features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $v);
 
- 					$tsk = explode('|', trim($features, '|'));
 
- 					if (stripos($tsk[0], ',') !== false) {
 
- 						$ftt = explode(',', $tsk[0]);
 
- 						$features = explode('-', trim($ftt[1], '-'));
 
- 						$features[] = $ftt[0];
 
- 					} else {
 
- 						$features = explode('-', trim($tsk[0], '-'));
 
- 					}
 
- 					$jm = $classid;
 
- 					$jm = $classid;
 
- 					foreach ($features as $vv) {
 
- 						if ($vv != 0) {
 
- 							if (!isset($typeclass[$vv])) {
 
- 								continue;
 
- 							}
 
- 							if (isset($jm[$typeclass[$vv]['classid']])) {
 
- 								if ($typeclass[$vv]['jm']) {
 
- 									$jm[$typeclass[$vv]['classid']] = $typeclass[$vv]['jm'];
 
- 								}
 
- 							}
 
- 						}
 
- 					}
 
- 					$jm = array_filter($jm); //去除空值
 
- 					$jm = implode("-", $jm);
 
- 					$zh = implode(" ", $pm);
 
- 					$zh = str_replace('自然色 ', '', rtrim($zh, ' '));
 
- 					$zh = str_replace(array('        ', '       ', '      ', '     ', '    ', '   ', '  '), ' ', $zh);
 
- 					if (isset($title[1])) {
 
- 						if (isset($sp[$title[1]])) {
 
- 							$sp[$title[1]]['n'] += $title[2];
 
- 							if (isset($sp[$title[1]]['warehouse'][$val['type']])) {
 
- 								$sp[$title[1]]['warehouse'][$val['type']] += $title[2];
 
- 							} else {
 
- 								$sp[$title[1]]['warehouse'][$val['type']] = $title[2];
 
- 							}
 
- 							//美仓
 
- 							if ($val['type'] == 5) {
 
- 								$sp[$title[1]]['mc'] +=  $title[2];
 
- 							} elseif ($val['type'] == 13) { //许昌仓
 
- 								$sp[$title[1]]['xcc'] +=  $title[2];
 
- 							} elseif ($val['type'] == 16) { //定制仓
 
- 								$sp[$title[1]]['dzc'] +=  $title[2];
 
- 							} else {
 
- 								$sp[$title[1]]['qtc'] +=  $title[2];
 
- 							}
 
- 						} else {
 
- 							$wh = explode('-', $w[$k]);
 
- 							$wsku = $this->whlabel->find_all("number = '" . $wh[0] . "' and sku != 'Preset'");
 
- 							$whs = (isset($wsku[0]['sku'])) ? $wsku[0]['sku'] : '';
 
- 							$sp[$title[1]] = array('t' => $title[1], 'z' => $zh, 'c' => $tmp_c, 'w' => $whs, 'j' => $jm, 'n' => $title[2], "warehouse" => [
 
- 								$val['type'] => $title[2],
 
- 							], "warehouse_show" => "", "xcc" => 0, "mc" => 0, "dzc" => 0, "qtc" => 0);
 
- 							//美仓
 
- 							if ($val['type'] == 5) {
 
- 								$sp[$title[1]]['mc'] =  $title[2];
 
- 							} elseif ($val['type'] == 13) { //许昌仓
 
- 								$sp[$title[1]]['xcc'] =  $title[2];
 
- 							} elseif ($val['type'] == 16) { //定制仓
 
- 								$sp[$title[1]]['dzc'] =  $title[2];
 
- 							} else {
 
- 								$sp[$title[1]]['qtc'] =  $title[2];
 
- 							}
 
- 						}
 
- 					}
 
- 					//由于原来的按照品名分组可能会有异常 这里将品名转化为skuid为分组依据
 
- 					// $wh = explode('-',$w[$k]);
 
- 					// if(isset($wh[0])){
 
- 					// 	if(isset($sp[$wh[0]]))
 
- 					// 	{
 
- 					// 		$sp[$wh[0]]['n'] += $title[2];
 
- 					// 		if(isset($sp[$wh[0]]['warehouse'][$val['type']])){
 
- 					// 		    $sp[$wh[0]]['warehouse'][$val['type']] += $title[2];
 
- 					// 		}else{
 
- 					// 		    $sp[$wh[0]]['warehouse'][$val['type']] = $title[2];
 
- 					// 		}
 
- 					// 		//美仓
 
- 					// 		if($val['type'] == 5){
 
- 					// 			$sp[$wh[0]]['mc'] +=  $title[2];
 
- 					// 		}elseif($val['type'] == 13){//许昌仓
 
- 					// 			$sp[$wh[0]]['xcc'] +=  $title[2];
 
- 					// 		}elseif($val['type'] == 16){//定制仓
 
- 					// 			$sp[$wh[0]]['dzc'] +=  $title[2];
 
- 					// 		}else{
 
- 					// 			$sp[$wh[0]]['qtc'] +=  $title[2];
 
- 					// 		}
 
- 					// 	}
 
- 					// 	else
 
- 					// 	{
 
- 					// 		$wh = explode('-',$w[$k]);
 
- 					// 		$wsku = $this->whlabel->find_all("number = '".$wh[0]."' and sku != 'Preset'");
 
- 					// 		$whs = (isset($wsku[0]['sku']))?$wsku[0]['sku']:'';
 
- 					// 		$sp[$wh[0]] = array('t'=>$title[1],'z'=>$zh,'c'=>$tmp_c,'w'=>$whs,'j'=>$jm,'n'=>$title[2],"warehouse"=>[
 
- 					// 		        $val['type'] =>$title[2],
 
- 					// 		    ],"warehouse_show"=>"","xcc"=>0,"mc"=>0,"dzc"=>0,"qtc"=>0);
 
- 					// 		//美仓
 
- 					// 		if($val['type'] == 5){
 
- 					// 			$sp[$wh[0]]['mc'] =  $title[2];
 
- 					// 		}elseif($val['type'] == 13){//许昌仓
 
- 					// 			$sp[$wh[0]]['xcc'] =  $title[2];
 
- 					// 		}elseif($val['type'] == 16){//定制仓
 
- 					// 			$sp[$wh[0]]['dzc'] =  $title[2];
 
- 					// 		}else{
 
- 					// 			$sp[$wh[0]]['qtc'] =  $title[2];
 
- 					// 		}
 
- 					// 	}
 
- 					// }
 
- 				}
 
- 			}
 
- 			foreach ($sp as $k => $v) {
 
- 				// foreach($sp[$k]['warehouse'] as $kk =>$vv){
 
- 				//     $warehouse_name = isset($warehouses[$kk])?$warehouses[$kk]:"异常仓库-".$kk;
 
- 				//     $sp[$k]['warehouse_show'] .=$warehouse_name.":".$vv."<br />";
 
- 				// }
 
- 				unset($sp[$k]['warehouse']);
 
- 				unset($sp[$k]['warehouse_show']);
 
- 			}
 
- 			$sp = array_values($sp);
 
- 			$title = "商品统计" . date('Y-m-d H-i-s', time());
 
- 			$titlename = "<table border=1>
 
-             <tr>
 
-             <td>名称</td>
 
- 			<td>中文</td>
 
- 			<td>类型</td>
 
- 			<td>SKU</td>
 
- 			<td>用友料号</td>
 
-             <td>数量</td>
 
- 			<td>许昌仓发货量</td>
 
- 			<td>美仓发货量</td>
 
- 			<td>定制仓发货量</td>
 
- 			<td>其他仓发货量</td>
 
-             </tr>
 
-             </table>";
 
- 			$filename = $title . ".xls";
 
- 			$tail = "\n";
 
- 			$this->excel->get_fz2($sp, $titlename, $filename, $tail);
 
- 		}
 
- 	}
 
- 	public function getCate($str)
 
- 	{
 
- 		//就是为了匹配类型的导出的一个定义数组
 
- 		$lx_list = [
 
- 			"126" => "Hair Weaving - 发条",
 
- 			"127" => "Closure - 发块前头",
 
- 			"128" => "Wigs",
 
- 			"130" => "Hair Extension - 接发",
 
- 			"131" => "Gift - 礼物",
 
- 			"133" => "Accessories - 配件",
 
- 			"1297" => "Synthetic Wig - 化纤头套",
 
- 			"1702" => "Synthetic Hair - 化纤其它",
 
- 		];
 
- 		if (stripos($str, '-126-') !== false) {
 
- 			$tmp_c = "Hair Weaving - 发条";
 
- 		} elseif (stripos($str, '-127-') !== false) {
 
- 			$tmp_c = "Closure - 发块前头";
 
- 		} elseif (stripos($str, '-128-') !== false) {
 
- 			$tmp_c = "Wigs";
 
- 		} elseif (stripos($str, '-130-') !== false) {
 
- 			$tmp_c = "Hair Extension - 接发";
 
- 		} elseif (stripos($str, '-131-') !== false) {
 
- 			$tmp_c = "Gift - 礼物";
 
- 		} elseif (stripos($str, '-133-') !== false) {
 
- 			$tmp_c = "Accessories - 配件";
 
- 		} elseif (stripos($str, '-1297-') !== false) {
 
- 			$tmp_c = "Synthetic Wig - 化纤头套";
 
- 		} elseif (stripos($str, '-1702-') !== false) {
 
- 			$tmp_c = "Synthetic Hair - 化纤其它";
 
- 		} else {
 
- 			$tmp_c = "其他";
 
- 		}
 
- 		return $tmp_c;
 
- 	}
 
- 	public function _setting()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['excelpass'])) {
 
- 			$excelpass = $this->input->post('excelpass', true);
 
- 			$exceljmnum = $this->input->post('exceljmnum', true);
 
- 			$excelusernum = $this->input->post('excelusernum', true);
 
- 			if ($excelpass == '') {
 
- 				echo json_encode(array('msg' => '密码不能为空', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			if ($exceljmnum < 1 || $excelusernum < 1) {
 
- 				echo json_encode(array('msg' => '数量不可以小于1', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$this->setting->save(array('svalue' => $excelpass), 'excelpass');
 
- 			echo json_encode(array('msg' => 'Excel加密密码修改成功', 'success' => false));
 
- 			exit;
 
- 		}
 
- 	}
 
- 	public function _sctime()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['sctime'])) {
 
- 			$sctime = $this->input->post('sctime', true);
 
- 			if (!is_numeric($sctime)) {
 
- 				echo json_encode(array('msg' => '必须为正整数的数字!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$sctime = ($sctime > 0) ? $sctime * 3600 : 0;
 
- 			$this->setting->save(array('svalue' => $sctime), 'sctime');
 
- 			echo json_encode(array('msg' => '时差修改成功!', 'success' => false));
 
- 			exit;
 
- 		}
 
- 	}
 
- 	public function _dpay()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['pay'])) {
 
- 			$pay = $this->input->post('pay', true);
 
- 			$timetk = $this->input->post('timetk', true);
 
- 			$timetj = $this->input->post('timetj', true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			$where = "shouldmoney > '0' and dtime > '$timetk' and dtime < '$timetj' and pay = '$pay'";
 
- 			if (!$pay) {
 
- 				echo json_encode(array('msg' => '请选择支付方式!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$fullorder = $this->fullorder->find_all($where);
 
- 			$this->db->trans_begin();
 
- 			$cs = array();
 
- 			$p = $this->pay->get_typeclass($pay);
 
- 			foreach ($fullorder as $v) {
 
- 				$yga = $v['shouldmoney']; //金额
 
- 				$ygc = $p['estimaterate']; //预估到账公式
 
- 				$ifbudget = eval("return $yga*1.$ygc;");
 
- 				if ($ifbudget > 0) {
 
- 					$this->fullorder->save(array('budget' => $ifbudget, 'estimaterate' => $ygc), $v['id']);
 
- 				}
 
- 			}
 
- 			if ($this->db->trans_status() === TRUE) {
 
- 				$this->db->trans_commit();
 
- 				echo json_encode(array('msg' => '操作成功!', 'success' => true));
 
- 				exit;
 
- 			} else {
 
- 				$this->db->trans_rollback();
 
- 				echo json_encode(array('msg' => '失败,请重试', 'success' => false));
 
- 			}
 
- 		}
 
- 	}
 
- 	public function _dpex()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['n'])) {
 
- 			$number = $this->input->post('n', true);
 
- 			$postdata = $this->input->post('postdata', true);
 
- 			$postdata = json_decode($postdata, true);
 
- 			$d = array();
 
- 			foreach ($postdata as $val) {
 
- 				$d[] = array(
 
- 					'Money' => 'USD', //货币单位
 
- 					//'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
 
- 					'Cnname' => $val['zh'], //产品中文名
 
- 					'Enname' => $val['en'] . '*' . $val['num'], //产品英文名
 
- 					'Price' => $val['dj'] * 1, //单价
 
- 					'Weight' => $val['zl'] * 1, //重量
 
- 					'Num' => $val['num'] * 1, //数量
 
- 					'CustomsCode' => $val['hg'] //海关编码
 
- 				);
 
- 			}
 
- 			$fullorder = $this->fullorder->get_number($number);
 
- 			if (!$fullorder) {
 
- 				$fullorder = $this->fullordersmt->get_number($number);
 
- 			}
 
- 			if (!$fullorder) {
 
- 				echo json_encode(array('msg' => '没有此编号的订单!', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$fullorder = $this->_text($fullorder);
 
- 			$fullorder['number'] = $fullorder['number'] . '-' . date('s', time()); //订单号重复修改新订单好
 
- 			$data = $fullorder;
 
- 			$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder";
 
- 			$Clientid = 'LYFZP';
 
- 			$Token = 'NGkJSDx3bAxojl1YN232';
 
- 			$code = array('DPEX' => array('11', 'DPEX', '1'), 'ARAMEX' => array('002', '安迈世', 0), 'FEDEX' => array('FEDEX_1CC', 'FEDEX_1CC', ';lab10_10'), 'UPS' => array('04', 'UPS', 0), 'DHL' => array('06', 'DHL', ';lab10_10'), 'FED-SN-IP' => array('07', 'FED-SN-IP', ';lab10_10'), 'WML-FEDEX-ZZ' => array('05', 'WML-FEDEX-ZZ', ';lab10_10'), 'FED-XS-F' => array('03', 'FED-XS-F', ';lab10_10'), 'CNE' => array('08', '全球优先CNE', 'label10x10;0'), 'TCNE' => array('09', 'E速宝特惠', 'label10x10;0'));
 
- 			$printcode = $code[$data['printcode']];
 
- 			//创建并预报订单
 
- 			$count = array(
 
- 				'Verify' => array(
 
- 					'Clientid' => $Clientid,
 
- 					'Token' => $Token
 
- 				),
 
- 				'OrderType' => '1', //1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。
 
- 				'OrderDatas' => array(0 => array(
 
- 					'CustomerNumber' => $data['number'], //订单号
 
- 					'ChannelCode' => $printcode[0], //渠道代码
 
- 					'CountryCode' => $data['lb'], //国家二字码
 
- 					'TotalWeight' => $data['zzl'], //订单重量
 
- 					'TotalValue' => $data['zsbjz'], //申报价值
 
- 					'Number' => $data['zjs'], //件数
 
- 					'Note' => $data['number'], //备注
 
- 					/**
 
- 			'Insurance' => array(//是否购买保险
 
- 			'Code' => '',//保险类型
 
- 			'Value' => '',//保险金额
 
- 			),
 
- 					 **/
 
- 					'FeePayData' => array( //运费支付信息
 
- 						'FeePayType' => 'PP', //支付方式 [ PP:预付,CC:到付, TP:第三方]
 
- 						'FeePayAccountNumber' => '', //支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
 
- 						'FeePayCountryCode' => '', //支付账号对应国家 支付方式为 TP 时必传
 
- 						'FeePayPostCode' => '', //支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
 
- 					),
 
- 					'TaxPayData' => array( //税金/关税支付信息 OrderType 为 [快递制单] 时必传字段
 
- 						'TaxPayType' => 'PP', //支付方式 [ PP:预付,CC:到付, TP:第三方]
 
- 						'TaxPayAccountNumber' => '', //支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
 
- 						'TaxPayCountryCode' => '', //支付账号对应国家 支付方式为 TP 时必传
 
- 						'TaxPayPostCode' => '', //支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
 
- 					),
 
- 					'Recipient' => array( //收件人信息
 
- 						'Name' => $data['name'], //姓名
 
- 						'Addres1' => $data['address'], //地址1
 
- 						'Addres2' => $data['address2'], //地址2
 
- 						'Mobile' => preg_replace('/\D/s', '', $data['phone']), //手机
 
- 						'Province' => $data['province'], //省/州
 
- 						'City' => $data['city'], //城市
 
- 						'Post' => trim($data['zipcode'], ' '), //邮编
 
- 					),
 
- 					'OrderItems' => $d
 
- 				))
 
- 				/**,
 
- 			'Volumes' => array(//材积明细 (OrderType 为快递制单必传)
 
- 			'Weight' => '123123',//实重
 
- 			'Number' => '123123',//件数
 
- 			'Length' => '123123',//长
 
- 			'Width' => '123123',//宽
 
- 			'Height' => '123123',//高
 
- 			),
 
- 			 **/
 
- 			);
 
- 			$count = json_encode($count, true);
 
- 			$ch = curl_init();
 
- 			curl_setopt($ch, CURLOPT_URL, $url);
 
- 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
- 			curl_setopt($ch, CURLOPT_HEADER, 0);
 
- 			curl_setopt($ch, CURLOPT_POST, 1);
 
- 			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
 
- 			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
 
- 			$res = curl_exec($ch);
 
- 			curl_close($ch);
 
- 			$res = json_decode($res, true);
 
- 			if (!isset($res['returnDatas'][0]['corpBillid'])) {
 
- 				echo json_encode(array('msg' => $res['returnDatas'][0]['message'], 'success' => false));
 
- 				exit;
 
- 			} else {
 
- 				$yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'], $printcode[2]);
 
- 				$fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'], $count);
 
- 				if ($yd != 'c' && $fp != 'c') {
 
- 					echo json_encode(array('msg' => '<p><a href="' . $fp . '" target="_blank">查看发票</a> <a href="' . $yd . '" target="_blank">查看运单</a></p>', 'success' => true));
 
- 					exit;
 
- 				} else {
 
- 					echo json_encode(array('msg' => '获取运单失败,请重试', 'success' => false));
 
- 					exit;
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- 	public function _text($fullorder)
 
- 	{
 
- 		/** 发票地址信息暂时无用 
 
- 		$fullorder['baddress'] = explode(',',$fullorder['baddress']);
 
- 		$fullorder['baddress'] = array_reverse($fullorder['baddress']);
 
- 		$fullorder['baddress'][1] = $country['ename'];
 
- 		 **/
 
- 		//获取所用相关信息
 
- 		$warehouse = $this->warehouse->read($fullorder['type']);
 
- 		$country = $this->country->read($fullorder['country']); //订单国家信息
 
- 		$fcountry = $this->country->read($warehouse['country']); //仓库国家信息
 
- 		$warehouse['country'] = $fcountry['ename']; //仓库国家名
 
- 		$warehouse['lb'] = $fcountry['lb']; //仓库国家编码
 
- 		$fullorder['warehouse'] = $warehouse; //仓库数据加入订单
 
- 		$fullorder['lb'] = $country['lb']; //订单国家编码加入
 
- 		$fullorder['country'] = $country['ename']; //订单国家名
 
- 		$fullorder['zhou'] = $country['continent']; //所属州
 
- 		$express = $this->express->read($fullorder['express']);
 
- 		$fullorder['express'] = $express['servicename'];
 
- 		$fullorder['account'] = $express['account'];
 
- 		$fullorder['printcode'] = $express['printcode'];
 
- 		$fullorder['time'] = date('Y-m-d', time());
 
- 		$fullorder['times'] = date('Y-m-d H:i', time());
 
- 		//$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
 
- 		// 修复报关编码问题
 
- 		$declara_info = $this->customsdeclaration->find("ename like '%" . trim($fullorder['sbpm']) . "%' ", "*");
 
- 		$sbbm = "";
 
- 		if (empty($declara_info)) {
 
- 			$sbbm = "";
 
- 		} else {
 
- 			$sbbm = $declara_info['bname'];
 
- 		}
 
- 		$fullorder['sbbm'] = $sbbm;
 
- 		$fullorder['address'] = str_replace(array('&'), array('&'), $fullorder['address']);
 
- 		$fullorder['address2'] = str_replace(array('&'), array('&'), $fullorder['address2']);
 
- 		$fullorder['shipremarks'] = str_replace(array('<', '>', ';', ';'), array('<', '>', ';<br>', ';<br>'), $fullorder['shipremarks']);
 
- 		$shop = $this->shop->read($fullorder['shop']);
 
- 		$fullorder['shop'] = $shop['shopname'];
 
- 		if (is_numeric($fullorder['pay'])) {
 
- 			$pay = $this->typeclass->read($fullorder['pay']);
 
- 			if ($pay['classid'] == '4') {
 
- 				$fullorder['pay'] = $pay['title'];
 
- 			}
 
- 		}
 
- 		if ($fullorder['printcode'] != "USPS") {
 
- 			$fullorder['client'] = htmlspecialchars($fullorder['client']);
 
- 			$fullorder['name'] = htmlspecialchars($fullorder['name']);
 
- 		}
 
- 		//增加退货单所需信息
 
- 		$pt = '';
 
- 		$fpdata = explode(';', trim($fullorder['fpdata'], ';'));
 
- 		foreach ($fpdata as $v) {
 
- 			$p = explode('|', trim($v, '|'));
 
- 			$pt .= '<p>' . $p[1] . ' * ' . $p[2] . '</p>';
 
- 		}
 
- 		$fullorder['pt'] = $pt;
 
- 		return $fullorder;
 
- 	}
 
- 	public function get_dpex_yd($waybill, $PrintPaper)
 
- 	{
 
- 		$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel";
 
- 		$Clientid = 'LYFZP';
 
- 		$Token = 'NGkJSDx3bAxojl1YN232';
 
- 		$count = array(
 
- 			'Verify' => array(
 
- 				'Clientid' => $Clientid,
 
- 				'Token' => $Token
 
- 			),
 
- 			'CorpBillidDatas' => array(0 => array('CorpBillid' => $waybill)),
 
- 			'OrderType' => "1", //1:快件订单 2:快递制单 3:仓库订单
 
- 			'PrintPaper' => $PrintPaper, //打印纸张 快递制单只固定为:label 和 A4
 
- 			'PrintContent' => "1" //打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3
 
- 		);
 
- 		$count = json_encode($count, true);
 
- 		$ch = curl_init();
 
- 		curl_setopt($ch, CURLOPT_URL, $url);
 
- 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
- 		curl_setopt($ch, CURLOPT_HEADER, 0);
 
- 		curl_setopt($ch, CURLOPT_POST, 1);
 
- 		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
 
- 		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res, true);
 
- 		if ($res['statusCode'] == 'success') {
 
- 			return $res['url'];
 
- 		} else {
 
- 			return 'c';
 
- 		}
 
- 	}
 
- 	public function get_dpex_fp($waybill)
 
- 	{
 
- 		$url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice";
 
- 		$Clientid = 'LYFZP';
 
- 		$Token = 'NGkJSDx3bAxojl1YN232';
 
- 		$count = array(
 
- 			'Verify' => array(
 
- 				'Clientid' => $Clientid,
 
- 				'Token' => $Token
 
- 			),
 
- 			'CorpBillidDatas' => array(0 => array('CorpBillid' => $waybill))
 
- 		);
 
- 		$count = json_encode($count, true);
 
- 		$ch = curl_init();
 
- 		curl_setopt($ch, CURLOPT_URL, $url);
 
- 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
- 		curl_setopt($ch, CURLOPT_HEADER, 0);
 
- 		curl_setopt($ch, CURLOPT_POST, 1);
 
- 		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
 
- 		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
 
- 		$res = curl_exec($ch);
 
- 		curl_close($ch);
 
- 		$res = json_decode($res, true);
 
- 		if ($res['statusCode'] == 'success') {
 
- 			return $res['url'];
 
- 		} else {
 
- 			return 'c';
 
- 		}
 
- 	}
 
- 	public function _excellkh()
 
- 	{
 
- 		if (isset($_SESSION['api'])) {
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 			$fgshop = "";
 
- 			$sid = "";
 
- 			$user = explode('|', trim($user['shop'], '|'));
 
- 			foreach ($user as $value) {
 
- 				if ($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') {
 
- 					$fgshop .= " shop = " . $value . " or"; //去掉指定的店铺
 
- 				}
 
- 				$sid .= " id = " . $value . " or";
 
- 			}
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($_GET['time'])) {
 
- 			$s = $this->input->get('shop', true);
 
- 			$time = $this->input->get('time', true);
 
- 			$timetk = $this->input->get('timetk', true);
 
- 			$timetj = $this->input->get('timetj', true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			if ($s) {
 
- 				$shop = $this->shop->find_all("id = '$shop'");
 
- 			} else {
 
- 				$shop = $this->shop->find_all("(type = 269 or type = 2768 ) and (" . rtrim($sid, 'or') . ')');
 
- 			}
 
- 			$d = array();
 
- 			$k = $timetk - 24 * 3600; //少一天为增加选择开始天时间
 
- 			$j = $timetj;
 
- 			$n = ($j - $k) / (24 * 3600);
 
- 			if ($n < 1) {
 
- 				$n = 1;
 
- 			}
 
- 			for ($i = 1; $i < $n; $i++) {
 
- 				$t = $j - ($n * 24 * 60 * 60) + ($i * 24 * 60 * 60);
 
- 				foreach ($shop as $val) {
 
- 					$data = $this->fullorder->find_all("source != 1 and $time > '$t' and $time < '" . ($t + 24 * 3600) . "' and shop = '" . $val['id'] . "'");
 
- 					$dd = 0;
 
- 					$m = 0;
 
- 					foreach ($data as $v) {
 
- 						$customer = $this->customer->get_email($v['email'], $v['shop']);
 
- 						$customernum = $this->fullorder->find_count("$time < '" . ($t + 24 * 3600) . "' and email = '" . $v['email'] . "' and shop = '" . $v['shop'] . "'   and  extra_status = 0 ");
 
- 						preg_match_all('/[0-9]/u', $v['phone'], $result);
 
- 						$numphone = join('', $result[0]);
 
- 						//$customerc = $this->customer->find_all("shop = '".$v['shop']."' and address = '".$v['address']."' and numphone = '".$numphone."'",'*','id desc');
 
- 						if ($customer) {
 
- 							if ($customernum > 1) // || (isset($customerc[0]['num']) && $customerc[0]['num'] > 1) // || $customerc['type'] == 1 && $customerc['num'] > 1
 
- 							{
 
- 								$dd++;
 
- 								$m += $v['shouldmoney'];
 
- 							}
 
- 						}
 
- 					}
 
- 					$ddzb = ($dd == 0 || count($data) == 0) ? 0 : sprintf("%01.2f", $dd / count($data) * 100) . '%';
 
- 					$ddjezb = ($m == 0 || array_sum(array_column($data, 'shouldmoney')) == 0) ? 0 : sprintf("%01.2f", $m / array_sum(array_column($data, 'shouldmoney')) * 100) . '%';
 
- 					$d[] = array(date('Y-m-d', $t), $val['shopname'], count($data), sprintf("%01.2f", array_sum(array_column($data, 'shouldmoney'))), $dd, $m, $ddzb, $ddjezb);
 
- 				}
 
- 			}
 
- 			$title = "老客户数据统计" . date('Y-m-d H-i-s', time());
 
- 			$titlename = "<table border=1>
 
-             <tr>
 
- 			<td>时间</td>
 
- 			<td>店铺</td>
 
-             <td>订单数</td>
 
- 			<td>订单金额 </td>
 
- 			<td>老客户订单数</td>
 
-             <td>老客户订单金额</td>
 
- 			<td>老客户订单数占比</td>
 
-             <td>老客户订单金额占比</td>
 
-             </tr>
 
-             </table>";
 
- 			$filename = $title . ".xls";
 
- 			$tail = "\n";
 
- 			$this->excel->get_fz2($d, $titlename, $filename, $tail);
 
- 		}
 
- 	}
 
- 	public function _excelshop()
 
- 	{
 
- 		if (isset($_SESSION['api'])) {
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 			$fgshop = "";
 
- 			$sid = "";
 
- 			$user = explode('|', trim($user['shop'], '|'));
 
- 			foreach ($user as $value) {
 
- 				if ($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') {
 
- 					$fgshop .= " shop = " . $value . " or"; //去掉指定的店铺
 
- 				}
 
- 				$sid .= " id = " . $value . " or";
 
- 			}
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($_GET['time'])) {
 
- 			$s = $this->input->get('shop', true);
 
- 			$time = $this->input->get('time', true);
 
- 			$timetk = $this->input->get('timetk', true);
 
- 			$timetj = $this->input->get('timetj', true);
 
- 			$timetk = strtotime($timetk);
 
- 			$timetj = strtotime($timetj);
 
- 			if ($s) {
 
- 				$shop = $this->shop->find_all("id = '$shop'");
 
- 			} else {
 
- 				$shop = $this->shop->find_all("(type = 269 or type = 2768 ) and (" . rtrim($sid, 'or') . ')');
 
- 			}
 
- 			$d = array();
 
- 			$k = $timetk - 24 * 3600; //少一天为增加选择开始天时间
 
- 			$j = $timetj;
 
- 			$n = ($j - $k) / (24 * 3600);
 
- 			if ($n < 1) {
 
- 				$n = 1;
 
- 			}
 
- 			for ($i = 1; $i < $n; $i++) {
 
- 				$t = $j - ($n * 24 * 60 * 60) + ($i * 24 * 60 * 60);
 
- 				foreach ($shop as $val) {
 
- 					$data = $this->fullorder->find_all("$time > '$t' and $time < '" . ($t + 24 * 3600) . "' and shop = '" . $val['id'] . "'");
 
- 					$dd = 0;
 
- 					$m = 0;
 
- 					$d[] = array(date('Y-m-d', $t), $val['shopname'], count($data), sprintf("%01.2f", array_sum(array_column($data, 'shouldmoney'))));
 
- 				}
 
- 			}
 
- 			$title = "店铺数据统计" . date('Y-m-d H-i-s', time());
 
- 			$titlename = "<table border=1>
 
-             <tr>
 
- 			<td>时间</td>
 
- 			<td>店铺</td>
 
-             <td>订单数</td>
 
- 			<td>订单金额 </td>
 
-             </tr>
 
-             </table>";
 
- 			$filename = $title . ".xls";
 
- 			$tail = "\n";
 
- 			$this->excel->get_fz2($d, $titlename, $filename, $tail);
 
- 		}
 
- 	}
 
- 	public function _qczd()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['number'])) {
 
- 			$number = $this->input->post('number', true);
 
- 			if (!$number || $number == '' || $number == NULL) {
 
- 				echo json_encode(array('msg' => '没有编号信息', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$a = $this->whlabel->find_all("zd = '$number' and state = '0'");
 
- 			foreach ($a as $v) {
 
- 				$this->whlabel->save(array('zd' => ''), $v['id']);
 
- 			}
 
- 			echo json_encode(array('msg' => '清除完成!', 'success' => true));
 
- 			exit;
 
- 		}
 
- 	}
 
- 	public function _ggdd()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if (isset($post['number'])) {
 
- 			$number = $this->input->post('number', true);
 
- 			$guarantee = $this->input->post('guarantee', true);
 
- 			$quantity = $this->input->post('quantity', true);
 
- 			$post = array();
 
- 			if ($guarantee) {
 
- 				$post['guarantee'] = $guarantee;
 
- 			}
 
- 			if ($quantity) {
 
- 				$post['quantity'] = $quantity;
 
- 			}
 
- 			if (!$number || $number == '' || $number == NULL) {
 
- 				echo json_encode(array('msg' => '没有编号信息', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			if (!$post) {
 
- 				echo json_encode(array('msg' => '没有修改信息', 'success' => false));
 
- 				exit;
 
- 			}
 
- 			$fullorder_name = 'fullorder';
 
- 			$y = $this->fullorder->get_number($number);
 
- 			if (!$y) {
 
- 				$fullorder_name = 'fullordersmt';
 
- 				$y = $this->fullordersmt->get_number($number);
 
- 				if (!$y) {
 
- 					$fullorder_name = 'fullordertt';
 
- 					$y = $this->fullordertt->get_number($number);
 
- 					if (!$y) {
 
- 						echo json_encode(array('msg' => '无此编号数据', 'success' => false));
 
- 						exit;
 
- 					}
 
- 				}
 
- 			}
 
- 			$this->$fullorder_name->save($post, $y['id']);
 
- 			echo json_encode(array('msg' => '修改完成!', 'success' => true));
 
- 			exit;
 
- 		}
 
- 	}
 
- }
 
 
  |