Systemprint.php 111 KB

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