Systemprint.php 99 KB

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