Systemprint.php 112 KB

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