Systemprint.php 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736
  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. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  706. {
  707. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  708. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  709. }
  710. }
  711. }
  712. else if($fullorder['printcode'] == "DHLUSA")//DHL9610
  713. {
  714. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  715. if(isset($barcode['AirwayBillNumber']))
  716. {
  717. $bctime = date('Ymd',$time);
  718. $Hwaybill = $barcode['AirwayBillNumber'];
  719. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  720. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  721. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  722. {
  723. if($fullorder['waybill'] != "")
  724. {
  725. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  726. }
  727. else
  728. {
  729. $oldwaybill = $fullorder['oldwaybill'];
  730. }
  731. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  732. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  733. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  734. {
  735. $type = 1;
  736. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  737. }
  738. }
  739. }
  740. else
  741. {
  742. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  743. {
  744. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  745. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  746. }
  747. }
  748. /**
  749. if(isset($barcode['AirwayBillNumber']))
  750. {
  751. $bctime = date('Ymd',$time);
  752. $Hwaybill = $barcode['AirwayBillNumber'];
  753. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  754. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  755. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  756. {
  757. $fullorder['waybill'] = $Hwaybill;
  758. $sb = $this->dhl->get_data_9610($fullorder);
  759. if($sb != 1)
  760. {
  761. $this->$fullorder_name->save(array('print'=>1,'failed'=>$sb),$va[$n]);
  762. }
  763. else
  764. {
  765. if($fullorder['waybill'] != "")
  766. {
  767. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  768. }
  769. else
  770. {
  771. $oldwaybill = $fullorder['oldwaybill'];
  772. }
  773. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  774. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  775. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  776. {
  777. $type = 1;
  778. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  779. }
  780. }
  781. }
  782. }
  783. else
  784. {
  785. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  786. {
  787. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  788. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  789. }
  790. }
  791. **/
  792. }
  793. /**
  794. else if($fullorder['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  795. {
  796. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  797. if($barcode['c'] == 1)
  798. {
  799. $bctime = date('Ymd',$time);
  800. $Hwaybill = $barcode['data']['waybill'];
  801. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  802. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  803. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  804. {
  805. if($fullorder['waybill'] != "")
  806. {
  807. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  808. }
  809. else
  810. {
  811. $oldwaybill = $fullorder['oldwaybill'];
  812. }
  813. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  814. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  815. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  816. {
  817. $type = 1;
  818. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  819. }
  820. }
  821. }
  822. else
  823. {
  824. if(isset($barcode['data']))
  825. {
  826. $failed = $barcode['data'];
  827. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  828. }
  829. }
  830. }
  831. **/
  832. else if($fullorder['printcode'] == "USPS")
  833. {
  834. $barcode = $this->usps->get_data($fullorder);
  835. //改新的去掉
  836. // if(isset($barcode[0]))
  837. // {
  838. // $barcode = $barcode[0];
  839. // }
  840. //if(isset($barcode['LabelImage']) || isset($barcode[0]['LabelImage']))
  841. //改新的去掉
  842. if(isset($barcode['labelImage']))
  843. {
  844. $bctime = date('Ymd',$time);
  845. //$Hwaybill = substr($barcode['BarcodeNumber'], 8); //改新的去掉 新的 Labellmage 改 labelImage
  846. $Hwaybill = $barcode['trackingNumber'];
  847. $Hyd = $this->_pdf($barcode['labelImage'],'y-'.$Hwaybill,$bctime);
  848. //$Hyd = $this->_pdf($barcode['LabelImage'],'y-'.$Hwaybill,$bctime);
  849. //if(isset($barcode['LabelImage']) && isset($Hwaybill))
  850. if(isset($barcode['labelImage']) && isset($Hwaybill))
  851. {
  852. if($fullorder['waybill'] != "")
  853. {
  854. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  855. }
  856. else
  857. {
  858. $oldwaybill = $fullorder['oldwaybill'];
  859. }
  860. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  861. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  862. 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']
  863. {
  864. $type = 1;
  865. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  866. }
  867. }
  868. }
  869. else if(isset($barcode['error']))
  870. {
  871. $failed = $barcode['Description'];//错误提示
  872. if(stripos($failed,'The requested Mail') === false)
  873. {
  874. if($failed != 'false')
  875. {
  876. $this->$fullorder_name->save(array('print'=>1,'failed'=>json_encode($barcode['error'])),$va[$n]);
  877. }
  878. }
  879. }
  880. /**
  881. else if(isset($barcode['error']['message']))
  882. {
  883. if(isset($barcode['error']['errors'][0]['detail']))
  884. {
  885. $failed = $barcode['error']['errors'][0]['detail'];//错误提示
  886. }
  887. else
  888. {
  889. $failed = $barcode['error']['message'];//错误提示
  890. }
  891. //if(stripos($failed,'The requested Mail') === false)
  892. //{
  893. if($failed != 'false')
  894. {
  895. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  896. }
  897. //}
  898. }
  899. **/
  900. else
  901. {
  902. $failed = json_encode($barcode);//错误提示
  903. if($failed != 'false')
  904. {
  905. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  906. }
  907. }
  908. }
  909. else if($fullorder['printcode'] == "FEDEXGF")//官方FEDEX接口
  910. {
  911. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  912. //接口升级
  913. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  914. if($barcode['x'] == 1)
  915. {
  916. $bctime = date('Ymd',$time);
  917. $Hwaybill = $barcode['waybill'];
  918. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  919. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  920. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  921. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  922. if(isset($barcode['label']) && isset($Hwaybill))
  923. {
  924. if($fullorder['waybill'] != "")
  925. {
  926. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  927. }
  928. else
  929. {
  930. $oldwaybill = $fullorder['oldwaybill'];
  931. }
  932. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  933. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  934. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  935. {
  936. $type = 1;
  937. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95,'fp'=>base_url().'data/pdf/'.$bctime.'/f-'.$Hwaybill.'.pdf');
  938. }
  939. }
  940. }
  941. else
  942. {
  943. if(isset($barcode['Description']))
  944. {
  945. if($barcode['Description'] != 'FEDEX_INTERNATIONAL_PRIORITY is not supported for the origin and destination pair.')
  946. {
  947. $failed = $barcode['Description'];//错误提示
  948. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  949. }
  950. else
  951. {
  952. $failed = 'FEDEX返回不正确信息';//错误提示
  953. }
  954. }
  955. }
  956. }
  957. /**
  958. else if($fullorder['printcode'] == "FEDEXCBY")//官方FEDEX接口许昌玉美桥
  959. {
  960. $barcode = $this->fedex_cby->get_data($fullorder);//获取联邦快递信息
  961. if($barcode['x'] == 1)
  962. {
  963. $bctime = date('Ymd',$time);
  964. $Hwaybill = $barcode['waybill'];
  965. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  966. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  967. if(isset($barcode['label']) && isset($Hwaybill))
  968. {
  969. if($fullorder['waybill'] != "")
  970. {
  971. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  972. }
  973. else
  974. {
  975. $oldwaybill = $fullorder['oldwaybill'];
  976. }
  977. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  978. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  979. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  980. {
  981. $type = 1;
  982. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  983. }
  984. }
  985. }
  986. else
  987. {
  988. if(isset($barcode['Description']))
  989. {
  990. $failed = $barcode['Description'];//错误提示
  991. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  992. }
  993. }
  994. }
  995. **/
  996. else if($fullorder['printcode'] == "DPD" || $fullorder['printcode'] == "FTFEDEX")
  997. {
  998. $barcode = $this->dpd->get_data($fullorder);//获取联邦快递信息
  999. if($barcode['x'] == 1)
  1000. {
  1001. $bctime = date('Ymd',$time);
  1002. $Hwaybill = $barcode['waybill'];
  1003. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1004. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1005. {
  1006. if($fullorder['waybill'] != "")
  1007. {
  1008. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1009. }
  1010. else
  1011. {
  1012. $oldwaybill = $fullorder['oldwaybill'];
  1013. }
  1014. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1015. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1016. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1017. {
  1018. $type = 1;
  1019. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1020. }
  1021. }
  1022. else if(isset($barcode['yd']) && $Hwaybill == '' && $barcode['yd'] == '')
  1023. {
  1024. $oldwaybill = $fullorder['oldwaybill'];
  1025. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1026. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1027. {
  1028. $type = 2;
  1029. }
  1030. }
  1031. else
  1032. {
  1033. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1034. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1035. }
  1036. }
  1037. else
  1038. {
  1039. $failed = $barcode['Description'];//错误提示
  1040. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1041. }
  1042. }
  1043. else if($fullorder['printcode'] == "DPDIOSS" || $fullorder['printcode'] == "FTFEDEXIOSS")
  1044. {
  1045. $barcode = $this->dpdioss->get_data($fullorder);//获取联邦快递信息
  1046. /** 正常
  1047. if($barcode['x'] == 1)
  1048. {
  1049. $bctime = date('Ymd',$time);
  1050. $Hwaybill = $barcode['waybill'];
  1051. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1052. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1053. {
  1054. if($fullorder['waybill'] != "")
  1055. {
  1056. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1057. }
  1058. else
  1059. {
  1060. $oldwaybill = $fullorder['oldwaybill'];
  1061. }
  1062. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1063. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1064. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1065. {
  1066. $type = 1;
  1067. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1068. }
  1069. }
  1070. else
  1071. {
  1072. $failed = '平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1073. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1074. }
  1075. }
  1076. **/
  1077. //临时开始
  1078. if($barcode['x'] == 1)
  1079. {
  1080. $bctime = date('Ymd',$time);
  1081. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1082. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1083. {
  1084. $type = 2;
  1085. }
  1086. }
  1087. //临时结束
  1088. else
  1089. {
  1090. $failed = $barcode['Description'];//错误提示
  1091. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1092. }
  1093. }
  1094. // 只获取运单号不打印运单
  1095. else if($fullorder['printcode'] == "DPDXW" || $fullorder['printcode'] == "UKDHLXW" || $fullorder['printcode'] == "FTFEDEXXW")
  1096. {
  1097. $barcode = $this->dpdxw->get_data($fullorder);//获取联邦快递信息
  1098. if($barcode['x'] == 1)
  1099. {
  1100. $bctime = date('Ymd',$time);
  1101. $Hwaybill = $barcode['waybill'];
  1102. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1103. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1104. {
  1105. if($fullorder['waybill'] != "")
  1106. {
  1107. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1108. }
  1109. else
  1110. {
  1111. $oldwaybill = $fullorder['oldwaybill'];
  1112. }
  1113. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1114. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1115. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1116. {
  1117. $type = 1;
  1118. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1119. }
  1120. }
  1121. else
  1122. {
  1123. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1124. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1125. }
  1126. }
  1127. else
  1128. {
  1129. $failed = $barcode['Description'];//错误提示
  1130. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1131. }
  1132. }
  1133. /**
  1134. // 此DPD接口暂时不用
  1135. // DPD只获取运单号不打印运单
  1136. else if($fullorder['printcode'] == "DPD")
  1137. {
  1138. if($fullorder['zhou'] == '12')//欧洲
  1139. {
  1140. if($fullorder_name == 'fullordersmt')//速卖通9610
  1141. {
  1142. $fullorder['ysfs'] == '1921';
  1143. }
  1144. else if($fullorder_name == 'fullorder')//独立站9610
  1145. {
  1146. $fullorder['ysfs'] == '2021';
  1147. }
  1148. }
  1149. else if($fullorder['zhou'] == '13')//非洲
  1150. {
  1151. $fullorder['ysfs'] == '1881';
  1152. }
  1153. //$fullorder['ysfs'] == '2041';//欧洲全程不包双清、税
  1154. //$fullorder['ysfs'] == '1981';//欧洲速卖通非9610
  1155. //$fullorder['ysfs'] == '2001';//欧洲独立站非9610
  1156. $barcode = $this->dpd->get_data($fullorder);//获取信息
  1157. if($barcode['x'] == 1)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1158. {
  1159. $bctime = date('Ymd',$time);
  1160. $Hwaybill = $barcode['waybill'];//运单号
  1161. if($fullorder['waybill'] != "")
  1162. {
  1163. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1164. }
  1165. else
  1166. {
  1167. $oldwaybill = $fullorder['oldwaybill'];
  1168. }
  1169. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1170. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1171. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1172. {
  1173. $type = 2;
  1174. }
  1175. }
  1176. else
  1177. {
  1178. $failed = $barcode['Description'];
  1179. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1180. }
  1181. }
  1182. **/
  1183. /** 阿里仓联邦不打印运单模式
  1184. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1185. {
  1186. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1187. $barcode = $this->ali->get_data($fullorder);//获取DHL快递信息
  1188. //$Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1189. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1190. if($barcode['a'] == 2)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1191. {
  1192. $bctime = date('Ymd',$time);
  1193. $Hwaybill = $barcode['number'];//运单号
  1194. //$this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//目前不需要打印标签
  1195. if($fullorder['waybill'] != "")
  1196. {
  1197. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1198. }
  1199. else
  1200. {
  1201. $oldwaybill = $fullorder['oldwaybill'];
  1202. }
  1203. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1204. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1205. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1206. {
  1207. $type = 2;
  1208. }
  1209. }
  1210. else
  1211. {
  1212. $failed = $barcode['m'];
  1213. //$failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1214. //$failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1215. if($fullorder['print'] == 3)
  1216. {
  1217. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1218. }
  1219. else
  1220. {
  1221. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1222. }
  1223. }
  1224. }
  1225. **/
  1226. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1227. {
  1228. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1229. $barcode = $this->ali->get_data($fullorder);//获取快递信息
  1230. $Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1231. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1232. if($barcode['a'] == 2 && $Hyd['a'] == 2)
  1233. {
  1234. $bctime = date('Ymd',$time);
  1235. $Hwaybill = $barcode['number'];//运单号
  1236. $this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//上传PDF
  1237. if($fullorder['waybill'] != "")
  1238. {
  1239. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1240. }
  1241. else
  1242. {
  1243. $oldwaybill = $fullorder['oldwaybill'];
  1244. }
  1245. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1246. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1247. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1248. {
  1249. $type = 1;
  1250. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1251. }
  1252. }
  1253. else
  1254. {
  1255. //$failed = $barcode['m'];
  1256. $failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1257. $failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1258. if($fullorder['print'] == 3)
  1259. {
  1260. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1261. }
  1262. else
  1263. {
  1264. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1265. }
  1266. }
  1267. }
  1268. else if($fullorder['printcode'] == "UPS")//接口
  1269. {
  1270. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1271. if($barcode['x'] == 1)
  1272. {
  1273. $bctime = date('Ymd',$time);
  1274. $Hwaybill = $barcode['waybill'];
  1275. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1276. if(isset($barcode['label']) && isset($Hwaybill))
  1277. {
  1278. if($fullorder['waybill'] != "")
  1279. {
  1280. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1281. }
  1282. else
  1283. {
  1284. $oldwaybill = $fullorder['oldwaybill'];
  1285. }
  1286. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1287. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1288. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1289. {
  1290. $type = 1;
  1291. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1292. }
  1293. }
  1294. }
  1295. else
  1296. {
  1297. $failed = $barcode['Description'];//错误提示
  1298. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1299. }
  1300. }
  1301. else if($fullorder['printcode'] == "DPEX" || $fullorder['printcode'] == "FedEx_2day" || $fullorder['printcode'] == "usps_priority" || $fullorder['printcode'] == 'FEDEX_G' || $fullorder['printcode'] == 'FedEx_GD')//官方FEDEX接口
  1302. {
  1303. if($fullorder['waybillid'] != '')
  1304. {
  1305. $del = $this->cne->get_del($fullorder['waybillid']);
  1306. }
  1307. $barcode = $this->cne->get_data($fullorder);
  1308. if($barcode['x'] == 1)
  1309. {
  1310. $bctime = date('Ymd',$time);
  1311. $Hwaybill = $barcode['waybill'];
  1312. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1313. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1314. if(isset($barcode['yd']) && isset($Hwaybill))
  1315. {
  1316. if($fullorder['waybill'] != "")
  1317. {
  1318. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1319. }
  1320. else
  1321. {
  1322. $oldwaybill = $fullorder['oldwaybill'];
  1323. }
  1324. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1325. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1326. 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]))
  1327. {
  1328. $type = 1;
  1329. $pdfnum = ($fullorder['printcode'] == "DPEX")?2:1;
  1330. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1331. }
  1332. }
  1333. }
  1334. else
  1335. {
  1336. $failed = $barcode['Description'];//错误提示
  1337. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1338. }
  1339. }
  1340. else if($fullorder['printcode'] == "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")
  1341. {
  1342. $barcode = $this->hualeixw->get_data($fullorder);
  1343. $bctime = date('Ymd',$time);
  1344. if(!isset($barcode['x']))
  1345. {
  1346. print_r($barcode);exit;
  1347. }
  1348. if($barcode['x'] == 1)
  1349. {
  1350. if($barcode['ys'] == 1)
  1351. {
  1352. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1353. {
  1354. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1355. }
  1356. $bctime = date('Ymd',$time);
  1357. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1358. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1359. {
  1360. $type = 2;
  1361. }
  1362. }
  1363. else
  1364. {
  1365. $Hwaybill = $barcode['waybill'];
  1366. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1367. if(isset($barcode['label']) && isset($Hwaybill))
  1368. {
  1369. if($fullorder['waybill'] != "")
  1370. {
  1371. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1372. }
  1373. else
  1374. {
  1375. $oldwaybill = $fullorder['oldwaybill'];
  1376. }
  1377. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1378. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1379. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1380. {
  1381. if($fullorder['printcode'] == "HUALEIXW-FEDEX")
  1382. {
  1383. $type = 5;
  1384. }
  1385. else
  1386. {
  1387. $type = 2;
  1388. }
  1389. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1390. }
  1391. }
  1392. }
  1393. }
  1394. else
  1395. {
  1396. $failed = $barcode['Description'];//错误提示
  1397. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1398. }
  1399. /**
  1400. if($barcode['x'] == 1)
  1401. {
  1402. if($barcode['ys'] == 1)
  1403. {
  1404. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1405. {
  1406. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1407. }
  1408. }
  1409. $bctime = date('Ymd',$time);
  1410. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1411. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','waybill'=>$barcode['waybill'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1412. {
  1413. $type = 2;
  1414. }
  1415. }
  1416. else
  1417. {
  1418. $failed = $barcode['Description'];//错误提示
  1419. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1420. }
  1421. **/
  1422. }
  1423. 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')
  1424. {
  1425. $barcode = $this->hualei->get_data($fullorder);
  1426. $bctime = date('Ymd',$time);
  1427. if(!isset($barcode['x']))
  1428. {
  1429. print_r($barcode);exit;
  1430. }
  1431. if($barcode['x'] == 1)
  1432. {
  1433. if($barcode['ys'] == 1)
  1434. {
  1435. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualei','number'=>$fullorder['number'])))
  1436. {
  1437. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1438. }
  1439. $bctime = date('Ymd',$time);
  1440. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1441. $waybill2 = '';
  1442. if(isset($barcode['waybill2']))
  1443. {
  1444. $waybill2 = $barcode['waybill2'];
  1445. }
  1446. 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]))
  1447. {
  1448. $type = 2;
  1449. }
  1450. }
  1451. else
  1452. {
  1453. $Hwaybill = $barcode['waybill'];
  1454. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1455. if(isset($barcode['label']) && isset($Hwaybill))
  1456. {
  1457. if($fullorder['waybill'] != "")
  1458. {
  1459. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1460. }
  1461. else
  1462. {
  1463. $oldwaybill = $fullorder['oldwaybill'];
  1464. }
  1465. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1466. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1467. $waybill2 = '';
  1468. if(isset($barcode['waybill2']))
  1469. {
  1470. $waybill2 = $barcode['waybill2'];
  1471. }
  1472. 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]))
  1473. {
  1474. if($fullorder['printcode'] == "HUALEI-FEDEX" || $fullorder['printcode'] == "HUALEI-MLXY" )
  1475. {
  1476. //$type = 5;
  1477. $type = 1;
  1478. }
  1479. else if($fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-ARAMEX-S" || $fullorder['printcode'] == "HUALEI-GES-EU")
  1480. {
  1481. $type = 1;
  1482. }
  1483. else if($fullorder['printcode'] == "HUALEI-DHL")
  1484. {
  1485. //$type = 5;
  1486. $type = 1;
  1487. }
  1488. else if($fullorder['printcode'] == "HUALEI-MGLB")
  1489. {
  1490. //$type = 5;
  1491. $type = 1;
  1492. }
  1493. else
  1494. {
  1495. $type = 2;
  1496. }
  1497. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1498. }
  1499. }
  1500. }
  1501. }
  1502. else
  1503. {
  1504. $failed = $barcode['Description'];//错误提示
  1505. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1506. }
  1507. }
  1508. /** 云途开始**/
  1509. else if(($fullorder['printcode'] == "YunExpress")||($fullorder['printcode'] =='YunExpress_BaoXian'))
  1510. {
  1511. // echo "123";
  1512. // exit;
  1513. // if(!empty($fullorder['waybill']))
  1514. // {
  1515. // $label = $this->yuntu->get_label($fullorder['number']);
  1516. // if($label['x'] == 1){
  1517. // $bctime = date('Ymd',$time);
  1518. // $Hwaybill = $fullorder['waybill'];//运单号
  1519. // $this->_pdfurl($label['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1520. // $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1521. // if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3),$va[$n]))
  1522. // {
  1523. // $type = 1;
  1524. // $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1525. // }
  1526. // }
  1527. // }
  1528. // else{
  1529. $barcode = $this->yuntu->get_data($fullorder);//获取快递信息
  1530. // var_dump($barcode);
  1531. if($barcode['x'] == 1){
  1532. $bctime = date('Ymd',$time);
  1533. $Hwaybill = $barcode['waybill'];//运单号
  1534. $this->_pdfurl($barcode['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1535. if($fullorder['waybill'] != "")
  1536. {
  1537. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1538. }
  1539. else
  1540. {
  1541. $oldwaybill = $fullorder['oldwaybill'];
  1542. }
  1543. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1544. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1545. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1546. {
  1547. $type = 1;
  1548. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1549. }
  1550. }else{
  1551. $failed = $barcode['Description'].'123';//错误提示
  1552. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1553. }
  1554. //}
  1555. //die;
  1556. }
  1557. elseif(($fullorder['printcode'] == "USKD01")){
  1558. if($fullorder['waybillid'] != '')
  1559. {
  1560. $del = $this->zxyuntu->get_del($fullorder['waybillid']);
  1561. }
  1562. // $send_info = $fullorder;
  1563. // $send_info['number'] = $send_info['number']."_".$fullorder['printnumber'];
  1564. //$barcode = $this->zxyuntu->get_data($send_info);
  1565. $barcode = $this->zxyuntu->get_data($fullorder);
  1566. if($barcode['x'] == 1)
  1567. {
  1568. $bctime = date('Ymd',$time);
  1569. $Hwaybill = $barcode['waybill'];
  1570. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1571. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1572. if(isset($barcode['yd']) && isset($Hwaybill))
  1573. {
  1574. if($fullorder['waybill'] != "")
  1575. {
  1576. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1577. }
  1578. else
  1579. {
  1580. $oldwaybill = $fullorder['oldwaybill'];
  1581. }
  1582. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1583. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1584. 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]))
  1585. {
  1586. $type = 1;
  1587. $pdfnum = 1;
  1588. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1589. }
  1590. }
  1591. }
  1592. else
  1593. {
  1594. $failed = $barcode['Description'];//错误提示
  1595. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1596. }
  1597. }elseif(($fullorder['printcode'] == "3PE_XB")){
  1598. if($fullorder['printnumber'] > 0){
  1599. $this->itsxb->cancel_order($fullorder['number']);
  1600. }
  1601. $barcode = $this->itsxb->get_data($fullorder);
  1602. if($barcode['x'] == 1)
  1603. {
  1604. $bctime = date('Ymd',$time);
  1605. $Hwaybill = $barcode['waybill'];
  1606. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1607. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1608. if(isset($barcode['label']) && isset($Hwaybill))
  1609. {
  1610. if($fullorder['waybill'] != "")
  1611. {
  1612. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1613. }
  1614. else
  1615. {
  1616. $oldwaybill = $fullorder['oldwaybill'];
  1617. }
  1618. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1619. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1620. 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]))
  1621. {
  1622. $type = 8;
  1623. $pdfnum = 1;
  1624. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1625. }
  1626. }
  1627. }
  1628. else
  1629. {
  1630. $failed = $barcode['Description'];//错误提示
  1631. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1632. }
  1633. }
  1634. else
  1635. {
  1636. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  1637. }
  1638. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1639. {
  1640. $text['name'] = '速卖通';
  1641. }
  1642. else if($fullorder_name == 'fullordertt')
  1643. {
  1644. $text['name'] = 'TikTok';
  1645. }
  1646. else if($fullorder_name == 'fullorderamz')
  1647. {
  1648. $text['name'] = '亚马逊';
  1649. }
  1650. else if($fullorder_name == 'fullorderxw')
  1651. {
  1652. $text['name'] = '翔文';
  1653. }
  1654. else
  1655. {
  1656. $text['name'] = '独立站';
  1657. }
  1658. $text['express'] = $fullorder['express'];
  1659. //$text['country'] = $fullorder['country'];
  1660. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1661. $text['orderinfo'] = $fullorder['orderinfo'];
  1662. $text['number'] = $fullorder['number'];
  1663. $text['shipremarks'] = $fullorder['shipremarks'];
  1664. $text['ts'] = $fullorder['ts'];
  1665. $text['time'] = $fullorder['times'];
  1666. $text['printnumber'] = $fullorder['printnumber'];
  1667. $text['pdfnum'] = $pdfnum;
  1668. $text['pt'] = $fullorder['pt'];
  1669. $text['warehouse'] = $fullorder['warehouse']['title'];
  1670. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1671. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1672. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1673. }
  1674. else if(($fullorder['printtype'] == 2 || $fullorder['printtype'] == 4) && $fullorder['library'] != 2)
  1675. {
  1676. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1677. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1678. {
  1679. $type = 2;
  1680. }
  1681. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1682. {
  1683. $text['name'] = '速卖通';
  1684. }
  1685. else
  1686. {
  1687. $text['name'] = '独立站';
  1688. }
  1689. $text['express'] = $fullorder['express'];
  1690. //$text['country'] = $fullorder['country'];
  1691. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1692. $text['orderinfo'] = $fullorder['orderinfo'];
  1693. $text['number'] = $fullorder['number'];
  1694. $text['shipremarks'] = $fullorder['shipremarks'];
  1695. $text['ts'] = $fullorder['ts'];
  1696. $text['time'] = $fullorder['times'];
  1697. $text['printnumber'] = $fullorder['printnumber'];
  1698. $text['pdfnum'] = $pdfnum;
  1699. $text['pt'] = $fullorder['pt'];
  1700. $text['warehouse'] = $fullorder['warehouse']['title'];
  1701. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1702. $rows = array('type'=>$fullorder['printtype'],'n'=>$n-1,'data'=>$v,'text'=>$text);
  1703. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1704. }
  1705. else
  1706. {
  1707. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1708. {
  1709. $text['name'] = '速卖通';
  1710. }
  1711. else
  1712. {
  1713. $text['name'] = '独立站';
  1714. }
  1715. $text['express'] = $fullorder['express'];
  1716. //$text['country'] = $fullorder['country'];
  1717. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1718. $text['orderinfo'] = $fullorder['orderinfo'];
  1719. $text['number'] = $fullorder['number'];
  1720. $text['shipremarks'] = $fullorder['shipremarks'];
  1721. $text['ts'] = $fullorder['ts'];
  1722. $text['time'] = $fullorder['times'];
  1723. $text['printnumber'] = $fullorder['printnumber'];
  1724. $text['pdfnum'] = $pdfnum;
  1725. $text['warehouse'] = $fullorder['warehouse']['title'];
  1726. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1727. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1728. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1729. }
  1730. }
  1731. }
  1732. public function _text($fullorder)
  1733. {
  1734. /** 发票地址信息暂时无用
  1735. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1736. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1737. $fullorder['baddress'][1] = $country['ename'];
  1738. **/
  1739. //获取所用相关信息
  1740. $warehouse = $this->warehouse->read($fullorder['type']);
  1741. $country = $this->country->read($fullorder['country']);//订单国家信息
  1742. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1743. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1744. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1745. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1746. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1747. $fullorder['country'] = $country['ename'];//订单国家名
  1748. $fullorder['zhou'] = $country['continent'];//所属州
  1749. $express = $this->express->read($fullorder['express']);
  1750. $fullorder['express'] = $express['servicename'];
  1751. $fullorder['account'] = $express['account'];
  1752. $fullorder['printcode'] = $express['printcode'];
  1753. $fullorder['time'] = date('Y-m-d',time());
  1754. $fullorder['times'] = date('Y-m-d H:i',time());
  1755. // $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1756. // 修复报关编码问题
  1757. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1758. $sbbm = "";
  1759. if(empty($declara_info)){
  1760. $sbbm = "";
  1761. }else{
  1762. $sbbm = $declara_info['bname'];
  1763. }
  1764. $fullorder['sbbm']= $sbbm;
  1765. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1766. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1767. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1768. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1769. $shop = $this->shop->read($fullorder['shop']);
  1770. $fullorder['shop'] = $shop['shopname'];
  1771. $shoptype = $this->typeclass->read($shop['type']);
  1772. $fullorder['shoptype'] = $shoptype['classtitle'];
  1773. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1774. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1775. if(is_numeric($fullorder['pay']))
  1776. {
  1777. $pay = $this->typeclass->read($fullorder['pay']);
  1778. if($pay['classid'] == '4')
  1779. {
  1780. $fullorder['pay'] = $pay['title'];
  1781. }
  1782. }
  1783. if($fullorder['printcode'] != "USPS")
  1784. {
  1785. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1786. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1787. }
  1788. //增加退货单所需信息
  1789. $pt = '';
  1790. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1791. foreach ($fpdata as $v)
  1792. {
  1793. $p = explode('|',trim($v,'|'));
  1794. if(isset($p[1]) && isset($p[2]))
  1795. {
  1796. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1797. }
  1798. }
  1799. $fullorder['pt'] = $pt;
  1800. return $fullorder;
  1801. }
  1802. public function _pdf($pdf,$title,$bctime)
  1803. {
  1804. $pdf_path = './data/pdf/'.$bctime.'/';
  1805. $file_base64 = $pdf;
  1806. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1807. $file_base64 = base64_decode($file_base64);
  1808. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1809. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1810. return $bctime;
  1811. }
  1812. public function _pdfurl($pdf,$title,$bctime)
  1813. {
  1814. $pdf_path = './data/pdf/'.$bctime.'/';
  1815. $pdf = fopen($pdf,"r");
  1816. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1817. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1818. return $bctime;
  1819. }
  1820. public function _exceldy()
  1821. {
  1822. if(isset($_GET['fexcel']))
  1823. {
  1824. if(isset($_SESSION['api']))
  1825. {
  1826. $user = $this->user->get_api($_SESSION['api']);
  1827. $usp = $user;
  1828. $fgshop = "";$sid = "";$wid="";$wtype="";
  1829. $usersp = explode('|',trim($user['shop'],'|'));
  1830. $userwh = explode('|',trim($user['warehouse'],'|'));
  1831. foreach ($usersp as $value)
  1832. {
  1833. $fgshop .= " shop = ".$value." or";
  1834. $sid .= " id = ".$value." or";
  1835. }
  1836. foreach ($userwh as $value)
  1837. {
  1838. $wid .= " id = ".$value." or";
  1839. $wtype .= " type = ".$value." or";
  1840. }
  1841. }
  1842. $dowid = $this->input->get('a');
  1843. $wid = "";
  1844. if($dowid != "")
  1845. {
  1846. $id_arr = explode(',',rtrim($dowid,','));
  1847. foreach ($id_arr as $v)
  1848. {
  1849. $wid .= " id = '$v' or";
  1850. }
  1851. $wid = " and (".rtrim($wid,'or').")";
  1852. }
  1853. $page = $this->input->get('page',true);
  1854. $perpage = $this->input->get('perpage',true);
  1855. $timetk = $this->input->get('timetk',true);
  1856. $timetj = $this->input->get('timetj',true);
  1857. $shop = $this->input->get('shop',true);
  1858. $print = $this->input->get('print',true);
  1859. $express = $this->input->get('express',true);
  1860. $waybill = $this->input->get('waybill',true);
  1861. $printtype = $this->input->get('printtype',true);
  1862. $orderinfo = $this->input->get('orderinfo',true);
  1863. $number = $this->input->get('number',true);
  1864. $type = $this->input->get('type',true);
  1865. $lowe = $this->input->get('lowe',true);
  1866. $info = $this->input->get('info',true);
  1867. $ji = $this->input->get('ji',true);
  1868. $so = $this->input->get('so',true);
  1869. $timetk = strtotime($timetk);
  1870. $timetj = strtotime($timetj);
  1871. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1872. if($print == 3)
  1873. {
  1874. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  1875. }
  1876. else
  1877. {
  1878. $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)."'";
  1879. }
  1880. if($shop)
  1881. {
  1882. $where .= " and shop = '$shop'";
  1883. }
  1884. if($express)
  1885. {
  1886. $where .= " and express = '$express'";
  1887. }
  1888. if($printtype)
  1889. {
  1890. $where .= " and printtype = '$printtype'";
  1891. }
  1892. if($orderinfo)
  1893. {
  1894. $where .= " and orderinfo = '$orderinfo'";
  1895. }
  1896. if($number)
  1897. {
  1898. $where .= " and number = '$number'";
  1899. }
  1900. if($waybill)
  1901. {
  1902. $where .= " and waybill = '$waybill'";
  1903. }
  1904. if($type)
  1905. {
  1906. $where .= " and type = '$type'";
  1907. }
  1908. else
  1909. {
  1910. $where .= " and type != '16'";
  1911. }
  1912. /**
  1913. if($type)
  1914. {
  1915. if($type != '4')
  1916. {
  1917. $where .= " and type = '$type'";
  1918. $where2 = '';
  1919. $where3 = '';
  1920. }
  1921. else
  1922. {
  1923. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  1924. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  1925. }
  1926. $where_a = "";
  1927. $where_b = "";
  1928. }
  1929. else
  1930. {
  1931. $where .= " and type != '4'";
  1932. $where_a = "(";
  1933. $where_b = ")";
  1934. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  1935. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  1936. }
  1937. **/
  1938. if($lowe)
  1939. {
  1940. $where .= " and fpdata like '%-$lowe-%'";
  1941. }
  1942. if($ji)
  1943. {
  1944. $where .= " and shipremarks like '%急%'";
  1945. }
  1946. if($so)
  1947. {
  1948. $where .= " and shipremarks like '%$so%'";
  1949. }
  1950. //数据排序
  1951. $order_str = ($print != 3)?"id desc":"printtime desc";
  1952. //取得信息列表
  1953. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  1954. //格式化数据
  1955. foreach ($info_list as $key=>$value)
  1956. {
  1957. $shop = $this->shop->read($value['shop']);
  1958. $info_list[$key]['shop'] = $shop['shopname'];
  1959. if($value['waybill'] == '0')
  1960. {
  1961. $info_list[$key]['waybill'] = "";
  1962. }
  1963. $express = $this->express->read($value['express']);
  1964. $info_list[$key]['express'] = $express['servicename'];
  1965. $warehouse = $this->warehouse->read($value['type']);
  1966. $info_list[$key]['type'] = $warehouse['title'];
  1967. if($value['printtime'] == '0')
  1968. {
  1969. $info_list[$key]['printtime'] = '<em class="t"></em>';
  1970. }
  1971. else
  1972. {
  1973. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  1974. }
  1975. if($value['print'] == 1)
  1976. {
  1977. $info_list[$key]['print'] = '不可打印';
  1978. }
  1979. else if($value['print'] == 2)
  1980. {
  1981. $info_list[$key]['print'] = '未打印';
  1982. }
  1983. else if($value['print'] == 3)
  1984. {
  1985. $info_list[$key]['print'] = '已打印';
  1986. }
  1987. if($value['library'] == 1)
  1988. {
  1989. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1990. }
  1991. else if($value['library'] == 2)
  1992. {
  1993. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1994. }
  1995. else if($value['library'] == 3)
  1996. {
  1997. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1998. }
  1999. if($value['printtype'] == 1){
  2000. $info_list[$key]['printtype'] = '运单';
  2001. }elseif($value['printtype'] == 2){
  2002. $info_list[$key]['printtype'] = '发货单';
  2003. }else{
  2004. $info_list[$key]['printtype'] = '不打印单据';
  2005. }
  2006. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2007. }
  2008. //取得信息列表
  2009. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2010. //格式化数据
  2011. foreach ($info_listsmt as $key=>$value)
  2012. {
  2013. $shop = $this->shop->read($value['shop']);
  2014. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2015. if($value['waybill'] == '0')
  2016. {
  2017. $info_listsmt[$key]['waybill'] = "";
  2018. }
  2019. $express = $this->express->read($value['express']);
  2020. $info_listsmt[$key]['express'] = $express['servicename'];
  2021. $warehouse = $this->warehouse->read($value['type']);
  2022. $info_listsmt[$key]['type'] = $warehouse['title'];
  2023. if($value['printtime'] == '0')
  2024. {
  2025. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  2026. }
  2027. else
  2028. {
  2029. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2030. }
  2031. if($value['print'] == 1)
  2032. {
  2033. $info_listsmt[$key]['print'] = '不可打印';
  2034. }
  2035. else if($value['print'] == 2)
  2036. {
  2037. $info_listsmt[$key]['print'] = '未打印';
  2038. }
  2039. else if($value['print'] == 3)
  2040. {
  2041. $info_listsmt[$key]['print'] = '已打印';
  2042. }
  2043. if($value['library'] == 1)
  2044. {
  2045. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2046. }
  2047. else if($value['library'] == 2)
  2048. {
  2049. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2050. }
  2051. else if($value['library'] == 3)
  2052. {
  2053. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2054. }
  2055. if($value['printtype'] == 1){
  2056. $info_listsmt[$key]['printtype'] = '运单';
  2057. }elseif($value['printtype'] == 2){
  2058. $info_listsmt[$key]['printtype'] = '发货单';
  2059. }else{
  2060. $info_listsmt[$key]['printtype'] = '不打印单据';
  2061. }
  2062. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2063. }
  2064. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2065. //格式化数据
  2066. foreach ($info_listtt as $key=>$value)
  2067. {
  2068. $shop = $this->shop->read($value['shop']);
  2069. $info_listtt[$key]['shop'] = $shop['shopname'];
  2070. if($value['waybill'] == '0')
  2071. {
  2072. $info_listtt[$key]['waybill'] = "";
  2073. }
  2074. $express = $this->express->read($value['express']);
  2075. $info_listtt[$key]['express'] = $express['servicename'];
  2076. $warehouse = $this->warehouse->read($value['type']);
  2077. $info_listtt[$key]['type'] = $warehouse['title'];
  2078. if($value['printtime'] == '0')
  2079. {
  2080. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  2081. }
  2082. else
  2083. {
  2084. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2085. }
  2086. if($value['print'] == 1)
  2087. {
  2088. $info_listtt[$key]['print'] = '不可打印';
  2089. }
  2090. else if($value['print'] == 2)
  2091. {
  2092. $info_listtt[$key]['print'] = '未打印';
  2093. }
  2094. else if($value['print'] == 3)
  2095. {
  2096. $info_listtt[$key]['print'] = '已打印';
  2097. }
  2098. if($value['library'] == 1)
  2099. {
  2100. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2101. }
  2102. else if($value['library'] == 2)
  2103. {
  2104. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2105. }
  2106. else if($value['library'] == 3)
  2107. {
  2108. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2109. }
  2110. if($value['printtype'] == 1){
  2111. $info_listtt[$key]['printtype'] = '运单';
  2112. }elseif($value['printtype'] == 2){
  2113. $info_listtt[$key]['printtype'] = '发货单';
  2114. }else{
  2115. $info_listtt[$key]['printtype'] = '不打印单据';
  2116. }
  2117. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2118. }
  2119. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2120. //格式化数据
  2121. foreach ($info_listamz as $key=>$value)
  2122. {
  2123. $shop = $this->shop->read($value['shop']);
  2124. $info_listamz[$key]['shop'] = $shop['shopname'];
  2125. if($value['waybill'] == '0')
  2126. {
  2127. $info_listamz[$key]['waybill'] = "";
  2128. }
  2129. $express = $this->express->read($value['express']);
  2130. $info_listamz[$key]['express'] = $express['servicename'];
  2131. $warehouse = $this->warehouse->read($value['type']);
  2132. $info_listamz[$key]['type'] = $warehouse['title'];
  2133. if($value['printtime'] == '0')
  2134. {
  2135. $info_listamz[$key]['printtime'] = '<em class="t"></em>';
  2136. }
  2137. else
  2138. {
  2139. $info_listamz[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2140. }
  2141. if($value['print'] == 1)
  2142. {
  2143. $info_listamz[$key]['print'] = '不可打印';
  2144. }
  2145. else if($value['print'] == 2)
  2146. {
  2147. $info_listamz[$key]['print'] = '未打印';
  2148. }
  2149. else if($value['print'] == 3)
  2150. {
  2151. $info_listamz[$key]['print'] = '已打印';
  2152. }
  2153. if($value['library'] == 1)
  2154. {
  2155. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2156. }
  2157. else if($value['library'] == 2)
  2158. {
  2159. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2160. }
  2161. else if($value['library'] == 3)
  2162. {
  2163. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2164. }
  2165. if($value['printtype'] == 1){
  2166. $info_listamz[$key]['printtype'] = '运单';
  2167. }elseif($value['printtype'] == 2){
  2168. $info_listamz[$key]['printtype'] = '发货单';
  2169. }else{
  2170. $info_listamz[$key]['printtype'] = '不打印单据';
  2171. }
  2172. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2173. }
  2174. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2175. //格式化数据
  2176. foreach ($info_listxw as $key=>$value)
  2177. {
  2178. $shop = $this->shop->read($value['shop']);
  2179. $info_listxw[$key]['shop'] = $shop['shopname'];
  2180. if($value['waybill'] == '0')
  2181. {
  2182. $info_listxw[$key]['waybill'] = "";
  2183. }
  2184. $express = $this->express->read($value['express']);
  2185. $info_listxw[$key]['express'] = $express['servicename'];
  2186. $warehouse = $this->warehouse->read($value['type']);
  2187. $info_listxw[$key]['type'] = $warehouse['title'];
  2188. if($value['printtime'] == '0')
  2189. {
  2190. $info_listxw[$key]['printtime'] = '<em class="t"></em>';
  2191. }
  2192. else
  2193. {
  2194. $info_listxw[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2195. }
  2196. if($value['print'] == 1)
  2197. {
  2198. $info_listxw[$key]['print'] = '不可打印';
  2199. }
  2200. else if($value['print'] == 2)
  2201. {
  2202. $info_listxw[$key]['print'] = '未打印';
  2203. }
  2204. else if($value['print'] == 3)
  2205. {
  2206. $info_listxw[$key]['print'] = '已打印';
  2207. }
  2208. if($value['library'] == 1)
  2209. {
  2210. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2211. }
  2212. else if($value['library'] == 2)
  2213. {
  2214. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2215. }
  2216. else if($value['library'] == 3)
  2217. {
  2218. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2219. }
  2220. if($value['printtype'] == 1){
  2221. $info_listxw[$key]['printtype'] = '运单';
  2222. }elseif($value['printtype'] == 2){
  2223. $info_listxw[$key]['printtype'] = '发货单';
  2224. }else{
  2225. $info_listxw[$key]['printtype'] = '不打印单据';
  2226. }
  2227. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2228. }
  2229. $title = '订单出库-'.date('Ymd',time());
  2230. $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>";
  2231. $tail = "\n";
  2232. $filename = $title.".xls";
  2233. $this->excel->get_fz2(array_merge($info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  2234. }
  2235. }
  2236. public function _barcode()
  2237. {
  2238. $post = $this->input->post(NULL, TRUE);
  2239. if(isset($_SESSION['api']))
  2240. {
  2241. $user = $this->user->get_api($_SESSION['api']);
  2242. $usp = $user;
  2243. $fgshop = "";$sid = "";$wid="";$wtype="";
  2244. $usersp = explode('|',trim($user['shop'],'|'));
  2245. $userwh = explode('|',trim($user['warehouse'],'|'));
  2246. foreach ($usersp as $value)
  2247. {
  2248. $fgshop .= " shop = ".$value." or";
  2249. $sid .= " id = ".$value." or";
  2250. }
  2251. foreach ($userwh as $value)
  2252. {
  2253. $wid .= " id = ".$value." or";
  2254. $wtype .= " type = ".$value." or";
  2255. }
  2256. }
  2257. if(isset($post['page']))
  2258. {
  2259. $page = $this->input->post('page',true);
  2260. $perpage = $this->input->post('perpage',true);
  2261. $warehouse = $this->input->post('warehouse',true);
  2262. $sku = $this->input->post('sku ',true);
  2263. $title = $this->input->post('title',true);
  2264. $print = $this->input->post('print ',true);
  2265. $timetk = $this->input->post('timetk',true);
  2266. $timetj = $this->input->post('timetj',true);
  2267. $timetk = strtotime($timetk);
  2268. $timetj = strtotime($timetj);
  2269. $where = "time > '$timetk' and time < '$timetj'";
  2270. if($warehouse)
  2271. {
  2272. $where .= " and warehouse = '$warehouse'";
  2273. }
  2274. if($sku)
  2275. {
  2276. $where .= " and sku like '%$sku%'";
  2277. }
  2278. if($title)
  2279. {
  2280. $where .= " and title like '%$title%'";
  2281. }
  2282. if($print)
  2283. {
  2284. $where .= " and print = '$print'";
  2285. }
  2286. //数据排序
  2287. $order_str = "time desc";
  2288. if(empty($page))
  2289. {
  2290. $start = 0;
  2291. $perpage = 1;
  2292. }
  2293. else
  2294. {
  2295. $start = ($page - 1)*$perpage;
  2296. }
  2297. //取得信息列表
  2298. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  2299. //格式化数据
  2300. foreach ($info_list as $key=>$value)
  2301. {
  2302. if($value['printtime'] > 0)
  2303. {
  2304. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  2305. }
  2306. else
  2307. {
  2308. $info_list[$key]['printtime'] = '未打印';
  2309. }
  2310. }
  2311. $total = $this->whlabelbarcodeprint->find_count($where);
  2312. $pagenum = ceil($total/$perpage);
  2313. $over = $total-($start+$perpage);
  2314. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2315. echo json_encode($rows);exit;
  2316. }
  2317. if(isset($_SESSION['api']))
  2318. {
  2319. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2320. $this->data['warehouse'] = $warehouse;
  2321. }
  2322. $this->_Template('systemprint_barcode',$this->data);
  2323. }
  2324. public function _barcodedc()
  2325. {
  2326. if(isset($_GET['excel']))
  2327. {
  2328. $warehouse = $this->input->post('warehouse',true);
  2329. $sku = $this->input->post('sku ',true);
  2330. $title = $this->input->post('title',true);
  2331. $print = $this->input->post('print ',true);
  2332. $ktime = $this->input->post('timetk',true);
  2333. $jtime = $this->input->post('timetj',true);
  2334. $ktime = strtotime($ktime);
  2335. $jtime = strtotime($jtime);
  2336. $where = "time > '$timetk' and time < '$timetj'";
  2337. if($warehouse)
  2338. {
  2339. $where .= " and warehouse = '$warehouse'";
  2340. }
  2341. if($sku)
  2342. {
  2343. $where .= " and sku like '%$sku%'";
  2344. }
  2345. if($title)
  2346. {
  2347. $where .= " and title like '%$title%'";
  2348. }
  2349. if($print)
  2350. {
  2351. $where .= " and print = '$print'";
  2352. }
  2353. $order_str = "time desc";
  2354. if(empty($page))
  2355. {
  2356. $start = 0;
  2357. $perpage = 1;
  2358. }
  2359. else
  2360. {
  2361. $start = ($page - 1)*$perpage;
  2362. }
  2363. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  2364. $title = '标签-'.date('Y-m-d H-i-s',time());
  2365. $titlename = "<table border=1>
  2366. <tr align='center'>
  2367. <td>条码号</td>
  2368. <td>SKU</td>
  2369. <td>产品名称</td>
  2370. </tr>
  2371. </table>";
  2372. $filename = $title.".xls";
  2373. $tail = "";
  2374. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2375. }
  2376. }
  2377. public function _barcodedr()
  2378. {
  2379. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2380. $config['upload_path'] = '.'.$dir ;
  2381. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2382. $config['allowed_types'] = 'xls|xlsx|csv';
  2383. $config['max_size'] = 10240;
  2384. $this->load->library('upload', $config);
  2385. $this->upload->initialize($config);
  2386. if ($this->upload->do_upload('userfile'))
  2387. {
  2388. $full_path = $dir.$this->upload->data('file_name');
  2389. $fileName = '.' . $full_path;
  2390. if (!file_exists($fileName))
  2391. {
  2392. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2393. }
  2394. else
  2395. {
  2396. libxml_use_internal_errors(true);
  2397. require_once "./data/excel/PHPExcel/IOFactory.php";
  2398. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2399. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2400. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2401. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2402. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2403. ++$column;//如果列数大于26行
  2404. $list = array();
  2405. for ($i = 2; $i <= $row; $i++) // 行数循环
  2406. {
  2407. $data = array();
  2408. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2409. {
  2410. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2411. }
  2412. $list[] = $data;
  2413. }
  2414. }
  2415. $i = 0;$j = 0;$ed = array();
  2416. foreach ($list as $key=>$value)
  2417. {
  2418. $time = time();
  2419. if($value['0'] == "")
  2420. {
  2421. continue;
  2422. }
  2423. $label = $value['0'];
  2424. $sku = $value['1'];
  2425. $title = $value['2'];
  2426. $num = $value['3'];
  2427. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2428. if(!$d)//如果没有这个SKU
  2429. {
  2430. $ed[] = array($sku.'-库存中不存在此SKU');
  2431. $j++;
  2432. continue;
  2433. }
  2434. if($num < 1)
  2435. {
  2436. $ed[] = array($sku.'-数量错误!');
  2437. $j++;
  2438. continue;
  2439. }
  2440. unset($d['id']);
  2441. $d['time'] = $time;
  2442. $d['num'] = $num;
  2443. $this->whlabelbarcodeprint->insert($d);
  2444. }
  2445. if($j > 0)
  2446. {
  2447. $tt = date('Ymd',time());
  2448. $title = '库存导入错误信息-'.$tt;
  2449. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2450. $tail = "\n";
  2451. $filename = $title.".xls";
  2452. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2453. $dir = '/data/excel/'.$time.'/';
  2454. $file_name = 'error_'.$time.rand(1000,9999);
  2455. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2456. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2457. fwrite($myfile,$ecl);
  2458. fclose($myfile);
  2459. $error = $dir.$file_name.'.xls';
  2460. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2461. }
  2462. else
  2463. {
  2464. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2465. }
  2466. }
  2467. }
  2468. public function _yswaybill()
  2469. {
  2470. $data = $this->yswaybill->find_all("waybill = ''");
  2471. foreach ($data as $v)
  2472. {
  2473. $type = $v['type'];
  2474. $number = $v['number'];
  2475. $express = $v['express'];
  2476. $fullorder = $this->$type->get_number($number);
  2477. $fullorder = $this->_text($fullorder);
  2478. $barcode = $this->$express->get_hqwaybill($number);
  2479. if(!isset($barcode['x']))
  2480. {
  2481. continue;
  2482. }
  2483. if($barcode['x'] == 1)
  2484. {
  2485. if($barcode['ys'] != 1)
  2486. {
  2487. $this->db->trans_begin();
  2488. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2489. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2490. if ($this->db->trans_status() === TRUE)
  2491. {
  2492. $this->db->trans_commit();
  2493. }
  2494. else
  2495. {
  2496. $this->db->trans_rollback();
  2497. }
  2498. }
  2499. }
  2500. else
  2501. {
  2502. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2503. }
  2504. }
  2505. echo 1;
  2506. }
  2507. /**
  2508. * 根据发货单打印快递
  2509. */
  2510. public function _printbyfh(){
  2511. $this->_Template('systemprint_fhd',$this->data);
  2512. }
  2513. /**
  2514. * 此方法是为了临时解决一下打印的问题
  2515. */
  2516. public function _getInfoByNumber(){
  2517. $param = $this->input->get(NULL, TRUE);
  2518. if(empty($param['number'])){
  2519. $param = $this->input->post(NULL, TRUE);
  2520. }
  2521. if(empty($param['number'])){
  2522. echo json_encode([
  2523. 'code'=>-1,
  2524. 'msg'=>"订单编码未传递",
  2525. 'data'=>[]
  2526. ],JSON_UNESCAPED_UNICODE);
  2527. die;
  2528. }
  2529. $this->logic_ding->sendToDing("扫面发货单出运单订单编码".json_encode($param));
  2530. $info = $this->logic_order->getInfo("number = '".$param['number']."'");
  2531. if(empty($info)){
  2532. echo json_encode([
  2533. 'code'=>-1,
  2534. 'msg'=>"未查询到订单信息",
  2535. 'data'=>[]
  2536. ],JSON_UNESCAPED_UNICODE);
  2537. die;
  2538. }
  2539. if(empty($param['is_ok'])){
  2540. if($info['printnumber'] > 1){
  2541. echo json_encode([
  2542. 'code'=>2,
  2543. 'msg'=>'该单共打印过<b style="color:red;">'.$info['printnumber'].'</b>次,请核对当前发货单是否是最新发货单',
  2544. 'data'=>[
  2545. 'number'=>$info['number'],
  2546. 'is_ok'=>1
  2547. ]
  2548. ],JSON_UNESCAPED_UNICODE);
  2549. die;
  2550. }
  2551. }
  2552. if(!in_array($info['express'],[71])){
  2553. echo json_encode([
  2554. 'code'=>-1,
  2555. 'msg'=>"快递不符合打印要求",
  2556. 'data'=>[]
  2557. ],JSON_UNESCAPED_UNICODE);
  2558. die;
  2559. }
  2560. $fullorder_name = $info['lv_platform'];
  2561. if($info['libraryconfirm'] == 1){
  2562. echo json_encode([
  2563. 'code'=>-1,
  2564. 'msg'=>"该订单不允许出库:".$info['librarynot'],
  2565. 'data'=>[]
  2566. ],JSON_UNESCAPED_UNICODE);
  2567. die;
  2568. }
  2569. if($info['library'] != 1){
  2570. echo json_encode([
  2571. 'code'=>-1,
  2572. 'msg'=>"该订单不是未出库状态,禁止打印",
  2573. 'data'=>[]
  2574. ],JSON_UNESCAPED_UNICODE);
  2575. die;
  2576. }
  2577. $fullorder = $this->_text($info);//获取所需信息
  2578. $this->logic_ding->sendToDing("打印快递单,订单的信息".json_encode($fullorder,JSON_UNESCAPED_UNICODE));
  2579. //美仓不需要海关报关信息,
  2580. if($fullorder['type'] != 5){
  2581. //中国发货的 目前是dhl需要海关申报编码
  2582. if(empty($fullorder['sbbm'])){
  2583. echo json_encode([
  2584. 'code'=>-1,
  2585. 'msg'=>$fullorder['number'].' 海关申报配置异常,请提交给技术处理'.$fullorder['sbbm'],
  2586. 'data'=>[]
  2587. ],JSON_UNESCAPED_UNICODE);
  2588. die;
  2589. }
  2590. }
  2591. $time = time();
  2592. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  2593. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  2594. $pdfnum = 1;//PDF打印几遍
  2595. if($fullorder['waybillid'] != '')
  2596. {
  2597. $del = $this->cne->get_del($fullorder['waybillid']);
  2598. }
  2599. $barcode = $this->cne->get_data($fullorder);
  2600. $this->logic_ding->sendToDing("扫面发货单出运单".json_encode($barcode,JSON_UNESCAPED_UNICODE));
  2601. if($barcode['x'] == 1)
  2602. {
  2603. $bctime = date('Ymd',$time);
  2604. $Hwaybill = $barcode['waybill'];
  2605. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  2606. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  2607. if(isset($barcode['yd']) && isset($Hwaybill))
  2608. {
  2609. if($fullorder['waybill'] != "")
  2610. {
  2611. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  2612. }
  2613. else
  2614. {
  2615. $oldwaybill = $fullorder['oldwaybill'];
  2616. }
  2617. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  2618. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  2619. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$info['id']))
  2620. {
  2621. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  2622. $this->logic_ding->sendToDing("扫面发货单出运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2623. echo json_encode([
  2624. 'code'=>1,
  2625. 'msg'=>"ok",
  2626. 'data'=>$text
  2627. ],JSON_UNESCAPED_UNICODE);
  2628. die;
  2629. }else{
  2630. echo json_encode([
  2631. 'code'=>-1,
  2632. 'msg'=>"订单信息保存异常",
  2633. 'data'=>[]
  2634. ],JSON_UNESCAPED_UNICODE);
  2635. die;
  2636. }
  2637. }
  2638. }
  2639. else
  2640. {
  2641. $failed = $barcode['Description'];//错误提示
  2642. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$info['id']);
  2643. echo json_encode([
  2644. 'code'=>-1,
  2645. 'msg'=>$failed,
  2646. 'data'=>[]
  2647. ],JSON_UNESCAPED_UNICODE);
  2648. die;
  2649. }
  2650. echo json_encode([
  2651. 'code'=>-1,
  2652. 'msg'=>"执行订单异常,请联系技术",
  2653. 'data'=>[]
  2654. ],JSON_UNESCAPED_UNICODE);
  2655. die;
  2656. }
  2657. }