Systemprint.php 118 KB

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