Systemretreat.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemretreat extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullordersmt','fullordersmt');
  13. $this->load->_model('Model_outbound','outbound');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_kdniao','kdniao');
  19. $this->load->_model('Model_notice','notice');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_usps','usps');
  22. $this->load->_model('Model_fedex','fedex');
  23. $this->load->_model('Model_ups','ups');
  24. $this->load->_model('Model_ali','ali');
  25. $this->load->_model('Model_dpd','dpd');
  26. $this->load->_model('Model_shop','shop');
  27. $this->load->_model('Model_user','user');
  28. $this->load->_model('Model_whlabel','whlabel');
  29. $this->load->_model('Model_specialstock','specialstock');
  30. $this->load->_model('Model_fullorderxw','fullorderxw');
  31. $this->load->_model('Model_retreatlogs','retreatlogs');
  32. $this->load->helper('url');
  33. }
  34. //定义方法的调用规则 获取URI第二段值
  35. public function _remap($arg,$arg_array)
  36. {
  37. if($arg == 'out')
  38. {
  39. $this->_out();
  40. }
  41. else if($arg == 'excel')
  42. {
  43. $this->_excel();
  44. }
  45. else
  46. {
  47. $this->_index();
  48. }
  49. }
  50. public function _out()
  51. {
  52. $post = $this->input->post(NULL, TRUE);
  53. if(isset($post['order']))
  54. {
  55. $time = time();
  56. $order = $this->input->post('order',true);
  57. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  58. {
  59. $order = substr($order,0,12);
  60. }
  61. $y = $this->fullorder->get_waybill($order);
  62. $fullorder_name = 'fullorder';
  63. if(!$y)
  64. {
  65. $y = $this->fullorder->get_number($order);
  66. if(!$y)
  67. {
  68. $fullorder_name = 'fullordersmt';
  69. $y = $this->fullordersmt->get_waybill($order);
  70. if(!$y)
  71. {
  72. $y = $this->fullordersmt->get_number($order);
  73. if(!$y)
  74. {
  75. if(!$y)
  76. {
  77. $fullorder_name = 'fullordertt';
  78. $y = $this->fullordertt->get_waybill($order);
  79. if(!$y)
  80. {
  81. $y = $this->fullordertt->get_number($order);
  82. if(!$y)
  83. {
  84. $fullorder_name = 'fullorderxw';
  85. $y = $this->fullorderxw->get_waybill($order);
  86. if(!$y)
  87. {
  88. $y = $this->fullorderxw->get_number($order);
  89. if(!$y)
  90. {
  91. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. if($y['library'] == 3)
  102. {
  103. //echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['retreattime']).' 已操作','success'=>false));exit;
  104. }
  105. if($y['library'] == 1)
  106. {
  107. echo json_encode(array('msg'=>'此数据未出库','success'=>false));exit;
  108. }
  109. $warehouse = $this->warehouse->read($y['type']);
  110. $this->db->trans_begin();
  111. if($warehouse['zd'] == '1')
  112. {
  113. $wl = $this->whlabel->find_all("zd = '".$y['number']."'");//查找是否有占用库存情况
  114. if($wl)//如果有那么清除所有占用
  115. {
  116. foreach ($wl as $v)
  117. {
  118. $this->whlabel->save(array('state'=>0,'rktype'=>5,'zd'=>'','retreat'=>$time,'time'=>$time),$v['id']);//专属
  119. }
  120. }
  121. }
  122. if(stripos($y['whlabel'],'z|') !== false)
  123. {
  124. $wl = $this->specialstock->find_all("zd = '".$y['number']."'");
  125. if($wl)//如果有那么清除所有占用
  126. {
  127. foreach ($wl as $v)
  128. {
  129. $this->specialstock->save(array('state'=>0,'rktype'=>5,'zd'=>'','retreat'=>$time,'time'=>$time),$v['id']);
  130. }
  131. }
  132. }
  133. $hbcfw = explode('|',trim($y['whlabel'],'|'));
  134. $hbcff = explode(';',trim($y['fpdata'],';'));
  135. $c = 0;
  136. $hbw = array();
  137. $hbf = array();
  138. for($i=0;$i<count($hbcfw);$i++)
  139. {
  140. $w = explode('-',$hbcfw[$i]);
  141. $f = explode('|',$hbcff[$i]);
  142. $f[9] = 0;
  143. $w[2] = 0;
  144. $hbw[] = implode("-",$w);
  145. $hbf[] = implode("|",$f);
  146. }
  147. $this->$fullorder_name->save(array('whlabel'=>'|'.implode("|",$hbw).'|','fpdata'=>implode(";",$hbf).';'),$y['id']);
  148. $user = $this->user->get_api($_SESSION['api']);
  149. $this->$fullorder_name->save(array('library'=>3,'retreattime'=>$time,'retreatdata'=>$y['retreatdata'].'['.$user['userid'].':'.date('Y-m-d H:i:s',time()).':'.$this->input->ip_address().']-'),$y['id']);
  150. $this->retreatlogs->insert([
  151. 'plat'=>$fullorder_name,
  152. 'fid'=>$y['id'],
  153. 'number'=>$y['number'],
  154. 'ck_goods'=>json_encode([
  155. 'whlabel'=>$y['whlabel'],
  156. 'fpdata'=>$y['fpdata'],
  157. ],JSON_UNESCAPED_UNICODE),
  158. 'ck_time'=>$y['librarytime'],
  159. 'tk_time'=>$time,
  160. ]);
  161. if ($this->db->trans_status() === FALSE)
  162. {
  163. $this->db->trans_commit();
  164. echo json_encode(array('msg'=>'退库失败,请重试','success'=>false));exit;
  165. }
  166. else
  167. {
  168. $this->db->trans_commit();
  169. echo json_encode(array('success'=>true));exit;
  170. }
  171. }
  172. }
  173. public function _index()
  174. {
  175. $post = $this->input->post(NULL, TRUE);
  176. if(isset($_SESSION['api']))
  177. {
  178. $user = $this->user->get_api($_SESSION['api']);
  179. $usp = $user;
  180. $fgshop = "";$sid = "";$wid="";$wtype="";
  181. $usersp = explode('|',trim($user['shop'],'|'));
  182. $userwh = explode('|',trim($user['warehouse'],'|'));
  183. foreach ($usersp as $value)
  184. {
  185. $fgshop .= " shop = ".$value." or";
  186. $sid .= " id = ".$value." or";
  187. }
  188. foreach ($userwh as $value)
  189. {
  190. $wid .= " id = ".$value." or";
  191. $wtype .= " type = ".$value." or";
  192. }
  193. }
  194. if(isset($post['page']))
  195. {
  196. $page = $this->input->post('page',true);
  197. $perpage = $this->input->post('perpage',true);
  198. $timetk = $this->input->post('timetk',true);
  199. $timetj = $this->input->post('timetj',true);
  200. $shop = $this->input->post('shop',true);
  201. $source = $this->input->post('source',true);
  202. $orderinfo = $this->input->post('orderinfo',true);
  203. $number = $this->input->post('number',true);
  204. $waybill = $this->input->post('waybill',true);
  205. $express = $this->input->post('express',true);
  206. $type = $this->input->post('type',true);
  207. $lowe = $this->input->post('lowe',true);
  208. $timetk = strtotime($timetk);
  209. $timetj = strtotime($timetj);
  210. $where = (isset($_SESSION['api']))?"library = 3 and (".rtrim($wtype,'or').")":"id= '0'";
  211. if($timetk && $timetj)
  212. {
  213. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  214. }
  215. if($shop)
  216. {
  217. $where .= " and shop = '$shop'";
  218. }
  219. if($orderinfo)
  220. {
  221. $where .= " and orderinfo = '$orderinfo'";
  222. }
  223. if($number)
  224. {
  225. $where .= " and number = '$number'";
  226. }
  227. if($waybill)
  228. {
  229. $where .= " and waybill = '$waybill'";
  230. }
  231. if($express)
  232. {
  233. $where .= " and express = '$express'";
  234. }
  235. if($orderinfo)
  236. {
  237. $where .= " and orderinfo = '$orderinfo'";
  238. }
  239. if($type)
  240. {
  241. $where .= " and type = '$type'";
  242. }
  243. if($lowe)
  244. {
  245. $where .= " and shipremarks like '%$lowe%'";
  246. }
  247. //数据排序
  248. $order_str = "retreattime desc";
  249. if(empty($page))
  250. {
  251. $start = 0;
  252. $perpage = 1;
  253. }
  254. else
  255. {
  256. $start = ($page - 1)*$perpage;
  257. }
  258. //取得信息列表
  259. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks',$order_str,$start,$perpage);
  260. //格式化数据
  261. foreach ($info_list as $key=>$value)
  262. {
  263. $shop = $this->shop->read($value['shop']);
  264. $info_list[$key]['shop'] = $shop['shopname'];
  265. if($value['waybill'] == 0)
  266. {
  267. $info_list[$key]['waybill'] = "";
  268. }
  269. $express = $this->express->read($value['express']);
  270. $info_list[$key]['express'] = $express['servicename'];
  271. $warehouse = $this->warehouse->read($value['type']);
  272. $info_list[$key]['type'] = $warehouse['title'];
  273. $typeclass = $this->typeclass->read($value['state']);
  274. $info_list[$key]['state'] = $typeclass['spare'];
  275. $info_list[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  276. if($value['retreattime'] == '0')
  277. {
  278. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  279. }
  280. else
  281. {
  282. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i',$value['retreattime']).'</em>';
  283. }
  284. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  285. }
  286. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  287. //格式化数据
  288. foreach ($info_listtt as $key=>$value)
  289. {
  290. $shop = $this->shop->read($value['shop']);
  291. $info_listtt[$key]['shop'] = $shop['shopname'];
  292. if($value['waybill'] == 0)
  293. {
  294. $info_listtt[$key]['waybill'] = "";
  295. }
  296. $express = $this->express->read($value['express']);
  297. $info_listtt[$key]['express'] = $express['servicename'];
  298. $warehouse = $this->warehouse->read($value['type']);
  299. $info_listtt[$key]['type'] = $warehouse['title'];
  300. $typeclass = $this->typeclass->read($value['state']);
  301. $info_listtt[$key]['state'] = $typeclass['spare'];
  302. if($value['print'] == 1)
  303. {
  304. $info_listtt[$key]['print'] = '不可打印';
  305. }
  306. else if($value['print'] == 2)
  307. {
  308. $info_listtt[$key]['print'] = '未打印';
  309. }
  310. else if($value['print'] == 3)
  311. {
  312. $info_listtt[$key]['print'] = '已打印';
  313. }
  314. if($value['retreattime'] == '0')
  315. {
  316. $info_listtt[$key]['retreattime'] = '<em class="t"></em>';
  317. }
  318. else
  319. {
  320. $info_listtt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  321. }
  322. }
  323. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  324. //格式化数据
  325. foreach ($info_listxw as $key=>$value)
  326. {
  327. $shop = $this->shop->read($value['shop']);
  328. $info_listxw[$key]['shop'] = $shop['shopname'];
  329. if($value['waybill'] == 0)
  330. {
  331. $info_listxw[$key]['waybill'] = "";
  332. }
  333. $express = $this->express->read($value['express']);
  334. $info_listxw[$key]['express'] = $express['servicename'];
  335. $warehouse = $this->warehouse->read($value['type']);
  336. $info_listxw[$key]['type'] = $warehouse['title'];
  337. $typeclass = $this->typeclass->read($value['state']);
  338. $info_listxw[$key]['state'] = $typeclass['spare'];
  339. if($value['print'] == 1)
  340. {
  341. $info_listxw[$key]['print'] = '不可打印';
  342. }
  343. else if($value['print'] == 2)
  344. {
  345. $info_listxw[$key]['print'] = '未打印';
  346. }
  347. else if($value['print'] == 3)
  348. {
  349. $info_listxw[$key]['print'] = '已打印';
  350. }
  351. if($value['retreattime'] == '0')
  352. {
  353. $info_listxw[$key]['retreattime'] = '<em class="t"></em>';
  354. }
  355. else
  356. {
  357. $info_listxw[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  358. }
  359. }
  360. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  361. //格式化数据
  362. foreach ($info_listsmt as $key=>$value)
  363. {
  364. $shop = $this->shop->read($value['shop']);
  365. $info_listsmt[$key]['shop'] = $shop['shopname'];
  366. if($value['waybill'] == 0)
  367. {
  368. $info_listsmt[$key]['waybill'] = "";
  369. }
  370. $express = $this->express->read($value['express']);
  371. $info_listsmt[$key]['express'] = $express['servicename'];
  372. $warehouse = $this->warehouse->read($value['type']);
  373. $info_listsmt[$key]['type'] = $warehouse['title'];
  374. $typeclass = $this->typeclass->read($value['state']);
  375. $info_listsmt[$key]['state'] = $typeclass['spare'];
  376. if($value['print'] == 1)
  377. {
  378. $info_listsmt[$key]['print'] = '不可打印';
  379. }
  380. else if($value['print'] == 2)
  381. {
  382. $info_listsmt[$key]['print'] = '未打印';
  383. }
  384. else if($value['print'] == 3)
  385. {
  386. $info_listsmt[$key]['print'] = '已打印';
  387. }
  388. if($value['retreattime'] == '0')
  389. {
  390. $info_listsmt[$key]['retreattime'] = '<em class="t"></em>';
  391. }
  392. else
  393. {
  394. $info_listsmt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  395. }
  396. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  397. }
  398. $total = $this->fullorder->find_count($where);
  399. $total += $this->fullordertt->find_count($where);
  400. $total += $this->fullorderxw->find_count($where);
  401. $total += $this->fullordersmt->find_count($where);
  402. $pagenum = ceil($total/$perpage);
  403. $over = $total-($start+$perpage);
  404. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));//$info_list_smt
  405. echo json_encode($rows);exit;
  406. }
  407. if(isset($_SESSION['api']))
  408. {
  409. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  410. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'));
  411. $this->data['wlshop'] = $wlshop;
  412. $this->data['warehouse'] = $warehouse;
  413. }
  414. $this->_Template('systemretreat',$this->data);
  415. }
  416. public function _excel()
  417. {
  418. $post = $this->input->get(NULL, TRUE);
  419. if(isset($_GET['excel']))
  420. {
  421. if(isset($_SESSION['api']))
  422. {
  423. $user = $this->user->get_api($_SESSION['api']);
  424. $usp = $user;
  425. $fgshop = "";$sid = "";$wid="";$wtype="";
  426. $usersp = explode('|',trim($user['shop'],'|'));
  427. $userwh = explode('|',trim($user['warehouse'],'|'));
  428. foreach ($usersp as $value)
  429. {
  430. $fgshop .= " shop = ".$value." or";
  431. $sid .= " id = ".$value." or";
  432. }
  433. foreach ($userwh as $value)
  434. {
  435. $wid .= " id = ".$value." or";
  436. $wtype .= " type = ".$value." or";
  437. }
  438. }
  439. if(isset($post['page']))
  440. {
  441. $timetk = $this->input->get('timetk',true);
  442. $timetj = $this->input->get('timetj',true);
  443. $shop = $this->input->get('shop',true);
  444. $source = $this->input->get('source',true);
  445. $orderinfo = $this->input->get('orderinfo',true);
  446. $number = $this->input->get('number',true);
  447. $waybill = $this->input->get('waybill',true);
  448. $express = $this->input->get('express',true);
  449. $type = $this->input->get('type',true);
  450. $lowe = $this->input->get('lowe',true);
  451. $sdd = $this->input->get('sid',true);
  452. $timetk = strtotime($timetk);
  453. $timetj = strtotime($timetj);
  454. $where = (isset($_SESSION['api']))?"library = 3 and (".rtrim($wtype,'or').")":"id= '0'";
  455. if($timetk && $timetj)
  456. {
  457. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  458. }
  459. if($shop)
  460. {
  461. $where .= " and shop = '$shop'";
  462. }
  463. if($orderinfo)
  464. {
  465. $where .= " and orderinfo = '$orderinfo'";
  466. }
  467. if($number)
  468. {
  469. $where .= " and number = '$number'";
  470. }
  471. if($waybill)
  472. {
  473. $where .= " and waybill = '$waybill'";
  474. }
  475. if($express)
  476. {
  477. $where .= " and express = '$express'";
  478. }
  479. if($orderinfo)
  480. {
  481. $where .= " and orderinfo = '$orderinfo'";
  482. }
  483. if($type)
  484. {
  485. $where .= " and type = '$type'";
  486. }
  487. if($lowe)
  488. {
  489. $where .= " and shipremarks like '%$lowe%'";
  490. }
  491. $sidwhere = '';
  492. if($sdd)
  493. {
  494. $sd = "";
  495. $s = explode(',',trim($sdd,','));
  496. foreach ($s as $value)
  497. {
  498. $sd .= " id = ".$value." or";
  499. }
  500. $sidwhere = " and (".rtrim($sd,'or').")";
  501. }
  502. //数据排序
  503. $order_str = "retreattime desc";
  504. if(empty($page))
  505. {
  506. $start = 0;
  507. $perpage = 1;
  508. }
  509. else
  510. {
  511. $start = ($page - 1)*$perpage;
  512. }
  513. //取得信息列表
  514. $info_list = $this->fullorder->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  515. //格式化数据
  516. foreach ($info_list as $key=>$value)
  517. {
  518. $shop = $this->shop->read($value['shop']);
  519. $info_list[$key]['shop'] = $shop['shopname'];
  520. if($value['waybill'] == 0)
  521. {
  522. $info_list[$key]['waybill'] = "";
  523. }
  524. $express = $this->express->read($value['express']);
  525. $info_list[$key]['express'] = $express['servicename'];
  526. $warehouse = $this->warehouse->read($value['type']);
  527. $info_list[$key]['type'] = $warehouse['title'];
  528. $typeclass = $this->typeclass->read($value['state']);
  529. $info_list[$key]['state'] = $typeclass['spare'];
  530. $info_list[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  531. if($value['retreattime'] == '0')
  532. {
  533. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  534. }
  535. else
  536. {
  537. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i',$value['retreattime']).'</em>';
  538. }
  539. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  540. }
  541. $info_listtt = $this->fullordertt->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  542. //格式化数据
  543. foreach ($info_listtt as $key=>$value)
  544. {
  545. $shop = $this->shop->read($value['shop']);
  546. $info_listtt[$key]['shop'] = $shop['shopname'];
  547. if($value['waybill'] == 0)
  548. {
  549. $info_listtt[$key]['waybill'] = "";
  550. }
  551. $express = $this->express->read($value['express']);
  552. $info_listtt[$key]['express'] = $express['servicename'];
  553. $warehouse = $this->warehouse->read($value['type']);
  554. $info_listtt[$key]['type'] = $warehouse['title'];
  555. $typeclass = $this->typeclass->read($value['state']);
  556. $info_listtt[$key]['state'] = $typeclass['spare'];
  557. $info_listtt[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  558. if($value['retreattime'] == '0')
  559. {
  560. $info_listtt[$key]['retreattime'] = '<em class="t"></em>';
  561. }
  562. else
  563. {
  564. $info_listtt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  565. }
  566. }
  567. $info_listxw = $this->fullorderxw->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  568. //格式化数据
  569. foreach ($info_listxw as $key=>$value)
  570. {
  571. $shop = $this->shop->read($value['shop']);
  572. $info_listxw[$key]['shop'] = $shop['shopname'];
  573. if($value['waybill'] == 0)
  574. {
  575. $info_listxw[$key]['waybill'] = "";
  576. }
  577. $express = $this->express->read($value['express']);
  578. $info_listxw[$key]['express'] = $express['servicename'];
  579. $warehouse = $this->warehouse->read($value['type']);
  580. $info_listxw[$key]['type'] = $warehouse['title'];
  581. $typeclass = $this->typeclass->read($value['state']);
  582. $info_listxw[$key]['state'] = $typeclass['spare'];
  583. $info_listxw[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  584. if($value['retreattime'] == '0')
  585. {
  586. $info_listxw[$key]['retreattime'] = '<em class="t"></em>';
  587. }
  588. else
  589. {
  590. $info_listxw[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  591. }
  592. }
  593. $info_listsmt = $this->fullordersmt->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  594. //格式化数据
  595. foreach ($info_listsmt as $key=>$value)
  596. {
  597. $shop = $this->shop->read($value['shop']);
  598. $info_listsmt[$key]['shop'] = $shop['shopname'];
  599. if($value['waybill'] == 0)
  600. {
  601. $info_listsmt[$key]['waybill'] = "";
  602. }
  603. $express = $this->express->read($value['express']);
  604. $info_listsmt[$key]['express'] = $express['servicename'];
  605. $warehouse = $this->warehouse->read($value['type']);
  606. $info_listsmt[$key]['type'] = $warehouse['title'];
  607. $typeclass = $this->typeclass->read($value['state']);
  608. $info_listsmt[$key]['state'] = $typeclass['spare'];
  609. $info_listsmt[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  610. if($value['retreattime'] == '0')
  611. {
  612. $info_listsmt[$key]['retreattime'] = '<em class="t"></em>';
  613. }
  614. else
  615. {
  616. $info_listsmt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  617. }
  618. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  619. }
  620. $rows = array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt);//$info_list_smt
  621. $title = '订单退库-'.date('Y-m-d H-i-s',time());
  622. $titlename = "<table border=1>
  623. <tr align='center'>
  624. <td>店铺名称</td>
  625. <td>发货仓库</td>
  626. <td>订单号</td>
  627. <td>编号</td>
  628. <td>运单号</td>
  629. <td>快递公司</td>
  630. <td>订单状态</td>
  631. <td>出库时间</td>
  632. <td>退库时间</td>
  633. <td>仓库品名</td>
  634. </tr>
  635. </table>";
  636. $tail = "\n";
  637. $filename = $title.".xls";
  638. $this->excel->get_fz2(array_merge($info_list,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  639. }
  640. }
  641. }
  642. }