Systembound.php 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systembound extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_outbound','outbound');
  8. $this->load->_model('Model_excel','excel');
  9. $this->load->_model('Model_express','express');
  10. $this->load->_model('Model_shop','shop');
  11. $this->load->_model('Model_warehouse','warehouse');
  12. $this->load->_model('Model_fullorder','fullorder');
  13. $this->load->_model('Model_fullordertt','fullordertt');
  14. $this->load->_model('Model_fullorderamz','fullorderamz');
  15. $this->load->_model('Model_fullordersmt','fullordersmt');
  16. $this->load->_model('Model_fullorderxw','fullorderxw');
  17. }
  18. //定义方法的调用规则 获取URI第二段值
  19. public function _remap($arg,$arg_array)
  20. {
  21. if($arg == 'data')
  22. {
  23. $this->_data();
  24. }
  25. else if($arg == 'out')
  26. {
  27. $this->_out();
  28. }
  29. else if($arg == 'del')
  30. {
  31. $this->_del();
  32. }
  33. else if($arg == 'add')
  34. {
  35. $this->_add();
  36. }
  37. else if($arg == 'excel')
  38. {
  39. $this->_excel();
  40. }
  41. else if($arg == 'excelhc')
  42. {
  43. //一件导出惠城和GES的全部快递
  44. $this->_excelhc();
  45. }
  46. else
  47. {
  48. $this->_index();
  49. }
  50. }
  51. public function _index()
  52. {
  53. if(isset($_SESSION['api']))
  54. {
  55. $user = $this->user->get_api($_SESSION['api']);
  56. $usp = $user;
  57. $fgshop = "";$sid = "";$wid="";$wtype="";
  58. $usersp = explode('|',trim($user['shop'],'|'));
  59. $userwh = explode('|',trim($user['warehouse'],'|'));
  60. foreach ($usersp as $value)
  61. {
  62. $fgshop .= " shop = ".$value." or";
  63. $sid .= " id = ".$value." or";
  64. }
  65. foreach ($userwh as $value)
  66. {
  67. $wid .= " id = ".$value." or";
  68. $wtype .= " type = ".$value." or";
  69. }
  70. }
  71. if(isset($_SESSION['api']))
  72. {
  73. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  74. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  75. $this->data['wlshop'] = $wlshop;
  76. $this->data['warehouse'] = $warehouse;
  77. $this->data['vip'] = $user['vip'];
  78. }
  79. $this->_Template('systembound',$this->data);
  80. }
  81. public function _data()
  82. {
  83. $post = $this->input->post(NULL, TRUE);
  84. if(isset($post['page']))
  85. {
  86. $api = $this->input->post('api',true);
  87. $page = $this->input->post('page',true);
  88. $perpage = $this->input->post('perpage',true);
  89. $number = $this->input->post('number',true);
  90. $waybill = $this->input->post('waybill',true);
  91. $express = $this->input->post('express',true);
  92. $type = $this->input->post('type',true);
  93. $timetk = $this->input->post('timetk',true);
  94. $timetj = $this->input->post('timetj',true);
  95. $timetk = strtotime($timetk);
  96. $timetj = strtotime($timetj);
  97. $where = "type != 0";
  98. if(isset($_SESSION['api']))
  99. {
  100. if($type)
  101. {
  102. $where .= " and type = '$type'";
  103. }
  104. else
  105. {
  106. $uw = '';
  107. $u = $this->user->get_api($_SESSION['api']);
  108. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  109. foreach ($u['warehouse'] as $v)
  110. {
  111. $uw .= " type = '$v' or";
  112. }
  113. $uw = rtrim($uw,'or');
  114. $uw = " and (".ltrim($uw,' ').")";
  115. $where .= $uw;
  116. }
  117. }
  118. if($timetk && $timetj)
  119. {
  120. $where .= " and time > '$timetk' and time < '$timetj'";
  121. }
  122. if($number)
  123. {
  124. $where .= " and number = '$number'";
  125. }
  126. if($waybill)
  127. {
  128. $where .= " and waybill = '$waybill'";
  129. }
  130. if($express)
  131. {
  132. $where .= " and express = '$express'";
  133. }
  134. //数据排序
  135. $order_str = "time desc";
  136. if(empty($page))
  137. {
  138. $start = 0;
  139. $perpage = 1;
  140. }
  141. else
  142. {
  143. $start = ($page - 1)*$perpage;
  144. }
  145. //取得信息列表
  146. $info_list = $this->outbound->find_all($where,'id,type,express,number,waybill,time',$order_str,$start,$perpage);
  147. //格式化数据
  148. foreach ($info_list as $key=>$value)
  149. {
  150. if($value['waybill'] == '0')
  151. {
  152. $info_list[$key]['waybill'] = "无";
  153. }
  154. if($value['express'] == '0')
  155. {
  156. $info_list[$key]['express'] = "无";
  157. }
  158. else
  159. {
  160. $express = $this->express->read($value['express']);
  161. $info_list[$key]['express'] = $express['servicename'];
  162. }
  163. $warehouse = $this->warehouse->read($value['type']);
  164. $info_list[$key]['type'] = $warehouse['title'];
  165. $info_list[$key]['time'] = '<em class="t">'.date('Y-m-d H:i:s',$value['time']).'</em>';
  166. }
  167. $ex = array();
  168. $ed = $this->outbound->find_all($where,'express');
  169. foreach ($ed as $key=>$value)
  170. {
  171. if(isset($ex[$value['express']]))
  172. {
  173. $ex[$value['express']] += 1;
  174. }
  175. else
  176. {
  177. $ex[$value['express']] = 1;
  178. }
  179. }
  180. $exdata = '';
  181. foreach ($ex as $k=>$v)
  182. {
  183. $e = $this->express->read($k);
  184. $exdata .= "<li>".$e['servicename'].":".$v."单</li>";
  185. }
  186. $datacount = $this->outbound->find_count($where." and gtime = '".date('Ymd',time())."'");
  187. $total = $this->outbound->find_count($where);
  188. $pagenum = ceil($total/$perpage);
  189. $over = $total-($start+$perpage);
  190. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'datacount'=>$datacount,'exdata'=>$exdata);
  191. echo json_encode($rows);exit;
  192. }
  193. }
  194. public function _out_bak()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if(isset($post['number']))
  198. {
  199. $where = "gtime = '".date('Ymd',time())."'";
  200. $number = $this->input->post('number',true);
  201. $type = $this->input->post('type',true);
  202. $express = $this->input->post('express',true);
  203. if($_SESSION['api'])
  204. {
  205. if($type)
  206. {
  207. $where .= " and type = '$type'";
  208. }
  209. else
  210. {
  211. $uw = '';
  212. $u = $this->user->get_api($_SESSION['api']);
  213. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  214. foreach ($u['warehouse'] as $v)
  215. {
  216. $uw .= " type = '$v' or";
  217. }
  218. $uw = rtrim($uw,'or');
  219. $uw = " and (".ltrim($uw,' ').")";
  220. $where .= $uw;
  221. }
  222. }
  223. if(!$number)
  224. {
  225. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  226. }
  227. if(!$type)
  228. {
  229. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  230. }
  231. if(!$express)
  232. {
  233. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  234. }
  235. $sex = $this->express->read($express);
  236. if(stripos($number,'-') === false)
  237. {
  238. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  239. {
  240. $number = substr($number,0,12);
  241. }
  242. if(strlen($number) == '34')//联邦杭州超长运单截取
  243. {
  244. $str = substr($number, 0,3);
  245. if($str == "420"){
  246. $number = substr($number,12);
  247. }else{
  248. $number = substr($number,22,12);
  249. }
  250. }
  251. /**
  252. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  253. if(isset($ex[$sex['printcode']]))
  254. {
  255. if(strlen($number) != $ex[$sex['printcode']])
  256. {
  257. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  258. }
  259. }
  260. **/
  261. if(strlen($number) == 12 && $sex['printcode'] != 'FEDEX' && $sex['printcode'] != 'FEDEXGF')
  262. {
  263. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  264. }
  265. if(strlen($number) == 10 && $sex['printcode'] != 'DHL' && $sex['printcode'] != 'DHLUSA')
  266. {
  267. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  268. }
  269. if(strlen($number) == 18 && $sex['printcode'] != 'UPS' && $sex['printcode'] != 'YunExpress')
  270. {
  271. echo json_encode(array('msg'=>'运单号和快递类型不符!U'.$sex['printcode'],'success'=>false));exit;
  272. }
  273. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  274. if(isset($yd[0]['number']))
  275. {
  276. $number = $yd[0]['number'];
  277. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  278. {
  279. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  280. }
  281. }
  282. else
  283. {
  284. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  285. if(isset($yd[0]['number']))
  286. {
  287. $number = $yd[0]['number'];
  288. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  289. {
  290. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  291. }
  292. }
  293. else
  294. {
  295. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  296. if(isset($yd[0]['number']))
  297. {
  298. $number = $yd[0]['number'];
  299. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  300. {
  301. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  302. }
  303. }
  304. else
  305. {
  306. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  307. if(isset($yd[0]['number']))
  308. {
  309. $number = $yd[0]['number'];
  310. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  311. {
  312. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  313. }
  314. }
  315. else
  316. {
  317. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  318. if(isset($yd[0]['number']))
  319. {
  320. $number = $yd[0]['number'];
  321. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  322. {
  323. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  324. }
  325. }
  326. else
  327. {
  328. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. /**
  335. if($yd[0]['printtype'] != 1)
  336. {
  337. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  338. }
  339. **/
  340. $nu = $this->outbound->get_number($number);
  341. if($nu)
  342. {
  343. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  344. }
  345. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>time())))
  346. {
  347. $data = $this->outbound->find_count($where);
  348. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  349. }
  350. else
  351. {
  352. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  353. }
  354. }
  355. else
  356. {
  357. $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  358. if(isset($dd[0]['number']))
  359. {
  360. if($dd[0]['express'] != $express)
  361. {
  362. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  363. }
  364. }
  365. else
  366. {
  367. $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  368. if(isset($dd[0]['number']))
  369. {
  370. $number = $dd[0]['number'];
  371. if($dd[0]['express'] != $express)
  372. {
  373. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  374. }
  375. }
  376. else
  377. {
  378. $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  379. if(isset($dd[0]['number']))
  380. {
  381. $number = $dd[0]['number'];
  382. if($dd[0]['express'] != $express)
  383. {
  384. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  385. }
  386. }
  387. else
  388. {
  389. $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  390. if(isset($dd[0]['number']))
  391. {
  392. $number = $dd[0]['number'];
  393. if($dd[0]['express'] != $express)
  394. {
  395. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  396. }
  397. }
  398. else
  399. {
  400. $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  401. if(isset($dd[0]['number']))
  402. {
  403. $number = $dd[0]['number'];
  404. if($dd[0]['express'] != $express)
  405. {
  406. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  407. }
  408. }
  409. else
  410. {
  411. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. if($dd[0]['printtype'] != 2)
  418. {
  419. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  420. }
  421. $nu = $this->outbound->get_number($number);
  422. if($nu)
  423. {
  424. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  425. }
  426. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>time())))
  427. {
  428. $data = $this->outbound->find_count($where);
  429. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  430. }
  431. else
  432. {
  433. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  434. }
  435. }
  436. }
  437. }
  438. public function _outxxxxxx()
  439. {
  440. $post = $this->input->post(NULL, TRUE);
  441. if(isset($post['number']))
  442. {
  443. $where = "gtime = '".date('Ymd',time())."'";
  444. $number = $this->input->post('number',true);
  445. $id = $this->input->post('id',true);
  446. $type = $this->input->post('type',true);
  447. $express = $this->input->post('express',true);
  448. if($id)
  449. {
  450. if($type)
  451. {
  452. $where .= " and type = '$type'";
  453. }
  454. else
  455. {
  456. $uw = '';
  457. $u = $this->user->get_api($id);
  458. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  459. foreach ($u['warehouse'] as $v)
  460. {
  461. $uw .= " type = '$v' or";
  462. }
  463. $uw = rtrim($uw,'or');
  464. $uw = " and (".ltrim($uw,' ').")";
  465. $where .= $uw;
  466. }
  467. }
  468. if(!$number)
  469. {
  470. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  471. }
  472. if(!$type)
  473. {
  474. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  475. }
  476. if(!$express)
  477. {
  478. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  479. }
  480. $nu = $this->outbound->get_number($number);
  481. if($nu)
  482. {
  483. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  484. }
  485. $wa = $this->outbound->get_waybill($number);
  486. if($wa)
  487. {
  488. echo json_encode(array('msg'=>'错误!此运单号'.date('Ymd',$wa['time']).'已录入!','success'=>false));exit;
  489. }
  490. $jd = $this->outbound->find_all($where,'*','id desc');
  491. if(!isset($jd[0]) || $jd[0]['waybill'] != '')
  492. {
  493. $pd = explode('-',$number);
  494. if(!isset($pd[1]) || !isset($pd[2]))
  495. {
  496. echo json_encode(array('msg'=>'编号不正确,请重试!','success'=>false));exit;
  497. }
  498. if(strlen($pd[1]) == '5' && strlen($pd[2]) == '3')
  499. {
  500. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>time())))
  501. {
  502. $data = $this->outbound->find_count($where);
  503. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  504. }
  505. else
  506. {
  507. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  508. }
  509. }
  510. else
  511. {
  512. echo json_encode(array('msg'=>'编号不正确!','success'=>false));exit;
  513. }
  514. }
  515. else
  516. {
  517. if(stripos($number,'-') !== false)
  518. {
  519. echo json_encode(array('msg'=>'请扫描'.$jd[0]['number'].'对应的运单号!','success'=>false));exit;
  520. }
  521. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  522. {
  523. $number = substr($number,0,12);
  524. }
  525. if(strlen($number) == '34')//联邦杭州超长运单截取
  526. {
  527. $str = substr($number, 0,3);
  528. if($str == "420"){
  529. $number = substr($number,12);
  530. }else{
  531. $number = substr($number,22,12);
  532. }
  533. }
  534. $sex = $this->express->read($express);
  535. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  536. if(isset($ex[$sex['printcode']]))
  537. {
  538. if(strlen($number) != $ex[$sex['printcode']])
  539. {
  540. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  541. }
  542. }
  543. if($this->outbound->save(array('waybill'=>$number),$jd[0]['id']))
  544. {
  545. $data = $this->outbound->find_count($where);
  546. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  547. }
  548. else
  549. {
  550. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  551. }
  552. }
  553. }
  554. }
  555. public function _excel()
  556. {
  557. if(isset($_GET['fexcel']))
  558. {
  559. $timetk = $this->input->get('timetk',true);
  560. $timetj = $this->input->get('timetj',true);
  561. $library = $this->input->get('library',true);
  562. $type = $this->input->get('type',true);
  563. $number = $this->input->get('number',true);
  564. $waybill = $this->input->get('waybill',true);
  565. $express = $this->input->get('express',true);
  566. $timetk = strtotime($timetk);
  567. $timetj = strtotime($timetj);
  568. $where = "type != 0";
  569. if($timetk && $timetj)
  570. {
  571. $where .= " and time > '$timetk' and time < '$timetj'";
  572. }
  573. if(isset($_SESSION['api']))
  574. {
  575. if($type)
  576. {
  577. $where .= " and type = '$type'";
  578. }
  579. else
  580. {
  581. $uw = '';
  582. $u = $this->user->get_api($_SESSION['api']);
  583. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  584. foreach ($u['warehouse'] as $v)
  585. {
  586. $uw .= " type = '$v' or";
  587. }
  588. $uw = rtrim($uw,'or');
  589. $uw = " and (".ltrim($uw,' ').")";
  590. $where .= $uw;
  591. }
  592. }
  593. else
  594. {
  595. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  596. }
  597. if($number)
  598. {
  599. $where .= " and number = '$number'";
  600. }
  601. if($waybill)
  602. {
  603. $where .= " and waybill = '$waybill'";
  604. }
  605. if($express)
  606. {
  607. $where .= " and express = '$express'";
  608. }
  609. $data = array();
  610. $datafy = array();
  611. $j = 0;
  612. $info_list = $this->outbound->find_all($where,'number,waybill','time asc');
  613. foreach ($info_list as $key=>$value)
  614. {
  615. $datafy[] = array($value['number'],$value['waybill']);
  616. if($j == $library-1)
  617. {
  618. $data[] = $datafy;
  619. $j = 0;$datafy = array();
  620. }
  621. else
  622. {
  623. $j++;
  624. }
  625. }
  626. $data[] = $datafy;
  627. //格式化数据
  628. $i = 0;$cpexcel = array();
  629. $title = date('Ymd',time())."发货统计信息"; $td = '';
  630. for($i=0;$i<ceil(count($info_list)/$library);$i++)
  631. {
  632. $td .= "<td>组".($i+1)."</td><td></td>";
  633. }
  634. $titlename = "<table border=1>
  635. <tr>
  636. ".$td."
  637. </tr>
  638. </table>";
  639. $filename = $title.".xls";
  640. $this->excel->get_fz6($data,$titlename,$filename);
  641. }
  642. }
  643. //一件导出惠城的全部快递
  644. public function _excelhc()
  645. {
  646. if(isset($_GET['fexcel']))
  647. {
  648. $timetk = $this->input->get('timetk',true);
  649. $timetj = $this->input->get('timetj',true);
  650. $library = $this->input->get('library',true);
  651. $type = $this->input->get('type',true);
  652. $number = $this->input->get('number',true);
  653. $waybill = $this->input->get('waybill',true);
  654. $timetk = strtotime($timetk);
  655. $timetj = strtotime($timetj);
  656. $select_express = $this->input->get('select_express',true);
  657. if($select_express == 'ozyt'){
  658. //云途(欧洲) 云途(欧洲)-带保险
  659. $cx_arr = [66,67];//需要的查询数据
  660. $typename = "云途(欧洲)";
  661. }else{
  662. //GES 7 惠城联邦 50 惠城GES 51 惠城安迈世 51 惠城DHL 69 惠城usps 73
  663. $cx_arr = [7,50,51,52,69,73];//需要的查询数据
  664. $typename = "惠程";
  665. }
  666. $ex_list = $this->express->find_all("id in (".implode(',',$cx_arr).")","id,servicename");
  667. $where = "type != 0 and express in (".implode(',',$cx_arr).")";
  668. if($timetk && $timetj)
  669. {
  670. $where .= " and time > '$timetk' and time < '$timetj'";
  671. }
  672. if(isset($_SESSION['api']))
  673. {
  674. if($type)
  675. {
  676. $where .= " and type = '$type'";
  677. }
  678. else
  679. {
  680. $uw = '';
  681. $u = $this->user->get_api($_SESSION['api']);
  682. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  683. foreach ($u['warehouse'] as $v)
  684. {
  685. $uw .= " type = '$v' or";
  686. }
  687. $uw = rtrim($uw,'or');
  688. $uw = " and (".ltrim($uw,' ').")";
  689. $where .= $uw;
  690. }
  691. }
  692. else
  693. {
  694. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  695. }
  696. if($number)
  697. {
  698. $where .= " and number = '$number'";
  699. }
  700. if($waybill)
  701. {
  702. $where .= " and waybill = '$waybill'";
  703. }
  704. $data = array();
  705. $datafy = array();
  706. $j = 0;
  707. $info_list = $this->outbound->find_all($where,'number,waybill,express','time asc');
  708. $final_list= [
  709. ];
  710. foreach($cx_arr as $v){
  711. $final_list[$v] = [];
  712. }
  713. foreach ($info_list as $key=>$value)
  714. {
  715. if(isset($final_list[$value['express']])){
  716. $final_list[$value['express']][] = [
  717. $value['number'],
  718. $value['waybill'],
  719. ];
  720. }
  721. }
  722. $data[] = $datafy;
  723. //格式化数据
  724. $i = 0;$cpexcel = array();
  725. $title = date('Ymd',time()).$typename."发货统计信息"; $td = '';
  726. $td = "";
  727. $count = 0;
  728. foreach($ex_list as $v){
  729. $num = count($final_list[$v['id']]);
  730. if($num > $count){
  731. $count = $num;
  732. }
  733. $td .= "<td>".$v['servicename']."</td><td>".$num."</td>";
  734. }
  735. foreach($final_list as $k=>$v){
  736. for($i=0;$i < $count ;$i++){
  737. if(!isset($final_list[$k][$i])){
  738. $final_list[$k][$i] = [
  739. " "," "
  740. ];
  741. }
  742. }
  743. }
  744. $titlename = "<table border=1>
  745. <tr>
  746. ".$td."
  747. </tr>
  748. </table>";
  749. $filename = $title.".xls";
  750. $this->excel->get_fz6($final_list,$titlename,$filename);
  751. }
  752. }
  753. public function _add()
  754. {
  755. $post = $this->input->post(NULL, TRUE);
  756. if(isset($post['number']))
  757. {
  758. $where = "gtime = '".date('Ymd',time())."'";
  759. $number = $this->input->post('number',true);
  760. //$waybill = $this->input->post('waybill',true);
  761. $id = $this->input->post('id',true);
  762. $type = $this->input->post('type',true);
  763. $express = $this->input->post('express',true);
  764. $time = $this->input->post('time',true);
  765. if($time)
  766. {
  767. $time = strtotime($time);
  768. }
  769. else
  770. {
  771. $time = time();
  772. }
  773. if($id)
  774. {
  775. if($type)
  776. {
  777. $where .= " and type = '$type'";
  778. }
  779. else
  780. {
  781. $uw = '';
  782. $u = $this->user->get_api($id);
  783. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  784. foreach ($u['warehouse'] as $v)
  785. {
  786. $uw .= " type = '$v' or";
  787. }
  788. $uw = rtrim($uw,'or');
  789. $uw = " and (".ltrim($uw,' ').")";
  790. $where .= $uw;
  791. }
  792. }
  793. /**
  794. if(!$number)
  795. {
  796. echo json_encode(array('msg'=>'编号不能为空!','success'=>false));exit;
  797. }
  798. if(!$waybill)
  799. {
  800. //echo json_encode(array('msg'=>'运单号不能为空!','success'=>false));exit;
  801. }
  802. if(!$type)
  803. {
  804. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  805. }
  806. if(!$express)
  807. {
  808. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  809. }
  810. $nu = $this->outbound->get_number($number);
  811. if($nu)
  812. {
  813. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  814. }
  815. if($waybill)
  816. {
  817. $wa = $this->outbound->get_waybill($waybill);
  818. if($wa)
  819. {
  820. echo json_encode(array('msg'=>'错误!此运单号'.date('Ymd',$wa['time']).'已录入!','success'=>false));exit;
  821. }
  822. $sex = $this->express->read($express);
  823. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  824. if(isset($ex[$sex['printcode']]))
  825. {
  826. if(strlen($waybill) != $ex[$sex['printcode']])
  827. {
  828. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  829. }
  830. }
  831. }
  832. **/
  833. if(!$number)
  834. {
  835. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  836. }
  837. if(!$type)
  838. {
  839. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  840. }
  841. if(!$express)
  842. {
  843. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  844. }
  845. $sex = $this->express->read($express);
  846. if(stripos($number,'-') === false)
  847. {
  848. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  849. {
  850. $number = substr($number,0,12);
  851. }
  852. if(strlen($number) == '34')//联邦杭州超长运单截取
  853. {
  854. $str = substr($number, 0,3);
  855. if($str == "420"){
  856. $number = substr($number,12);
  857. }else{
  858. $number = substr($number,22,12);
  859. }
  860. }
  861. /**
  862. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  863. if(isset($ex[$sex['printcode']]))
  864. {
  865. if(strlen($number) != $ex[$sex['printcode']])
  866. {
  867. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  868. }
  869. }
  870. **/
  871. if(strlen($number) == 12 && $sex['printcode'] != 'FEDEX' && $sex['printcode'] != 'FEDEXGF' && $sex['printcode'] != 'HUALEI-MLXY' && $sex['printcode'] != 'FEDEX_G' && $sex['printcode'] != 'HUALEIXW-USPS' && $sex['printcode'] != 'FedEx_GD' )
  872. {
  873. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  874. }
  875. if(strlen($number) == 10 && $sex['printcode'] != 'DHL' && $sex['printcode'] != 'DHLUSA' && $sex['printcode'] != 'HUALEI-DHL')
  876. {
  877. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  878. }
  879. if(strlen($number) == 18 && $sex['printcode'] != 'UPS' && $sex['printcode'] != 'YunExpress' && $sex['printcode'] != 'YunExpress_BaoXian' && $sex['printcode'] != 'USKD01')
  880. {
  881. echo json_encode(array('msg'=>'运单号和快递类型不符!U'.$sex['printcode'],'success'=>false));exit;
  882. }
  883. if(strlen($number) == 16 && $sex['printcode'] != '3PE_XB')
  884. {
  885. echo json_encode(array('msg'=>'运单号和快递类型不符!PE'.$sex['printcode'],'success'=>false));exit;
  886. }
  887. $tmp_waybill = $number;
  888. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  889. if(isset($yd[0]['number']))
  890. {
  891. $number = $yd[0]['number'];
  892. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  893. {
  894. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  895. }
  896. }
  897. else
  898. {
  899. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  900. if(isset($yd[0]['number']))
  901. {
  902. $number = $yd[0]['number'];
  903. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  904. {
  905. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  906. }
  907. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  908. {
  909. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  910. }
  911. }
  912. else
  913. {
  914. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  915. if(isset($yd[0]['number']))
  916. {
  917. $number = $yd[0]['number'];
  918. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  919. {
  920. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  921. }
  922. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  923. {
  924. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  925. }
  926. }
  927. else
  928. {
  929. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  930. if(isset($yd[0]['number']))
  931. {
  932. $number = $yd[0]['number'];
  933. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  934. {
  935. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  936. }
  937. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  938. {
  939. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  940. }
  941. }
  942. else
  943. {
  944. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  945. if(isset($yd[0]['number']))
  946. {
  947. $number = $yd[0]['number'];
  948. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  949. {
  950. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  951. }
  952. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  953. {
  954. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  955. }
  956. }
  957. else
  958. {
  959. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  960. }
  961. }
  962. }
  963. }
  964. }
  965. /**
  966. if($yd[0]['printtype'] != 1)
  967. {
  968. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  969. }
  970. **/
  971. $nu = $this->outbound->get_number($number);
  972. if($nu)
  973. {
  974. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  975. }
  976. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$tmp_waybill,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>$time)))
  977. {
  978. $data = $this->outbound->find_count($where);
  979. echo json_encode(array('msg'=>'提交成功,数量:'.$data,'music'=>'1','success'=>true));exit;
  980. }
  981. else
  982. {
  983. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  984. }
  985. }
  986. else
  987. {
  988. $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  989. if(isset($dd[0]['number']))
  990. {
  991. if($dd[0]['express'] != $express)
  992. {
  993. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  994. }
  995. }
  996. else
  997. {
  998. $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  999. if(isset($dd[0]['number']))
  1000. {
  1001. $number = $dd[0]['number'];
  1002. if($dd[0]['express'] != $express)
  1003. {
  1004. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1005. }
  1006. }
  1007. else
  1008. {
  1009. $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1010. if(isset($dd[0]['number']))
  1011. {
  1012. $number = $dd[0]['number'];
  1013. if($dd[0]['express'] != $express)
  1014. {
  1015. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1016. }
  1017. }
  1018. else
  1019. {
  1020. $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1021. if(isset($dd[0]['number']))
  1022. {
  1023. $number = $dd[0]['number'];
  1024. if($dd[0]['express'] != $express)
  1025. {
  1026. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1027. }
  1028. }
  1029. else
  1030. {
  1031. $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1032. if(isset($dd[0]['number']))
  1033. {
  1034. $number = $dd[0]['number'];
  1035. if($dd[0]['express'] != $express)
  1036. {
  1037. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1038. }
  1039. }
  1040. else
  1041. {
  1042. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. $tmp_waybill = "";
  1049. if(isset($dd[0]['waybill'])){
  1050. $tmp_waybill= $dd[0]['waybill'];
  1051. }
  1052. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,69,73])))
  1053. {
  1054. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  1055. }
  1056. $nu = $this->outbound->get_number($number);
  1057. if($nu)
  1058. {
  1059. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1060. }
  1061. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$tmp_waybill,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>$time)))
  1062. {
  1063. $data = $this->outbound->find_count($where);
  1064. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  1065. }
  1066. else
  1067. {
  1068. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1069. }
  1070. }
  1071. /**
  1072. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$waybill,'express'=>$express,'gtime'=>date('Ymd',$time),'time'=>$time+1)))
  1073. {
  1074. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  1075. }
  1076. **/
  1077. }
  1078. }
  1079. public function _del()
  1080. {
  1081. $post = $this->input->post(NULL, TRUE);
  1082. if(isset($post['delarr']))
  1083. {
  1084. $id_arr = $this->input->post('delarr');
  1085. $id_arr = explode(',',rtrim($id_arr,','));
  1086. if(!$id_arr)
  1087. {
  1088. echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;
  1089. }
  1090. //循环删除记录
  1091. $a=0;
  1092. foreach ($id_arr as $v)
  1093. {
  1094. if($this->outbound->remove($v))
  1095. {
  1096. $a++;
  1097. }
  1098. }
  1099. if($a == count($id_arr))
  1100. {
  1101. $data = $this->outbound->find_count("gtime = '".date('Ymd',time())."'");
  1102. echo json_encode(array('del'=>$id_arr,'data'=>$data,'msg'=>'删除成功!','success'=>true));
  1103. }
  1104. else
  1105. {
  1106. echo json_encode(array('del'=>$id_arr,'msg'=>'部分记录删除失败,请查询确认!','success'=>true));
  1107. }
  1108. }
  1109. }
  1110. public function _ex()
  1111. {
  1112. }
  1113. public function _out()
  1114. {
  1115. $post = $this->input->post(NULL, TRUE);
  1116. if(isset($post['number']))
  1117. {
  1118. $where = "gtime = '".date('Ymd',time())."'";
  1119. $number = $this->input->post('number',true);
  1120. $type = $this->input->post('type',true);
  1121. $express = $this->input->post('express',true);
  1122. if($_SESSION['api'])
  1123. {
  1124. if($type)
  1125. {
  1126. $where .= " and type = '$type'";
  1127. }
  1128. else
  1129. {
  1130. $uw = '';
  1131. $u = $this->user->get_api($_SESSION['api']);
  1132. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1133. foreach ($u['warehouse'] as $v)
  1134. {
  1135. $uw .= " type = '$v' or";
  1136. }
  1137. $uw = rtrim($uw,'or');
  1138. $uw = " and (".ltrim($uw,' ').")";
  1139. $where .= $uw;
  1140. }
  1141. }
  1142. if(!$number)
  1143. {
  1144. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1145. }
  1146. if(!$type)
  1147. {
  1148. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  1149. }
  1150. if(!$express)
  1151. {
  1152. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  1153. }
  1154. $sex = $this->express->read($express);
  1155. if(stripos($number,'-') === false)
  1156. {
  1157. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  1158. {
  1159. $number = substr($number,0,12);
  1160. }
  1161. if(strlen($number) == '34')//联邦杭州超长运单截取
  1162. {
  1163. //$number = substr($number,22,12);
  1164. $str = substr($number, 0,3);
  1165. if($str == "420"){
  1166. $number = substr($number,12);
  1167. }else{
  1168. $number = substr($number,22,12);
  1169. }
  1170. }
  1171. /**
  1172. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  1173. if(isset($ex[$sex['printcode']]))
  1174. {
  1175. if(strlen($number) != $ex[$sex['printcode']])
  1176. {
  1177. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  1178. }
  1179. }
  1180. **/
  1181. if(strlen($number) == 12 && $sex['printcode'] != 'FEDEX' && $sex['printcode'] != 'FEDEXGF' && $sex['printcode'] != 'HUALEI-MLXY' && $sex['printcode'] != 'FEDEX_G' && $sex['printcode'] != 'HUALEIXW-USPS' && $sex['printcode'] != 'FedEx_GD' && $sex['printcode'] != 'HUALEI-GES-EU' && $sex['printcode'] != 'ZXDPD_UK' && $sex['printcode'] != 'ZXDPD_EU')
  1182. {
  1183. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  1184. }
  1185. if(strlen($number) == 10 && $sex['printcode'] != 'DHL' && $sex['printcode'] != 'DHLUSA' && $sex['printcode'] != 'HUALEI-DHL' && $sex['printcode'] != 'ZXDPD_UK' && $sex['printcode'] != 'ZXDPD_EU')
  1186. {
  1187. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  1188. }
  1189. if(strlen($number) == 18 && $sex['printcode'] != 'UPS' && $sex['printcode'] != 'YunExpress' && $sex['printcode'] != 'YunExpress_BaoXian' && $sex['printcode'] != 'USKD01')
  1190. {
  1191. echo json_encode(array('msg'=>'运单号和快递类型不符!U'.$sex['printcode'],'success'=>false));exit;
  1192. }
  1193. if(strlen($number) == 16 && $sex['printcode'] != '3PE_XB')
  1194. {
  1195. echo json_encode(array('msg'=>'运单号和快递类型不符!PE'.$sex['printcode'],'success'=>false));exit;
  1196. }
  1197. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1198. if(isset($yd[0]['number']))
  1199. {
  1200. $number = $yd[0]['number'];
  1201. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1202. {
  1203. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1204. }
  1205. }
  1206. else
  1207. {
  1208. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1209. if(isset($yd[0]['number']))
  1210. {
  1211. $number = $yd[0]['number'];
  1212. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1213. {
  1214. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1215. }
  1216. }
  1217. else
  1218. {
  1219. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1220. if(isset($yd[0]['number']))
  1221. {
  1222. $number = $yd[0]['number'];
  1223. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1224. {
  1225. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1226. }
  1227. }
  1228. else
  1229. {
  1230. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1231. if(isset($yd[0]['number']))
  1232. {
  1233. $number = $yd[0]['number'];
  1234. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1235. {
  1236. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1237. }
  1238. }
  1239. else
  1240. {
  1241. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1242. if(isset($yd[0]['number']))
  1243. {
  1244. $number = $yd[0]['number'];
  1245. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1246. {
  1247. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1248. }
  1249. }
  1250. else
  1251. {
  1252. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  1253. }
  1254. }
  1255. }
  1256. }
  1257. }
  1258. /**
  1259. if($yd[0]['printtype'] != 1)
  1260. {
  1261. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  1262. }
  1263. **/
  1264. //再次判断下杭州不报关的类别是否满足条件 如果有影响可以删除
  1265. if($yd[0]['express'] != $express){
  1266. echo json_encode(array('msg'=>'录入信息和选择快递不一致!2','success'=>false));exit;
  1267. }
  1268. $nu = $this->outbound->get_number($number);
  1269. if($nu)
  1270. {
  1271. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1272. }
  1273. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$yd[0]['waybill'],'express'=>$yd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  1274. {
  1275. $data = $this->outbound->find_count($where);
  1276. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  1277. }
  1278. else
  1279. {
  1280. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1281. }
  1282. }
  1283. else
  1284. {
  1285. $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1286. if(isset($dd[0]['number']))
  1287. {
  1288. if($dd[0]['express'] != $express)
  1289. {
  1290. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1291. }
  1292. }
  1293. else
  1294. {
  1295. $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1296. if(isset($dd[0]['number']))
  1297. {
  1298. $number = $dd[0]['number'];
  1299. if($dd[0]['express'] != $express)
  1300. {
  1301. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1302. }
  1303. }
  1304. else
  1305. {
  1306. $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1307. if(isset($dd[0]['number']))
  1308. {
  1309. $number = $dd[0]['number'];
  1310. if($dd[0]['express'] != $express)
  1311. {
  1312. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1313. }
  1314. }
  1315. else
  1316. {
  1317. $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1318. if(isset($dd[0]['number']))
  1319. {
  1320. $number = $dd[0]['number'];
  1321. if($dd[0]['express'] != $express)
  1322. {
  1323. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1324. }
  1325. }
  1326. else
  1327. {
  1328. $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1329. if(isset($dd[0]['number']))
  1330. {
  1331. $number = $dd[0]['number'];
  1332. if($dd[0]['express'] != $express)
  1333. {
  1334. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1335. }
  1336. }
  1337. else
  1338. {
  1339. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1340. }
  1341. }
  1342. }
  1343. }
  1344. }
  1345. //惠程-美国USPS 惠程-联邦 惠程-安迈世 惠程-DHL 惠程-GES(欧盟)
  1346. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,69,73,75])))
  1347. {
  1348. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  1349. }
  1350. //判断该订单的快递单号是否存在 如果不存在提示 补齐快递单号 在进行扫描
  1351. // if(empty($dd[0]['waybill'])){
  1352. // echo json_encode(array('msg'=>'该订单未检索到快递信息,请补齐快递单号!','success'=>false));exit;
  1353. // }
  1354. $nu = $this->outbound->get_number($number);
  1355. if($nu)
  1356. {
  1357. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1358. }
  1359. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$dd[0]['waybill'],'express'=>$dd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  1360. {
  1361. $data = $this->outbound->find_count($where);
  1362. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  1363. }
  1364. else
  1365. {
  1366. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1367. }
  1368. }
  1369. }
  1370. }
  1371. }