Systemprint.php 112 KB

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