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