Systemprint.php 89 KB

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