Systembound.php 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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,92];
  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,93];//需要的查询数据
  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' && $sex['printcode'] != 'HUALEI-FEDEX-9610' && $sex['printcode'] != 'HUALEI-FEDEX-BBG' && $sex['printcode'] != 'HUALEI-WMS')
  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. $info = $this->logic_order->getInfo("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  743. $dd = [];
  744. $dd[] = $info;
  745. if(isset($dd[0]['number'])){
  746. if($dd[0]['express'] != $express)
  747. {
  748. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  749. }
  750. }else{
  751. $tmp_number_arr = explode('-',$number);
  752. array_pop($tmp_number_arr);
  753. $number = implode("-",$tmp_number_arr);
  754. $info = $this->logic_order->getInfo("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  755. $dd = [];
  756. $dd[] = $info;
  757. if(isset($dd[0]['number'])){
  758. if($dd[0]['express'] != $express)
  759. {
  760. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  761. }
  762. }else{
  763. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  764. }
  765. }
  766. $tmp_waybill = "";
  767. if(isset($dd[0]['waybill'])){
  768. $tmp_waybill= $dd[0]['waybill'];
  769. }
  770. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,54,69,73,75,91,93])))
  771. {
  772. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  773. }
  774. $nu = $this->outbound->get_number($number);
  775. if($nu)
  776. {
  777. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  778. }
  779. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$tmp_waybill,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>$time)))
  780. {
  781. $data = $this->outbound->find_count($where);
  782. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  783. }
  784. else
  785. {
  786. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  787. }
  788. }
  789. /**
  790. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$waybill,'express'=>$express,'gtime'=>date('Ymd',$time),'time'=>$time+1)))
  791. {
  792. echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
  793. }
  794. **/
  795. }
  796. }
  797. public function _del()
  798. {
  799. $post = $this->input->post(NULL, TRUE);
  800. if(isset($post['delarr']))
  801. {
  802. $id_arr = $this->input->post('delarr');
  803. $id_arr = explode(',',rtrim($id_arr,','));
  804. if(!$id_arr)
  805. {
  806. echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;
  807. }
  808. //循环删除记录
  809. $a=0;
  810. foreach ($id_arr as $v)
  811. {
  812. if($this->outbound->remove($v))
  813. {
  814. $a++;
  815. }
  816. }
  817. if($a == count($id_arr))
  818. {
  819. $data = $this->outbound->find_count("gtime = '".date('Ymd',time())."'");
  820. echo json_encode(array('del'=>$id_arr,'data'=>$data,'msg'=>'删除成功!','success'=>true));
  821. }
  822. else
  823. {
  824. echo json_encode(array('del'=>$id_arr,'msg'=>'部分记录删除失败,请查询确认!','success'=>true));
  825. }
  826. }
  827. }
  828. public function _ex()
  829. {
  830. }
  831. public function _out()
  832. {
  833. $post = $this->input->post(NULL, TRUE);
  834. if(isset($post['number']))
  835. {
  836. $where = "gtime = '".date('Ymd',time())."'";
  837. $number = $this->input->post('number',true);
  838. $type = $this->input->post('type',true);
  839. $express = $this->input->post('express',true);
  840. if($_SESSION['api'])
  841. {
  842. if($type)
  843. {
  844. $where .= " and type = '$type'";
  845. }
  846. else
  847. {
  848. $uw = '';
  849. $u = $this->user->get_api($_SESSION['api']);
  850. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  851. foreach ($u['warehouse'] as $v)
  852. {
  853. $uw .= " type = '$v' or";
  854. }
  855. $uw = rtrim($uw,'or');
  856. $uw = " and (".ltrim($uw,' ').")";
  857. $where .= $uw;
  858. }
  859. }
  860. if(!$number)
  861. {
  862. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  863. }
  864. if(!$type)
  865. {
  866. echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
  867. }
  868. if(!$express)
  869. {
  870. echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
  871. }
  872. $sex = $this->express->read($express);
  873. if(stripos($number,'-') === false)
  874. {
  875. if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
  876. {
  877. $number = substr($number,0,12);
  878. }
  879. if(strlen($number) == '34')//联邦杭州超长运单截取
  880. {
  881. //$number = substr($number,22,12);
  882. $str = substr($number, 0,3);
  883. if($str == "420"){
  884. $number = substr($number,12);
  885. }else{
  886. $number = substr($number,22,12);
  887. }
  888. }
  889. /**
  890. $ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
  891. if(isset($ex[$sex['printcode']]))
  892. {
  893. if(strlen($number) != $ex[$sex['printcode']])
  894. {
  895. echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
  896. }
  897. }
  898. **/
  899. 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' && $sex['printcode'] != 'HUALEI-FEDEX-9610' && $sex['printcode'] != 'HUALEI-FEDEX-BBG' && $sex['printcode'] != 'HUALEI-WMS')
  900. {
  901. echo json_encode(array('msg'=>'运单号和快递类型不符!F','success'=>false));exit;
  902. }
  903. 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')
  904. {
  905. echo json_encode(array('msg'=>'运单号和快递类型不符!D','success'=>false));exit;
  906. }
  907. 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')
  908. {
  909. echo json_encode(array('msg'=>'运单号和快递类型不符!U'.$sex['printcode'],'success'=>false));exit;
  910. }
  911. 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')
  912. {
  913. echo json_encode(array('msg'=>'运单号和快递类型不符!PE'.$sex['printcode'],'success'=>false));exit;
  914. }
  915. // $r = $this->logic_express->ydCheckByPrintcode($number,$sex['printcode']);
  916. // if(!$r){
  917. // echo json_encode(array('msg'=>'运单号和快递类型不符-'.$sex['printcode'],'success'=>false));exit;
  918. // }
  919. $yd = $this->fullorder->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  920. if(isset($yd[0]['number']))
  921. {
  922. $number = $yd[0]['number'];
  923. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  924. {
  925. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  926. }
  927. }
  928. else
  929. {
  930. $yd = $this->fullordersmt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  931. if(isset($yd[0]['number']))
  932. {
  933. $number = $yd[0]['number'];
  934. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  935. {
  936. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  937. }
  938. }
  939. else
  940. {
  941. $yd = $this->fullordertt->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  942. if(isset($yd[0]['number']))
  943. {
  944. $number = $yd[0]['number'];
  945. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  946. {
  947. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  948. }
  949. }
  950. else
  951. {
  952. $yd = $this->fullorderamz->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  953. if(isset($yd[0]['number']))
  954. {
  955. $number = $yd[0]['number'];
  956. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  957. {
  958. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  959. }
  960. }
  961. else
  962. {
  963. $yd = $this->fullorderxw->find_all("waybill = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  964. if(isset($yd[0]['number']))
  965. {
  966. $number = $yd[0]['number'];
  967. if($yd[0]['express'] != $express && $yd[0]['express'] != 31)
  968. {
  969. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  970. }
  971. }
  972. else
  973. {
  974. echo json_encode(array('msg'=>'系统中未查到此运单,请确认!'.$number,'success'=>false));exit;
  975. }
  976. }
  977. }
  978. }
  979. }
  980. /**
  981. if($yd[0]['printtype'] != 1)
  982. {
  983. echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
  984. }
  985. **/
  986. //再次判断下杭州不报关的类别是否满足条件 如果有影响可以删除
  987. if($yd[0]['express'] != $express){
  988. echo json_encode(array('msg'=>'录入信息和选择快递不一致!2','success'=>false));exit;
  989. }
  990. $nu = $this->outbound->get_number($number);
  991. if($nu)
  992. {
  993. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  994. }
  995. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$yd[0]['waybill'],'express'=>$yd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  996. {
  997. $data = $this->outbound->find_count($where);
  998. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  999. }
  1000. else
  1001. {
  1002. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1003. }
  1004. }
  1005. else
  1006. {
  1007. // $dd = $this->fullorder->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1008. // if(isset($dd[0]['number']))
  1009. // {
  1010. // if($dd[0]['express'] != $express)
  1011. // {
  1012. // echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1013. // }
  1014. // }
  1015. // else
  1016. // {
  1017. // $dd = $this->fullordersmt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1018. // if(isset($dd[0]['number']))
  1019. // {
  1020. // $number = $dd[0]['number'];
  1021. // if($dd[0]['express'] != $express)
  1022. // {
  1023. // echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1024. // }
  1025. // }
  1026. // else
  1027. // {
  1028. // $dd = $this->fullordertt->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1029. // if(isset($dd[0]['number']))
  1030. // {
  1031. // $number = $dd[0]['number'];
  1032. // if($dd[0]['express'] != $express)
  1033. // {
  1034. // echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1035. // }
  1036. // }
  1037. // else
  1038. // {
  1039. // $dd = $this->fullorderamz->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1040. // if(isset($dd[0]['number']))
  1041. // {
  1042. // $number = $dd[0]['number'];
  1043. // if($dd[0]['express'] != $express)
  1044. // {
  1045. // echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1046. // }
  1047. // }
  1048. // else
  1049. // {
  1050. // $dd = $this->fullorderxw->find_all("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1051. // if(isset($dd[0]['number']))
  1052. // {
  1053. // $number = $dd[0]['number'];
  1054. // if($dd[0]['express'] != $express)
  1055. // {
  1056. // echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1057. // }
  1058. // }
  1059. // else
  1060. // {
  1061. // echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1062. // }
  1063. // }
  1064. // }
  1065. // }
  1066. // }
  1067. $info = $this->logic_order->getInfo("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1068. $dd = [];
  1069. $dd[] = $info;
  1070. if(isset($dd[0]['number'])){
  1071. if($dd[0]['express'] != $express)
  1072. {
  1073. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1074. }
  1075. }else{
  1076. $tmp_number_arr = explode('-',$number);
  1077. array_pop($tmp_number_arr);
  1078. $number = implode("-",$tmp_number_arr);
  1079. $info = $this->logic_order->getInfo("number = '$number' and library = '2' and librarytime > '".(time()-30*24*3600)."'");
  1080. $dd = [];
  1081. $dd[] = $info;
  1082. if(isset($dd[0]['number'])){
  1083. if($dd[0]['express'] != $express)
  1084. {
  1085. echo json_encode(array('msg'=>'录入信息和选择快递不一致!','success'=>false));exit;
  1086. }
  1087. }else{
  1088. echo json_encode(array('msg'=>'系统中未查到此编号,请确认!','success'=>false));exit;
  1089. }
  1090. }
  1091. //惠程-美国USPS 惠程-联邦 惠程-安迈世 惠程-DHL 惠程-GES(欧盟)
  1092. if(($dd[0]['printtype'] != 2) && (!in_array($dd[0]['express'],[50,51,52,54,69,73,75,91,93])))
  1093. {
  1094. echo json_encode(array('msg'=>'请扫描正确的条码!','success'=>false));exit;
  1095. }
  1096. //判断该订单的快递单号是否存在 如果不存在提示 补齐快递单号 在进行扫描
  1097. // if(empty($dd[0]['waybill'])){
  1098. // echo json_encode(array('msg'=>'该订单未检索到快递信息,请补齐快递单号!','success'=>false));exit;
  1099. // }
  1100. $nu = $this->outbound->get_number($number);
  1101. if($nu)
  1102. {
  1103. echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
  1104. }
  1105. if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$dd[0]['waybill'],'express'=>$dd[0]['express'],'gtime'=>date('Ymd',time()),'time'=>time())))
  1106. {
  1107. $data = $this->outbound->find_count($where);
  1108. echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
  1109. }
  1110. else
  1111. {
  1112. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. public function _dcall(){
  1118. if(isset($_GET['fexcel']))
  1119. {
  1120. $timetk = $this->input->get('timetk',true);
  1121. $timetj = $this->input->get('timetj',true);
  1122. $library = $this->input->get('library',true);
  1123. $type = $this->input->get('type',true);
  1124. $number = $this->input->get('number',true);
  1125. $waybill = $this->input->get('waybill',true);
  1126. $timetk = strtotime($timetk);
  1127. $timetj = strtotime($timetj);
  1128. $typename = "订单计数";
  1129. // $cx_arr = [78,79];
  1130. // $ex_list = $this->express->find_all("id in (".implode(',',$cx_arr).")","id,servicename");
  1131. // $where = "type != 0 and express in (".implode(',',$cx_arr).")";
  1132. $where = " type != 0 ";
  1133. if($timetk && $timetj)
  1134. {
  1135. $where .= " and time > '$timetk' and time < '$timetj'";
  1136. }
  1137. if(isset($_SESSION['api']))
  1138. {
  1139. if($type)
  1140. {
  1141. $where .= " and type = '$type'";
  1142. }
  1143. else
  1144. {
  1145. $uw = '';
  1146. $u = $this->user->get_api($_SESSION['api']);
  1147. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1148. foreach ($u['warehouse'] as $v)
  1149. {
  1150. $uw .= " type = '$v' or";
  1151. }
  1152. $uw = rtrim($uw,'or');
  1153. $uw = " and (".ltrim($uw,' ').")";
  1154. $where .= $uw;
  1155. }
  1156. }
  1157. else
  1158. {
  1159. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1160. }
  1161. if($number)
  1162. {
  1163. $where .= " and number = '$number'";
  1164. }
  1165. if($waybill)
  1166. {
  1167. $where .= " and waybill = '$waybill'";
  1168. }
  1169. $data = array();
  1170. $datafy = array();
  1171. $j = 0;
  1172. $info_list = $this->outbound->find_all($where,'number,waybill,express','time asc');
  1173. $express_ids = array_unique(array_column($info_list,'express'));
  1174. $express_ids = array_values($express_ids);
  1175. $ex_list = $this->express->find_all("id in (".implode(',',$express_ids).")","id,servicename",'id asc');
  1176. $final_list= [
  1177. ];
  1178. foreach($ex_list as $v){
  1179. $final_list[$v['id']] = [];
  1180. }
  1181. foreach ($info_list as $key=>$value)
  1182. {
  1183. if(isset($final_list[$value['express']])){
  1184. $orderinfo = $this->logic_order->getInfo('number = "'.$value['number'].'"');
  1185. $weight = 0;
  1186. if(!empty($orderinfo)){
  1187. $weight = $orderinfo['weight'];
  1188. }
  1189. $weight = str_replace('kgkg','kg',$weight);
  1190. $final_list[$value['express']][] = [
  1191. $value['number'],
  1192. $value['waybill'],
  1193. $weight
  1194. ];
  1195. }
  1196. }
  1197. $data[] = $datafy;
  1198. //格式化数据
  1199. $i = 0;$cpexcel = array();
  1200. $title = date('Ymd',time()).$typename."发货统计信息"; $td = '';
  1201. $td = "";
  1202. $count = 0;
  1203. foreach($ex_list as $v){
  1204. $num = count($final_list[$v['id']]);
  1205. if($num > $count){
  1206. $count = $num;
  1207. }
  1208. $td .= "<td>".$v['servicename']."</td><td>总数(".$num.")</td><td>重量</td>";
  1209. }
  1210. foreach($final_list as $k=>$v){
  1211. for($i=0;$i < $count ;$i++){
  1212. if(!isset($final_list[$k][$i])){
  1213. $final_list[$k][$i] = [
  1214. " "," ",""
  1215. ];
  1216. }
  1217. }
  1218. }
  1219. $titlename = "<table border=1>
  1220. <tr>
  1221. ".$td."
  1222. </tr>
  1223. </table>";
  1224. $filename = $title.".xls";
  1225. $this->excel->get_fz7($final_list,$titlename,$filename);
  1226. }
  1227. }
  1228. }