Systemprint.php 93 KB

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