Systembound.php 42 KB

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