Systemprint.php 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144
  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 _pdfurlbak($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 _pdfurl($pdf, $title, $bctime)
  1952. {
  1953. $pdf_path = './data/pdf/' . $bctime . '/';
  1954. // 创建目录(如果不存在)
  1955. if (!is_dir($pdf_path)) {
  1956. mkdir($pdf_path, 0777, true); // 第三个参数 true 可以递归创建目录
  1957. }
  1958. // 获取PDF内容
  1959. $pdf_content = file_get_contents($pdf);
  1960. // 保存文件
  1961. file_put_contents($pdf_path . $title . '.pdf', $pdf_content);
  1962. $size = filesize($pdf_path . $title . '.pdf');
  1963. if($size > 0){
  1964. }else{
  1965. sleep(1);
  1966. // 获取PDF内容
  1967. $pdf_content = file_get_contents($pdf);
  1968. // 保存文件
  1969. file_put_contents($pdf_path . $title . '.pdf', $pdf_content);
  1970. }
  1971. return $bctime;
  1972. }
  1973. public function _exceldy()
  1974. {
  1975. if(isset($_GET['fexcel']))
  1976. {
  1977. if(isset($_SESSION['api']))
  1978. {
  1979. $user = $this->user->get_api($_SESSION['api']);
  1980. $usp = $user;
  1981. $fgshop = "";$sid = "";$wid="";$wtype="";
  1982. $usersp = explode('|',trim($user['shop'],'|'));
  1983. $userwh = explode('|',trim($user['warehouse'],'|'));
  1984. foreach ($usersp as $value)
  1985. {
  1986. $fgshop .= " shop = ".$value." or";
  1987. $sid .= " id = ".$value." or";
  1988. }
  1989. foreach ($userwh as $value)
  1990. {
  1991. $wid .= " id = ".$value." or";
  1992. $wtype .= " type = ".$value." or";
  1993. }
  1994. }
  1995. $dowid = $this->input->get('a');
  1996. $wid = "";
  1997. if($dowid != "")
  1998. {
  1999. $id_arr = explode(',',rtrim($dowid,','));
  2000. foreach ($id_arr as $v)
  2001. {
  2002. $wid .= " id = '$v' or";
  2003. }
  2004. $wid = " and (".rtrim($wid,'or').")";
  2005. }
  2006. $page = $this->input->get('page',true);
  2007. $perpage = $this->input->get('perpage',true);
  2008. $timetk = $this->input->get('timetk',true);
  2009. $timetj = $this->input->get('timetj',true);
  2010. $shop = $this->input->get('shop',true);
  2011. $print = $this->input->get('print',true);
  2012. $express = $this->input->get('express',true);
  2013. $waybill = $this->input->get('waybill',true);
  2014. $printtype = $this->input->get('printtype',true);
  2015. $orderinfo = $this->input->get('orderinfo',true);
  2016. $number = $this->input->get('number',true);
  2017. $type = $this->input->get('type',true);
  2018. $lowe = $this->input->get('lowe',true);
  2019. $info = $this->input->get('info',true);
  2020. $ji = $this->input->get('ji',true);
  2021. $so = $this->input->get('so',true);
  2022. $timetk = strtotime($timetk);
  2023. $timetj = strtotime($timetj);
  2024. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  2025. if($print == 3)
  2026. {
  2027. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  2028. }
  2029. else
  2030. {
  2031. $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)."'";
  2032. }
  2033. if($shop)
  2034. {
  2035. $where .= " and shop = '$shop'";
  2036. }
  2037. if($express)
  2038. {
  2039. $where .= " and express = '$express'";
  2040. }
  2041. if($printtype)
  2042. {
  2043. $where .= " and printtype = '$printtype'";
  2044. }
  2045. if($orderinfo)
  2046. {
  2047. $where .= " and orderinfo = '$orderinfo'";
  2048. }
  2049. if($number)
  2050. {
  2051. $where .= " and number = '$number'";
  2052. }
  2053. if($waybill)
  2054. {
  2055. $where .= " and waybill = '$waybill'";
  2056. }
  2057. if($type)
  2058. {
  2059. $where .= " and type = '$type'";
  2060. }
  2061. else
  2062. {
  2063. $where .= " and type != '16'";
  2064. }
  2065. /**
  2066. if($type)
  2067. {
  2068. if($type != '4')
  2069. {
  2070. $where .= " and type = '$type'";
  2071. $where2 = '';
  2072. $where3 = '';
  2073. }
  2074. else
  2075. {
  2076. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  2077. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  2078. }
  2079. $where_a = "";
  2080. $where_b = "";
  2081. }
  2082. else
  2083. {
  2084. $where .= " and type != '4'";
  2085. $where_a = "(";
  2086. $where_b = ")";
  2087. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  2088. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  2089. }
  2090. **/
  2091. if($lowe)
  2092. {
  2093. $where .= " and fpdata like '%-$lowe-%'";
  2094. }
  2095. if($ji)
  2096. {
  2097. $where .= " and shipremarks like '%急%'";
  2098. }
  2099. if($so)
  2100. {
  2101. $where .= " and shipremarks like '%$so%'";
  2102. }
  2103. //数据排序
  2104. $order_str = ($print != 3)?"id desc":"printtime desc";
  2105. //取得信息列表
  2106. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2107. //格式化数据
  2108. foreach ($info_list as $key=>$value)
  2109. {
  2110. $shop = $this->shop->read($value['shop']);
  2111. $info_list[$key]['shop'] = $shop['shopname'];
  2112. if($value['waybill'] == '0')
  2113. {
  2114. $info_list[$key]['waybill'] = "";
  2115. }
  2116. $express = $this->express->read($value['express']);
  2117. $info_list[$key]['express'] = $express['servicename'];
  2118. $warehouse = $this->warehouse->read($value['type']);
  2119. $info_list[$key]['type'] = $warehouse['title'];
  2120. if($value['printtime'] == '0')
  2121. {
  2122. $info_list[$key]['printtime'] = '<em class="t"></em>';
  2123. }
  2124. else
  2125. {
  2126. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2127. }
  2128. if($value['print'] == 1)
  2129. {
  2130. $info_list[$key]['print'] = '不可打印';
  2131. }
  2132. else if($value['print'] == 2)
  2133. {
  2134. $info_list[$key]['print'] = '未打印';
  2135. }
  2136. else if($value['print'] == 3)
  2137. {
  2138. $info_list[$key]['print'] = '已打印';
  2139. }
  2140. if($value['library'] == 1)
  2141. {
  2142. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2143. }
  2144. else if($value['library'] == 2)
  2145. {
  2146. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2147. }
  2148. else if($value['library'] == 3)
  2149. {
  2150. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2151. }
  2152. if($value['printtype'] == 1){
  2153. $info_list[$key]['printtype'] = '运单';
  2154. }elseif($value['printtype'] == 2){
  2155. $info_list[$key]['printtype'] = '发货单';
  2156. }else{
  2157. $info_list[$key]['printtype'] = '不打印单据';
  2158. }
  2159. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2160. }
  2161. //取得信息列表
  2162. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2163. //格式化数据
  2164. foreach ($info_listsmt as $key=>$value)
  2165. {
  2166. $shop = $this->shop->read($value['shop']);
  2167. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2168. if($value['waybill'] == '0')
  2169. {
  2170. $info_listsmt[$key]['waybill'] = "";
  2171. }
  2172. $express = $this->express->read($value['express']);
  2173. $info_listsmt[$key]['express'] = $express['servicename'];
  2174. $warehouse = $this->warehouse->read($value['type']);
  2175. $info_listsmt[$key]['type'] = $warehouse['title'];
  2176. if($value['printtime'] == '0')
  2177. {
  2178. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  2179. }
  2180. else
  2181. {
  2182. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2183. }
  2184. if($value['print'] == 1)
  2185. {
  2186. $info_listsmt[$key]['print'] = '不可打印';
  2187. }
  2188. else if($value['print'] == 2)
  2189. {
  2190. $info_listsmt[$key]['print'] = '未打印';
  2191. }
  2192. else if($value['print'] == 3)
  2193. {
  2194. $info_listsmt[$key]['print'] = '已打印';
  2195. }
  2196. if($value['library'] == 1)
  2197. {
  2198. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2199. }
  2200. else if($value['library'] == 2)
  2201. {
  2202. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2203. }
  2204. else if($value['library'] == 3)
  2205. {
  2206. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2207. }
  2208. if($value['printtype'] == 1){
  2209. $info_listsmt[$key]['printtype'] = '运单';
  2210. }elseif($value['printtype'] == 2){
  2211. $info_listsmt[$key]['printtype'] = '发货单';
  2212. }else{
  2213. $info_listsmt[$key]['printtype'] = '不打印单据';
  2214. }
  2215. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2216. }
  2217. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2218. //格式化数据
  2219. foreach ($info_listtt as $key=>$value)
  2220. {
  2221. $shop = $this->shop->read($value['shop']);
  2222. $info_listtt[$key]['shop'] = $shop['shopname'];
  2223. if($value['waybill'] == '0')
  2224. {
  2225. $info_listtt[$key]['waybill'] = "";
  2226. }
  2227. $express = $this->express->read($value['express']);
  2228. $info_listtt[$key]['express'] = $express['servicename'];
  2229. $warehouse = $this->warehouse->read($value['type']);
  2230. $info_listtt[$key]['type'] = $warehouse['title'];
  2231. if($value['printtime'] == '0')
  2232. {
  2233. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  2234. }
  2235. else
  2236. {
  2237. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2238. }
  2239. if($value['print'] == 1)
  2240. {
  2241. $info_listtt[$key]['print'] = '不可打印';
  2242. }
  2243. else if($value['print'] == 2)
  2244. {
  2245. $info_listtt[$key]['print'] = '未打印';
  2246. }
  2247. else if($value['print'] == 3)
  2248. {
  2249. $info_listtt[$key]['print'] = '已打印';
  2250. }
  2251. if($value['library'] == 1)
  2252. {
  2253. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2254. }
  2255. else if($value['library'] == 2)
  2256. {
  2257. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2258. }
  2259. else if($value['library'] == 3)
  2260. {
  2261. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2262. }
  2263. if($value['printtype'] == 1){
  2264. $info_listtt[$key]['printtype'] = '运单';
  2265. }elseif($value['printtype'] == 2){
  2266. $info_listtt[$key]['printtype'] = '发货单';
  2267. }else{
  2268. $info_listtt[$key]['printtype'] = '不打印单据';
  2269. }
  2270. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2271. }
  2272. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2273. //格式化数据
  2274. foreach ($info_listamz as $key=>$value)
  2275. {
  2276. $shop = $this->shop->read($value['shop']);
  2277. $info_listamz[$key]['shop'] = $shop['shopname'];
  2278. if($value['waybill'] == '0')
  2279. {
  2280. $info_listamz[$key]['waybill'] = "";
  2281. }
  2282. $express = $this->express->read($value['express']);
  2283. $info_listamz[$key]['express'] = $express['servicename'];
  2284. $warehouse = $this->warehouse->read($value['type']);
  2285. $info_listamz[$key]['type'] = $warehouse['title'];
  2286. if($value['printtime'] == '0')
  2287. {
  2288. $info_listamz[$key]['printtime'] = '<em class="t"></em>';
  2289. }
  2290. else
  2291. {
  2292. $info_listamz[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2293. }
  2294. if($value['print'] == 1)
  2295. {
  2296. $info_listamz[$key]['print'] = '不可打印';
  2297. }
  2298. else if($value['print'] == 2)
  2299. {
  2300. $info_listamz[$key]['print'] = '未打印';
  2301. }
  2302. else if($value['print'] == 3)
  2303. {
  2304. $info_listamz[$key]['print'] = '已打印';
  2305. }
  2306. if($value['library'] == 1)
  2307. {
  2308. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2309. }
  2310. else if($value['library'] == 2)
  2311. {
  2312. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2313. }
  2314. else if($value['library'] == 3)
  2315. {
  2316. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2317. }
  2318. if($value['printtype'] == 1){
  2319. $info_listamz[$key]['printtype'] = '运单';
  2320. }elseif($value['printtype'] == 2){
  2321. $info_listamz[$key]['printtype'] = '发货单';
  2322. }else{
  2323. $info_listamz[$key]['printtype'] = '不打印单据';
  2324. }
  2325. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2326. }
  2327. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2328. //格式化数据
  2329. foreach ($info_listxw as $key=>$value)
  2330. {
  2331. $shop = $this->shop->read($value['shop']);
  2332. $info_listxw[$key]['shop'] = $shop['shopname'];
  2333. if($value['waybill'] == '0')
  2334. {
  2335. $info_listxw[$key]['waybill'] = "";
  2336. }
  2337. $express = $this->express->read($value['express']);
  2338. $info_listxw[$key]['express'] = $express['servicename'];
  2339. $warehouse = $this->warehouse->read($value['type']);
  2340. $info_listxw[$key]['type'] = $warehouse['title'];
  2341. if($value['printtime'] == '0')
  2342. {
  2343. $info_listxw[$key]['printtime'] = '<em class="t"></em>';
  2344. }
  2345. else
  2346. {
  2347. $info_listxw[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2348. }
  2349. if($value['print'] == 1)
  2350. {
  2351. $info_listxw[$key]['print'] = '不可打印';
  2352. }
  2353. else if($value['print'] == 2)
  2354. {
  2355. $info_listxw[$key]['print'] = '未打印';
  2356. }
  2357. else if($value['print'] == 3)
  2358. {
  2359. $info_listxw[$key]['print'] = '已打印';
  2360. }
  2361. if($value['library'] == 1)
  2362. {
  2363. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2364. }
  2365. else if($value['library'] == 2)
  2366. {
  2367. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2368. }
  2369. else if($value['library'] == 3)
  2370. {
  2371. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2372. }
  2373. if($value['printtype'] == 1){
  2374. $info_listxw[$key]['printtype'] = '运单';
  2375. }elseif($value['printtype'] == 2){
  2376. $info_listxw[$key]['printtype'] = '发货单';
  2377. }else{
  2378. $info_listxw[$key]['printtype'] = '不打印单据';
  2379. }
  2380. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2381. }
  2382. $title = '订单出库-'.date('Ymd',time());
  2383. $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>";
  2384. $tail = "\n";
  2385. $filename = $title.".xls";
  2386. $this->excel->get_fz2(array_merge($info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  2387. }
  2388. }
  2389. public function _barcode()
  2390. {
  2391. $post = $this->input->post(NULL, TRUE);
  2392. if(isset($_SESSION['api']))
  2393. {
  2394. $user = $this->user->get_api($_SESSION['api']);
  2395. $usp = $user;
  2396. $fgshop = "";$sid = "";$wid="";$wtype="";
  2397. $usersp = explode('|',trim($user['shop'],'|'));
  2398. $userwh = explode('|',trim($user['warehouse'],'|'));
  2399. foreach ($usersp as $value)
  2400. {
  2401. $fgshop .= " shop = ".$value." or";
  2402. $sid .= " id = ".$value." or";
  2403. }
  2404. foreach ($userwh as $value)
  2405. {
  2406. $wid .= " id = ".$value." or";
  2407. $wtype .= " type = ".$value." or";
  2408. }
  2409. }
  2410. if(isset($post['page']))
  2411. {
  2412. $page = $this->input->post('page',true);
  2413. $perpage = $this->input->post('perpage',true);
  2414. $warehouse = $this->input->post('warehouse',true);
  2415. $sku = $this->input->post('sku ',true);
  2416. $title = $this->input->post('title',true);
  2417. $print = $this->input->post('print ',true);
  2418. $timetk = $this->input->post('timetk',true);
  2419. $timetj = $this->input->post('timetj',true);
  2420. $timetk = strtotime($timetk);
  2421. $timetj = strtotime($timetj);
  2422. $where = "time > '$timetk' and time < '$timetj'";
  2423. if($warehouse)
  2424. {
  2425. $where .= " and warehouse = '$warehouse'";
  2426. }
  2427. if($sku)
  2428. {
  2429. $where .= " and sku like '%$sku%'";
  2430. }
  2431. if($title)
  2432. {
  2433. $where .= " and title like '%$title%'";
  2434. }
  2435. if($print)
  2436. {
  2437. $where .= " and print = '$print'";
  2438. }
  2439. //数据排序
  2440. $order_str = "time desc";
  2441. if(empty($page))
  2442. {
  2443. $start = 0;
  2444. $perpage = 1;
  2445. }
  2446. else
  2447. {
  2448. $start = ($page - 1)*$perpage;
  2449. }
  2450. //取得信息列表
  2451. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  2452. //格式化数据
  2453. foreach ($info_list as $key=>$value)
  2454. {
  2455. if($value['printtime'] > 0)
  2456. {
  2457. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  2458. }
  2459. else
  2460. {
  2461. $info_list[$key]['printtime'] = '未打印';
  2462. }
  2463. }
  2464. $total = $this->whlabelbarcodeprint->find_count($where);
  2465. $pagenum = ceil($total/$perpage);
  2466. $over = $total-($start+$perpage);
  2467. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2468. echo json_encode($rows);exit;
  2469. }
  2470. if(isset($_SESSION['api']))
  2471. {
  2472. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2473. $this->data['warehouse'] = $warehouse;
  2474. }
  2475. $this->_Template('systemprint_barcode',$this->data);
  2476. }
  2477. public function _barcodedc()
  2478. {
  2479. if(isset($_GET['excel']))
  2480. {
  2481. $warehouse = $this->input->post('warehouse',true);
  2482. $sku = $this->input->post('sku ',true);
  2483. $title = $this->input->post('title',true);
  2484. $print = $this->input->post('print ',true);
  2485. $ktime = $this->input->post('timetk',true);
  2486. $jtime = $this->input->post('timetj',true);
  2487. $ktime = strtotime($ktime);
  2488. $jtime = strtotime($jtime);
  2489. $where = "time > '$timetk' and time < '$timetj'";
  2490. if($warehouse)
  2491. {
  2492. $where .= " and warehouse = '$warehouse'";
  2493. }
  2494. if($sku)
  2495. {
  2496. $where .= " and sku like '%$sku%'";
  2497. }
  2498. if($title)
  2499. {
  2500. $where .= " and title like '%$title%'";
  2501. }
  2502. if($print)
  2503. {
  2504. $where .= " and print = '$print'";
  2505. }
  2506. $order_str = "time desc";
  2507. if(empty($page))
  2508. {
  2509. $start = 0;
  2510. $perpage = 1;
  2511. }
  2512. else
  2513. {
  2514. $start = ($page - 1)*$perpage;
  2515. }
  2516. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  2517. $title = '标签-'.date('Y-m-d H-i-s',time());
  2518. $titlename = "<table border=1>
  2519. <tr align='center'>
  2520. <td>条码号</td>
  2521. <td>SKU</td>
  2522. <td>产品名称</td>
  2523. </tr>
  2524. </table>";
  2525. $filename = $title.".xls";
  2526. $tail = "";
  2527. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2528. }
  2529. }
  2530. public function _barcodedr()
  2531. {
  2532. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2533. $config['upload_path'] = '.'.$dir ;
  2534. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2535. $config['allowed_types'] = 'xls|xlsx|csv';
  2536. $config['max_size'] = 10240;
  2537. $this->load->library('upload', $config);
  2538. $this->upload->initialize($config);
  2539. if ($this->upload->do_upload('userfile'))
  2540. {
  2541. $full_path = $dir.$this->upload->data('file_name');
  2542. $fileName = '.' . $full_path;
  2543. if (!file_exists($fileName))
  2544. {
  2545. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2546. }
  2547. else
  2548. {
  2549. libxml_use_internal_errors(true);
  2550. require_once "./data/excel/PHPExcel/IOFactory.php";
  2551. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2552. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2553. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2554. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2555. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2556. ++$column;//如果列数大于26行
  2557. $list = array();
  2558. for ($i = 2; $i <= $row; $i++) // 行数循环
  2559. {
  2560. $data = array();
  2561. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2562. {
  2563. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2564. }
  2565. $list[] = $data;
  2566. }
  2567. }
  2568. $i = 0;$j = 0;$ed = array();
  2569. foreach ($list as $key=>$value)
  2570. {
  2571. $time = time();
  2572. if($value['0'] == "")
  2573. {
  2574. continue;
  2575. }
  2576. $label = $value['0'];
  2577. $sku = $value['1'];
  2578. $title = $value['2'];
  2579. $num = $value['3'];
  2580. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2581. if(!$d)//如果没有这个SKU
  2582. {
  2583. $ed[] = array($sku.'-库存中不存在此SKU');
  2584. $j++;
  2585. continue;
  2586. }
  2587. if($num < 1)
  2588. {
  2589. $ed[] = array($sku.'-数量错误!');
  2590. $j++;
  2591. continue;
  2592. }
  2593. unset($d['id']);
  2594. $d['time'] = $time;
  2595. $d['num'] = $num;
  2596. $this->whlabelbarcodeprint->insert($d);
  2597. }
  2598. if($j > 0)
  2599. {
  2600. $tt = date('Ymd',time());
  2601. $title = '库存导入错误信息-'.$tt;
  2602. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2603. $tail = "\n";
  2604. $filename = $title.".xls";
  2605. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2606. $dir = '/data/excel/'.$time.'/';
  2607. $file_name = 'error_'.$time.rand(1000,9999);
  2608. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2609. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2610. fwrite($myfile,$ecl);
  2611. fclose($myfile);
  2612. $error = $dir.$file_name.'.xls';
  2613. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2614. }
  2615. else
  2616. {
  2617. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2618. }
  2619. }
  2620. }
  2621. public function _yswaybill()
  2622. {
  2623. $data = $this->yswaybill->find_all("waybill = ''");
  2624. foreach ($data as $v)
  2625. {
  2626. $type = $v['type'];
  2627. $number = $v['number'];
  2628. $express = $v['express'];
  2629. $fullorder = $this->$type->get_number($number);
  2630. $fullorder = $this->_text($fullorder);
  2631. $barcode = $this->$express->get_hqwaybill($number);
  2632. if(!isset($barcode['x']))
  2633. {
  2634. continue;
  2635. }
  2636. if($barcode['x'] == 1)
  2637. {
  2638. if($barcode['ys'] != 1)
  2639. {
  2640. $this->db->trans_begin();
  2641. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2642. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2643. if ($this->db->trans_status() === TRUE)
  2644. {
  2645. $this->db->trans_commit();
  2646. }
  2647. else
  2648. {
  2649. $this->db->trans_rollback();
  2650. }
  2651. }
  2652. }
  2653. else
  2654. {
  2655. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2656. }
  2657. }
  2658. echo 1;
  2659. }
  2660. /**
  2661. * 根据发货单打印快递
  2662. */
  2663. public function _printbyfh(){
  2664. $this->_Template('systemprint_fhd',$this->data);
  2665. }
  2666. /**
  2667. * 此方法是为了临时解决一下打印的问题
  2668. */
  2669. public function _getInfoByNumber(){
  2670. $param = $this->input->get(NULL, TRUE);
  2671. if(empty($param['number'])){
  2672. $param = $this->input->post(NULL, TRUE);
  2673. }
  2674. if(empty($param['number'])){
  2675. echo json_encode([
  2676. 'code'=>-1,
  2677. 'msg'=>"订单编码未传递",
  2678. 'data'=>[]
  2679. ],JSON_UNESCAPED_UNICODE);
  2680. die;
  2681. }
  2682. $this->logic_ding->sendToDing("扫面发货单出运单订单编码".json_encode($param));
  2683. $info = $this->logic_order->getInfo("number = '".$param['number']."'");
  2684. if(empty($info)){
  2685. echo json_encode([
  2686. 'code'=>-1,
  2687. 'msg'=>"未查询到订单信息",
  2688. 'data'=>[]
  2689. ],JSON_UNESCAPED_UNICODE);
  2690. die;
  2691. }
  2692. if($info['library'] ==2 ){
  2693. echo json_encode([
  2694. 'code'=>-1,
  2695. 'msg'=>"该订单已出库!",
  2696. 'data'=>[]
  2697. ],JSON_UNESCAPED_UNICODE);
  2698. die;
  2699. }
  2700. if(empty($param['is_ok'])){
  2701. if($info['printnumber'] > 1){
  2702. echo json_encode([
  2703. 'code'=>2,
  2704. 'msg'=>'该单共打印过<b style="color:red;">'.$info['printnumber'].'</b>次,请核对当前发货单是否是最新发货单',
  2705. 'data'=>[
  2706. 'number'=>$info['number'],
  2707. 'is_ok'=>1
  2708. ]
  2709. ],JSON_UNESCAPED_UNICODE);
  2710. die;
  2711. }
  2712. }
  2713. if(!in_array($info['express'],[71])){
  2714. // if(!empty($info['waybill'])&&!empty($info['waybill'])){
  2715. // $yd = base_url()."data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf' ;
  2716. // if(file_exists("./data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf')){
  2717. // if(!in_array($info['express'],[76,77])){
  2718. // $text = array('yd'=>$yd,'mode'=>100,'type'=>1);
  2719. // }else{
  2720. // $text = array('yd'=>$yd,'mode'=>100,'type'=>8);
  2721. // }
  2722. // $this->logic_ding->sendToDing($info['number']."扫面发货单补发运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2723. // echo json_encode([
  2724. // 'code'=>1,
  2725. // 'msg'=>"ok",
  2726. // 'data'=>$text
  2727. // ],JSON_UNESCAPED_UNICODE);
  2728. // die;
  2729. // }
  2730. // ob_clean();
  2731. // echo json_encode([
  2732. // 'code'=>-1,
  2733. // 'msg'=>"快递面单不存在",
  2734. // 'data'=>[]
  2735. // ],JSON_UNESCAPED_UNICODE);
  2736. // die;
  2737. // }
  2738. echo json_encode([
  2739. 'code'=>-1,
  2740. 'msg'=>"快递不符合打印要求",
  2741. 'data'=>[]
  2742. ],JSON_UNESCAPED_UNICODE);
  2743. die;
  2744. }
  2745. $fullorder_name = $info['lv_platform'];
  2746. if($info['libraryconfirm'] == 1){
  2747. echo json_encode([
  2748. 'code'=>-1,
  2749. 'msg'=>"该订单不允许出库:".$info['librarynot'],
  2750. 'data'=>[]
  2751. ],JSON_UNESCAPED_UNICODE);
  2752. die;
  2753. }
  2754. if($info['library'] == 3){
  2755. echo json_encode([
  2756. 'code'=>-1,
  2757. 'msg'=>"该订单已退库!",
  2758. 'data'=>[]
  2759. ],JSON_UNESCAPED_UNICODE);
  2760. die;
  2761. }
  2762. $fullorder = $this->_text($info);//获取所需信息
  2763. $this->logic_ding->sendToDing("打印快递单,订单的信息".json_encode($fullorder,JSON_UNESCAPED_UNICODE));
  2764. //美仓不需要海关报关信息,
  2765. if($fullorder['type'] != 5){
  2766. //中国发货的 目前是dhl需要海关申报编码
  2767. if(empty($fullorder['sbbm'])){
  2768. echo json_encode([
  2769. 'code'=>-1,
  2770. 'msg'=>$fullorder['number'].' 海关申报配置异常,请提交给技术处理'.$fullorder['sbbm'],
  2771. 'data'=>[]
  2772. ],JSON_UNESCAPED_UNICODE);
  2773. die;
  2774. }
  2775. }
  2776. $time = time();
  2777. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  2778. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  2779. $pdfnum = 1;//PDF打印几遍
  2780. if($fullorder['waybillid'] != '')
  2781. {
  2782. $del = $this->cne->get_del($fullorder['waybillid']);
  2783. }
  2784. $barcode = $this->cne->get_data($fullorder);
  2785. $this->logic_ding->sendToDing("扫面发货单出运单".json_encode($barcode,JSON_UNESCAPED_UNICODE));
  2786. if($barcode['x'] == 1)
  2787. {
  2788. $bctime = date('Ymd',$time);
  2789. $Hwaybill = $barcode['waybill'];
  2790. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  2791. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  2792. if(isset($barcode['yd']) && isset($Hwaybill))
  2793. {
  2794. if($fullorder['waybill'] != "")
  2795. {
  2796. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  2797. }
  2798. else
  2799. {
  2800. $oldwaybill = $fullorder['oldwaybill'];
  2801. }
  2802. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  2803. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  2804. 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']))
  2805. {
  2806. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  2807. $this->logic_ding->sendToDing("扫面发货单出运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2808. echo json_encode([
  2809. 'code'=>1,
  2810. 'msg'=>"ok",
  2811. 'data'=>$text
  2812. ],JSON_UNESCAPED_UNICODE);
  2813. die;
  2814. }else{
  2815. echo json_encode([
  2816. 'code'=>-1,
  2817. 'msg'=>"订单信息保存异常",
  2818. 'data'=>[]
  2819. ],JSON_UNESCAPED_UNICODE);
  2820. die;
  2821. }
  2822. }
  2823. }
  2824. else
  2825. {
  2826. $failed = $barcode['Description'];//错误提示
  2827. //$fullorder['printnumber'] = $fullorder['printnumber'] +1;
  2828. //$this->$fullorder_name->save(array('print'=>1,'failed'=>$failed,'printnumber'=>$fullorder['printnumber']),$info['id']);
  2829. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$info['id']);
  2830. echo json_encode([
  2831. 'code'=>-1,
  2832. 'msg'=>$failed,
  2833. 'data'=>[]
  2834. ],JSON_UNESCAPED_UNICODE);
  2835. die;
  2836. }
  2837. echo json_encode([
  2838. 'code'=>-1,
  2839. 'msg'=>"执行订单异常,请联系技术",
  2840. 'data'=>[]
  2841. ],JSON_UNESCAPED_UNICODE);
  2842. die;
  2843. }
  2844. public function _ckpmcheck(){
  2845. $params = $this->input->get(NULL, TRUE);
  2846. $user = $this->user->get_api($_SESSION['api']);
  2847. $fgshop = "";$sid = "";$wid="";$wtype="";
  2848. $usersp = explode('|',trim($user['shop'],'|'));
  2849. $userwh = explode('|',trim($user['warehouse'],'|'));
  2850. foreach ($usersp as $value)
  2851. {
  2852. $fgshop .= " shop = ".$value." or";
  2853. $sid .= " id = ".$value." or";
  2854. }
  2855. foreach ($userwh as $value)
  2856. {
  2857. $wid .= " id = ".$value." or";
  2858. $wtype .= " type = ".$value." or";
  2859. }
  2860. if(isset($params['excel'])&& ($params['excel'] == 1)){
  2861. $timetk = $this->input->get('timetk',true);
  2862. $timetj = $this->input->get('timetj',true);
  2863. $shop = $this->input->get('shop',true);
  2864. $print = $this->input->get('print',true);
  2865. $express = $this->input->get('express',true);
  2866. $waybill = $this->input->get('waybill',true);
  2867. $printtype = $this->input->get('printtype',true);
  2868. $orderinfo = $this->input->get('orderinfo',true);
  2869. $number = $this->input->get('number',true);
  2870. $type = $this->input->get('type',true);
  2871. $lowe = $this->input->get('lowe',true);
  2872. $ji = $this->input->get('ji',true);
  2873. $so = $this->input->get('so',true);
  2874. $ckfl = $this->input->get('ckfl',true);
  2875. $sfxh = $this->input->get('sfxh',true);
  2876. $lowe = $this->input->get('lowe',true);
  2877. $color = $this->input->get('color',true);
  2878. $timetk = strtotime($timetk);
  2879. $timetj = strtotime($timetj);
  2880. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  2881. if($print == 3)
  2882. {
  2883. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  2884. }
  2885. else
  2886. {
  2887. $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)."'";
  2888. }
  2889. if($shop)
  2890. {
  2891. $where .= " and shop = '$shop'";
  2892. }
  2893. if($express)
  2894. {
  2895. $where .= " and express = '$express'";
  2896. }
  2897. if($printtype)
  2898. {
  2899. $where .= " and printtype = '$printtype'";
  2900. }
  2901. if($orderinfo)
  2902. {
  2903. $where .= " and orderinfo = '$orderinfo'";
  2904. }
  2905. if($number)
  2906. {
  2907. $where .= " and number = '$number'";
  2908. }
  2909. if($waybill)
  2910. {
  2911. $where .= " and waybill = '$waybill'";
  2912. }
  2913. if($color)
  2914. {
  2915. $where .= " and fpdata like '%-$color-%'";
  2916. }
  2917. if($lowe)
  2918. {
  2919. $where .= " and fpdata like '%-$lowe-%'";
  2920. }
  2921. if($type)
  2922. {
  2923. $where .= " and type = '$type'";
  2924. }
  2925. else
  2926. {
  2927. $where .= " and type != '16'";
  2928. }
  2929. if($ji)
  2930. {
  2931. $where .= " and shipremarks like '%急%'";
  2932. }
  2933. if($so)
  2934. {
  2935. $where .= " and shipremarks like '%$so%'";
  2936. }
  2937. if($ckfl)
  2938. {
  2939. $where .= " and ckfl = '$ckfl'";
  2940. }
  2941. if($sfxh != '')
  2942. {
  2943. $where .= " and sfxh = '$sfxh'";
  2944. }
  2945. //数据排序
  2946. $order_str = ($print != 3)?"id desc":"printtime desc";
  2947. $field = 'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks,is_jiaji,fpdata';
  2948. $dlz_ret = $this->indexData('fullorder',0,1000,$where,$field,$order_str);
  2949. $dlz_list = $dlz_ret['list'];
  2950. $smt_ret = $this->indexData('fullordersmt',0,1000,$where,$field,$order_str);
  2951. $smt_list = $smt_ret['list'];
  2952. $tt_ret = $this->indexData('fullordertt',0,1000,$where,$field,$order_str);
  2953. $tt_list = $tt_ret['list'];
  2954. $amz_ret = $this->indexData('fullorderamz',0,1000,$where,$field,$order_str);
  2955. $amz_list = $amz_ret['list'];
  2956. $list = array_merge($dlz_list,$smt_list,$tt_list,$amz_list);
  2957. $typeclass = [];
  2958. $classid = $this->classid->sku();
  2959. $tcall = $this->typeclass->find_all();
  2960. foreach ($tcall as $v)
  2961. {
  2962. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  2963. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  2964. }
  2965. foreach($list as $key=>$value){
  2966. $tmp = explode(';',trim($value['fpdata'],";"));
  2967. foreach($tmp as $k => $v){
  2968. $arr_tmp = explode('|',$v);
  2969. if(strpos($arr_tmp[0],',')!== false){
  2970. $sku = "-".str_replace(',','-',$arr_tmp[0]);
  2971. }else{
  2972. $sku = $arr_tmp[0];
  2973. }
  2974. $r = $this->logic_u9tools->getOneU9bmHasGift($sku,$classid,$typeclass);
  2975. $list[$key]['u9_zh'][] = $r['zh'];
  2976. $list[$key]['u9_jm'][] = $r['jm'];
  2977. }
  2978. }
  2979. //生成excel
  2980. $filename = date("Y-m-d")."打印订单核对导出.xls";
  2981. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2982. <head>
  2983. <!--[if gte mso 9]><xml>
  2984. <x:ExcelWorkbook>
  2985. <x:ExcelWorksheets>
  2986. <x:ExcelWorksheet>
  2987. <x:Name>EXCEL</x:Name>
  2988. <x:WorksheetOptions>
  2989. <x:Print>
  2990. <x:ValidPrinterInfo />
  2991. </x:Print>
  2992. </x:WorksheetOptions>
  2993. </x:ExcelWorksheet>
  2994. </x:ExcelWorksheets>
  2995. </x:ExcelWorkbook>
  2996. </xml>
  2997. <![endif]-->
  2998. </head><body>";
  2999. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  3000. $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>";
  3001. foreach ($list as $key=>$value)
  3002. {
  3003. $u9_zh = implode('<br/>',$value['u9_zh']);
  3004. $u9_jm = implode('<br/>',$value['u9_jm']);
  3005. $str .= "<tr>";
  3006. $str .= "<td>". $value['shop']. "</td>";
  3007. $str .= "<td>". $value['orderinfo']. "</td>";
  3008. $str .= "<td>". $value['number']. "</td>";
  3009. $str .= "<td>". $value['express']. "</td>";
  3010. $str .= "<td>". $value['waybill']. "</td>";
  3011. $str .= "<td>". $value['print']. "</td>";
  3012. $str .= "<td>". $value['printtype']. "</td>";
  3013. $str .= "<td>". $value['printnumber']. "</td>";
  3014. $str .= "<td>". $value['printtime']. "</td>";
  3015. $str .= "<td>". $value['shipremarks']. "</td>";
  3016. $str .= "<td>".trim($u9_zh,"<br/>"). "</td>";
  3017. $str .= "<td>".trim($u9_jm,"<br/>"). "</td>";
  3018. $str .= "</tr>";
  3019. }
  3020. $str .= "</table></body></html>";
  3021. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  3022. header( "Content-type: application/octet-stream" );
  3023. header( "Content-Disposition: attachment; filename=".$filename );
  3024. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  3025. header( "Pragma: no-cache" );
  3026. header( "Expires: 0" );
  3027. exit($str);
  3028. }
  3029. }
  3030. }