Systemprint.php 116 KB

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