Systemprint.php 92 KB

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