Systemprint.php 113 KB

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