Systemprint.php 116 KB

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