Systembound.php 45 KB

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