Systemprint.php 97 KB

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