Systembound.php 45 KB

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