Systemprint.php 99 KB

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