Systemprint.php 88 KB

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