Systemprint.php 101 KB

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