Systemprint.php 85 KB

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