Aptsmt.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Aptsmt 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_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  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_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_shop','shop');
  24. $this->load->_model('Model_user','user');
  25. $this->load->_model('Model_whlabel','whlabel');
  26. $this->load->helper('url');
  27. }
  28. //定义方法的调用规则 获取URI第二段值
  29. public function _remap($arg,$arg_array)
  30. {
  31. if($arg == 'fout')//出库页
  32. {
  33. $this->_fout();
  34. }
  35. else if($arg == 'printing')//打印操作
  36. {
  37. $this->_printing();
  38. }
  39. else if($arg == 'print')//打印操作
  40. {
  41. $this->_print();
  42. }
  43. else if($arg == 'fhd')//打印操作
  44. {
  45. $this->_fhd($arg_array);
  46. }
  47. else if($arg == 'fhdusa')//打印操作
  48. {
  49. $this->_fhdusa($arg_array);
  50. }
  51. else if($arg == 'shop')
  52. {
  53. $this->_shop();
  54. }
  55. else if($arg == 'lowe')
  56. {
  57. $this->_lowe();
  58. }
  59. else if($arg == 'express')
  60. {
  61. $this->_express();
  62. }
  63. else if($arg == 'retreat')
  64. {
  65. $this->_retreat();
  66. }
  67. else if($arg == 'excel')
  68. {
  69. $this->_excel();
  70. }
  71. else
  72. {
  73. $this->_index();
  74. }
  75. }
  76. //管理
  77. public function _index()
  78. {
  79. $post = $this->input->post(NULL, TRUE);
  80. if(isset($post['userid']))
  81. {
  82. $userid = $this->input->post('userid',true);
  83. $userpass = $this->input->post('userpass',true);
  84. $password = sha1($userpass);
  85. $user = $this->user->get_uid($userid,'dlz');
  86. if($user)
  87. {
  88. if($user['type'] == 2)
  89. {
  90. echo json_encode(array('msg'=>"账户已停用",'success'=>false));exit;
  91. }
  92. if($user['userpass'] == $password)
  93. {
  94. $this->user->get_land($user); //更新登录数据
  95. echo json_encode(array('url'=>'?id='.$user['api'],'success'=>true));exit;
  96. }
  97. else
  98. {
  99. echo json_encode(array('msg'=>"用户或密码不正确",'success'=>false));exit;
  100. }
  101. }
  102. else
  103. {
  104. echo json_encode(array('msg'=>"用户不正确",'success'=>false));exit;
  105. }
  106. }
  107. }
  108. //出库
  109. public function _fout()
  110. {
  111. $post = $this->input->post(NULL, TRUE);
  112. if(isset($post['order']))
  113. {
  114. $time = time();
  115. $order = $this->input->post('order',true);
  116. $y = $this->fullorder->get_waybill($order);
  117. $fullorder_name = 'fullorder';
  118. if(!$y)
  119. {
  120. $y = $this->fullorder->get_number($order);
  121. if(!$y)
  122. {
  123. $fullorder_name = 'fullordersmt';
  124. $y = $this->fullordersmt->get_waybill($order);
  125. if(!$y)
  126. {
  127. $y = $this->fullordersmt->get_number($order);
  128. if(!$y)
  129. {
  130. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  131. }
  132. }
  133. }
  134. }
  135. if($y['libraryconfirm'] == 1 || $y['state'] == 217)
  136. {
  137. echo json_encode(array('msg'=>$y['librarynot'],'success'=>false));exit;
  138. }
  139. if($y['library'] > 1)
  140. {
  141. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  142. }
  143. if($y['type'] == 5)
  144. {
  145. $ckcg = 0;$save = array();
  146. $pp = explode('|',trim($y['whlabel'],'|'));
  147. foreach ($pp as $va)
  148. {
  149. $uid = array();//储存可用出库产品的ID
  150. $num = explode('-',$va);
  151. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '".$y['type']."' and shop !='' and shop like '%,".$y['shop'].",%'");
  152. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '".$y['type']."' and (shop IS NULL or shop = '')");
  153. if($shopwhlabel)
  154. {
  155. if(count($shopwhlabel) >= $num[1])//如果专用的条数大于需求
  156. {
  157. for($i=0;$i<$num[1];$i++)
  158. {
  159. $uid[] = $shopwhlabel[$i]['id'];
  160. }
  161. $save[] = $uid;
  162. }
  163. else if(count($shopwhlabel) < $num[1] && (count($whlabel)+count($shopwhlabel)) >= $num[1])//如果专用的条数小于需求,但专用的条数+通用的条数大于等于需求,判断为可用,有限扣减专用数
  164. {
  165. for($i=0;$i<count($shopwhlabel);$i++)
  166. {
  167. $uid[] = $shopwhlabel[$i]['id'];
  168. }
  169. for($x=0;$x<($num[1]-count($shopwhlabel));$x++)
  170. {
  171. $uid[] = $whlabel[$x]['id'];
  172. }
  173. $save[] = $uid;
  174. }
  175. else
  176. {
  177. $ckcg++;
  178. }
  179. }
  180. else if(!$whlabel || count($whlabel) < $num[1])
  181. {
  182. $ckcg++;
  183. }
  184. else
  185. {
  186. for($i=0;$i<$num[1];$i++)
  187. {
  188. $uid[] = $whlabel[$i]['id'];
  189. }
  190. $save[] = $uid;
  191. }
  192. }
  193. if($ckcg > 0)
  194. {
  195. echo json_encode(array('msg'=>'无法匹配库存或库存为0','success'=>false));exit;
  196. }
  197. else
  198. {
  199. foreach ($save as $vb)
  200. {
  201. foreach ($vb as $vc)
  202. {
  203. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vc);
  204. }
  205. }
  206. }
  207. }
  208. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time),$y['id']))
  209. {
  210. echo json_encode(array('success'=>true));exit;
  211. if($fullorder_name == 'fullordersmt' && $y['source'] != 1)//速卖通发货声明
  212. {
  213. $ex = $this->express->read($y['express']);
  214. $shop = $shop->shop->read($y['shop']);
  215. if($y['dlz'] == 1)//如果已经声明过需要操作修改声明
  216. {
  217. $obtain = $this->apismt->get_obtain($y['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  218. $result = $this->apismt->get_editout($obtain['logistics_no'],$y['whlabel'],'all',$y['orderinfo'],$obtain['service_name'],$ex['servicetitle'],$shop['code']);
  219. if($result['result_success'] == 'true')
  220. {
  221. $this->db->trans_begin();
  222. $this->$fullorder_name->save(array('dlz'=>1),$y['id']);
  223. if($y['merge'] != '0')
  224. {
  225. $hdata = $this->$fullorder_name->find_all("merge = '".$y['merge']."' and id != '".$y['id']."'");
  226. foreach ($hdata as $v)
  227. {
  228. $obtain = $this->apismt->get_obtain($v['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  229. $result = $this->apismt->get_editout($obtain['logistics_no'],$y['whlabel'],'all',$v['orderinfo'],$obtain['service_name'],$ex['servicetitle'],$shop['code']);
  230. if($result['result_success'] == 'true')
  231. {
  232. $this->$fullorder_name->save(array('dlz'=>1),$v['id']);
  233. }
  234. }
  235. }
  236. if ($this->db->trans_status() === TRUE)
  237. {
  238. $this->db->trans_commit();
  239. }
  240. else
  241. {
  242. $this->db->trans_rollback();
  243. }
  244. }
  245. else
  246. {
  247. $this->$fullorder_name->save(array('dlz'=>2),$y['id']);
  248. }
  249. }
  250. else //未发货声明状态
  251. {
  252. $result = $this->apismt->get_out($y['whlabel'],'all',$y['orderinfo'],$ex['servicetitle'],$shop['code']);
  253. $shop = $this->shop->read($y['shop']);
  254. $go = $this->notice->get_go($y,$shop,'logisticstatus',1);//速卖通发送订单留言:已揽收
  255. $go = ($go==1)?'揽收留言发送成功':'揽收留言发送失败';
  256. //速卖通出库后状态需要改为209:买家待收货状态
  257. if($result['result_success'] == 'true')
  258. {
  259. $this->db->trans_begin();
  260. $this->$fullorder_name->save(array('dlz'=>1,'fscontent'=>$go,'state'=>209),$y['id']);
  261. if($y['merge'] != '0')
  262. {
  263. $hdata = $this->$fullorder_name->find_all("merge = '".$y['merge']."' and id != '".$y['id']."'");
  264. foreach ($hdata as $v)
  265. {
  266. $result = $this->apismt->get_out($y['whlabel'],'all',$v['orderinfo'],$ex['servicetitle'],$shop['code']);
  267. $go = $this->notice->get_go($v,$shop,'logisticstatus',1);//速卖通发送订单留言:已揽收
  268. $go = ($go==1)?'揽收留言发送成功':'揽收留言发送失败';
  269. if($result['result_success'] == 'true')
  270. {
  271. $this->$fullorder_name->save(array('dlz'=>1,'fscontent'=>$go,'state'=>209),$v['id']);
  272. }
  273. }
  274. }
  275. if ($this->db->trans_status() === TRUE)
  276. {
  277. $this->db->trans_commit();
  278. }
  279. else
  280. {
  281. $this->db->trans_rollback();
  282. }
  283. }
  284. else
  285. {
  286. $this->$fullorder_name->save(array('dlz'=>2,'fscontent'=>$go,'state'=>209),$y['id']);
  287. }
  288. }
  289. }
  290. $sp = $this->shop->read($y['shop']);
  291. $this->notice->get_go($y,$sp,'ordertatus',209);//通知消息模板,是否有已发货需要发送内容
  292. }
  293. else
  294. {
  295. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  296. }
  297. }
  298. if(isset($post['page']))
  299. {
  300. $page = $this->input->post('page',true);
  301. $perpage = $this->input->post('perpage',true);
  302. $timetk = $this->input->post('timetk',true);
  303. $timetj = $this->input->post('timetj',true);
  304. $shop = $this->input->post('shop',true);
  305. $source = $this->input->post('source',true);
  306. $orderinfo = $this->input->post('orderinfo',true);
  307. $number = $this->input->post('number',true);
  308. $library = $this->input->post('library',true);
  309. $waybill = $this->input->post('waybill',true);
  310. $express = $this->input->post('express',true);
  311. $type = $this->input->post('type',true);
  312. $lowe = $this->input->post('lowe',true);
  313. $librarytime = $this->input->post('librarytime',true);
  314. $timetk = strtotime($timetk);
  315. $timetj = strtotime($timetj);
  316. $cxtime = 'id';
  317. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  318. if($timetk && $timetj && $library == 2 && $librarytime != 1)
  319. {
  320. $cxtime = 'reviewtime';
  321. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  322. }
  323. else if($timetk && $timetj && $library == 2 && $librarytime == 1)
  324. {
  325. $cxtime = 'librarytime';
  326. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  327. }
  328. if($shop)
  329. {
  330. $where .= " and shop = '$shop'";
  331. }
  332. if($number)
  333. {
  334. $where .= " and number = '$number'";
  335. }
  336. if($library)
  337. {
  338. $where .= " and library = '$library'";
  339. }
  340. if($waybill)
  341. {
  342. $where .= " and waybill = '$waybill'";
  343. }
  344. if($express)
  345. {
  346. $where .= " and express = '$express'";
  347. }
  348. if($orderinfo)
  349. {
  350. $where .= " and orderinfo = '$orderinfo'";
  351. }
  352. if($type)
  353. {
  354. $where .= " and type = '$type'";
  355. }
  356. if($lowe)
  357. {
  358. $where .= " and shipremarks like '%$lowe%'";
  359. }
  360. //数据排序
  361. $order_str = $cxtime." desc";
  362. if(empty($page))
  363. {
  364. $start = 0;
  365. $perpage = 1;
  366. }
  367. else
  368. {
  369. $start = ($page - 1)*$perpage;
  370. }
  371. //取得信息列表
  372. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  373. //格式化数据
  374. foreach ($info_list as $key=>$value)
  375. {
  376. $shop = $this->shop->read($value['shop']);
  377. $info_list[$key]['shop'] = $shop['shopname'];
  378. if($value['waybill'] == 0)
  379. {
  380. $info_list[$key]['waybill'] = "";
  381. }
  382. $express = $this->express->read($value['express']);
  383. $info_list[$key]['express'] = $express['servicename'];
  384. $warehouse = $this->warehouse->read($value['type']);
  385. $info_list[$key]['type'] = $warehouse['title'];
  386. if($value['print'] == 1)
  387. {
  388. $info_list[$key]['print'] = '不可打印';
  389. }
  390. else if($value['print'] == 2)
  391. {
  392. $info_list[$key]['print'] = '未打印';
  393. }
  394. else if($value['print'] == 3)
  395. {
  396. $info_list[$key]['print'] = '已打印';
  397. }
  398. if($value['library'] == 1)
  399. {
  400. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  401. }
  402. else if($value['library'] == 2)
  403. {
  404. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  405. }
  406. else if($value['library'] == 3)
  407. {
  408. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  409. }
  410. if($value['librarytime'] == '0')
  411. {
  412. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  413. }
  414. else
  415. {
  416. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  417. }
  418. }
  419. $info_list_smt = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  420. //格式化数据
  421. foreach ($info_list_smt as $key=>$value)
  422. {
  423. $shop = $this->shop->read($value['shop']);
  424. $info_list_smt[$key]['shop'] = $shop['shopname'];
  425. if($value['waybill'] == 0)
  426. {
  427. $info_list_smt[$key]['waybill'] = "";
  428. }
  429. $express = $this->express->read($value['express']);
  430. $info_list_smt[$key]['express'] = $express['servicename'];
  431. $warehouse = $this->warehouse->read($value['type']);
  432. $info_list_smt[$key]['type'] = $warehouse['title'];
  433. if($value['print'] == 1)
  434. {
  435. $info_list_smt[$key]['print'] = '不可打印';
  436. }
  437. else if($value['print'] == 2)
  438. {
  439. $info_list_smt[$key]['print'] = '未打印';
  440. }
  441. else if($value['print'] == 3)
  442. {
  443. $info_list_smt[$key]['print'] = '已打印';
  444. }
  445. if($value['library'] == 1)
  446. {
  447. $info_list_smt[$key]['library'] = '<em class="c">未出库</em>';
  448. }
  449. else if($value['library'] == 2)
  450. {
  451. $info_list_smt[$key]['library'] = '<em class="c">已出库</em>';
  452. }
  453. else if($value['library'] == 3)
  454. {
  455. $info_list_smt[$key]['library'] = '<em class="c">已退库</em>';
  456. }
  457. if($value['librarytime'] == '0')
  458. {
  459. $info_list_smt[$key]['librarytime'] = '<em class="t"></em>';
  460. }
  461. else
  462. {
  463. $info_list_smt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  464. }
  465. }
  466. $total = $this->fullorder->find_count($where);
  467. $total += $this->fullordersmt->find_count($where);
  468. $pagenum = ceil($total/$perpage);
  469. $over = $total-($start+$perpage);
  470. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_list_smt)));
  471. echo json_encode($rows);exit;
  472. }
  473. $this->data['express'] = $this->express->find_all();
  474. $this->_Template('whlabel_fout',$this->data);
  475. }
  476. //退库
  477. public function _retreat()
  478. {
  479. $post = $this->input->post(NULL, TRUE);
  480. if(isset($post['order']))
  481. {
  482. $time = time();
  483. $order = $this->input->post('order',true);
  484. $y = $this->fullorder->get_waybill($order);
  485. $fullorder_name = 'fullorder';
  486. if(!$y)
  487. {
  488. $y = $this->fullorder->get_number($order);
  489. if(!$y)
  490. {
  491. $fullorder_name = 'fullordersmt';
  492. $y = $this->fullordersmt->get_waybill($order);
  493. if(!$y)
  494. {
  495. $y = $this->fullordersmt->get_number($order);
  496. if(!$y)
  497. {
  498. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  499. }
  500. }
  501. }
  502. }
  503. if($y['library'] == 3)
  504. {
  505. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['retreattime']).' 已操作','success'=>false));exit;
  506. }
  507. if($y['library'] == 1)
  508. {
  509. echo json_encode(array('msg'=>'此数据未出库','success'=>false));exit;
  510. }
  511. if($y['type'] == 5)
  512. {
  513. $ckcg = 0;$save = array();
  514. $pp = explode('|',trim($y['whlabel'],'|'));
  515. foreach ($pp as $va)
  516. {
  517. $uid = array();//储存可用出库产品的ID
  518. $num = explode('-',$va);
  519. $whlabel = $this->whlabel->find_all("state = 1 and number = '$num[0]' and warehouse = '".$y['type']."' and orderinfo = '".$y['orderinfo']."' and waybill = '".$y['waybill']."'");
  520. if(!$whlabel || count($whlabel) != $num[1])
  521. {
  522. $ckcg++;
  523. }
  524. else
  525. {
  526. for($i=0;$i<$num[1];$i++)
  527. {
  528. $uid[] = $whlabel[$i]['id'];
  529. }
  530. $save[] = $uid;
  531. }
  532. }
  533. if($ckcg > 0)
  534. {
  535. echo json_encode(array('msg'=>'有产品无出库信息','success'=>false));exit;
  536. }
  537. else
  538. {
  539. foreach ($save as $vb)
  540. {
  541. foreach ($vb as $vc)
  542. {
  543. $this->whlabel->save(array('state'=>2,'retreat'=>$time,'time'=>$time),$vc);
  544. }
  545. }
  546. }
  547. }
  548. if($this->$fullorder_name->save(array('library'=>3,'retreattime'=>$time),$y['id']))
  549. {
  550. echo json_encode(array('success'=>true));exit;
  551. }
  552. else
  553. {
  554. echo json_encode(array('msg'=>'退库失败,请重试','success'=>false));exit;
  555. }
  556. }
  557. if(isset($post['page']))
  558. {
  559. $page = $this->input->post('page',true);
  560. $perpage = $this->input->post('perpage',true);
  561. $timetk = $this->input->post('timetk',true);
  562. $timetj = $this->input->post('timetj',true);
  563. $shop = $this->input->post('shop',true);
  564. $source = $this->input->post('source',true);
  565. $orderinfo = $this->input->post('orderinfo',true);
  566. $number = $this->input->post('number',true);
  567. $waybill = $this->input->post('waybill',true);
  568. $express = $this->input->post('express',true);
  569. $type = $this->input->post('type',true);
  570. $lowe = $this->input->post('lowe',true);
  571. $timetk = strtotime($timetk);
  572. $timetj = strtotime($timetj);
  573. $where = "library=3 and gtime > 20190127";
  574. if($timetk && $timetj)
  575. {
  576. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  577. }
  578. if($shop)
  579. {
  580. $where .= " and shop = '$shop'";
  581. }
  582. if($orderinfo)
  583. {
  584. $where .= " and orderinfo = '$orderinfo'";
  585. }
  586. if($number)
  587. {
  588. $where .= " and number = '$number'";
  589. }
  590. if($waybill)
  591. {
  592. $where .= " and waybill = '$waybill'";
  593. }
  594. if($express)
  595. {
  596. $where .= " and express = '$express'";
  597. }
  598. if($orderinfo)
  599. {
  600. $where .= " and orderinfo = '$orderinfo'";
  601. }
  602. if($type)
  603. {
  604. $where .= " and type = '$type'";
  605. }
  606. if($lowe)
  607. {
  608. $where .= " and shipremarks like '%$lowe%'";
  609. }
  610. //数据排序
  611. $order_str = "retreattime desc";
  612. if(empty($page))
  613. {
  614. $start = 0;
  615. $perpage = 1;
  616. }
  617. else
  618. {
  619. $start = ($page - 1)*$perpage;
  620. }
  621. //取得信息列表
  622. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  623. //格式化数据
  624. foreach ($info_list as $key=>$value)
  625. {
  626. $shop = $this->shop->read($value['shop']);
  627. $info_list[$key]['shop'] = $shop['shopname'];
  628. if($value['waybill'] == 0)
  629. {
  630. $info_list[$key]['waybill'] = "";
  631. }
  632. $express = $this->express->read($value['express']);
  633. $info_list[$key]['express'] = $express['servicename'];
  634. $warehouse = $this->warehouse->read($value['type']);
  635. $info_list[$key]['type'] = $warehouse['title'];
  636. $typeclass = $this->typeclass->read($value['state']);
  637. $info_list[$key]['state'] = $typeclass['spare'];
  638. if($value['print'] == 1)
  639. {
  640. $info_list[$key]['print'] = '不可打印';
  641. }
  642. else if($value['print'] == 2)
  643. {
  644. $info_list[$key]['print'] = '未打印';
  645. }
  646. else if($value['print'] == 3)
  647. {
  648. $info_list[$key]['print'] = '已打印';
  649. }
  650. if($value['retreattime'] == '0')
  651. {
  652. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  653. }
  654. else
  655. {
  656. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  657. }
  658. }
  659. $info_list_smt = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  660. //格式化数据
  661. foreach ($info_list_smt as $key=>$value)
  662. {
  663. $shop = $this->shop->read($value['shop']);
  664. $info_list_smt[$key]['shop'] = $shop['shopname'];
  665. if($value['waybill'] == 0)
  666. {
  667. $info_list_smt[$key]['waybill'] = "";
  668. }
  669. $express = $this->express->read($value['express']);
  670. $info_list_smt[$key]['express'] = $express['servicename'];
  671. $warehouse = $this->warehouse->read($value['type']);
  672. $info_list_smt[$key]['type'] = $warehouse['title'];
  673. $typeclass = $this->typeclass->read($value['state']);
  674. $info_list_smt[$key]['state'] = $typeclass['spare'];
  675. if($value['print'] == 1)
  676. {
  677. $info_list_smt[$key]['print'] = '不可打印';
  678. }
  679. else if($value['print'] == 2)
  680. {
  681. $info_list_smt[$key]['print'] = '未打印';
  682. }
  683. else if($value['print'] == 3)
  684. {
  685. $info_list_smt[$key]['print'] = '已打印';
  686. }
  687. if($value['retreattime'] == '0')
  688. {
  689. $info_list_smt[$key]['retreattime'] = '<em class="t"></em>';
  690. }
  691. else
  692. {
  693. $info_list_smt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  694. }
  695. }
  696. $total = $this->fullorder->find_count($where);
  697. $total += $this->fullordersmt->find_count($where);
  698. $pagenum = ceil($total/$perpage);
  699. $over = $total-($start+$perpage);
  700. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_list_smt)));
  701. echo json_encode($rows);exit;
  702. }
  703. $this->data['express'] = $this->express->find_all();
  704. $this->_Template('whlabel_fout',$this->data);
  705. }
  706. //打印页面
  707. public function _print()
  708. {
  709. $post = $this->input->post(NULL, TRUE);
  710. if(isset($post['page']))
  711. {
  712. $page = $this->input->post('page',true);
  713. $perpage = $this->input->post('perpage',true);
  714. $timetk = $this->input->post('timetk',true);
  715. $timetj = $this->input->post('timetj',true);
  716. $shop = $this->input->post('shop',true);
  717. $print = $this->input->post('print',true);
  718. $express = $this->input->post('express',true);
  719. $waybill = $this->input->post('waybill',true);
  720. $printtype = $this->input->post('printtype',true);
  721. $orderinfo = $this->input->post('orderinfo',true);
  722. $number = $this->input->post('number',true);
  723. $type = $this->input->post('type',true);
  724. $lowe = $this->input->post('lowe',true);
  725. $timetk = strtotime($timetk);
  726. $timetj = strtotime($timetj);
  727. $where = "1=1";
  728. if($print == 3)
  729. {
  730. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = 3";
  731. }
  732. else
  733. {
  734. $where .= " and express != 0 and printtype > 0 and printtype < 3 and print = 2 and review > 4 and library = 1 and state = 207";
  735. }
  736. if($shop)
  737. {
  738. $where .= " and shop = '$shop'";
  739. }
  740. if($express)
  741. {
  742. $where .= " and express = '$express'";
  743. }
  744. if($printtype)
  745. {
  746. $where .= " and printtype = '$printtype'";
  747. }
  748. if($orderinfo)
  749. {
  750. $where .= " and orderinfo = '$orderinfo'";
  751. }
  752. if($number)
  753. {
  754. $where .= " and number = '$number'";
  755. }
  756. if($waybill)
  757. {
  758. $where .= " and waybill = '$waybill'";
  759. }
  760. if($type)
  761. {
  762. $where .= " and type = '$type'";
  763. }
  764. if($lowe)
  765. {
  766. $where .= " and shipremarks like '%$lowe%'";
  767. }
  768. //数据排序
  769. $order_str = ($print != 3)?"id desc":"printtime desc";
  770. if(empty($page))
  771. {
  772. $start = 0;
  773. $perpage = 1;
  774. }
  775. else
  776. {
  777. $start = ($page - 1)*$perpage;
  778. }
  779. //取得信息列表
  780. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  781. //格式化数据
  782. foreach ($info_list as $key=>$value)
  783. {
  784. $shop = $this->shop->read($value['shop']);
  785. $info_list[$key]['shop'] = $shop['shopname'];
  786. $express = $this->express->read($value['express']);
  787. if($express)
  788. {
  789. $info_list[$key]['express'] = $express['servicename'];
  790. }
  791. else
  792. {
  793. $info_list[$key]['express'] = '未选择';
  794. }
  795. if($value['printtime'] != 0)
  796. {
  797. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  798. }
  799. else
  800. {
  801. $info_list[$key]['printtime'] = '无';
  802. }
  803. if($value['print'] == 1)
  804. {
  805. $info_list[$key]['print'] = "禁止打印";
  806. }
  807. else if($value['print'] == 2)
  808. {
  809. $info_list[$key]['print'] = "未打印";
  810. }
  811. else if($value['print'] == 3)
  812. {
  813. $info_list[$key]['print'] = "已打印";
  814. }
  815. if($value['printtype'] == 1)
  816. {
  817. $info_list[$key]['printtype'] = "运单";
  818. }
  819. else if($value['printtype'] == 2)
  820. {
  821. $info_list[$key]['printtype'] = "发货单";
  822. }
  823. else if($value['printtype'] == 0)
  824. {
  825. $info_list[$key]['printtype'] = "未选择";
  826. }
  827. }
  828. $info_list_smt = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  829. //格式化数据
  830. foreach ($info_list_smt as $key=>$value)
  831. {
  832. $shop = $this->shop->read($value['shop']);
  833. $info_list_smt[$key]['shop'] = $shop['shopname'];
  834. $express = $this->express->read($value['express']);
  835. if($express)
  836. {
  837. $info_list_smt[$key]['express'] = $express['servicename'];
  838. }
  839. else
  840. {
  841. $info_list_smt[$key]['express'] = '未选择';
  842. }
  843. if($value['printtime'] != 0)
  844. {
  845. $info_list_smt[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  846. }
  847. else
  848. {
  849. $info_list_smt[$key]['printtime'] = '无';
  850. }
  851. if($value['print'] == 1)
  852. {
  853. $info_list_smt[$key]['print'] = "禁止打印";
  854. }
  855. else if($value['print'] == 2)
  856. {
  857. $info_list_smt[$key]['print'] = "未打印";
  858. }
  859. else if($value['print'] == 3)
  860. {
  861. $info_list_smt[$key]['print'] = "已打印";
  862. }
  863. if($value['printtype'] == 1)
  864. {
  865. $info_list_smt[$key]['printtype'] = "运单";
  866. }
  867. else if($value['printtype'] == 2)
  868. {
  869. $info_list_smt[$key]['printtype'] = "发货单";
  870. }
  871. else if($value['printtype'] == 0)
  872. {
  873. $info_list_smt[$key]['printtype'] = "未选择";
  874. }
  875. }
  876. $total = $this->fullorder->find_count($where);
  877. $total += $this->fullordersmt->find_count($where);
  878. $pagenum = ceil($total/$perpage);
  879. $over = $total-($start+$perpage);
  880. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_list_smt)));
  881. echo json_encode($rows);exit;
  882. }
  883. $this->_Template('whlabel_print',$this->data);
  884. }
  885. //打印
  886. public function _printing()
  887. {
  888. $post = $this->input->post(NULL, TRUE);
  889. if(isset($post['s']))
  890. {
  891. $v = $this->input->post('s');
  892. $va = explode(',',rtrim($v,','));
  893. $n = $this->input->post('n');
  894. $type = 3;$text = '';$time = time();
  895. if($va[$n] < 100000)
  896. {
  897. $fullorder_name = 'fullordersmt';
  898. }
  899. else
  900. {
  901. $fullorder_name = 'fullorder';
  902. }
  903. $fullorder = $this->$fullorder_name->read($va[$n]);
  904. if(isset($va[$n+1]))
  905. {
  906. $sf = $this->$fullorder_name->read($va[$n+1]);
  907. if($sf['printtype'] == 1 && $fullorder['printtype'] == 2)
  908. {
  909. sleep(9);
  910. }
  911. }
  912. $fullorder = $this->_text($fullorder);//获取所需信息
  913. $fullorder['printtime'] = date('Y-m-d H:i',$time);//打印用时间
  914. if($fullorder['printtype'] == 1 && $fullorder['library'] != 2)
  915. {
  916. if($fullorder['servicecode'] == "DHLGF")//如果打印过那么重新获取运单
  917. {
  918. sleep(3);
  919. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  920. if(isset($barcode['AirwayBillNumber']))
  921. {
  922. $bctime = date('Ymd',$time);
  923. $Hwaybill = $barcode['AirwayBillNumber'];
  924. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  925. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  926. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  927. {
  928. if($fullorder['waybill'] != "")//如果已有运单号
  929. {
  930. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  931. }
  932. else
  933. {
  934. $oldwaybill = $fullorder['oldwaybill'];
  935. }
  936. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  937. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill),$va[$n]))
  938. {
  939. $type = 1;
  940. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder);
  941. }
  942. }
  943. }
  944. else
  945. {
  946. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  947. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  948. }
  949. }
  950. else if($fullorder['servicecode'] == "USPS")
  951. {
  952. sleep(10);
  953. $barcode = $this->usps->get_data($fullorder);//获取DHL快递信息
  954. if(isset($barcode['LabelImage']))
  955. {
  956. $bctime = date('Ymd',$time);
  957. $Hwaybill = $barcode['BarcodeNumber'];
  958. $Hyd = $this->_pdf($barcode['LabelImage'],'y-'.$Hwaybill,$bctime);
  959. if(isset($barcode['LabelImage']) && isset($Hwaybill))
  960. {
  961. if($fullorder['waybill'] != "")//如果已有运单号
  962. {
  963. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  964. }
  965. else
  966. {
  967. $oldwaybill = $fullorder['oldwaybill'];
  968. }
  969. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  970. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill),$va[$n]))
  971. {
  972. $type = 1;
  973. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  974. }
  975. }
  976. }
  977. else
  978. {
  979. $failed = $barcode['Description'];//错误提示
  980. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  981. }
  982. }
  983. else
  984. {
  985. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  986. }
  987. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  988. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  989. }
  990. else if($fullorder['printtype'] == 2 && $fullorder['library'] != 2)
  991. {
  992. sleep(4);
  993. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  994. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3),$va[$n]))
  995. {
  996. $type = 2;
  997. $text = array('data'=>$fullorder);
  998. }
  999. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1000. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1001. }
  1002. else
  1003. {
  1004. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1005. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1006. }
  1007. }
  1008. }
  1009. public function _excel()
  1010. {
  1011. if(isset($_GET['fexcel']))
  1012. {
  1013. $dowid = $this->input->get('a');
  1014. $wid = "";
  1015. if($dowid != "")
  1016. {
  1017. $id_arr = explode(',',rtrim($dowid,','));
  1018. foreach ($id_arr as $v)
  1019. {
  1020. $wid .= " id = 0 or";
  1021. $wid .= " id = '$v' or";
  1022. }
  1023. $wid = " and".rtrim($wid,'or');
  1024. }
  1025. $t = $this->input->get('t',true);
  1026. $timetk = $this->input->get('timetk',true);
  1027. $timetj = $this->input->get('timetj',true);
  1028. $shop = $this->input->get('shop',true);
  1029. $source = $this->input->get('source',true);
  1030. $orderinfo = $this->input->get('orderinfo',true);
  1031. $number = $this->input->get('number',true);
  1032. $library = $this->input->get('library',true);
  1033. $waybill = $this->input->get('waybill',true);
  1034. $express = $this->input->get('express',true);
  1035. $timetk = strtotime($timetk);
  1036. $timetj = strtotime($timetj);
  1037. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1038. if($timetk && $timetj && $library == 2)
  1039. {
  1040. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1041. }
  1042. if($shop)
  1043. {
  1044. $where .= " and shop = '$shop'";
  1045. }
  1046. if($number)
  1047. {
  1048. $where .= " and number = '$number'";
  1049. }
  1050. if($library)
  1051. {
  1052. $where .= " and library = '$library'";
  1053. }
  1054. if($waybill)
  1055. {
  1056. $where .= " and waybill = '$waybill'";
  1057. }
  1058. if($express)
  1059. {
  1060. $where .= " and express = '$express'";
  1061. }
  1062. if($orderinfo)
  1063. {
  1064. $where .= " and orderinfo = '$orderinfo'";
  1065. }
  1066. //数据排序
  1067. $order_str = ($print != 3)?"id desc":"librarytime desc";
  1068. if(empty($page))
  1069. {
  1070. $start = 0;
  1071. $perpage = 1;
  1072. }
  1073. else
  1074. {
  1075. $start = ($page - 1)*$perpage;
  1076. }
  1077. //取得信息列表
  1078. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str);
  1079. //格式化数据
  1080. foreach ($info_list as $key=>$value)
  1081. {
  1082. $shop = $this->shop->read($value['shop']);
  1083. $info_list[$key]['shop'] = $shop['shopname'];
  1084. if($value['waybill'] == 0)
  1085. {
  1086. $info_list[$key]['waybill'] = "";
  1087. }
  1088. $express = $this->express->read($value['express']);
  1089. $info_list[$key]['express'] = $express['servicename'];
  1090. $warehouse = $this->warehouse->read($value['type']);
  1091. $info_list[$key]['type'] = $warehouse['title'];
  1092. if($value['print'] == 1)
  1093. {
  1094. $info_list[$key]['print'] = '不可打印';
  1095. }
  1096. else if($value['print'] == 2)
  1097. {
  1098. $info_list[$key]['print'] = '未打印';
  1099. }
  1100. else if($value['print'] == 3)
  1101. {
  1102. $info_list[$key]['print'] = '已打印';
  1103. }
  1104. if($value['library'] == 1)
  1105. {
  1106. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1107. }
  1108. else if($value['library'] == 2)
  1109. {
  1110. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1111. }
  1112. else if($value['library'] == 3)
  1113. {
  1114. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1115. }
  1116. if($value['librarytime'] == '0')
  1117. {
  1118. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1119. }
  1120. else
  1121. {
  1122. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1123. }
  1124. }
  1125. //取得信息列表
  1126. $info_list_smt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str);
  1127. //格式化数据
  1128. foreach ($info_list_smt as $key=>$value)
  1129. {
  1130. $shop = $this->shop->read($value['shop']);
  1131. $info_list_smt[$key]['shop'] = $shop['shopname'];
  1132. if($value['waybill'] == 0)
  1133. {
  1134. $info_list_smt[$key]['waybill'] = "";
  1135. }
  1136. $express = $this->express->read($value['express']);
  1137. $info_list_smt[$key]['express'] = $express['servicename'];
  1138. $warehouse = $this->warehouse->read($value['type']);
  1139. $info_list_smt[$key]['type'] = $warehouse['title'];
  1140. if($value['print'] == 1)
  1141. {
  1142. $info_list_smt[$key]['print'] = '不可打印';
  1143. }
  1144. else if($value['print'] == 2)
  1145. {
  1146. $info_list_smt[$key]['print'] = '未打印';
  1147. }
  1148. else if($value['print'] == 3)
  1149. {
  1150. $info_list_smt[$key]['print'] = '已打印';
  1151. }
  1152. if($value['library'] == 1)
  1153. {
  1154. $info_list_smt[$key]['library'] = '<em class="c">未出库</em>';
  1155. }
  1156. else if($value['library'] == 2)
  1157. {
  1158. $info_list_smt[$key]['library'] = '<em class="c">已出库</em>';
  1159. }
  1160. else if($value['library'] == 3)
  1161. {
  1162. $info_list_smt[$key]['library'] = '<em class="c">已退库</em>';
  1163. }
  1164. if($value['librarytime'] == '0')
  1165. {
  1166. $info_list_smt[$key]['librarytime'] = '<em class="t"></em>';
  1167. }
  1168. else
  1169. {
  1170. $info_list_smt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1171. }
  1172. }
  1173. $title = '订单出库-'.date('Ymd',time());
  1174. $titlename = "<table border=1>".$t."</table>";
  1175. $tail = "\n";
  1176. $filename = $title.".xls";
  1177. $this->excel->get_fz2(array_merge($info_list,$info_list_smt),$titlename,$filename,$tail);
  1178. }
  1179. }
  1180. public function _fhd($arg_array)
  1181. {
  1182. if(isset($arg_array[0]))
  1183. {
  1184. $fullorder = $this->fullorder->read($arg_array[0]);
  1185. $fullorder = $this->_text($fullorder);//获取所需信息
  1186. $this->data['data'] = $fullorder;
  1187. $this->_Template('apt_fhd',$this->data);
  1188. }
  1189. }
  1190. public function _fhdusa($arg_array)
  1191. {
  1192. if(isset($arg_array[0]))
  1193. {
  1194. if($arg_array[0] < 100000)
  1195. {
  1196. $fullorder_name = 'fullordersmt';
  1197. }
  1198. else
  1199. {
  1200. $fullorder_name = 'fullorder';
  1201. }
  1202. $fullorder = $this->$fullorder_name->read($arg_array[0]);
  1203. $fullorder = $this->_text($fullorder);//获取所需信息
  1204. $fullorder['printtime'] = date('Y-m-d H:i:s',$fullorder['printtime']);
  1205. $this->data['data'] = $fullorder;
  1206. $this->_Template('apt_fhdusa',$this->data);
  1207. }
  1208. }
  1209. public function _text($fullorder)
  1210. {
  1211. /** 发票地址信息暂时无用
  1212. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1213. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1214. $fullorder['baddress'][1] = $country['ename'];
  1215. **/
  1216. //获取所用相关信息
  1217. $warehouse = $this->warehouse->read($fullorder['type']);
  1218. $country = $this->country->read($fullorder['country']);//订单国家信息
  1219. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1220. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1221. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1222. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1223. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1224. $fullorder['country'] = $country['ename'];//订单国家名
  1225. $express = $this->express->read($fullorder['express']);
  1226. $fullorder['express'] = $express['servicename'];
  1227. $fullorder['account'] = $express['account'];
  1228. $fullorder['servicecode'] = $express['servicecode'];
  1229. $fullorder['time'] = date('Y-m-d',time());
  1230. $fullorder['times'] = date('Y-m-d H:i',time());
  1231. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1232. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1233. $shop = $this->shop->read($fullorder['shop']);
  1234. $fullorder['shop'] = $shop['shopname'];
  1235. return $fullorder;
  1236. }
  1237. public function _shop()
  1238. {
  1239. $post = $this->input->post(NULL, TRUE);
  1240. if(isset($post['shop']))
  1241. {
  1242. $shop = $this->shop->find_all();
  1243. echo json_encode(array('msg'=>$shop));exit;
  1244. }
  1245. }
  1246. public function _lowe()
  1247. {
  1248. $post = $this->input->post(NULL, TRUE);
  1249. if(isset($post['lowe']))
  1250. {
  1251. $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
  1252. echo json_encode(array('msg'=>$lowe));exit;
  1253. }
  1254. }
  1255. public function _express()
  1256. {
  1257. $post = $this->input->post(NULL, TRUE);
  1258. if(isset($post['express']))
  1259. {
  1260. $express = $this->express->find_all();
  1261. echo json_encode(array('msg'=>$express));exit;
  1262. }
  1263. }
  1264. public function _pdf($pdf,$title,$bctime)
  1265. {
  1266. $pdf_path = './data/pdf/'.$bctime.'/';
  1267. $file_base64 = $pdf;
  1268. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1269. $file_base64 = base64_decode($file_base64);
  1270. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1271. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1272. return $bctime;
  1273. }
  1274. }