Systemprint.php 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemprint 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_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_fullordertt','fullordertt');
  15. $this->load->_model('Model_outbound','outbound');
  16. $this->load->_model('Model_express','express');
  17. $this->load->_model('Model_shop','shop');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_country','country');
  20. $this->load->_model('Model_kdniao','kdniao');
  21. $this->load->_model('Model_notice','notice');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_dhlhz','dhlhz');
  24. $this->load->_model('Model_usps','usps');
  25. $this->load->_model('Model_fedex','fedex');
  26. $this->load->_model('Model_cne','cne');
  27. $this->load->_model('Model_fedex_cby','fedex_cby');
  28. $this->load->_model('Model_ups','ups');
  29. $this->load->_model('Model_ali','ali');
  30. $this->load->_model('Model_dpd','dpd');
  31. $this->load->_model('Model_hualeixw','hualeixw');
  32. $this->load->_model('Model_dpdxw','dpdxw');
  33. $this->load->_model('Model_shop','shop');
  34. $this->load->_model('Model_user','user');
  35. $this->load->_model('Model_whlabel','whlabel');
  36. $this->load->_model('Model_dpd_IOSS','dpdioss');
  37. $this->load->_model('Model_whlabelbarcodeprint','whlabelbarcodeprint');
  38. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  39. $this->load->_model('Model_yswaybill','yswaybill');
  40. $this->load->_model('Model_hualei','hualei');
  41. $this->load->_model('Model_apiyy','apiyy');
  42. $this->load->_model('Model_classid','classid');
  43. $this->load->helper('url');
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg,$arg_array)
  47. {
  48. if($arg == 'printing')//打印操作
  49. {
  50. $this->_printing();
  51. }
  52. else if($arg == 'exceldy')
  53. {
  54. $this->_exceldy($arg_array);
  55. }
  56. else if($arg == 'screen')
  57. {
  58. $this->_screen();
  59. }
  60. else if($arg == 'cz')
  61. {
  62. $this->_cz();
  63. }
  64. else if($arg == 'barcode')
  65. {
  66. $this->_barcode();
  67. }
  68. else if($arg == 'barcodedc')
  69. {
  70. $this->_barcodedc();
  71. }
  72. else if($arg == 'barcodedr')
  73. {
  74. $this->_barcodedr();
  75. }
  76. else if($arg == 'yswaybill')
  77. {
  78. $this->_yswaybill();
  79. }
  80. else
  81. {
  82. $this->_index();
  83. }
  84. }
  85. public function _cz()
  86. {
  87. if(isset($_SESSION['api']))
  88. {
  89. $user = $this->user->get_api($_SESSION['api']);
  90. $usp = $user;
  91. $shop = array();$type = array();
  92. $usersp = explode('|',trim($user['shop'],'|'));
  93. $userwh = explode('|',trim($user['warehouse'],'|'));
  94. foreach ($usersp as $v)
  95. {
  96. $shop[$v] = $v;
  97. }
  98. foreach ($userwh as $v)
  99. {
  100. $type[$v] = $v;
  101. }
  102. }
  103. $post = $this->input->post(NULL, TRUE);
  104. if(isset($post['cz']))
  105. {
  106. $cz = $this->input->post('cz');
  107. $cz = explode(',',trim($cz,','));
  108. $bj = $this->input->post('bj');
  109. $i = 0;$a = array();
  110. foreach ($cz as $v)
  111. {
  112. $dd = explode('-',$v);
  113. $fu = $dd[1];
  114. $thisdd = $this->$fu->read($dd[0]);
  115. if(isset($shop[$thisdd['shop']]) && isset($type[$thisdd['type']]))
  116. {
  117. $this->$fu->save(array('wigs'=>$bj),$dd[0]);
  118. $i++;
  119. }
  120. }
  121. if(count($cz) == $i)
  122. {
  123. echo json_encode(array('msg'=>'标记完成!','success'=>true));exit;
  124. }
  125. else if($i == '0')
  126. {
  127. echo json_encode(array('msg'=>'标记失败,请重试!','success'=>false));exit;
  128. }
  129. else
  130. {
  131. echo json_encode(array('msg'=>'有部分标记失败,请检查!','success'=>false));exit;
  132. }
  133. }
  134. }
  135. public function _screen()
  136. {
  137. $post = $this->input->post(NULL, TRUE);
  138. if(isset($_SESSION['api']))
  139. {
  140. $user = $this->user->get_api($_SESSION['api']);
  141. $usp = $user;
  142. $fgshop = "";$sid = "";$wid="";$wtype="";
  143. $usersp = explode('|',trim($user['shop'],'|'));
  144. $userwh = explode('|',trim($user['warehouse'],'|'));
  145. foreach ($usersp as $value)
  146. {
  147. $fgshop .= " shop = ".$value." or";
  148. $sid .= " id = ".$value." or";
  149. }
  150. foreach ($userwh as $value)
  151. {
  152. $wid .= " id = ".$value." or";
  153. $wtype .= " type = ".$value." or";
  154. }
  155. }
  156. if(isset($post['page']))
  157. {
  158. $page = $this->input->post('page',true);
  159. $perpage = $this->input->post('perpage',true);
  160. $wigs = $this->input->post('wigs',true);
  161. $shop = $this->input->post('shop',true);
  162. $orderinfo = $this->input->post('orderinfo',true);
  163. $number = $this->input->post('number',true);
  164. $so = $this->input->post('so',true);
  165. //$where = (isset($_SESSION['api']))?"mergeid != '1' and (state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  166. //$where .= " and express != 0 and printtype > 0 and printtype < 3 and print = 2 and review > 4 and library = 1 and type = 4";
  167. $where = (isset($_SESSION['api']))?"mergeid != '1' and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  168. if($shop)
  169. {
  170. $where .= " and shop = '$shop'";
  171. }
  172. if($orderinfo)
  173. {
  174. $where .= " and orderinfo = '$orderinfo'";
  175. }
  176. if($number)
  177. {
  178. $where .= " and number = '$number'";
  179. }
  180. if($wigs || $wigs == '0')
  181. {
  182. $where .= " and wigs = '$wigs'";
  183. }
  184. //数据排序
  185. $order_str = "id desc";
  186. if(empty($page))
  187. {
  188. $start = 0;
  189. $perpage = 1;
  190. }
  191. else
  192. {
  193. $start = ($page - 1)*$perpage;
  194. }
  195. $info_list = array();
  196. $info_listsmt = array();
  197. $info_listtt = array();
  198. $dlz = 0; $smt = 0; $tt = 0;
  199. //取得信息列表
  200. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  201. //格式化数据
  202. foreach ($info_list as $key=>$value)
  203. {
  204. $w = $this->fullorder->read($value['id']);
  205. if(stripos($w['issku'],'#pack') !== false)
  206. {
  207. unset($info_list[$key]);
  208. continue;
  209. }
  210. $info_list[$key]['id'] = $value['id'].'-fullorder';
  211. $shop = $this->shop->read($value['shop']);
  212. $info_list[$key]['shop'] = $shop['shopname'];
  213. }
  214. $dlz = $this->fullorder->find_count($where);
  215. $info_listtt = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  216. //格式化数据
  217. foreach ($info_listtt as $key=>$value)
  218. {
  219. $w = $this->fullordertt->read($value['id']);
  220. if(stripos($w['issku'],'#pack') !== false)
  221. {
  222. unset($info_list[$key]);
  223. continue;
  224. }
  225. $info_list[$key]['id'] = $value['id'].'-fullordertt';
  226. $shop = $this->shop->read($value['shop']);
  227. $info_list[$key]['shop'] = $shop['shopname'];
  228. }
  229. $tt = $this->fullordertt->find_count($where);
  230. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  231. //格式化数据
  232. foreach ($info_listsmt as $key=>$value)
  233. {
  234. $w = $this->fullordersmt->read($value['id']);
  235. if(stripos($w['sku'],'#pack') !== false)
  236. {
  237. unset($info_listsmt[$key]);
  238. continue;
  239. }
  240. $info_listsmt[$key]['id'] = $value['id'].'-fullordersmt';
  241. $shop = $this->shop->read($value['shop']);
  242. $info_listsmt[$key]['shop'] = $shop['shopname'];
  243. }
  244. $smt += $this->fullordersmt->find_count($where);
  245. //$total += $this->fullorder_smt->find_count($where);
  246. $total = $dlz+$smt+$tt;
  247. $rows = array_merge($info_list,$info_listtt,$info_listsmt);
  248. //$rows = array_slice($rows,$start,$perpage);
  249. $pagenum = ceil($total/$perpage);
  250. $over = $total-($start+$perpage);
  251. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));//array_merge($info_list,$info_list_smt,$info_listsmt)
  252. echo json_encode($rows);exit;
  253. }
  254. if(isset($_SESSION['api']))
  255. {
  256. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  257. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  258. $this->data['wlshop'] = $wlshop;
  259. $this->data['warehouse'] = $warehouse;
  260. }
  261. $this->_Template('systemprint_screen',$this->data);
  262. }
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if(isset($_SESSION['api']))
  267. {
  268. $user = $this->user->get_api($_SESSION['api']);
  269. $usp = $user;
  270. $fgshop = "";$sid = "";$wid="";$wtype="";
  271. $usersp = explode('|',trim($user['shop'],'|'));
  272. $userwh = explode('|',trim($user['warehouse'],'|'));
  273. foreach ($usersp as $value)
  274. {
  275. $fgshop .= " shop = ".$value." or";
  276. $sid .= " id = ".$value." or";
  277. }
  278. foreach ($userwh as $value)
  279. {
  280. $wid .= " id = ".$value." or";
  281. $wtype .= " type = ".$value." or";
  282. }
  283. }
  284. if(isset($post['page']))
  285. {
  286. $page = $this->input->post('page',true);
  287. $perpage = $this->input->post('perpage',true);
  288. $timetk = $this->input->post('timetk',true);
  289. $timetj = $this->input->post('timetj',true);
  290. $shop = $this->input->post('shop',true);
  291. $print = $this->input->post('print',true);
  292. $express = $this->input->post('express',true);
  293. $waybill = $this->input->post('waybill',true);
  294. $printtype = $this->input->post('printtype',true);
  295. $orderinfo = $this->input->post('orderinfo',true);
  296. $number = $this->input->post('number',true);
  297. $type = $this->input->post('type',true);
  298. $lowe = $this->input->post('lowe',true);
  299. $info = $this->input->post('info',true);
  300. $ji = $this->input->post('ji',true);
  301. $so = $this->input->post('so',true);
  302. $ckfl = $this->input->post('ckfl',true);
  303. $sfxh = $this->input->post('sfxh',true);
  304. $timetk = strtotime($timetk);
  305. $timetj = strtotime($timetj);
  306. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  307. if($print == 3)
  308. {
  309. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  310. }
  311. else
  312. {
  313. $where .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 and reviewtime > '".(time() - 30*24*3600)."'";
  314. }
  315. if($shop)
  316. {
  317. $where .= " and shop = '$shop'";
  318. }
  319. if($express)
  320. {
  321. $where .= " and express = '$express'";
  322. }
  323. if($printtype)
  324. {
  325. $where .= " and printtype = '$printtype'";
  326. }
  327. if($orderinfo)
  328. {
  329. $where .= " and orderinfo = '$orderinfo'";
  330. }
  331. if($number)
  332. {
  333. $where .= " and number = '$number'";
  334. }
  335. if($waybill)
  336. {
  337. $where .= " and waybill = '$waybill'";
  338. }
  339. if($type)
  340. {
  341. $where .= " and type = '$type'";
  342. }
  343. else
  344. {
  345. $where .= " and type != '16'";
  346. }
  347. /**
  348. if($type)
  349. {
  350. if($type != '4')
  351. {
  352. $where .= " and type = '$type'";
  353. $where2 = '';
  354. $where3 = '';
  355. }
  356. else
  357. {
  358. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  359. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  360. }
  361. $where_a = "";
  362. $where_b = "";
  363. }
  364. else
  365. {
  366. $where .= " and type != '4'";
  367. $where_a = "(";
  368. $where_b = ")";
  369. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  370. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  371. }
  372. **/
  373. if($lowe)
  374. {
  375. $where .= " and fpdata like '%-$lowe-%'";
  376. }
  377. if($ji)
  378. {
  379. $where .= " and shipremarks like '%急%'";
  380. }
  381. if($so)
  382. {
  383. $where .= " and shipremarks like '%$so%'";
  384. }
  385. if($ckfl)
  386. {
  387. $where .= " and ckfl = '$ckfl'";
  388. }
  389. if($sfxh != '')
  390. {
  391. $where .= " and sfxh = '$sfxh'";
  392. }
  393. //数据排序
  394. $order_str = ($print != 3)?"id desc":"printtime desc";
  395. if(empty($page))
  396. {
  397. $start = 0;
  398. $perpage = 1;
  399. }
  400. else
  401. {
  402. $start = ($page - 1)*$perpage;
  403. }
  404. $info_list = array();
  405. $info_listtt = array();
  406. $info_listsmt = array();
  407. $dlz = 0; $smt = 0; $tt = 0;
  408. //取得信息列表
  409. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  410. //格式化数据
  411. foreach ($info_list as $key=>$value)
  412. {
  413. $info_list[$key]['id'] = $value['id'].'-fullorder';
  414. $shop = $this->shop->read($value['shop']);
  415. $info_list[$key]['shop'] = $shop['shopname'];
  416. $express = $this->express->read($value['express']);
  417. if($express)
  418. {
  419. $info_list[$key]['express'] = $express['servicename'];
  420. }
  421. else
  422. {
  423. $info_list[$key]['express'] = '未选择';
  424. }
  425. if($value['printtime'] != 0)
  426. {
  427. $info_list[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  428. }
  429. else
  430. {
  431. $info_list[$key]['printtime'] = '无';
  432. }
  433. if($value['print'] == 1)
  434. {
  435. $info_list[$key]['print'] = "禁止打印";
  436. }
  437. else if($value['print'] == 2)
  438. {
  439. $info_list[$key]['print'] = "未打印";
  440. }
  441. else if($value['print'] == 3)
  442. {
  443. $info_list[$key]['print'] = "已打印";
  444. }
  445. if($value['printtype'] == 1)
  446. {
  447. $info_list[$key]['printtype'] = "运单";
  448. }
  449. else if($value['printtype'] == 2)
  450. {
  451. $info_list[$key]['printtype'] = "发货单";
  452. }
  453. else if($value['printtype'] == 0)
  454. {
  455. $info_list[$key]['printtype'] = "未选择";
  456. }
  457. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  458. }
  459. $dlz = $this->fullorder->find_count($where);
  460. //取得信息列表
  461. $info_listtt = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  462. //格式化数据
  463. foreach ($info_listtt as $key=>$value)
  464. {
  465. $info_listtt[$key]['id'] = $value['id'].'-fullordertt';
  466. $shop = $this->shop->read($value['shop']);
  467. $info_listtt[$key]['shop'] = $shop['shopname'];
  468. $express = $this->express->read($value['express']);
  469. if($express)
  470. {
  471. $info_listtt[$key]['express'] = $express['servicename'];
  472. }
  473. else
  474. {
  475. $info_listtt[$key]['express'] = '未选择';
  476. }
  477. if($value['printtime'] != 0)
  478. {
  479. $info_listtt[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  480. }
  481. else
  482. {
  483. $info_listtt[$key]['printtime'] = '无';
  484. }
  485. if($value['print'] == 1)
  486. {
  487. $info_listtt[$key]['print'] = "禁止打印";
  488. }
  489. else if($value['print'] == 2)
  490. {
  491. $info_listtt[$key]['print'] = "未打印";
  492. }
  493. else if($value['print'] == 3)
  494. {
  495. $info_listtt[$key]['print'] = "已打印";
  496. }
  497. if($value['printtype'] == 1)
  498. {
  499. $info_listtt[$key]['printtype'] = "运单";
  500. }
  501. else if($value['printtype'] == 2)
  502. {
  503. $info_listtt[$key]['printtype'] = "发货单";
  504. }
  505. else if($value['printtype'] == 0)
  506. {
  507. $info_listtt[$key]['printtype'] = "未选择";
  508. }
  509. $info_listtt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  510. }
  511. $tt = $this->fullordertt->find_count($where);
  512. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  513. //格式化数据
  514. foreach ($info_listsmt as $key=>$value)
  515. {
  516. $info_listsmt[$key]['id'] = $value['id'].'-fullordersmt';
  517. $shop = $this->shop->read($value['shop']);
  518. $info_listsmt[$key]['shop'] = $shop['shopname'];
  519. $express = $this->express->read($value['express']);
  520. if($express)
  521. {
  522. $info_listsmt[$key]['express'] = $express['servicename'];
  523. }
  524. else
  525. {
  526. $info_listsmt[$key]['express'] = '未选择';
  527. }
  528. if($value['printtime'] != 0)
  529. {
  530. $info_listsmt[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  531. }
  532. else
  533. {
  534. $info_listsmt[$key]['printtime'] = '无';
  535. }
  536. if($value['print'] == 1)
  537. {
  538. $info_listsmt[$key]['print'] = "禁止打印";
  539. }
  540. else if($value['print'] == 2)
  541. {
  542. $info_listsmt[$key]['print'] = "未打印";
  543. }
  544. else if($value['print'] == 3)
  545. {
  546. $info_listsmt[$key]['print'] = "已打印";
  547. }
  548. if($value['printtype'] == 1)
  549. {
  550. $info_listsmt[$key]['printtype'] = "运单";
  551. }
  552. else if($value['printtype'] == 2)
  553. {
  554. $info_listsmt[$key]['printtype'] = "发货单";
  555. }
  556. else if($value['printtype'] == 0)
  557. {
  558. $info_listsmt[$key]['printtype'] = "未选择";
  559. }
  560. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  561. }
  562. $smt += $this->fullordersmt->find_count($where);
  563. //$total += $this->fullorder_smt->find_count($where);
  564. $total = $dlz+$smt+$tt;
  565. $rows = array_merge($info_list,$info_listtt,$info_listsmt);
  566. //$rows = array_slice($rows,$start,$perpage);
  567. $pagenum = ceil($total/$perpage);
  568. $over = $total-($start+$perpage);
  569. $tmp = array();
  570. if($print == 3)
  571. {
  572. foreach ($rows as $key => $val)
  573. {
  574. $tmp[$key] = $val['printtime'];
  575. }
  576. array_multisort($tmp,SORT_DESC,$rows);
  577. }
  578. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  579. echo json_encode($rows);exit;
  580. }
  581. if(isset($_SESSION['api']))
  582. {
  583. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  584. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  585. $this->data['wlshop'] = $wlshop;
  586. $this->data['warehouse'] = $warehouse;
  587. }
  588. $this->_Template('systemprint',$this->data);
  589. }
  590. //打印
  591. public function _printing()
  592. {
  593. $post = $this->input->post(NULL, TRUE);
  594. if(isset($post['s']))
  595. {
  596. $v = $this->input->post('s');
  597. $va = explode(',',rtrim($v,','));
  598. $n = $this->input->post('n');
  599. $tf = $this->input->post('tf');
  600. $type = 3;$text = array();$text['data'] = array();$time = time();
  601. $pd = explode('-',$va[$n]);
  602. $va[$n] = $pd[0];
  603. $fullorder_name = $pd[1];
  604. $fullorder = $this->$fullorder_name->read($va[$n]);
  605. if(isset($va[$n+1]))
  606. {
  607. $xyz = explode('-',$va[$n+1]);
  608. $sf = $this->$fullorder_name->read($xyz[0]);
  609. }
  610. if($tf)
  611. {
  612. if($tf == '2' && ($fullorder['print'] == 3 || $fullorder['printtime'] > 0))
  613. {
  614. echo json_encode(array('msg'=>$fullorder['number'].' 此订单已打印,请提交给技术处理','success'=>false));exit;
  615. }
  616. }
  617. if($fullorder['print'] == 1)
  618. {
  619. echo json_encode(array('msg'=>$fullorder['number'].' 店员已操作禁止打印,请刷新当前程序','success'=>false));exit;
  620. }
  621. if($fullorder['print'] == 2 && $fullorder['printtime'] > 0)
  622. {
  623. echo json_encode(array('msg'=>$fullorder['number'].' 状态异常,请提交给技术处理','success'=>false));exit;
  624. }
  625. $fullorder = $this->_text($fullorder);//获取所需信息
  626. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  627. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  628. $pdfnum = 1;//PDF打印几遍
  629. if($fullorder['printtype'] == 1 && $fullorder['library'] != 2)// && $fullorder['library'] != 2
  630. {
  631. if($fullorder['printcode'] == "DHL")//如果打印过那么重新获取运单
  632. {
  633. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  634. if(isset($barcode['AirwayBillNumber']))
  635. {
  636. $bctime = date('Ymd',$time);
  637. $Hwaybill = $barcode['AirwayBillNumber'];
  638. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  639. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  640. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  641. {
  642. if($fullorder['waybill'] != "")
  643. {
  644. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  645. }
  646. else
  647. {
  648. $oldwaybill = $fullorder['oldwaybill'];
  649. }
  650. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  651. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  652. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  653. {
  654. $type = 1;
  655. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  656. }
  657. }
  658. }
  659. else
  660. {
  661. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  662. {
  663. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  664. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  665. }
  666. }
  667. }
  668. else if($fullorder['printcode'] == "DHLUSA")//DHL9610
  669. {
  670. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  671. if(isset($barcode['AirwayBillNumber']))
  672. {
  673. $bctime = date('Ymd',$time);
  674. $Hwaybill = $barcode['AirwayBillNumber'];
  675. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  676. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  677. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  678. {
  679. if($fullorder['waybill'] != "")
  680. {
  681. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  682. }
  683. else
  684. {
  685. $oldwaybill = $fullorder['oldwaybill'];
  686. }
  687. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  688. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  689. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  690. {
  691. $type = 1;
  692. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  693. }
  694. }
  695. }
  696. else
  697. {
  698. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  699. {
  700. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  701. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  702. }
  703. }
  704. /**
  705. if(isset($barcode['AirwayBillNumber']))
  706. {
  707. $bctime = date('Ymd',$time);
  708. $Hwaybill = $barcode['AirwayBillNumber'];
  709. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  710. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  711. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  712. {
  713. $fullorder['waybill'] = $Hwaybill;
  714. $sb = $this->dhl->get_data_9610($fullorder);
  715. if($sb != 1)
  716. {
  717. $this->$fullorder_name->save(array('print'=>1,'failed'=>$sb),$va[$n]);
  718. }
  719. else
  720. {
  721. if($fullorder['waybill'] != "")
  722. {
  723. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  724. }
  725. else
  726. {
  727. $oldwaybill = $fullorder['oldwaybill'];
  728. }
  729. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  730. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  731. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  732. {
  733. $type = 1;
  734. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  735. }
  736. }
  737. }
  738. }
  739. else
  740. {
  741. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  742. {
  743. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  744. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  745. }
  746. }
  747. **/
  748. }
  749. else if($fullorder['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  750. {
  751. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  752. if($barcode['c'] == 1)
  753. {
  754. $bctime = date('Ymd',$time);
  755. $Hwaybill = $barcode['data']['waybill'];
  756. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  757. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  758. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  759. {
  760. if($fullorder['waybill'] != "")
  761. {
  762. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  763. }
  764. else
  765. {
  766. $oldwaybill = $fullorder['oldwaybill'];
  767. }
  768. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  769. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  770. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  771. {
  772. $type = 1;
  773. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  774. }
  775. }
  776. }
  777. else
  778. {
  779. if(isset($barcode['data']))
  780. {
  781. $failed = $barcode['data'];
  782. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  783. }
  784. }
  785. }
  786. else if($fullorder['printcode'] == "USPS")
  787. {
  788. $barcode = $this->usps->get_data($fullorder);
  789. if(isset($barcode['LabelImage']))
  790. {
  791. $bctime = date('Ymd',$time);
  792. $Hwaybill = $barcode['BarcodeNumber'];
  793. $Hyd = $this->_pdf($barcode['LabelImage'],'y-'.$Hwaybill,$bctime);
  794. if(isset($barcode['LabelImage']) && isset($Hwaybill))
  795. {
  796. if($fullorder['waybill'] != "")
  797. {
  798. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  799. }
  800. else
  801. {
  802. $oldwaybill = $fullorder['oldwaybill'];
  803. }
  804. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  805. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  806. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime,'freight'=>$barcode['Postage']),$va[$n]))
  807. {
  808. $type = 1;
  809. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  810. }
  811. }
  812. }
  813. else if(isset($barcode['Description']))
  814. {
  815. $failed = $barcode['Description'];//错误提示
  816. if($failed != 'false')
  817. {
  818. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  819. }
  820. }
  821. else
  822. {
  823. $failed = json_encode($barcode);//错误提示
  824. if($failed != 'false')
  825. {
  826. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  827. }
  828. }
  829. }
  830. else if($fullorder['printcode'] == "FEDEXGF")//官方FEDEX接口
  831. {
  832. $barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  833. if($barcode['x'] == 1)
  834. {
  835. $bctime = date('Ymd',$time);
  836. $Hwaybill = $barcode['waybill'];
  837. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  838. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  839. if(isset($barcode['label']) && isset($Hwaybill))
  840. {
  841. if($fullorder['waybill'] != "")
  842. {
  843. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  844. }
  845. else
  846. {
  847. $oldwaybill = $fullorder['oldwaybill'];
  848. }
  849. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  850. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  851. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  852. {
  853. $type = 1;
  854. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  855. }
  856. }
  857. }
  858. else
  859. {
  860. if(isset($barcode['Description']))
  861. {
  862. if($barcode['Description'] != 'FEDEX_INTERNATIONAL_PRIORITY is not supported for the origin and destination pair.')
  863. {
  864. $failed = $barcode['Description'];//错误提示
  865. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  866. }
  867. else
  868. {
  869. $failed = 'FEDEX返回不正确信息';//错误提示
  870. }
  871. }
  872. }
  873. }
  874. else if($fullorder['printcode'] == "FEDEXCBY")//官方FEDEX接口许昌玉美桥
  875. {
  876. $barcode = $this->fedex_cby->get_data($fullorder);//获取联邦快递信息
  877. if($barcode['x'] == 1)
  878. {
  879. $bctime = date('Ymd',$time);
  880. $Hwaybill = $barcode['waybill'];
  881. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  882. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  883. if(isset($barcode['label']) && isset($Hwaybill))
  884. {
  885. if($fullorder['waybill'] != "")
  886. {
  887. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  888. }
  889. else
  890. {
  891. $oldwaybill = $fullorder['oldwaybill'];
  892. }
  893. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  894. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  895. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  896. {
  897. $type = 1;
  898. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  899. }
  900. }
  901. }
  902. else
  903. {
  904. if(isset($barcode['Description']))
  905. {
  906. $failed = $barcode['Description'];//错误提示
  907. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  908. }
  909. }
  910. }
  911. else if($fullorder['printcode'] == "DPD" || $fullorder['printcode'] == "FTFEDEX")
  912. {
  913. $barcode = $this->dpd->get_data($fullorder);//获取联邦快递信息
  914. if($barcode['x'] == 1)
  915. {
  916. $bctime = date('Ymd',$time);
  917. $Hwaybill = $barcode['waybill'];
  918. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  919. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  920. {
  921. if($fullorder['waybill'] != "")
  922. {
  923. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  924. }
  925. else
  926. {
  927. $oldwaybill = $fullorder['oldwaybill'];
  928. }
  929. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  930. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  931. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  932. {
  933. $type = 1;
  934. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  935. }
  936. }
  937. else if(isset($barcode['yd']) && $Hwaybill == '' && $barcode['yd'] == '')
  938. {
  939. $oldwaybill = $fullorder['oldwaybill'];
  940. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  941. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  942. {
  943. $type = 2;
  944. }
  945. }
  946. else
  947. {
  948. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  949. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  950. }
  951. }
  952. else
  953. {
  954. $failed = $barcode['Description'];//错误提示
  955. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  956. }
  957. }
  958. else if($fullorder['printcode'] == "DPDIOSS" || $fullorder['printcode'] == "FTFEDEXIOSS")
  959. {
  960. $barcode = $this->dpdioss->get_data($fullorder);//获取联邦快递信息
  961. /** 正常
  962. if($barcode['x'] == 1)
  963. {
  964. $bctime = date('Ymd',$time);
  965. $Hwaybill = $barcode['waybill'];
  966. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  967. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  968. {
  969. if($fullorder['waybill'] != "")
  970. {
  971. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  972. }
  973. else
  974. {
  975. $oldwaybill = $fullorder['oldwaybill'];
  976. }
  977. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  978. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  979. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  980. {
  981. $type = 1;
  982. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  983. }
  984. }
  985. else
  986. {
  987. $failed = '平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  988. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  989. }
  990. }
  991. **/
  992. //临时开始
  993. if($barcode['x'] == 1)
  994. {
  995. $bctime = date('Ymd',$time);
  996. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  997. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  998. {
  999. $type = 2;
  1000. }
  1001. }
  1002. //临时结束
  1003. else
  1004. {
  1005. $failed = $barcode['Description'];//错误提示
  1006. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1007. }
  1008. }
  1009. // 只获取运单号不打印运单
  1010. else if($fullorder['printcode'] == "DPDXW" || $fullorder['printcode'] == "UKDHLXW" || $fullorder['printcode'] == "FTFEDEXXW")
  1011. {
  1012. $barcode = $this->dpdxw->get_data($fullorder);//获取联邦快递信息
  1013. if($barcode['x'] == 1)
  1014. {
  1015. $bctime = date('Ymd',$time);
  1016. $Hwaybill = $barcode['waybill'];
  1017. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1018. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1019. {
  1020. if($fullorder['waybill'] != "")
  1021. {
  1022. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1023. }
  1024. else
  1025. {
  1026. $oldwaybill = $fullorder['oldwaybill'];
  1027. }
  1028. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1029. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1030. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1031. {
  1032. $type = 1;
  1033. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1034. }
  1035. }
  1036. else
  1037. {
  1038. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1039. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1040. }
  1041. }
  1042. else
  1043. {
  1044. $failed = $barcode['Description'];//错误提示
  1045. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1046. }
  1047. }
  1048. /**
  1049. // 此DPD接口暂时不用
  1050. // DPD只获取运单号不打印运单
  1051. else if($fullorder['printcode'] == "DPD")
  1052. {
  1053. if($fullorder['zhou'] == '12')//欧洲
  1054. {
  1055. if($fullorder_name == 'fullordersmt')//速卖通9610
  1056. {
  1057. $fullorder['ysfs'] == '1921';
  1058. }
  1059. else if($fullorder_name == 'fullorder')//独立站9610
  1060. {
  1061. $fullorder['ysfs'] == '2021';
  1062. }
  1063. }
  1064. else if($fullorder['zhou'] == '13')//非洲
  1065. {
  1066. $fullorder['ysfs'] == '1881';
  1067. }
  1068. //$fullorder['ysfs'] == '2041';//欧洲全程不包双清、税
  1069. //$fullorder['ysfs'] == '1981';//欧洲速卖通非9610
  1070. //$fullorder['ysfs'] == '2001';//欧洲独立站非9610
  1071. $barcode = $this->dpd->get_data($fullorder);//获取信息
  1072. if($barcode['x'] == 1)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1073. {
  1074. $bctime = date('Ymd',$time);
  1075. $Hwaybill = $barcode['waybill'];//运单号
  1076. if($fullorder['waybill'] != "")
  1077. {
  1078. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1079. }
  1080. else
  1081. {
  1082. $oldwaybill = $fullorder['oldwaybill'];
  1083. }
  1084. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1085. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1086. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1087. {
  1088. $type = 2;
  1089. }
  1090. }
  1091. else
  1092. {
  1093. $failed = $barcode['Description'];
  1094. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1095. }
  1096. }
  1097. **/
  1098. /** 阿里仓联邦不打印运单模式
  1099. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1100. {
  1101. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1102. $barcode = $this->ali->get_data($fullorder);//获取DHL快递信息
  1103. //$Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1104. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1105. if($barcode['a'] == 2)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1106. {
  1107. $bctime = date('Ymd',$time);
  1108. $Hwaybill = $barcode['number'];//运单号
  1109. //$this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//目前不需要打印标签
  1110. if($fullorder['waybill'] != "")
  1111. {
  1112. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1113. }
  1114. else
  1115. {
  1116. $oldwaybill = $fullorder['oldwaybill'];
  1117. }
  1118. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1119. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1120. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1121. {
  1122. $type = 2;
  1123. }
  1124. }
  1125. else
  1126. {
  1127. $failed = $barcode['m'];
  1128. //$failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1129. //$failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1130. if($fullorder['print'] == 3)
  1131. {
  1132. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1133. }
  1134. else
  1135. {
  1136. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1137. }
  1138. }
  1139. }
  1140. **/
  1141. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1142. {
  1143. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1144. $barcode = $this->ali->get_data($fullorder);//获取快递信息
  1145. $Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1146. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1147. if($barcode['a'] == 2 && $Hyd['a'] == 2)
  1148. {
  1149. $bctime = date('Ymd',$time);
  1150. $Hwaybill = $barcode['number'];//运单号
  1151. $this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//上传PDF
  1152. if($fullorder['waybill'] != "")
  1153. {
  1154. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1155. }
  1156. else
  1157. {
  1158. $oldwaybill = $fullorder['oldwaybill'];
  1159. }
  1160. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1161. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1162. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1163. {
  1164. $type = 1;
  1165. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1166. }
  1167. }
  1168. else
  1169. {
  1170. //$failed = $barcode['m'];
  1171. $failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1172. $failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1173. if($fullorder['print'] == 3)
  1174. {
  1175. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1176. }
  1177. else
  1178. {
  1179. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1180. }
  1181. }
  1182. }
  1183. else if($fullorder['printcode'] == "UPS")//接口
  1184. {
  1185. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1186. if($barcode['x'] == 1)
  1187. {
  1188. $bctime = date('Ymd',$time);
  1189. $Hwaybill = $barcode['waybill'];
  1190. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1191. if(isset($barcode['label']) && isset($Hwaybill))
  1192. {
  1193. if($fullorder['waybill'] != "")
  1194. {
  1195. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1196. }
  1197. else
  1198. {
  1199. $oldwaybill = $fullorder['oldwaybill'];
  1200. }
  1201. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1202. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1203. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1204. {
  1205. $type = 1;
  1206. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1207. }
  1208. }
  1209. }
  1210. else
  1211. {
  1212. $failed = $barcode['Description'];//错误提示
  1213. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1214. }
  1215. }
  1216. else if($fullorder['printcode'] == "DPEX" || $fullorder['printcode'] == "CNE")//官方FEDEX接口
  1217. {
  1218. if($fullorder['waybillid'] != '')
  1219. {
  1220. $del = $this->cne->get_del($fullorder['waybillid']);
  1221. }
  1222. $barcode = $this->cne->get_data($fullorder);
  1223. if($barcode['x'] == 1)
  1224. {
  1225. $bctime = date('Ymd',$time);
  1226. $Hwaybill = $barcode['waybill'];
  1227. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1228. $Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1229. if(isset($barcode['yd']) && isset($Hwaybill))
  1230. {
  1231. if($fullorder['waybill'] != "")
  1232. {
  1233. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1234. }
  1235. else
  1236. {
  1237. $oldwaybill = $fullorder['oldwaybill'];
  1238. }
  1239. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1240. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1241. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1242. {
  1243. $type = 1;
  1244. $pdfnum = ($fullorder['printcode'] == "DPEX")?2:1;
  1245. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1246. }
  1247. }
  1248. }
  1249. else
  1250. {
  1251. $failed = $barcode['Description'];//错误提示
  1252. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1253. }
  1254. }
  1255. else if($fullorder['printcode'] == "HUALEIXW-FEDEX" || $fullorder['printcode'] == "HUALEIXW-GES-GB-A" || $fullorder['printcode'] == "HUALEIXW-GES-EU9610" || $fullorder['printcode'] == "HUALEIXW-TNT" || $fullorder['printcode'] == "HUALEIXW-FEDEX" || $fullorder['printcode'] == "HUALEIXW-UPS" || $fullorder['printcode'] == "HUALEIXW-FEDEX-EUROPE" || $fullorder['printcode'] == "HUALEIXW-USPS")
  1256. {
  1257. $barcode = $this->hualeixw->get_data($fullorder);
  1258. $bctime = date('Ymd',$time);
  1259. if(!isset($barcode['x']))
  1260. {
  1261. print_r($barcode);exit;
  1262. }
  1263. if($barcode['x'] == 1)
  1264. {
  1265. if($barcode['ys'] == 1)
  1266. {
  1267. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1268. {
  1269. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1270. }
  1271. $bctime = date('Ymd',$time);
  1272. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1273. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1274. {
  1275. $type = 2;
  1276. }
  1277. }
  1278. else
  1279. {
  1280. $Hwaybill = $barcode['waybill'];
  1281. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1282. if(isset($barcode['label']) && isset($Hwaybill))
  1283. {
  1284. if($fullorder['waybill'] != "")
  1285. {
  1286. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1287. }
  1288. else
  1289. {
  1290. $oldwaybill = $fullorder['oldwaybill'];
  1291. }
  1292. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1293. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1294. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1295. {
  1296. if($fullorder['printcode'] == "HUALEIXW-FEDEX")
  1297. {
  1298. $type = 5;
  1299. }
  1300. else
  1301. {
  1302. $type = 2;
  1303. }
  1304. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1305. }
  1306. }
  1307. }
  1308. }
  1309. else
  1310. {
  1311. $failed = $barcode['Description'];//错误提示
  1312. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1313. }
  1314. /**
  1315. if($barcode['x'] == 1)
  1316. {
  1317. if($barcode['ys'] == 1)
  1318. {
  1319. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1320. {
  1321. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1322. }
  1323. }
  1324. $bctime = date('Ymd',$time);
  1325. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1326. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','waybill'=>$barcode['waybill'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1327. {
  1328. $type = 2;
  1329. }
  1330. }
  1331. else
  1332. {
  1333. $failed = $barcode['Description'];//错误提示
  1334. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1335. }
  1336. **/
  1337. }
  1338. else if($fullorder['printcode'] == "HUALEI-FEDEX" || $fullorder['printcode'] == "HUALEI-ARAMEX-S" || $fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-GES-EU" || $fullorder['printcode'] == "HUALEI-DHL-A1" || $fullorder['printcode'] == "HUALEI-WMS")
  1339. {
  1340. $barcode = $this->hualei->get_data($fullorder);
  1341. $bctime = date('Ymd',$time);
  1342. if(!isset($barcode['x']))
  1343. {
  1344. print_r($barcode);exit;
  1345. }
  1346. if($barcode['x'] == 1)
  1347. {
  1348. if($barcode['ys'] == 1)
  1349. {
  1350. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualei','number'=>$fullorder['number'])))
  1351. {
  1352. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1353. }
  1354. $bctime = date('Ymd',$time);
  1355. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1356. $waybill2 = '';
  1357. if(isset($barcode['waybill2']))
  1358. {
  1359. $waybill2 = $barcode['waybill2'];
  1360. }
  1361. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1362. {
  1363. $type = 2;
  1364. }
  1365. }
  1366. else
  1367. {
  1368. $Hwaybill = $barcode['waybill'];
  1369. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1370. if(isset($barcode['label']) && isset($Hwaybill))
  1371. {
  1372. if($fullorder['waybill'] != "")
  1373. {
  1374. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1375. }
  1376. else
  1377. {
  1378. $oldwaybill = $fullorder['oldwaybill'];
  1379. }
  1380. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1381. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1382. $waybill2 = '';
  1383. if(isset($barcode['waybill2']))
  1384. {
  1385. $waybill2 = $barcode['waybill2'];
  1386. }
  1387. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1388. {
  1389. if($fullorder['printcode'] == "HUALEI-FEDEX")
  1390. {
  1391. $type = 5;
  1392. }
  1393. else if($fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-ARAMEX-S")
  1394. {
  1395. $type = 1;
  1396. }
  1397. else
  1398. {
  1399. $type = 2;
  1400. }
  1401. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1402. }
  1403. }
  1404. }
  1405. }
  1406. else
  1407. {
  1408. $failed = $barcode['Description'];//错误提示
  1409. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1410. }
  1411. }
  1412. else
  1413. {
  1414. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  1415. }
  1416. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1417. {
  1418. $text['name'] = '速卖通';
  1419. }
  1420. else if($fullorder_name == 'fullordertt')
  1421. {
  1422. $text['name'] = 'TikTok';
  1423. }
  1424. else
  1425. {
  1426. $text['name'] = '独立站';
  1427. }
  1428. $text['express'] = $fullorder['express'];
  1429. $text['country'] = $fullorder['country'];
  1430. $text['orderinfo'] = $fullorder['orderinfo'];
  1431. $text['number'] = $fullorder['number'];
  1432. $text['shipremarks'] = $fullorder['shipremarks'];
  1433. $text['ts'] = $fullorder['ts'];
  1434. $text['time'] = $fullorder['times'];
  1435. $text['printnumber'] = $fullorder['printnumber'];
  1436. $text['pdfnum'] = $pdfnum;
  1437. $text['pt'] = $fullorder['pt'];
  1438. $text['warehouse'] = $fullorder['warehouse']['title'];
  1439. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1440. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1441. }
  1442. else if(($fullorder['printtype'] == 2 || $fullorder['printtype'] == 4) && $fullorder['library'] != 2)
  1443. {
  1444. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1445. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1446. {
  1447. $type = 2;
  1448. }
  1449. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1450. {
  1451. $text['name'] = '速卖通';
  1452. }
  1453. else
  1454. {
  1455. $text['name'] = '独立站';
  1456. }
  1457. $text['express'] = $fullorder['express'];
  1458. $text['country'] = $fullorder['country'];
  1459. $text['orderinfo'] = $fullorder['orderinfo'];
  1460. $text['number'] = $fullorder['number'];
  1461. $text['shipremarks'] = $fullorder['shipremarks'];
  1462. $text['ts'] = $fullorder['ts'];
  1463. $text['time'] = $fullorder['times'];
  1464. $text['printnumber'] = $fullorder['printnumber'];
  1465. $text['pdfnum'] = $pdfnum;
  1466. $text['pt'] = $fullorder['pt'];
  1467. $text['warehouse'] = $fullorder['warehouse']['title'];
  1468. $rows = array('type'=>$fullorder['printtype'],'n'=>$n-1,'data'=>$v,'text'=>$text);
  1469. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1470. }
  1471. else
  1472. {
  1473. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1474. {
  1475. $text['name'] = '速卖通';
  1476. }
  1477. else
  1478. {
  1479. $text['name'] = '独立站';
  1480. }
  1481. $text['express'] = $fullorder['express'];
  1482. $text['country'] = $fullorder['country'];
  1483. $text['orderinfo'] = $fullorder['orderinfo'];
  1484. $text['number'] = $fullorder['number'];
  1485. $text['shipremarks'] = $fullorder['shipremarks'];
  1486. $text['ts'] = $fullorder['ts'];
  1487. $text['time'] = $fullorder['times'];
  1488. $text['printnumber'] = $fullorder['printnumber'];
  1489. $text['pdfnum'] = $pdfnum;
  1490. $text['warehouse'] = $fullorder['warehouse']['title'];
  1491. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1492. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1493. }
  1494. }
  1495. }
  1496. public function _text($fullorder)
  1497. {
  1498. /** 发票地址信息暂时无用
  1499. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1500. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1501. $fullorder['baddress'][1] = $country['ename'];
  1502. **/
  1503. //获取所用相关信息
  1504. $warehouse = $this->warehouse->read($fullorder['type']);
  1505. $country = $this->country->read($fullorder['country']);//订单国家信息
  1506. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1507. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1508. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1509. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1510. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1511. $fullorder['country'] = $country['ename'];//订单国家名
  1512. $fullorder['zhou'] = $country['continent'];//所属州
  1513. $express = $this->express->read($fullorder['express']);
  1514. $fullorder['express'] = $express['servicename'];
  1515. $fullorder['account'] = $express['account'];
  1516. $fullorder['printcode'] = $express['printcode'];
  1517. $fullorder['time'] = date('Y-m-d',time());
  1518. $fullorder['times'] = date('Y-m-d H:i',time());
  1519. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1520. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1521. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1522. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1523. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1524. $shop = $this->shop->read($fullorder['shop']);
  1525. $fullorder['shop'] = $shop['shopname'];
  1526. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1527. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1528. if(is_numeric($fullorder['pay']))
  1529. {
  1530. $pay = $this->typeclass->read($fullorder['pay']);
  1531. if($pay['classid'] == '4')
  1532. {
  1533. $fullorder['pay'] = $pay['title'];
  1534. }
  1535. }
  1536. if($fullorder['printcode'] != "USPS")
  1537. {
  1538. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1539. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1540. }
  1541. //增加退货单所需信息
  1542. $pt = '';
  1543. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1544. foreach ($fpdata as $v)
  1545. {
  1546. $p = explode('|',trim($v,'|'));
  1547. if(isset($p[1]) && isset($p[2]))
  1548. {
  1549. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1550. }
  1551. }
  1552. $fullorder['pt'] = $pt;
  1553. return $fullorder;
  1554. }
  1555. public function _pdf($pdf,$title,$bctime)
  1556. {
  1557. $pdf_path = './data/pdf/'.$bctime.'/';
  1558. $file_base64 = $pdf;
  1559. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1560. $file_base64 = base64_decode($file_base64);
  1561. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1562. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1563. return $bctime;
  1564. }
  1565. public function _pdfurl($pdf,$title,$bctime)
  1566. {
  1567. $pdf_path = './data/pdf/'.$bctime.'/';
  1568. $pdf = fopen($pdf,"r");
  1569. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1570. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1571. return $bctime;
  1572. }
  1573. public function _exceldy()
  1574. {
  1575. if(isset($_GET['fexcel']))
  1576. {
  1577. if(isset($_SESSION['api']))
  1578. {
  1579. $user = $this->user->get_api($_SESSION['api']);
  1580. $usp = $user;
  1581. $fgshop = "";$sid = "";$wid="";$wtype="";
  1582. $usersp = explode('|',trim($user['shop'],'|'));
  1583. $userwh = explode('|',trim($user['warehouse'],'|'));
  1584. foreach ($usersp as $value)
  1585. {
  1586. $fgshop .= " shop = ".$value." or";
  1587. $sid .= " id = ".$value." or";
  1588. }
  1589. foreach ($userwh as $value)
  1590. {
  1591. $wid .= " id = ".$value." or";
  1592. $wtype .= " type = ".$value." or";
  1593. }
  1594. }
  1595. $dowid = $this->input->get('a');
  1596. $wid = "";
  1597. if($dowid != "")
  1598. {
  1599. $id_arr = explode(',',rtrim($dowid,','));
  1600. foreach ($id_arr as $v)
  1601. {
  1602. $wid .= " id = '$v' or";
  1603. }
  1604. $wid = " and (".rtrim($wid,'or').")";
  1605. }
  1606. $page = $this->input->get('page',true);
  1607. $perpage = $this->input->get('perpage',true);
  1608. $timetk = $this->input->get('timetk',true);
  1609. $timetj = $this->input->get('timetj',true);
  1610. $shop = $this->input->get('shop',true);
  1611. $print = $this->input->get('print',true);
  1612. $express = $this->input->get('express',true);
  1613. $waybill = $this->input->get('waybill',true);
  1614. $printtype = $this->input->get('printtype',true);
  1615. $orderinfo = $this->input->get('orderinfo',true);
  1616. $number = $this->input->get('number',true);
  1617. $type = $this->input->get('type',true);
  1618. $lowe = $this->input->get('lowe',true);
  1619. $info = $this->input->get('info',true);
  1620. $ji = $this->input->get('ji',true);
  1621. $so = $this->input->get('so',true);
  1622. $timetk = strtotime($timetk);
  1623. $timetj = strtotime($timetj);
  1624. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1625. if($print == 3)
  1626. {
  1627. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  1628. }
  1629. else
  1630. {
  1631. $where .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 and reviewtime > '".(time() - 30*24*3600)."'";
  1632. }
  1633. if($shop)
  1634. {
  1635. $where .= " and shop = '$shop'";
  1636. }
  1637. if($express)
  1638. {
  1639. $where .= " and express = '$express'";
  1640. }
  1641. if($printtype)
  1642. {
  1643. $where .= " and printtype = '$printtype'";
  1644. }
  1645. if($orderinfo)
  1646. {
  1647. $where .= " and orderinfo = '$orderinfo'";
  1648. }
  1649. if($number)
  1650. {
  1651. $where .= " and number = '$number'";
  1652. }
  1653. if($waybill)
  1654. {
  1655. $where .= " and waybill = '$waybill'";
  1656. }
  1657. if($type)
  1658. {
  1659. $where .= " and type = '$type'";
  1660. }
  1661. else
  1662. {
  1663. $where .= " and type != '16'";
  1664. }
  1665. /**
  1666. if($type)
  1667. {
  1668. if($type != '4')
  1669. {
  1670. $where .= " and type = '$type'";
  1671. $where2 = '';
  1672. $where3 = '';
  1673. }
  1674. else
  1675. {
  1676. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  1677. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  1678. }
  1679. $where_a = "";
  1680. $where_b = "";
  1681. }
  1682. else
  1683. {
  1684. $where .= " and type != '4'";
  1685. $where_a = "(";
  1686. $where_b = ")";
  1687. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  1688. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  1689. }
  1690. **/
  1691. if($lowe)
  1692. {
  1693. $where .= " and fpdata like '%-$lowe-%'";
  1694. }
  1695. if($ji)
  1696. {
  1697. $where .= " and shipremarks like '%急%'";
  1698. }
  1699. if($so)
  1700. {
  1701. $where .= " and shipremarks like '%$so%'";
  1702. }
  1703. //取得信息列表
  1704. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  1705. //格式化数据
  1706. foreach ($info_list as $key=>$value)
  1707. {
  1708. $shop = $this->shop->read($value['shop']);
  1709. $info_list[$key]['shop'] = $shop['shopname'];
  1710. if($value['waybill'] == '0')
  1711. {
  1712. $info_list[$key]['waybill'] = "";
  1713. }
  1714. $express = $this->express->read($value['express']);
  1715. $info_list[$key]['express'] = $express['servicename'];
  1716. $warehouse = $this->warehouse->read($value['type']);
  1717. $info_list[$key]['type'] = $warehouse['title'];
  1718. if($value['printtime'] == '0')
  1719. {
  1720. $info_list[$key]['printtime'] = '<em class="t"></em>';
  1721. }
  1722. else
  1723. {
  1724. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  1725. }
  1726. if($value['print'] == 1)
  1727. {
  1728. $info_list[$key]['print'] = '不可打印';
  1729. }
  1730. else if($value['print'] == 2)
  1731. {
  1732. $info_list[$key]['print'] = '未打印';
  1733. }
  1734. else if($value['print'] == 3)
  1735. {
  1736. $info_list[$key]['print'] = '已打印';
  1737. }
  1738. if($value['library'] == 1)
  1739. {
  1740. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1741. }
  1742. else if($value['library'] == 2)
  1743. {
  1744. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1745. }
  1746. else if($value['library'] == 3)
  1747. {
  1748. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1749. }
  1750. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1751. }
  1752. //取得信息列表
  1753. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  1754. //格式化数据
  1755. foreach ($info_listsmt as $key=>$value)
  1756. {
  1757. $shop = $this->shop->read($value['shop']);
  1758. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1759. if($value['waybill'] == '0')
  1760. {
  1761. $info_listsmt[$key]['waybill'] = "";
  1762. }
  1763. $express = $this->express->read($value['express']);
  1764. $info_listsmt[$key]['express'] = $express['servicename'];
  1765. $warehouse = $this->warehouse->read($value['type']);
  1766. $info_listsmt[$key]['type'] = $warehouse['title'];
  1767. if($value['printtime'] == '0')
  1768. {
  1769. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  1770. }
  1771. else
  1772. {
  1773. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  1774. }
  1775. if($value['print'] == 1)
  1776. {
  1777. $info_listsmt[$key]['print'] = '不可打印';
  1778. }
  1779. else if($value['print'] == 2)
  1780. {
  1781. $info_listsmt[$key]['print'] = '未打印';
  1782. }
  1783. else if($value['print'] == 3)
  1784. {
  1785. $info_listsmt[$key]['print'] = '已打印';
  1786. }
  1787. if($value['library'] == 1)
  1788. {
  1789. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1790. }
  1791. else if($value['library'] == 2)
  1792. {
  1793. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1794. }
  1795. else if($value['library'] == 3)
  1796. {
  1797. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1798. }
  1799. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1800. }
  1801. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  1802. //格式化数据
  1803. foreach ($info_listtt as $key=>$value)
  1804. {
  1805. $shop = $this->shop->read($value['shop']);
  1806. $info_listtt[$key]['shop'] = $shop['shopname'];
  1807. if($value['waybill'] == '0')
  1808. {
  1809. $info_listtt[$key]['waybill'] = "";
  1810. }
  1811. $express = $this->express->read($value['express']);
  1812. $info_listtt[$key]['express'] = $express['servicename'];
  1813. $warehouse = $this->warehouse->read($value['type']);
  1814. $info_listtt[$key]['type'] = $warehouse['title'];
  1815. if($value['printtime'] == '0')
  1816. {
  1817. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  1818. }
  1819. else
  1820. {
  1821. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  1822. }
  1823. if($value['print'] == 1)
  1824. {
  1825. $info_listtt[$key]['print'] = '不可打印';
  1826. }
  1827. else if($value['print'] == 2)
  1828. {
  1829. $info_listtt[$key]['print'] = '未打印';
  1830. }
  1831. else if($value['print'] == 3)
  1832. {
  1833. $info_listtt[$key]['print'] = '已打印';
  1834. }
  1835. if($value['library'] == 1)
  1836. {
  1837. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1838. }
  1839. else if($value['library'] == 2)
  1840. {
  1841. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1842. }
  1843. else if($value['library'] == 3)
  1844. {
  1845. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1846. }
  1847. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1848. }
  1849. $title = '订单出库-'.date('Ymd',time());
  1850. $titlename = "<table border=1><td>店铺名称</td><td>仓库</td><td>订单号</td><td>编号</td><td>运单号</td><td>快递</td><td>类型</td><td>打印次数</td><td>状态</td><td>打印时间</td><td>仓库品名</td><td>条数</td></table>";
  1851. $tail = "\n";
  1852. $filename = $title.".xls";
  1853. $this->excel->get_fz2(array_merge($info_list,$info_listsmt,$info_listtt),$titlename,$filename,$tail);
  1854. }
  1855. }
  1856. public function _barcode()
  1857. {
  1858. $post = $this->input->post(NULL, TRUE);
  1859. if(isset($_SESSION['api']))
  1860. {
  1861. $user = $this->user->get_api($_SESSION['api']);
  1862. $usp = $user;
  1863. $fgshop = "";$sid = "";$wid="";$wtype="";
  1864. $usersp = explode('|',trim($user['shop'],'|'));
  1865. $userwh = explode('|',trim($user['warehouse'],'|'));
  1866. foreach ($usersp as $value)
  1867. {
  1868. $fgshop .= " shop = ".$value." or";
  1869. $sid .= " id = ".$value." or";
  1870. }
  1871. foreach ($userwh as $value)
  1872. {
  1873. $wid .= " id = ".$value." or";
  1874. $wtype .= " type = ".$value." or";
  1875. }
  1876. }
  1877. if(isset($post['page']))
  1878. {
  1879. $page = $this->input->post('page',true);
  1880. $perpage = $this->input->post('perpage',true);
  1881. $warehouse = $this->input->post('warehouse',true);
  1882. $sku = $this->input->post('sku ',true);
  1883. $title = $this->input->post('title',true);
  1884. $print = $this->input->post('print ',true);
  1885. $timetk = $this->input->post('timetk',true);
  1886. $timetj = $this->input->post('timetj',true);
  1887. $timetk = strtotime($timetk);
  1888. $timetj = strtotime($timetj);
  1889. $where = "time > '$timetk' and time < '$timetj'";
  1890. if($warehouse)
  1891. {
  1892. $where .= " and warehouse = '$warehouse'";
  1893. }
  1894. if($sku)
  1895. {
  1896. $where .= " and sku like '%$sku%'";
  1897. }
  1898. if($title)
  1899. {
  1900. $where .= " and title like '%$title%'";
  1901. }
  1902. if($print)
  1903. {
  1904. $where .= " and print = '$print'";
  1905. }
  1906. //数据排序
  1907. $order_str = "time desc";
  1908. if(empty($page))
  1909. {
  1910. $start = 0;
  1911. $perpage = 1;
  1912. }
  1913. else
  1914. {
  1915. $start = ($page - 1)*$perpage;
  1916. }
  1917. //取得信息列表
  1918. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  1919. //格式化数据
  1920. foreach ($info_list as $key=>$value)
  1921. {
  1922. if($value['printtime'] > 0)
  1923. {
  1924. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  1925. }
  1926. else
  1927. {
  1928. $info_list[$key]['printtime'] = '未打印';
  1929. }
  1930. }
  1931. $total = $this->whlabelbarcodeprint->find_count($where);
  1932. $pagenum = ceil($total/$perpage);
  1933. $over = $total-($start+$perpage);
  1934. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1935. echo json_encode($rows);exit;
  1936. }
  1937. if(isset($_SESSION['api']))
  1938. {
  1939. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1940. $this->data['warehouse'] = $warehouse;
  1941. }
  1942. $this->_Template('systemprint_barcode',$this->data);
  1943. }
  1944. public function _barcodedc()
  1945. {
  1946. if(isset($_GET['excel']))
  1947. {
  1948. $warehouse = $this->input->post('warehouse',true);
  1949. $sku = $this->input->post('sku ',true);
  1950. $title = $this->input->post('title',true);
  1951. $print = $this->input->post('print ',true);
  1952. $ktime = $this->input->post('timetk',true);
  1953. $jtime = $this->input->post('timetj',true);
  1954. $ktime = strtotime($ktime);
  1955. $jtime = strtotime($jtime);
  1956. $where = "time > '$timetk' and time < '$timetj'";
  1957. if($warehouse)
  1958. {
  1959. $where .= " and warehouse = '$warehouse'";
  1960. }
  1961. if($sku)
  1962. {
  1963. $where .= " and sku like '%$sku%'";
  1964. }
  1965. if($title)
  1966. {
  1967. $where .= " and title like '%$title%'";
  1968. }
  1969. if($print)
  1970. {
  1971. $where .= " and print = '$print'";
  1972. }
  1973. $order_str = "time desc";
  1974. if(empty($page))
  1975. {
  1976. $start = 0;
  1977. $perpage = 1;
  1978. }
  1979. else
  1980. {
  1981. $start = ($page - 1)*$perpage;
  1982. }
  1983. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  1984. $title = '标签-'.date('Y-m-d H-i-s',time());
  1985. $titlename = "<table border=1>
  1986. <tr align='center'>
  1987. <td>条码号</td>
  1988. <td>SKU</td>
  1989. <td>产品名称</td>
  1990. </tr>
  1991. </table>";
  1992. $filename = $title.".xls";
  1993. $tail = "";
  1994. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  1995. }
  1996. }
  1997. public function _barcodedr()
  1998. {
  1999. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2000. $config['upload_path'] = '.'.$dir ;
  2001. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2002. $config['allowed_types'] = 'xls|xlsx|csv';
  2003. $config['max_size'] = 10240;
  2004. $this->load->library('upload', $config);
  2005. $this->upload->initialize($config);
  2006. if ($this->upload->do_upload('userfile'))
  2007. {
  2008. $full_path = $dir.$this->upload->data('file_name');
  2009. $fileName = '.' . $full_path;
  2010. if (!file_exists($fileName))
  2011. {
  2012. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2013. }
  2014. else
  2015. {
  2016. libxml_use_internal_errors(true);
  2017. require_once "./data/excel/PHPExcel/IOFactory.php";
  2018. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2019. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2020. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2021. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2022. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2023. ++$column;//如果列数大于26行
  2024. $list = array();
  2025. for ($i = 2; $i <= $row; $i++) // 行数循环
  2026. {
  2027. $data = array();
  2028. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2029. {
  2030. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2031. }
  2032. $list[] = $data;
  2033. }
  2034. }
  2035. $i = 0;$j = 0;$ed = array();
  2036. foreach ($list as $key=>$value)
  2037. {
  2038. $time = time();
  2039. if($value['0'] == "")
  2040. {
  2041. continue;
  2042. }
  2043. $label = $value['0'];
  2044. $sku = $value['1'];
  2045. $title = $value['2'];
  2046. $num = $value['3'];
  2047. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2048. if(!$d)//如果没有这个SKU
  2049. {
  2050. $ed[] = array($sku.'-库存中不存在此SKU');
  2051. $j++;
  2052. continue;
  2053. }
  2054. if($num < 1)
  2055. {
  2056. $ed[] = array($sku.'-数量错误!');
  2057. $j++;
  2058. continue;
  2059. }
  2060. unset($d['id']);
  2061. $d['time'] = $time;
  2062. $d['num'] = $num;
  2063. $this->whlabelbarcodeprint->insert($d);
  2064. }
  2065. if($j > 0)
  2066. {
  2067. $tt = date('Ymd',time());
  2068. $title = '库存导入错误信息-'.$tt;
  2069. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2070. $tail = "\n";
  2071. $filename = $title.".xls";
  2072. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2073. $dir = '/data/excel/'.$time.'/';
  2074. $file_name = 'error_'.$time.rand(1000,9999);
  2075. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2076. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2077. fwrite($myfile,$ecl);
  2078. fclose($myfile);
  2079. $error = $dir.$file_name.'.xls';
  2080. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2081. }
  2082. else
  2083. {
  2084. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2085. }
  2086. }
  2087. }
  2088. public function _yswaybill()
  2089. {
  2090. $data = $this->yswaybill->find_all("waybill = ''");
  2091. foreach ($data as $v)
  2092. {
  2093. $type = $v['type'];
  2094. $number = $v['number'];
  2095. $express = $v['express'];
  2096. $fullorder = $this->$type->get_number($number);
  2097. $fullorder = $this->_text($fullorder);
  2098. $barcode = $this->$express->get_hqwaybill($number);
  2099. if(!isset($barcode['x']))
  2100. {
  2101. continue;
  2102. }
  2103. if($barcode['x'] == 1)
  2104. {
  2105. if($barcode['ys'] != 1)
  2106. {
  2107. $this->db->trans_begin();
  2108. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2109. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2110. if ($this->db->trans_status() === TRUE)
  2111. {
  2112. $this->db->trans_commit();
  2113. }
  2114. else
  2115. {
  2116. $this->db->trans_rollback();
  2117. }
  2118. }
  2119. }
  2120. else
  2121. {
  2122. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2123. }
  2124. }
  2125. echo 1;
  2126. }
  2127. }