Systemprint.php 111 KB

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