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. var_dump($barcode);
  1689. die;
  1690. if($barcode['x'] == 1)
  1691. {
  1692. $bctime = date('Ymd',$time);
  1693. $Hwaybill = $barcode['waybill'];
  1694. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1695. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1696. if(isset($barcode['label']) && isset($Hwaybill))
  1697. {
  1698. if($fullorder['waybill'] != "")
  1699. {
  1700. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1701. }
  1702. else
  1703. {
  1704. $oldwaybill = $fullorder['oldwaybill'];
  1705. }
  1706. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1707. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1708. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybill2'=>$barcode['waybill2'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1709. {
  1710. $type = 1;
  1711. $pdfnum = 1;
  1712. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1713. }
  1714. }
  1715. }
  1716. else
  1717. {
  1718. $failed = $barcode['Description'];//错误提示
  1719. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1720. }
  1721. }else
  1722. {
  1723. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  1724. }
  1725. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1726. {
  1727. $text['name'] = '速卖通';
  1728. }
  1729. else if($fullorder_name == 'fullordertt')
  1730. {
  1731. $text['name'] = 'TikTok';
  1732. }
  1733. else if($fullorder_name == 'fullorderamz')
  1734. {
  1735. $text['name'] = '亚马逊';
  1736. }
  1737. else if($fullorder_name == 'fullorderxw')
  1738. {
  1739. $text['name'] = '翔文';
  1740. }
  1741. else
  1742. {
  1743. $text['name'] = '独立站';
  1744. }
  1745. $text['express'] = $fullorder['express'];
  1746. //$text['country'] = $fullorder['country'];
  1747. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1748. $text['orderinfo'] = $fullorder['orderinfo'];
  1749. $text['number'] = $fullorder['number'];
  1750. $text['shipremarks'] = $fullorder['shipremarks'];
  1751. $text['ts'] = $fullorder['ts'];
  1752. $text['time'] = $fullorder['times'];
  1753. $text['printnumber'] = $fullorder['printnumber'];
  1754. $text['pdfnum'] = $pdfnum;
  1755. $text['pt'] = $fullorder['pt'];
  1756. $text['warehouse'] = $fullorder['warehouse']['title'];
  1757. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1758. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1759. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1760. }
  1761. else if(($fullorder['printtype'] == 2 || $fullorder['printtype'] == 4) && $fullorder['library'] != 2)
  1762. {
  1763. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1764. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1765. {
  1766. $type = 2;
  1767. }
  1768. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1769. {
  1770. $text['name'] = '速卖通';
  1771. }
  1772. else
  1773. {
  1774. $text['name'] = '独立站';
  1775. }
  1776. $text['express'] = $fullorder['express'];
  1777. //$text['country'] = $fullorder['country'];
  1778. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1779. $text['orderinfo'] = $fullorder['orderinfo'];
  1780. $text['number'] = $fullorder['number'];
  1781. $text['shipremarks'] = $fullorder['shipremarks'];
  1782. $text['ts'] = $fullorder['ts'];
  1783. $text['time'] = $fullorder['times'];
  1784. $text['printnumber'] = $fullorder['printnumber'];
  1785. $text['pdfnum'] = $pdfnum;
  1786. $text['pt'] = $fullorder['pt'];
  1787. $text['warehouse'] = $fullorder['warehouse']['title'];
  1788. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1789. $rows = array('type'=>$fullorder['printtype'],'n'=>$n-1,'data'=>$v,'text'=>$text);
  1790. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1791. }
  1792. else
  1793. {
  1794. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1795. {
  1796. $text['name'] = '速卖通';
  1797. }
  1798. else
  1799. {
  1800. $text['name'] = '独立站';
  1801. }
  1802. $text['express'] = $fullorder['express'];
  1803. //$text['country'] = $fullorder['country'];
  1804. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1805. $text['orderinfo'] = $fullorder['orderinfo'];
  1806. $text['number'] = $fullorder['number'];
  1807. $text['shipremarks'] = $fullorder['shipremarks'];
  1808. $text['ts'] = $fullorder['ts'];
  1809. $text['time'] = $fullorder['times'];
  1810. $text['printnumber'] = $fullorder['printnumber'];
  1811. $text['pdfnum'] = $pdfnum;
  1812. $text['warehouse'] = $fullorder['warehouse']['title'];
  1813. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1814. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1815. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1816. }
  1817. }
  1818. }
  1819. public function _text($fullorder)
  1820. {
  1821. /** 发票地址信息暂时无用
  1822. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1823. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1824. $fullorder['baddress'][1] = $country['ename'];
  1825. **/
  1826. //获取所用相关信息
  1827. $warehouse = $this->warehouse->read($fullorder['type']);
  1828. $country = $this->country->read($fullorder['country']);//订单国家信息
  1829. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1830. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1831. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1832. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1833. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1834. $fullorder['country'] = $country['ename'];//订单国家名
  1835. $fullorder['zhou'] = $country['continent'];//所属州
  1836. $express = $this->express->read($fullorder['express']);
  1837. $fullorder['express'] = $express['servicename'];
  1838. $fullorder['account'] = $express['account'];
  1839. $fullorder['printcode'] = $express['printcode'];
  1840. $fullorder['time'] = date('Y-m-d',time());
  1841. $fullorder['times'] = date('Y-m-d H:i',time());
  1842. // $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1843. // 修复报关编码问题
  1844. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1845. $sbbm = "";
  1846. if(empty($declara_info)){
  1847. $sbbm = "";
  1848. }else{
  1849. $sbbm = $declara_info['bname'];
  1850. }
  1851. $fullorder['sbbm']= $sbbm;
  1852. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1853. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1854. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1855. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1856. $shop = $this->shop->read($fullorder['shop']);
  1857. $fullorder['shop'] = $shop['shopname'];
  1858. $shoptype = $this->typeclass->read($shop['type']);
  1859. $fullorder['shoptype'] = $shoptype['classtitle'];
  1860. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1861. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1862. if(is_numeric($fullorder['pay']))
  1863. {
  1864. $pay = $this->typeclass->read($fullorder['pay']);
  1865. if($pay['classid'] == '4')
  1866. {
  1867. $fullorder['pay'] = $pay['title'];
  1868. }
  1869. }
  1870. if($fullorder['printcode'] != "USPS")
  1871. {
  1872. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1873. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1874. }
  1875. //增加退货单所需信息
  1876. $pt = '';
  1877. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1878. foreach ($fpdata as $v)
  1879. {
  1880. $p = explode('|',trim($v,'|'));
  1881. if(isset($p[1]) && isset($p[2]))
  1882. {
  1883. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1884. }
  1885. }
  1886. $fullorder['pt'] = $pt;
  1887. return $fullorder;
  1888. }
  1889. public function _pdf($pdf,$title,$bctime)
  1890. {
  1891. $pdf_path = './data/pdf/'.$bctime.'/';
  1892. $file_base64 = $pdf;
  1893. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1894. $file_base64 = base64_decode($file_base64);
  1895. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1896. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1897. return $bctime;
  1898. }
  1899. public function _pdfurl($pdf,$title,$bctime)
  1900. {
  1901. $pdf_path = './data/pdf/'.$bctime.'/';
  1902. $pdf = fopen($pdf,"r");
  1903. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1904. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1905. return $bctime;
  1906. }
  1907. public function _exceldy()
  1908. {
  1909. if(isset($_GET['fexcel']))
  1910. {
  1911. if(isset($_SESSION['api']))
  1912. {
  1913. $user = $this->user->get_api($_SESSION['api']);
  1914. $usp = $user;
  1915. $fgshop = "";$sid = "";$wid="";$wtype="";
  1916. $usersp = explode('|',trim($user['shop'],'|'));
  1917. $userwh = explode('|',trim($user['warehouse'],'|'));
  1918. foreach ($usersp as $value)
  1919. {
  1920. $fgshop .= " shop = ".$value." or";
  1921. $sid .= " id = ".$value." or";
  1922. }
  1923. foreach ($userwh as $value)
  1924. {
  1925. $wid .= " id = ".$value." or";
  1926. $wtype .= " type = ".$value." or";
  1927. }
  1928. }
  1929. $dowid = $this->input->get('a');
  1930. $wid = "";
  1931. if($dowid != "")
  1932. {
  1933. $id_arr = explode(',',rtrim($dowid,','));
  1934. foreach ($id_arr as $v)
  1935. {
  1936. $wid .= " id = '$v' or";
  1937. }
  1938. $wid = " and (".rtrim($wid,'or').")";
  1939. }
  1940. $page = $this->input->get('page',true);
  1941. $perpage = $this->input->get('perpage',true);
  1942. $timetk = $this->input->get('timetk',true);
  1943. $timetj = $this->input->get('timetj',true);
  1944. $shop = $this->input->get('shop',true);
  1945. $print = $this->input->get('print',true);
  1946. $express = $this->input->get('express',true);
  1947. $waybill = $this->input->get('waybill',true);
  1948. $printtype = $this->input->get('printtype',true);
  1949. $orderinfo = $this->input->get('orderinfo',true);
  1950. $number = $this->input->get('number',true);
  1951. $type = $this->input->get('type',true);
  1952. $lowe = $this->input->get('lowe',true);
  1953. $info = $this->input->get('info',true);
  1954. $ji = $this->input->get('ji',true);
  1955. $so = $this->input->get('so',true);
  1956. $timetk = strtotime($timetk);
  1957. $timetj = strtotime($timetj);
  1958. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1959. if($print == 3)
  1960. {
  1961. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  1962. }
  1963. else
  1964. {
  1965. $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)."'";
  1966. }
  1967. if($shop)
  1968. {
  1969. $where .= " and shop = '$shop'";
  1970. }
  1971. if($express)
  1972. {
  1973. $where .= " and express = '$express'";
  1974. }
  1975. if($printtype)
  1976. {
  1977. $where .= " and printtype = '$printtype'";
  1978. }
  1979. if($orderinfo)
  1980. {
  1981. $where .= " and orderinfo = '$orderinfo'";
  1982. }
  1983. if($number)
  1984. {
  1985. $where .= " and number = '$number'";
  1986. }
  1987. if($waybill)
  1988. {
  1989. $where .= " and waybill = '$waybill'";
  1990. }
  1991. if($type)
  1992. {
  1993. $where .= " and type = '$type'";
  1994. }
  1995. else
  1996. {
  1997. $where .= " and type != '16'";
  1998. }
  1999. /**
  2000. if($type)
  2001. {
  2002. if($type != '4')
  2003. {
  2004. $where .= " and type = '$type'";
  2005. $where2 = '';
  2006. $where3 = '';
  2007. }
  2008. else
  2009. {
  2010. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  2011. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  2012. }
  2013. $where_a = "";
  2014. $where_b = "";
  2015. }
  2016. else
  2017. {
  2018. $where .= " and type != '4'";
  2019. $where_a = "(";
  2020. $where_b = ")";
  2021. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  2022. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  2023. }
  2024. **/
  2025. if($lowe)
  2026. {
  2027. $where .= " and fpdata like '%-$lowe-%'";
  2028. }
  2029. if($ji)
  2030. {
  2031. $where .= " and shipremarks like '%急%'";
  2032. }
  2033. if($so)
  2034. {
  2035. $where .= " and shipremarks like '%$so%'";
  2036. }
  2037. //数据排序
  2038. $order_str = ($print != 3)?"id desc":"printtime desc";
  2039. //取得信息列表
  2040. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2041. //格式化数据
  2042. foreach ($info_list as $key=>$value)
  2043. {
  2044. $shop = $this->shop->read($value['shop']);
  2045. $info_list[$key]['shop'] = $shop['shopname'];
  2046. if($value['waybill'] == '0')
  2047. {
  2048. $info_list[$key]['waybill'] = "";
  2049. }
  2050. $express = $this->express->read($value['express']);
  2051. $info_list[$key]['express'] = $express['servicename'];
  2052. $warehouse = $this->warehouse->read($value['type']);
  2053. $info_list[$key]['type'] = $warehouse['title'];
  2054. if($value['printtime'] == '0')
  2055. {
  2056. $info_list[$key]['printtime'] = '<em class="t"></em>';
  2057. }
  2058. else
  2059. {
  2060. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2061. }
  2062. if($value['print'] == 1)
  2063. {
  2064. $info_list[$key]['print'] = '不可打印';
  2065. }
  2066. else if($value['print'] == 2)
  2067. {
  2068. $info_list[$key]['print'] = '未打印';
  2069. }
  2070. else if($value['print'] == 3)
  2071. {
  2072. $info_list[$key]['print'] = '已打印';
  2073. }
  2074. if($value['library'] == 1)
  2075. {
  2076. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2077. }
  2078. else if($value['library'] == 2)
  2079. {
  2080. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2081. }
  2082. else if($value['library'] == 3)
  2083. {
  2084. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2085. }
  2086. if($value['printtype'] == 1){
  2087. $info_list[$key]['printtype'] = '运单';
  2088. }elseif($value['printtype'] == 2){
  2089. $info_list[$key]['printtype'] = '发货单';
  2090. }else{
  2091. $info_list[$key]['printtype'] = '不打印单据';
  2092. }
  2093. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2094. }
  2095. //取得信息列表
  2096. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2097. //格式化数据
  2098. foreach ($info_listsmt as $key=>$value)
  2099. {
  2100. $shop = $this->shop->read($value['shop']);
  2101. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2102. if($value['waybill'] == '0')
  2103. {
  2104. $info_listsmt[$key]['waybill'] = "";
  2105. }
  2106. $express = $this->express->read($value['express']);
  2107. $info_listsmt[$key]['express'] = $express['servicename'];
  2108. $warehouse = $this->warehouse->read($value['type']);
  2109. $info_listsmt[$key]['type'] = $warehouse['title'];
  2110. if($value['printtime'] == '0')
  2111. {
  2112. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  2113. }
  2114. else
  2115. {
  2116. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2117. }
  2118. if($value['print'] == 1)
  2119. {
  2120. $info_listsmt[$key]['print'] = '不可打印';
  2121. }
  2122. else if($value['print'] == 2)
  2123. {
  2124. $info_listsmt[$key]['print'] = '未打印';
  2125. }
  2126. else if($value['print'] == 3)
  2127. {
  2128. $info_listsmt[$key]['print'] = '已打印';
  2129. }
  2130. if($value['library'] == 1)
  2131. {
  2132. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2133. }
  2134. else if($value['library'] == 2)
  2135. {
  2136. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2137. }
  2138. else if($value['library'] == 3)
  2139. {
  2140. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2141. }
  2142. if($value['printtype'] == 1){
  2143. $info_listsmt[$key]['printtype'] = '运单';
  2144. }elseif($value['printtype'] == 2){
  2145. $info_listsmt[$key]['printtype'] = '发货单';
  2146. }else{
  2147. $info_listsmt[$key]['printtype'] = '不打印单据';
  2148. }
  2149. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2150. }
  2151. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2152. //格式化数据
  2153. foreach ($info_listtt as $key=>$value)
  2154. {
  2155. $shop = $this->shop->read($value['shop']);
  2156. $info_listtt[$key]['shop'] = $shop['shopname'];
  2157. if($value['waybill'] == '0')
  2158. {
  2159. $info_listtt[$key]['waybill'] = "";
  2160. }
  2161. $express = $this->express->read($value['express']);
  2162. $info_listtt[$key]['express'] = $express['servicename'];
  2163. $warehouse = $this->warehouse->read($value['type']);
  2164. $info_listtt[$key]['type'] = $warehouse['title'];
  2165. if($value['printtime'] == '0')
  2166. {
  2167. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  2168. }
  2169. else
  2170. {
  2171. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2172. }
  2173. if($value['print'] == 1)
  2174. {
  2175. $info_listtt[$key]['print'] = '不可打印';
  2176. }
  2177. else if($value['print'] == 2)
  2178. {
  2179. $info_listtt[$key]['print'] = '未打印';
  2180. }
  2181. else if($value['print'] == 3)
  2182. {
  2183. $info_listtt[$key]['print'] = '已打印';
  2184. }
  2185. if($value['library'] == 1)
  2186. {
  2187. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2188. }
  2189. else if($value['library'] == 2)
  2190. {
  2191. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2192. }
  2193. else if($value['library'] == 3)
  2194. {
  2195. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2196. }
  2197. if($value['printtype'] == 1){
  2198. $info_listtt[$key]['printtype'] = '运单';
  2199. }elseif($value['printtype'] == 2){
  2200. $info_listtt[$key]['printtype'] = '发货单';
  2201. }else{
  2202. $info_listtt[$key]['printtype'] = '不打印单据';
  2203. }
  2204. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2205. }
  2206. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2207. //格式化数据
  2208. foreach ($info_listamz as $key=>$value)
  2209. {
  2210. $shop = $this->shop->read($value['shop']);
  2211. $info_listamz[$key]['shop'] = $shop['shopname'];
  2212. if($value['waybill'] == '0')
  2213. {
  2214. $info_listamz[$key]['waybill'] = "";
  2215. }
  2216. $express = $this->express->read($value['express']);
  2217. $info_listamz[$key]['express'] = $express['servicename'];
  2218. $warehouse = $this->warehouse->read($value['type']);
  2219. $info_listamz[$key]['type'] = $warehouse['title'];
  2220. if($value['printtime'] == '0')
  2221. {
  2222. $info_listamz[$key]['printtime'] = '<em class="t"></em>';
  2223. }
  2224. else
  2225. {
  2226. $info_listamz[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2227. }
  2228. if($value['print'] == 1)
  2229. {
  2230. $info_listamz[$key]['print'] = '不可打印';
  2231. }
  2232. else if($value['print'] == 2)
  2233. {
  2234. $info_listamz[$key]['print'] = '未打印';
  2235. }
  2236. else if($value['print'] == 3)
  2237. {
  2238. $info_listamz[$key]['print'] = '已打印';
  2239. }
  2240. if($value['library'] == 1)
  2241. {
  2242. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2243. }
  2244. else if($value['library'] == 2)
  2245. {
  2246. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2247. }
  2248. else if($value['library'] == 3)
  2249. {
  2250. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2251. }
  2252. if($value['printtype'] == 1){
  2253. $info_listamz[$key]['printtype'] = '运单';
  2254. }elseif($value['printtype'] == 2){
  2255. $info_listamz[$key]['printtype'] = '发货单';
  2256. }else{
  2257. $info_listamz[$key]['printtype'] = '不打印单据';
  2258. }
  2259. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2260. }
  2261. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2262. //格式化数据
  2263. foreach ($info_listxw as $key=>$value)
  2264. {
  2265. $shop = $this->shop->read($value['shop']);
  2266. $info_listxw[$key]['shop'] = $shop['shopname'];
  2267. if($value['waybill'] == '0')
  2268. {
  2269. $info_listxw[$key]['waybill'] = "";
  2270. }
  2271. $express = $this->express->read($value['express']);
  2272. $info_listxw[$key]['express'] = $express['servicename'];
  2273. $warehouse = $this->warehouse->read($value['type']);
  2274. $info_listxw[$key]['type'] = $warehouse['title'];
  2275. if($value['printtime'] == '0')
  2276. {
  2277. $info_listxw[$key]['printtime'] = '<em class="t"></em>';
  2278. }
  2279. else
  2280. {
  2281. $info_listxw[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2282. }
  2283. if($value['print'] == 1)
  2284. {
  2285. $info_listxw[$key]['print'] = '不可打印';
  2286. }
  2287. else if($value['print'] == 2)
  2288. {
  2289. $info_listxw[$key]['print'] = '未打印';
  2290. }
  2291. else if($value['print'] == 3)
  2292. {
  2293. $info_listxw[$key]['print'] = '已打印';
  2294. }
  2295. if($value['library'] == 1)
  2296. {
  2297. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2298. }
  2299. else if($value['library'] == 2)
  2300. {
  2301. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2302. }
  2303. else if($value['library'] == 3)
  2304. {
  2305. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2306. }
  2307. if($value['printtype'] == 1){
  2308. $info_listxw[$key]['printtype'] = '运单';
  2309. }elseif($value['printtype'] == 2){
  2310. $info_listxw[$key]['printtype'] = '发货单';
  2311. }else{
  2312. $info_listxw[$key]['printtype'] = '不打印单据';
  2313. }
  2314. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2315. }
  2316. $title = '订单出库-'.date('Ymd',time());
  2317. $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>";
  2318. $tail = "\n";
  2319. $filename = $title.".xls";
  2320. $this->excel->get_fz2(array_merge($info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  2321. }
  2322. }
  2323. public function _barcode()
  2324. {
  2325. $post = $this->input->post(NULL, TRUE);
  2326. if(isset($_SESSION['api']))
  2327. {
  2328. $user = $this->user->get_api($_SESSION['api']);
  2329. $usp = $user;
  2330. $fgshop = "";$sid = "";$wid="";$wtype="";
  2331. $usersp = explode('|',trim($user['shop'],'|'));
  2332. $userwh = explode('|',trim($user['warehouse'],'|'));
  2333. foreach ($usersp as $value)
  2334. {
  2335. $fgshop .= " shop = ".$value." or";
  2336. $sid .= " id = ".$value." or";
  2337. }
  2338. foreach ($userwh as $value)
  2339. {
  2340. $wid .= " id = ".$value." or";
  2341. $wtype .= " type = ".$value." or";
  2342. }
  2343. }
  2344. if(isset($post['page']))
  2345. {
  2346. $page = $this->input->post('page',true);
  2347. $perpage = $this->input->post('perpage',true);
  2348. $warehouse = $this->input->post('warehouse',true);
  2349. $sku = $this->input->post('sku ',true);
  2350. $title = $this->input->post('title',true);
  2351. $print = $this->input->post('print ',true);
  2352. $timetk = $this->input->post('timetk',true);
  2353. $timetj = $this->input->post('timetj',true);
  2354. $timetk = strtotime($timetk);
  2355. $timetj = strtotime($timetj);
  2356. $where = "time > '$timetk' and time < '$timetj'";
  2357. if($warehouse)
  2358. {
  2359. $where .= " and warehouse = '$warehouse'";
  2360. }
  2361. if($sku)
  2362. {
  2363. $where .= " and sku like '%$sku%'";
  2364. }
  2365. if($title)
  2366. {
  2367. $where .= " and title like '%$title%'";
  2368. }
  2369. if($print)
  2370. {
  2371. $where .= " and print = '$print'";
  2372. }
  2373. //数据排序
  2374. $order_str = "time desc";
  2375. if(empty($page))
  2376. {
  2377. $start = 0;
  2378. $perpage = 1;
  2379. }
  2380. else
  2381. {
  2382. $start = ($page - 1)*$perpage;
  2383. }
  2384. //取得信息列表
  2385. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  2386. //格式化数据
  2387. foreach ($info_list as $key=>$value)
  2388. {
  2389. if($value['printtime'] > 0)
  2390. {
  2391. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  2392. }
  2393. else
  2394. {
  2395. $info_list[$key]['printtime'] = '未打印';
  2396. }
  2397. }
  2398. $total = $this->whlabelbarcodeprint->find_count($where);
  2399. $pagenum = ceil($total/$perpage);
  2400. $over = $total-($start+$perpage);
  2401. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2402. echo json_encode($rows);exit;
  2403. }
  2404. if(isset($_SESSION['api']))
  2405. {
  2406. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2407. $this->data['warehouse'] = $warehouse;
  2408. }
  2409. $this->_Template('systemprint_barcode',$this->data);
  2410. }
  2411. public function _barcodedc()
  2412. {
  2413. if(isset($_GET['excel']))
  2414. {
  2415. $warehouse = $this->input->post('warehouse',true);
  2416. $sku = $this->input->post('sku ',true);
  2417. $title = $this->input->post('title',true);
  2418. $print = $this->input->post('print ',true);
  2419. $ktime = $this->input->post('timetk',true);
  2420. $jtime = $this->input->post('timetj',true);
  2421. $ktime = strtotime($ktime);
  2422. $jtime = strtotime($jtime);
  2423. $where = "time > '$timetk' and time < '$timetj'";
  2424. if($warehouse)
  2425. {
  2426. $where .= " and warehouse = '$warehouse'";
  2427. }
  2428. if($sku)
  2429. {
  2430. $where .= " and sku like '%$sku%'";
  2431. }
  2432. if($title)
  2433. {
  2434. $where .= " and title like '%$title%'";
  2435. }
  2436. if($print)
  2437. {
  2438. $where .= " and print = '$print'";
  2439. }
  2440. $order_str = "time desc";
  2441. if(empty($page))
  2442. {
  2443. $start = 0;
  2444. $perpage = 1;
  2445. }
  2446. else
  2447. {
  2448. $start = ($page - 1)*$perpage;
  2449. }
  2450. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  2451. $title = '标签-'.date('Y-m-d H-i-s',time());
  2452. $titlename = "<table border=1>
  2453. <tr align='center'>
  2454. <td>条码号</td>
  2455. <td>SKU</td>
  2456. <td>产品名称</td>
  2457. </tr>
  2458. </table>";
  2459. $filename = $title.".xls";
  2460. $tail = "";
  2461. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2462. }
  2463. }
  2464. public function _barcodedr()
  2465. {
  2466. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2467. $config['upload_path'] = '.'.$dir ;
  2468. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2469. $config['allowed_types'] = 'xls|xlsx|csv';
  2470. $config['max_size'] = 10240;
  2471. $this->load->library('upload', $config);
  2472. $this->upload->initialize($config);
  2473. if ($this->upload->do_upload('userfile'))
  2474. {
  2475. $full_path = $dir.$this->upload->data('file_name');
  2476. $fileName = '.' . $full_path;
  2477. if (!file_exists($fileName))
  2478. {
  2479. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2480. }
  2481. else
  2482. {
  2483. libxml_use_internal_errors(true);
  2484. require_once "./data/excel/PHPExcel/IOFactory.php";
  2485. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2486. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2487. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2488. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2489. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2490. ++$column;//如果列数大于26行
  2491. $list = array();
  2492. for ($i = 2; $i <= $row; $i++) // 行数循环
  2493. {
  2494. $data = array();
  2495. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2496. {
  2497. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2498. }
  2499. $list[] = $data;
  2500. }
  2501. }
  2502. $i = 0;$j = 0;$ed = array();
  2503. foreach ($list as $key=>$value)
  2504. {
  2505. $time = time();
  2506. if($value['0'] == "")
  2507. {
  2508. continue;
  2509. }
  2510. $label = $value['0'];
  2511. $sku = $value['1'];
  2512. $title = $value['2'];
  2513. $num = $value['3'];
  2514. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2515. if(!$d)//如果没有这个SKU
  2516. {
  2517. $ed[] = array($sku.'-库存中不存在此SKU');
  2518. $j++;
  2519. continue;
  2520. }
  2521. if($num < 1)
  2522. {
  2523. $ed[] = array($sku.'-数量错误!');
  2524. $j++;
  2525. continue;
  2526. }
  2527. unset($d['id']);
  2528. $d['time'] = $time;
  2529. $d['num'] = $num;
  2530. $this->whlabelbarcodeprint->insert($d);
  2531. }
  2532. if($j > 0)
  2533. {
  2534. $tt = date('Ymd',time());
  2535. $title = '库存导入错误信息-'.$tt;
  2536. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2537. $tail = "\n";
  2538. $filename = $title.".xls";
  2539. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2540. $dir = '/data/excel/'.$time.'/';
  2541. $file_name = 'error_'.$time.rand(1000,9999);
  2542. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2543. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2544. fwrite($myfile,$ecl);
  2545. fclose($myfile);
  2546. $error = $dir.$file_name.'.xls';
  2547. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2548. }
  2549. else
  2550. {
  2551. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2552. }
  2553. }
  2554. }
  2555. public function _yswaybill()
  2556. {
  2557. $data = $this->yswaybill->find_all("waybill = ''");
  2558. foreach ($data as $v)
  2559. {
  2560. $type = $v['type'];
  2561. $number = $v['number'];
  2562. $express = $v['express'];
  2563. $fullorder = $this->$type->get_number($number);
  2564. $fullorder = $this->_text($fullorder);
  2565. $barcode = $this->$express->get_hqwaybill($number);
  2566. if(!isset($barcode['x']))
  2567. {
  2568. continue;
  2569. }
  2570. if($barcode['x'] == 1)
  2571. {
  2572. if($barcode['ys'] != 1)
  2573. {
  2574. $this->db->trans_begin();
  2575. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2576. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2577. if ($this->db->trans_status() === TRUE)
  2578. {
  2579. $this->db->trans_commit();
  2580. }
  2581. else
  2582. {
  2583. $this->db->trans_rollback();
  2584. }
  2585. }
  2586. }
  2587. else
  2588. {
  2589. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2590. }
  2591. }
  2592. echo 1;
  2593. }
  2594. /**
  2595. * 根据发货单打印快递
  2596. */
  2597. public function _printbyfh(){
  2598. $this->_Template('systemprint_fhd',$this->data);
  2599. }
  2600. /**
  2601. * 此方法是为了临时解决一下打印的问题
  2602. */
  2603. public function _getInfoByNumber(){
  2604. $param = $this->input->get(NULL, TRUE);
  2605. if(empty($param['number'])){
  2606. $param = $this->input->post(NULL, TRUE);
  2607. }
  2608. if(empty($param['number'])){
  2609. echo json_encode([
  2610. 'code'=>-1,
  2611. 'msg'=>"订单编码未传递",
  2612. 'data'=>[]
  2613. ],JSON_UNESCAPED_UNICODE);
  2614. die;
  2615. }
  2616. $this->logic_ding->sendToDing("扫面发货单出运单订单编码".json_encode($param));
  2617. $info = $this->logic_order->getInfo("number = '".$param['number']."'");
  2618. if(empty($info)){
  2619. echo json_encode([
  2620. 'code'=>-1,
  2621. 'msg'=>"未查询到订单信息",
  2622. 'data'=>[]
  2623. ],JSON_UNESCAPED_UNICODE);
  2624. die;
  2625. }
  2626. if($info['library'] ==2 ){
  2627. echo json_encode([
  2628. 'code'=>-1,
  2629. 'msg'=>"该订单已出库!",
  2630. 'data'=>[]
  2631. ],JSON_UNESCAPED_UNICODE);
  2632. die;
  2633. }
  2634. if(empty($param['is_ok'])){
  2635. if($info['printnumber'] > 1){
  2636. echo json_encode([
  2637. 'code'=>2,
  2638. 'msg'=>'该单共打印过<b style="color:red;">'.$info['printnumber'].'</b>次,请核对当前发货单是否是最新发货单',
  2639. 'data'=>[
  2640. 'number'=>$info['number'],
  2641. 'is_ok'=>1
  2642. ]
  2643. ],JSON_UNESCAPED_UNICODE);
  2644. die;
  2645. }
  2646. }
  2647. if(!in_array($info['express'],[71])){
  2648. // if(!empty($info['waybill'])&&!empty($info['waybill'])){
  2649. // $yd = base_url()."data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf' ;
  2650. // if(file_exists("./data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf')){
  2651. // if(!in_array($info['express'],[76,77])){
  2652. // $text = array('yd'=>$yd,'mode'=>100,'type'=>1);
  2653. // }else{
  2654. // $text = array('yd'=>$yd,'mode'=>100,'type'=>8);
  2655. // }
  2656. // $this->logic_ding->sendToDing($info['number']."扫面发货单补发运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2657. // echo json_encode([
  2658. // 'code'=>1,
  2659. // 'msg'=>"ok",
  2660. // 'data'=>$text
  2661. // ],JSON_UNESCAPED_UNICODE);
  2662. // die;
  2663. // }
  2664. // ob_clean();
  2665. // echo json_encode([
  2666. // 'code'=>-1,
  2667. // 'msg'=>"快递面单不存在",
  2668. // 'data'=>[]
  2669. // ],JSON_UNESCAPED_UNICODE);
  2670. // die;
  2671. // }
  2672. echo json_encode([
  2673. 'code'=>-1,
  2674. 'msg'=>"快递不符合打印要求",
  2675. 'data'=>[]
  2676. ],JSON_UNESCAPED_UNICODE);
  2677. die;
  2678. }
  2679. $fullorder_name = $info['lv_platform'];
  2680. if($info['libraryconfirm'] == 1){
  2681. echo json_encode([
  2682. 'code'=>-1,
  2683. 'msg'=>"该订单不允许出库:".$info['librarynot'],
  2684. 'data'=>[]
  2685. ],JSON_UNESCAPED_UNICODE);
  2686. die;
  2687. }
  2688. if($info['library'] == 3){
  2689. echo json_encode([
  2690. 'code'=>-1,
  2691. 'msg'=>"该订单已退库!",
  2692. 'data'=>[]
  2693. ],JSON_UNESCAPED_UNICODE);
  2694. die;
  2695. }
  2696. $fullorder = $this->_text($info);//获取所需信息
  2697. $this->logic_ding->sendToDing("打印快递单,订单的信息".json_encode($fullorder,JSON_UNESCAPED_UNICODE));
  2698. //美仓不需要海关报关信息,
  2699. if($fullorder['type'] != 5){
  2700. //中国发货的 目前是dhl需要海关申报编码
  2701. if(empty($fullorder['sbbm'])){
  2702. echo json_encode([
  2703. 'code'=>-1,
  2704. 'msg'=>$fullorder['number'].' 海关申报配置异常,请提交给技术处理'.$fullorder['sbbm'],
  2705. 'data'=>[]
  2706. ],JSON_UNESCAPED_UNICODE);
  2707. die;
  2708. }
  2709. }
  2710. $time = time();
  2711. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  2712. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  2713. $pdfnum = 1;//PDF打印几遍
  2714. if($fullorder['waybillid'] != '')
  2715. {
  2716. $del = $this->cne->get_del($fullorder['waybillid']);
  2717. }
  2718. $barcode = $this->cne->get_data($fullorder);
  2719. $this->logic_ding->sendToDing("扫面发货单出运单".json_encode($barcode,JSON_UNESCAPED_UNICODE));
  2720. if($barcode['x'] == 1)
  2721. {
  2722. $bctime = date('Ymd',$time);
  2723. $Hwaybill = $barcode['waybill'];
  2724. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  2725. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  2726. if(isset($barcode['yd']) && isset($Hwaybill))
  2727. {
  2728. if($fullorder['waybill'] != "")
  2729. {
  2730. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  2731. }
  2732. else
  2733. {
  2734. $oldwaybill = $fullorder['oldwaybill'];
  2735. }
  2736. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  2737. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  2738. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$info['id']))
  2739. {
  2740. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  2741. $this->logic_ding->sendToDing("扫面发货单出运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2742. echo json_encode([
  2743. 'code'=>1,
  2744. 'msg'=>"ok",
  2745. 'data'=>$text
  2746. ],JSON_UNESCAPED_UNICODE);
  2747. die;
  2748. }else{
  2749. echo json_encode([
  2750. 'code'=>-1,
  2751. 'msg'=>"订单信息保存异常",
  2752. 'data'=>[]
  2753. ],JSON_UNESCAPED_UNICODE);
  2754. die;
  2755. }
  2756. }
  2757. }
  2758. else
  2759. {
  2760. $failed = $barcode['Description'];//错误提示
  2761. //$fullorder['printnumber'] = $fullorder['printnumber'] +1;
  2762. //$this->$fullorder_name->save(array('print'=>1,'failed'=>$failed,'printnumber'=>$fullorder['printnumber']),$info['id']);
  2763. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$info['id']);
  2764. echo json_encode([
  2765. 'code'=>-1,
  2766. 'msg'=>$failed,
  2767. 'data'=>[]
  2768. ],JSON_UNESCAPED_UNICODE);
  2769. die;
  2770. }
  2771. echo json_encode([
  2772. 'code'=>-1,
  2773. 'msg'=>"执行订单异常,请联系技术",
  2774. 'data'=>[]
  2775. ],JSON_UNESCAPED_UNICODE);
  2776. die;
  2777. }
  2778. }