Systembound.php 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  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. $cx_arr = [7,50,51,52,69,73];//需要的查询数据
  657. $ex_list = $this->express->find_all("id in (".implode(',',$cx_arr).")","id,servicename");
  658. //GES 7 惠城联邦 50 惠城GES 51 惠城安迈世 51 惠城DHL 69 惠城usps 73
  659. $where = "type != 0 and express in (".implode(',',$cx_arr).")";
  660. if($timetk && $timetj)
  661. {
  662. $where .= " and time > '$timetk' and time < '$timetj'";
  663. }
  664. if(isset($_SESSION['api']))
  665. {
  666. if($type)
  667. {
  668. $where .= " and type = '$type'";
  669. }
  670. else
  671. {
  672. $uw = '';
  673. $u = $this->user->get_api($_SESSION['api']);
  674. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  675. foreach ($u['warehouse'] as $v)
  676. {
  677. $uw .= " type = '$v' or";
  678. }
  679. $uw = rtrim($uw,'or');
  680. $uw = " and (".ltrim($uw,' ').")";
  681. $where .= $uw;
  682. }
  683. }
  684. else
  685. {
  686. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  687. }
  688. if($number)
  689. {
  690. $where .= " and number = '$number'";
  691. }
  692. if($waybill)
  693. {
  694. $where .= " and waybill = '$waybill'";
  695. }
  696. $data = array();
  697. $datafy = array();
  698. $j = 0;
  699. $info_list = $this->outbound->find_all($where,'number,waybill,express','time asc');
  700. $final_list= [
  701. ];
  702. foreach($cx_arr as $v){
  703. $final_list[$v] = [];
  704. }
  705. foreach ($info_list as $key=>$value)
  706. {
  707. if(isset($final_list[$value['express']])){
  708. $final_list[$value['express']][] = [
  709. $value['number'],
  710. $value['waybill'],
  711. ];
  712. }
  713. }
  714. $data[] = $datafy;
  715. //格式化数据
  716. $i = 0;$cpexcel = array();
  717. $title = date('Ymd',time())."惠程发货统计信息"; $td = '';
  718. $td = "";
  719. $count = 0;
  720. foreach($ex_list as $v){
  721. $num = count($final_list[$v['id']]);
  722. if($num > $count){
  723. $count = $num;
  724. }
  725. $td .= "<td>".$v['servicename']."</td><td>".$num."</td>";
  726. }
  727. foreach($final_list as $k=>$v){
  728. for($i=0;$i < $count ;$i++){
  729. if(!isset($final_list[$k][$i])){
  730. $final_list[$k][$i] = [
  731. " "," "
  732. ];
  733. }
  734. }
  735. }
  736. $titlename = "<table border=1>
  737. <tr>
  738. ".$td."
  739. </tr>
  740. </table>";
  741. $filename = $title.".xls";
  742. $this->excel->get_fz6($final_list,$titlename,$filename);
  743. }
  744. }
  745. public function _add()
  746. {
  747. $post = $this->input->post(NULL, TRUE);
  748. if(isset($post['number']))
  749. {
  750. $where = "gtime = '".date('Ymd',time())."'";
  751. $number = $this->input->post('number',true);
  752. //$waybill = $this->input->post('waybill',true);
  753. $id = $this->input->post('id',true);
  754. $type = $this->input->post('type',true);
  755. $express = $this->input->post('express',true);
  756. $time = $this->input->post('time',true);
  757. if($time)
  758. {
  759. $time = strtotime($time);
  760. }
  761. else
  762. {
  763. $time = time();
  764. }
  765. if($id)
  766. {
  767. if($type)
  768. {
  769. $where .= " and type = '$type'";
  770. }
  771. else
  772. {
  773. $uw = '';
  774. $u = $this->user->get_api($id);
  775. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  776. foreach ($u['warehouse'] as $v)
  777. {
  778. $uw .= " type = '$v' or";
  779. }
  780. $uw = rtrim($uw,'or');
  781. $uw = " and (".ltrim($uw,' ').")";
  782. $where .= $uw;
  783. }
  784. }
  785. /**
  786. if(!$number)
  787. {
  788. echo json_encode(array('msg'=>'编号不能为空!','success'=>false));exit;
  789. }
  790. if(!$waybill)
  791. {
  792. //echo json_encode(array('msg'=>'运单号不能为空!','success'=>false));exit;
  793. }
  794. if(!$type)
  795. {
  796. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  797. }
  798. if(!$express)
  799. {
  800. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  801. }
  802. $nu = $this->outbound->get_number($number);
  803. if($nu)
  804. {
  805. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  806. }
  807. if($waybill)
  808. {
  809. $wa = $this->outbound->get_waybill($waybill);
  810. if($wa)
  811. {
  812. echo json_encode(array('msg'=>'错误!此运单号'.date('Ymd',$wa['time']).'已录入!','success'=>false));exit;
  813. }
  814. $sex = $this->express->read($express);
  815. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  816. if(isset($ex[$sex['printcode']]))
  817. {
  818. if(strlen($waybill) != $ex[$sex['printcode']])
  819. {
  820. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  821. }
  822. }
  823. }
  824. **/
  825. if(!$number)
  826. {
  827. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  828. }
  829. if(!$type)
  830. {
  831. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  832. }
  833. if(!$express)
  834. {
  835. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  836. }
  837. $sex = $this->express->read($express);
  838. if(stripos($number,'-') === false)
  839. {
  840. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  841. {
  842. $number = substr($number,0,12);
  843. }
  844. if(strlen($number) == '34')//联邦杭州超长运单截取
  845. {
  846. $str = substr($number, 0,3);
  847. if($str == "420"){
  848. $number = substr($number,12);
  849. }else{
  850. $number = substr($number,22,12);
  851. }
  852. }
  853. /**
  854. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  855. if(isset($ex[$sex['printcode']]))
  856. {
  857. if(strlen($number) != $ex[$sex['printcode']])
  858. {
  859. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  860. }
  861. }
  862. **/
  863. 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' )
  864. {
  865. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  866. }
  867. if(strlen($number) == 10 && $sex['printcode'] != 'DHL' && $sex['printcode'] != 'DHLUSA')
  868. {
  869. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  870. }
  871. if(strlen($number) == 18 && $sex['printcode'] != 'UPS')
  872. {
  873. echo json_encode(array('msg'=>'运单号和快递类型不符!U','success'=>false));exit;
  874. }
  875. $tmp_waybill = $number;
  876. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  877. if(isset($yd[0]['number']))
  878. {
  879. $number = $yd[0]['number'];
  880. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  881. {
  882. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  883. }
  884. }
  885. else
  886. {
  887. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  888. if(isset($yd[0]['number']))
  889. {
  890. $number = $yd[0]['number'];
  891. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  892. {
  893. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  894. }
  895. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  896. {
  897. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  898. }
  899. }
  900. else
  901. {
  902. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  903. if(isset($yd[0]['number']))
  904. {
  905. $number = $yd[0]['number'];
  906. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  907. {
  908. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  909. }
  910. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  911. {
  912. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  913. }
  914. }
  915. else
  916. {
  917. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  918. if(isset($yd[0]['number']))
  919. {
  920. $number = $yd[0]['number'];
  921. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  922. {
  923. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  924. }
  925. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  926. {
  927. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  928. }
  929. }
  930. else
  931. {
  932. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  933. if(isset($yd[0]['number']))
  934. {
  935. $number = $yd[0]['number'];
  936. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  937. {
  938. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  939. }
  940. if($yd[0]['express'] != 24 && $yd[0]['express'] == 31)
  941. {
  942. echo json_encode(array('msg'=>'请选择杭州联邦快递方式录入','success'=>false));exit;
  943. }
  944. }
  945. else
  946. {
  947. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  948. }
  949. }
  950. }
  951. }
  952. }
  953. /**
  954. if($yd[0]['printtype'] != 1)
  955. {
  956. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  957. }
  958. **/
  959. $nu = $this->outbound->get_number($number);
  960. if($nu)
  961. {
  962. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  963. }
  964. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$tmp_waybill,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>$time)))
  965. {
  966. $data = $this->outbound->find_count($where);
  967. echo json_encode(array('msg'=>'提交成功,数量:'.$data,'music'=>'1','success'=>true));exit;
  968. }
  969. else
  970. {
  971. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  972. }
  973. }
  974. else
  975. {
  976. $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  977. if(isset($dd[0]['number']))
  978. {
  979. if($dd[0]['express'] != $express)
  980. {
  981. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  982. }
  983. }
  984. else
  985. {
  986. $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  987. if(isset($dd[0]['number']))
  988. {
  989. $number = $dd[0]['number'];
  990. if($dd[0]['express'] != $express)
  991. {
  992. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  993. }
  994. }
  995. else
  996. {
  997. $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  998. if(isset($dd[0]['number']))
  999. {
  1000. $number = $dd[0]['number'];
  1001. if($dd[0]['express'] != $express)
  1002. {
  1003. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1004. }
  1005. }
  1006. else
  1007. {
  1008. $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1009. if(isset($dd[0]['number']))
  1010. {
  1011. $number = $dd[0]['number'];
  1012. if($dd[0]['express'] != $express)
  1013. {
  1014. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1015. }
  1016. }
  1017. else
  1018. {
  1019. $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1020. if(isset($dd[0]['number']))
  1021. {
  1022. $number = $dd[0]['number'];
  1023. if($dd[0]['express'] != $express)
  1024. {
  1025. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1026. }
  1027. }
  1028. else
  1029. {
  1030. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. }
  1036. $tmp_waybill = "";
  1037. if(isset($dd[0]['waybill'])){
  1038. $tmp_waybill= $dd[0]['waybill'];
  1039. }
  1040. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,69,73])))
  1041. {
  1042. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  1043. }
  1044. $nu = $this->outbound->get_number($number);
  1045. if($nu)
  1046. {
  1047. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1048. }
  1049. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$tmp_waybill,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>$time)))
  1050. {
  1051. $data = $this->outbound->find_count($where);
  1052. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  1053. }
  1054. else
  1055. {
  1056. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1057. }
  1058. }
  1059. /**
  1060. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$waybill,'express'=>$express,'gtime'=>date('Ymd',$time),'time'=>$time+1)))
  1061. {
  1062. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  1063. }
  1064. **/
  1065. }
  1066. }
  1067. public function _del()
  1068. {
  1069. $post = $this->input->post(NULL, TRUE);
  1070. if(isset($post['delarr']))
  1071. {
  1072. $id_arr = $this->input->post('delarr');
  1073. $id_arr = explode(',',rtrim($id_arr,','));
  1074. if(!$id_arr)
  1075. {
  1076. echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;
  1077. }
  1078. //循环删除记录
  1079. $a=0;
  1080. foreach ($id_arr as $v)
  1081. {
  1082. if($this->outbound->remove($v))
  1083. {
  1084. $a++;
  1085. }
  1086. }
  1087. if($a == count($id_arr))
  1088. {
  1089. $data = $this->outbound->find_count("gtime = '".date('Ymd',time())."'");
  1090. echo json_encode(array('del'=>$id_arr,'data'=>$data,'msg'=>'删除成功!','success'=>true));
  1091. }
  1092. else
  1093. {
  1094. echo json_encode(array('del'=>$id_arr,'msg'=>'部分记录删除失败,请查询确认!','success'=>true));
  1095. }
  1096. }
  1097. }
  1098. public function _ex()
  1099. {
  1100. }
  1101. public function _out()
  1102. {
  1103. $post = $this->input->post(NULL, TRUE);
  1104. if(isset($post['number']))
  1105. {
  1106. $where = "gtime = '".date('Ymd',time())."'";
  1107. $number = $this->input->post('number',true);
  1108. $type = $this->input->post('type',true);
  1109. $express = $this->input->post('express',true);
  1110. if($_SESSION['api'])
  1111. {
  1112. if($type)
  1113. {
  1114. $where .= " and type = '$type'";
  1115. }
  1116. else
  1117. {
  1118. $uw = '';
  1119. $u = $this->user->get_api($_SESSION['api']);
  1120. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1121. foreach ($u['warehouse'] as $v)
  1122. {
  1123. $uw .= " type = '$v' or";
  1124. }
  1125. $uw = rtrim($uw,'or');
  1126. $uw = " and (".ltrim($uw,' ').")";
  1127. $where .= $uw;
  1128. }
  1129. }
  1130. if(!$number)
  1131. {
  1132. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1133. }
  1134. if(!$type)
  1135. {
  1136. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  1137. }
  1138. if(!$express)
  1139. {
  1140. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  1141. }
  1142. $sex = $this->express->read($express);
  1143. if(stripos($number,'-') === false)
  1144. {
  1145. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  1146. {
  1147. $number = substr($number,0,12);
  1148. }
  1149. if(strlen($number) == '34')//联邦杭州超长运单截取
  1150. {
  1151. //$number = substr($number,22,12);
  1152. $str = substr($number, 0,3);
  1153. if($str == "420"){
  1154. $number = substr($number,12);
  1155. }else{
  1156. $number = substr($number,22,12);
  1157. }
  1158. }
  1159. /**
  1160. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  1161. if(isset($ex[$sex['printcode']]))
  1162. {
  1163. if(strlen($number) != $ex[$sex['printcode']])
  1164. {
  1165. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  1166. }
  1167. }
  1168. **/
  1169. 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' )
  1170. {
  1171. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  1172. }
  1173. if(strlen($number) == 10 && $sex['printcode'] != 'DHL' && $sex['printcode'] != 'DHLUSA' && $sex['printcode'] != 'HUALEI-DHL')
  1174. {
  1175. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  1176. }
  1177. if(strlen($number) == 18 && $sex['printcode'] != 'UPS' && $sex['printcode'] != 'YunExpress' && $sex['printcode'] != 'YunExpress_BaoXian' && $sex['printcode'] != 'USKD01')
  1178. {
  1179. echo json_encode(array('msg'=>'运单号和快递类型不符!U'.$sex['printcode'],'success'=>false));exit;
  1180. }
  1181. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1182. if(isset($yd[0]['number']))
  1183. {
  1184. $number = $yd[0]['number'];
  1185. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1186. {
  1187. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1188. }
  1189. }
  1190. else
  1191. {
  1192. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1193. if(isset($yd[0]['number']))
  1194. {
  1195. $number = $yd[0]['number'];
  1196. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1197. {
  1198. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1199. }
  1200. }
  1201. else
  1202. {
  1203. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1204. if(isset($yd[0]['number']))
  1205. {
  1206. $number = $yd[0]['number'];
  1207. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1208. {
  1209. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1210. }
  1211. }
  1212. else
  1213. {
  1214. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1215. if(isset($yd[0]['number']))
  1216. {
  1217. $number = $yd[0]['number'];
  1218. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1219. {
  1220. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1221. }
  1222. }
  1223. else
  1224. {
  1225. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1226. if(isset($yd[0]['number']))
  1227. {
  1228. $number = $yd[0]['number'];
  1229. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  1230. {
  1231. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1232. }
  1233. }
  1234. else
  1235. {
  1236. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. }
  1242. /**
  1243. if($yd[0]['printtype'] != 1)
  1244. {
  1245. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  1246. }
  1247. **/
  1248. //再次判断下杭州不报关的类别是否满足条件 如果有影响可以删除
  1249. if($yd[0]['express'] != $express){
  1250. echo json_encode(array('msg'=>'录入信息和选择快递不一致!2','success'=>false));exit;
  1251. }
  1252. $nu = $this->outbound->get_number($number);
  1253. if($nu)
  1254. {
  1255. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1256. }
  1257. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$yd[0]['waybill'],'express'=>$yd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  1258. {
  1259. $data = $this->outbound->find_count($where);
  1260. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  1261. }
  1262. else
  1263. {
  1264. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1265. }
  1266. }
  1267. else
  1268. {
  1269. $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1270. if(isset($dd[0]['number']))
  1271. {
  1272. if($dd[0]['express'] != $express)
  1273. {
  1274. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1275. }
  1276. }
  1277. else
  1278. {
  1279. $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1280. if(isset($dd[0]['number']))
  1281. {
  1282. $number = $dd[0]['number'];
  1283. if($dd[0]['express'] != $express)
  1284. {
  1285. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1286. }
  1287. }
  1288. else
  1289. {
  1290. $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1291. if(isset($dd[0]['number']))
  1292. {
  1293. $number = $dd[0]['number'];
  1294. if($dd[0]['express'] != $express)
  1295. {
  1296. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1297. }
  1298. }
  1299. else
  1300. {
  1301. $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1302. if(isset($dd[0]['number']))
  1303. {
  1304. $number = $dd[0]['number'];
  1305. if($dd[0]['express'] != $express)
  1306. {
  1307. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1308. }
  1309. }
  1310. else
  1311. {
  1312. $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1313. if(isset($dd[0]['number']))
  1314. {
  1315. $number = $dd[0]['number'];
  1316. if($dd[0]['express'] != $express)
  1317. {
  1318. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1319. }
  1320. }
  1321. else
  1322. {
  1323. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1324. }
  1325. }
  1326. }
  1327. }
  1328. }
  1329. //惠程-美国USPS 惠程-联邦 惠程-安迈世 惠程-DHL 惠程-GES(欧盟)
  1330. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,69,73])))
  1331. {
  1332. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  1333. }
  1334. //判断该订单的快递单号是否存在 如果不存在提示 补齐快递单号 在进行扫描
  1335. // if(empty($dd[0]['waybill'])){
  1336. // echo json_encode(array('msg'=>'该订单未检索到快递信息,请补齐快递单号!','success'=>false));exit;
  1337. // }
  1338. $nu = $this->outbound->get_number($number);
  1339. if($nu)
  1340. {
  1341. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1342. }
  1343. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$dd[0]['waybill'],'express'=>$dd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  1344. {
  1345. $data = $this->outbound->find_count($where);
  1346. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  1347. }
  1348. else
  1349. {
  1350. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1351. }
  1352. }
  1353. }
  1354. }
  1355. }