Systemprint.php 110 KB

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