Systemprint.php 101 KB

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