Systemprint.php 97 KB

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