Systemprint.php 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553
  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_apiyy','apiyy');
  43. $this->load->_model('Model_classid','classid');
  44. $this->load->_model('Model_fullorderxw','fullorderxw');
  45. $this->load->_model('Model_setting','setting');
  46. $this->load->helper('url');
  47. $this->load->_model("Model_yuntu","yuntu");
  48. $this->load->_model("Model_api","api");
  49. $this->load->_model("Model_fedexv1",'fedexv1');
  50. }
  51. //定义方法的调用规则 获取URI第二段值
  52. public function _remap($arg,$arg_array)
  53. {
  54. if($arg == 'printing')//打印操作
  55. {
  56. $this->_printing();
  57. }
  58. else if($arg == 'exceldy')
  59. {
  60. $this->_exceldy($arg_array);
  61. }
  62. else if($arg == 'screen')
  63. {
  64. $this->_screen();
  65. }
  66. else if($arg == 'cz')
  67. {
  68. $this->_cz();
  69. }
  70. else if($arg == 'barcode')
  71. {
  72. $this->_barcode();
  73. }
  74. else if($arg == 'barcodedc')
  75. {
  76. $this->_barcodedc();
  77. }
  78. else if($arg == 'barcodedr')
  79. {
  80. $this->_barcodedr();
  81. }
  82. else if($arg == 'yswaybill')
  83. {
  84. $this->_yswaybill();
  85. }
  86. else
  87. {
  88. $this->_index();
  89. }
  90. }
  91. public function _cz()
  92. {
  93. if(isset($_SESSION['api']))
  94. {
  95. $user = $this->user->get_api($_SESSION['api']);
  96. $usp = $user;
  97. $shop = array();$type = array();
  98. $usersp = explode('|',trim($user['shop'],'|'));
  99. $userwh = explode('|',trim($user['warehouse'],'|'));
  100. foreach ($usersp as $v)
  101. {
  102. $shop[$v] = $v;
  103. }
  104. foreach ($userwh as $v)
  105. {
  106. $type[$v] = $v;
  107. }
  108. }
  109. $post = $this->input->post(NULL, TRUE);
  110. if(isset($post['cz']))
  111. {
  112. $cz = $this->input->post('cz');
  113. $cz = explode(',',trim($cz,','));
  114. $bj = $this->input->post('bj');
  115. $i = 0;$a = array();
  116. foreach ($cz as $v)
  117. {
  118. $dd = explode('-',$v);
  119. $fu = $dd[1];
  120. $thisdd = $this->$fu->read($dd[0]);
  121. if(isset($shop[$thisdd['shop']]) && isset($type[$thisdd['type']]))
  122. {
  123. $this->$fu->save(array('wigs'=>$bj),$dd[0]);
  124. $i++;
  125. }
  126. }
  127. if(count($cz) == $i)
  128. {
  129. echo json_encode(array('msg'=>'标记完成!','success'=>true));exit;
  130. }
  131. else if($i == '0')
  132. {
  133. echo json_encode(array('msg'=>'标记失败,请重试!','success'=>false));exit;
  134. }
  135. else
  136. {
  137. echo json_encode(array('msg'=>'有部分标记失败,请检查!','success'=>false));exit;
  138. }
  139. }
  140. }
  141. public function _screen()
  142. {
  143. $post = $this->input->post(NULL, TRUE);
  144. if(isset($_SESSION['api']))
  145. {
  146. $user = $this->user->get_api($_SESSION['api']);
  147. $usp = $user;
  148. $fgshop = "";$sid = "";$wid="";$wtype="";
  149. $usersp = explode('|',trim($user['shop'],'|'));
  150. $userwh = explode('|',trim($user['warehouse'],'|'));
  151. foreach ($usersp as $value)
  152. {
  153. $fgshop .= " shop = ".$value." or";
  154. $sid .= " id = ".$value." or";
  155. }
  156. foreach ($userwh as $value)
  157. {
  158. $wid .= " id = ".$value." or";
  159. $wtype .= " type = ".$value." or";
  160. }
  161. }
  162. if(isset($post['page']))
  163. {
  164. $page = $this->input->post('page',true);
  165. $perpage = $this->input->post('perpage',true);
  166. $wigs = $this->input->post('wigs',true);
  167. $shop = $this->input->post('shop',true);
  168. $orderinfo = $this->input->post('orderinfo',true);
  169. $number = $this->input->post('number',true);
  170. $so = $this->input->post('so',true);
  171. //$where = (isset($_SESSION['api']))?"mergeid != '1' and (state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  172. //$where .= " and express != 0 and printtype > 0 and printtype < 3 and print = 2 and review > 4 and library = 1 and type = 4";
  173. $where = (isset($_SESSION['api']))?"mergeid != '1' and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  174. if($shop)
  175. {
  176. $where .= " and shop = '$shop'";
  177. }
  178. if($orderinfo)
  179. {
  180. $where .= " and orderinfo = '$orderinfo'";
  181. }
  182. if($number)
  183. {
  184. $where .= " and number = '$number'";
  185. }
  186. if($wigs || $wigs == '0')
  187. {
  188. $where .= " and wigs = '$wigs'";
  189. }
  190. //数据排序
  191. $order_str = "id desc";
  192. if(empty($page))
  193. {
  194. $start = 0;
  195. $perpage = 1;
  196. }
  197. else
  198. {
  199. $start = ($page - 1)*$perpage;
  200. }
  201. $info_list = array();
  202. $info_listsmt = array();
  203. $info_listtt = array();
  204. $info_listxw = array();
  205. $dlz = 0; $smt = 0; $tt = 0;$xw = 0;
  206. //取得信息列表
  207. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  208. //格式化数据
  209. foreach ($info_list as $key=>$value)
  210. {
  211. $w = $this->fullorder->read($value['id']);
  212. if(stripos($w['issku'],'#pack') !== false)
  213. {
  214. unset($info_list[$key]);
  215. continue;
  216. }
  217. $info_list[$key]['id'] = $value['id'].'-fullorder';
  218. $shop = $this->shop->read($value['shop']);
  219. $info_list[$key]['shop'] = $shop['shopname'];
  220. }
  221. $dlz = $this->fullorder->find_count($where);
  222. $info_listtt = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  223. //格式化数据
  224. foreach ($info_listtt as $key=>$value)
  225. {
  226. $w = $this->fullordertt->read($value['id']);
  227. if(stripos($w['issku'],'#pack') !== false)
  228. {
  229. unset($info_list[$key]);
  230. continue;
  231. }
  232. $info_list[$key]['id'] = $value['id'].'-fullordertt';
  233. $shop = $this->shop->read($value['shop']);
  234. $info_list[$key]['shop'] = $shop['shopname'];
  235. }
  236. $tt = $this->fullordertt->find_count($where);
  237. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  238. //格式化数据
  239. foreach ($info_listamz as $key=>$value)
  240. {
  241. $w = $this->fullorderamz->read($value['id']);
  242. if(stripos($w['issku'],'#pack') !== false)
  243. {
  244. unset($info_list[$key]);
  245. continue;
  246. }
  247. $info_list[$key]['id'] = $value['id'].'-fullorderamz';
  248. $shop = $this->shop->read($value['shop']);
  249. $info_list[$key]['shop'] = $shop['shopname'];
  250. }
  251. $amz = $this->fullorderamz->find_count($where);
  252. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  253. //格式化数据
  254. foreach ($info_listxw as $key=>$value)
  255. {
  256. $w = $this->fullorderxw->read($value['id']);
  257. if(stripos($w['issku'],'#pack') !== false)
  258. {
  259. unset($info_list[$key]);
  260. continue;
  261. }
  262. $info_list[$key]['id'] = $value['id'].'-fullorderxw';
  263. $shop = $this->shop->read($value['shop']);
  264. $info_list[$key]['shop'] = $shop['shopname'];
  265. }
  266. $xw = $this->fullorderxw->find_count($where);
  267. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  268. //格式化数据
  269. foreach ($info_listsmt as $key=>$value)
  270. {
  271. $w = $this->fullordersmt->read($value['id']);
  272. if(stripos($w['sku'],'#pack') !== false)
  273. {
  274. unset($info_listsmt[$key]);
  275. continue;
  276. }
  277. $info_listsmt[$key]['id'] = $value['id'].'-fullordersmt';
  278. $shop = $this->shop->read($value['shop']);
  279. $info_listsmt[$key]['shop'] = $shop['shopname'];
  280. }
  281. $smt += $this->fullordersmt->find_count($where);
  282. //$total += $this->fullorder_smt->find_count($where);
  283. $total = $dlz+$smt+$tt+$xw+$amz;
  284. $rows = array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt);
  285. //$rows = array_slice($rows,$start,$perpage);
  286. $pagenum = ceil($total/$perpage);
  287. $over = $total-($start+$perpage);
  288. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));//array_merge($info_list,$info_list_smt,$info_listsmt)
  289. echo json_encode($rows);exit;
  290. }
  291. if(isset($_SESSION['api']))
  292. {
  293. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  294. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  295. $this->data['wlshop'] = $wlshop;
  296. $this->data['warehouse'] = $warehouse;
  297. }
  298. $this->_Template('systemprint_screen',$this->data);
  299. }
  300. public function _index()
  301. {
  302. $post = $this->input->post(NULL, TRUE);
  303. if(isset($_SESSION['api']))
  304. {
  305. $user = $this->user->get_api($_SESSION['api']);
  306. $usp = $user;
  307. $fgshop = "";$sid = "";$wid="";$wtype="";
  308. $usersp = explode('|',trim($user['shop'],'|'));
  309. $userwh = explode('|',trim($user['warehouse'],'|'));
  310. foreach ($usersp as $value)
  311. {
  312. $fgshop .= " shop = ".$value." or";
  313. $sid .= " id = ".$value." or";
  314. }
  315. foreach ($userwh as $value)
  316. {
  317. $wid .= " id = ".$value." or";
  318. $wtype .= " type = ".$value." or";
  319. }
  320. }
  321. if(isset($post['page']))
  322. {
  323. $page = $this->input->post('page',true);
  324. $perpage = $this->input->post('perpage',true);
  325. $timetk = $this->input->post('timetk',true);
  326. $timetj = $this->input->post('timetj',true);
  327. $shop = $this->input->post('shop',true);
  328. $print = $this->input->post('print',true);
  329. $express = $this->input->post('express',true);
  330. $waybill = $this->input->post('waybill',true);
  331. $printtype = $this->input->post('printtype',true);
  332. $orderinfo = $this->input->post('orderinfo',true);
  333. $number = $this->input->post('number',true);
  334. $type = $this->input->post('type',true);
  335. $lowe = $this->input->post('lowe',true);
  336. $info = $this->input->post('info',true);
  337. $ji = $this->input->post('ji',true);
  338. $so = $this->input->post('so',true);
  339. $ckfl = $this->input->post('ckfl',true);
  340. $sfxh = $this->input->post('sfxh',true);
  341. $lowe = $this->input->post('lowe',true);
  342. $color = $this->input->post('color',true);
  343. $timetk = strtotime($timetk);
  344. $timetj = strtotime($timetj);
  345. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  346. if($print == 3)
  347. {
  348. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  349. }
  350. else
  351. {
  352. $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)."'";
  353. }
  354. if($shop)
  355. {
  356. $where .= " and shop = '$shop'";
  357. }
  358. if($express)
  359. {
  360. $where .= " and express = '$express'";
  361. }
  362. if($printtype)
  363. {
  364. $where .= " and printtype = '$printtype'";
  365. }
  366. if($orderinfo)
  367. {
  368. $where .= " and orderinfo = '$orderinfo'";
  369. }
  370. if($number)
  371. {
  372. $where .= " and number = '$number'";
  373. }
  374. if($waybill)
  375. {
  376. $where .= " and waybill = '$waybill'";
  377. }
  378. if($color)
  379. {
  380. $where .= " and fpdata like '%-$color-%'";
  381. }
  382. if($lowe)
  383. {
  384. $where .= " and fpdata like '%-$lowe-%'";
  385. }
  386. if($type)
  387. {
  388. $where .= " and type = '$type'";
  389. }
  390. else
  391. {
  392. $where .= " and type != '16'";
  393. }
  394. /**
  395. if($type)
  396. {
  397. if($type != '4')
  398. {
  399. $where .= " and type = '$type'";
  400. $where2 = '';
  401. $where3 = '';
  402. }
  403. else
  404. {
  405. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  406. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  407. }
  408. $where_a = "";
  409. $where_b = "";
  410. }
  411. else
  412. {
  413. $where .= " and type != '4'";
  414. $where_a = "(";
  415. $where_b = ")";
  416. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  417. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  418. }
  419. **/
  420. if($ji)
  421. {
  422. $where .= " and shipremarks like '%急%'";
  423. }
  424. if($so)
  425. {
  426. $where .= " and shipremarks like '%$so%'";
  427. }
  428. if($ckfl)
  429. {
  430. $where .= " and ckfl = '$ckfl'";
  431. }
  432. if($sfxh != '')
  433. {
  434. $where .= " and sfxh = '$sfxh'";
  435. }
  436. //数据排序
  437. $order_str = ($print != 3)?"id desc":"printtime desc";
  438. if(empty($page))
  439. {
  440. $start = 0;
  441. $perpage = 1;
  442. }
  443. else
  444. {
  445. $start = ($page - 1)*$perpage;
  446. }
  447. $info_list = array();
  448. $info_listtt = array();
  449. $info_listxw = array();
  450. $info_listsmt = array();
  451. $dlz = 0; $smt = 0; $tt = 0; $xw = 0;
  452. //取得信息列表
  453. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  454. //格式化数据
  455. foreach ($info_list as $key=>$value)
  456. {
  457. $info_list[$key]['id'] = $value['id'].'-fullorder';
  458. $shop = $this->shop->read($value['shop']);
  459. $info_list[$key]['shop'] = $shop['shopname'];
  460. $express = $this->express->read($value['express']);
  461. if($express)
  462. {
  463. $info_list[$key]['express'] = $express['servicename'];
  464. }
  465. else
  466. {
  467. $info_list[$key]['express'] = '未选择';
  468. }
  469. if($value['printtime'] != 0)
  470. {
  471. $info_list[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  472. }
  473. else
  474. {
  475. $info_list[$key]['printtime'] = '无';
  476. }
  477. if($value['print'] == 1)
  478. {
  479. $info_list[$key]['print'] = "禁止打印";
  480. }
  481. else if($value['print'] == 2)
  482. {
  483. $info_list[$key]['print'] = "未打印";
  484. }
  485. else if($value['print'] == 3)
  486. {
  487. $info_list[$key]['print'] = "已打印";
  488. }
  489. if($value['printtype'] == 1)
  490. {
  491. $info_list[$key]['printtype'] = "运单";
  492. }
  493. else if($value['printtype'] == 2)
  494. {
  495. $info_list[$key]['printtype'] = "发货单";
  496. }
  497. else if($value['printtype'] == 0)
  498. {
  499. $info_list[$key]['printtype'] = "未选择";
  500. }
  501. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  502. }
  503. $dlz = $this->fullorder->find_count($where);
  504. //取得信息列表
  505. $info_listtt = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  506. //格式化数据
  507. foreach ($info_listtt as $key=>$value)
  508. {
  509. $info_listtt[$key]['id'] = $value['id'].'-fullordertt';
  510. $shop = $this->shop->read($value['shop']);
  511. $info_listtt[$key]['shop'] = $shop['shopname'];
  512. $express = $this->express->read($value['express']);
  513. if($express)
  514. {
  515. $info_listtt[$key]['express'] = $express['servicename'];
  516. }
  517. else
  518. {
  519. $info_listtt[$key]['express'] = '未选择';
  520. }
  521. if($value['printtime'] != 0)
  522. {
  523. $info_listtt[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  524. }
  525. else
  526. {
  527. $info_listtt[$key]['printtime'] = '无';
  528. }
  529. if($value['print'] == 1)
  530. {
  531. $info_listtt[$key]['print'] = "禁止打印";
  532. }
  533. else if($value['print'] == 2)
  534. {
  535. $info_listtt[$key]['print'] = "未打印";
  536. }
  537. else if($value['print'] == 3)
  538. {
  539. $info_listtt[$key]['print'] = "已打印";
  540. }
  541. if($value['printtype'] == 1)
  542. {
  543. $info_listtt[$key]['printtype'] = "运单";
  544. }
  545. else if($value['printtype'] == 2)
  546. {
  547. $info_listtt[$key]['printtype'] = "发货单";
  548. }
  549. else if($value['printtype'] == 0)
  550. {
  551. $info_listtt[$key]['printtype'] = "未选择";
  552. }
  553. $info_listtt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  554. }
  555. $tt = $this->fullordertt->find_count($where);
  556. //取得信息列表
  557. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  558. //格式化数据
  559. foreach ($info_listamz as $key=>$value)
  560. {
  561. $info_listamz[$key]['id'] = $value['id'].'-fullorderamz';
  562. $shop = $this->shop->read($value['shop']);
  563. $info_listamz[$key]['shop'] = $shop['shopname'];
  564. $express = $this->express->read($value['express']);
  565. if($express)
  566. {
  567. $info_listamz[$key]['express'] = $express['servicename'];
  568. }
  569. else
  570. {
  571. $info_listamz[$key]['express'] = '未选择';
  572. }
  573. if($value['printtime'] != 0)
  574. {
  575. $info_listamz[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  576. }
  577. else
  578. {
  579. $info_listamz[$key]['printtime'] = '无';
  580. }
  581. if($value['print'] == 1)
  582. {
  583. $info_listamz[$key]['print'] = "禁止打印";
  584. }
  585. else if($value['print'] == 2)
  586. {
  587. $info_listamz[$key]['print'] = "未打印";
  588. }
  589. else if($value['print'] == 3)
  590. {
  591. $info_listamz[$key]['print'] = "已打印";
  592. }
  593. if($value['printtype'] == 1)
  594. {
  595. $info_listamz[$key]['printtype'] = "运单";
  596. }
  597. else if($value['printtype'] == 2)
  598. {
  599. $info_listamz[$key]['printtype'] = "发货单";
  600. }
  601. else if($value['printtype'] == 0)
  602. {
  603. $info_listamz[$key]['printtype'] = "未选择";
  604. }
  605. $info_listamz[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  606. }
  607. $amz = $this->fullorderamz->find_count($where);
  608. //取得信息列表
  609. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  610. //格式化数据
  611. foreach ($info_listxw as $key=>$value)
  612. {
  613. $info_listxw[$key]['id'] = $value['id'].'-fullorderxw';
  614. $shop = $this->shop->read($value['shop']);
  615. $info_listxw[$key]['shop'] = $shop['shopname'];
  616. $express = $this->express->read($value['express']);
  617. if($express)
  618. {
  619. $info_listxw[$key]['express'] = $express['servicename'];
  620. }
  621. else
  622. {
  623. $info_listxw[$key]['express'] = '未选择';
  624. }
  625. if($value['printtime'] != 0)
  626. {
  627. $info_listxw[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  628. }
  629. else
  630. {
  631. $info_listxw[$key]['printtime'] = '无';
  632. }
  633. if($value['print'] == 1)
  634. {
  635. $info_listxw[$key]['print'] = "禁止打印";
  636. }
  637. else if($value['print'] == 2)
  638. {
  639. $info_listxw[$key]['print'] = "未打印";
  640. }
  641. else if($value['print'] == 3)
  642. {
  643. $info_listxw[$key]['print'] = "已打印";
  644. }
  645. if($value['printtype'] == 1)
  646. {
  647. $info_listxw[$key]['printtype'] = "运单";
  648. }
  649. else if($value['printtype'] == 2)
  650. {
  651. $info_listxw[$key]['printtype'] = "发货单";
  652. }
  653. else if($value['printtype'] == 0)
  654. {
  655. $info_listxw[$key]['printtype'] = "未选择";
  656. }
  657. $info_listxw[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  658. }
  659. $xw = $this->fullorderxw->find_count($where);
  660. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks',$order_str,$start,$perpage);
  661. //格式化数据
  662. foreach ($info_listsmt as $key=>$value)
  663. {
  664. $info_listsmt[$key]['id'] = $value['id'].'-fullordersmt';
  665. $shop = $this->shop->read($value['shop']);
  666. $info_listsmt[$key]['shop'] = $shop['shopname'];
  667. $express = $this->express->read($value['express']);
  668. if($express)
  669. {
  670. $info_listsmt[$key]['express'] = $express['servicename'];
  671. }
  672. else
  673. {
  674. $info_listsmt[$key]['express'] = '未选择';
  675. }
  676. if($value['printtime'] != 0)
  677. {
  678. $info_listsmt[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  679. }
  680. else
  681. {
  682. $info_listsmt[$key]['printtime'] = '无';
  683. }
  684. if($value['print'] == 1)
  685. {
  686. $info_listsmt[$key]['print'] = "禁止打印";
  687. }
  688. else if($value['print'] == 2)
  689. {
  690. $info_listsmt[$key]['print'] = "未打印";
  691. }
  692. else if($value['print'] == 3)
  693. {
  694. $info_listsmt[$key]['print'] = "已打印";
  695. }
  696. if($value['printtype'] == 1)
  697. {
  698. $info_listsmt[$key]['printtype'] = "运单";
  699. }
  700. else if($value['printtype'] == 2)
  701. {
  702. $info_listsmt[$key]['printtype'] = "发货单";
  703. }
  704. else if($value['printtype'] == 0)
  705. {
  706. $info_listsmt[$key]['printtype'] = "未选择";
  707. }
  708. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  709. }
  710. $smt += $this->fullordersmt->find_count($where);
  711. //$total += $this->fullorder_smt->find_count($where);
  712. $total = $dlz+$smt+$tt+$xw+$amz;
  713. $rows = array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt);
  714. //$rows = array_slice($rows,$start,$perpage);
  715. foreach($rows as $k=>$v){
  716. $rows[$k]['index'] = $v['shipremarks'].$v['id'];
  717. }
  718. $tmp_rows = array_column($rows,null,'index');
  719. ksort($tmp_rows);
  720. $tmp_rows = array_values($tmp_rows);
  721. foreach($tmp_rows as $k=>$v){
  722. unset($tmp_rows[$k]['index']);
  723. }
  724. $rows = $tmp_rows;
  725. $pagenum = ceil($total/$perpage);
  726. $over = $total-($start+$perpage);
  727. $tmp = array();
  728. if($print == 3)
  729. {
  730. foreach ($rows as $key => $val)
  731. {
  732. $tmp[$key] = $val['printtime'];
  733. }
  734. array_multisort($tmp,SORT_DESC,$rows);
  735. }
  736. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  737. echo json_encode($rows);exit;
  738. }
  739. if(isset($_SESSION['api']))
  740. {
  741. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  742. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  743. $this->data['wlshop'] = $wlshop;
  744. $this->data['warehouse'] = $warehouse;
  745. }
  746. $this->_Template('systemprint',$this->data);
  747. }
  748. //打印
  749. public function _printing()
  750. {
  751. $post = $this->input->post(NULL, TRUE);
  752. if(isset($post['s']))
  753. {
  754. $v = $this->input->post('s');
  755. $va = explode(',',rtrim($v,','));
  756. $n = $this->input->post('n');
  757. $tf = $this->input->post('tf');
  758. $type = 3;$text = array();$text['data'] = array();$time = time();
  759. $pd = explode('-',$va[$n]);
  760. $va[$n] = $pd[0];
  761. $fullorder_name = $pd[1];
  762. $fullorder = $this->$fullorder_name->read($va[$n]);
  763. if(isset($va[$n+1]))
  764. {
  765. $xyz = explode('-',$va[$n+1]);
  766. $sf = $this->$fullorder_name->read($xyz[0]);
  767. }
  768. if($tf)
  769. {
  770. if($tf == '2' && ($fullorder['print'] == 3 || $fullorder['printtime'] > 0))
  771. {
  772. echo json_encode(array('msg'=>$fullorder['number'].' 此订单已打印,请提交给技术处理','success'=>false));exit;
  773. }
  774. }
  775. if($fullorder['print'] == 1)
  776. {
  777. echo json_encode(array('msg'=>$fullorder['number'].' 店员已操作禁止打印,请刷新当前程序','success'=>false));exit;
  778. }
  779. if($fullorder['print'] == 2 && $fullorder['printtime'] > 0)
  780. {
  781. echo json_encode(array('msg'=>$fullorder['number'].' 状态异常,请提交给技术处理','success'=>false));exit;
  782. }
  783. $fullorder = $this->_text($fullorder);//获取所需信息
  784. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  785. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  786. $pdfnum = 1;//PDF打印几遍
  787. if($fullorder['printtype'] == 1 && $fullorder['library'] != 2)// && $fullorder['library'] != 2
  788. {
  789. if($fullorder['printcode'] == "DHL")//如果打印过那么重新获取运单
  790. {
  791. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  792. if(isset($barcode['AirwayBillNumber']))
  793. {
  794. $bctime = date('Ymd',$time);
  795. $Hwaybill = $barcode['AirwayBillNumber'];
  796. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  797. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  798. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  799. {
  800. if($fullorder['waybill'] != "")
  801. {
  802. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  803. }
  804. else
  805. {
  806. $oldwaybill = $fullorder['oldwaybill'];
  807. }
  808. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  809. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  810. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  811. {
  812. $type = 1;
  813. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  814. }
  815. }
  816. }
  817. else
  818. {
  819. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  820. {
  821. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  822. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  823. }
  824. }
  825. }
  826. else if($fullorder['printcode'] == "DHLUSA")//DHL9610
  827. {
  828. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  829. if(isset($barcode['AirwayBillNumber']))
  830. {
  831. $bctime = date('Ymd',$time);
  832. $Hwaybill = $barcode['AirwayBillNumber'];
  833. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  834. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  835. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  836. {
  837. if($fullorder['waybill'] != "")
  838. {
  839. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  840. }
  841. else
  842. {
  843. $oldwaybill = $fullorder['oldwaybill'];
  844. }
  845. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  846. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  847. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  848. {
  849. $type = 1;
  850. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  851. }
  852. }
  853. }
  854. else
  855. {
  856. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  857. {
  858. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  859. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  860. }
  861. }
  862. /**
  863. if(isset($barcode['AirwayBillNumber']))
  864. {
  865. $bctime = date('Ymd',$time);
  866. $Hwaybill = $barcode['AirwayBillNumber'];
  867. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  868. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  869. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  870. {
  871. $fullorder['waybill'] = $Hwaybill;
  872. $sb = $this->dhl->get_data_9610($fullorder);
  873. if($sb != 1)
  874. {
  875. $this->$fullorder_name->save(array('print'=>1,'failed'=>$sb),$va[$n]);
  876. }
  877. else
  878. {
  879. if($fullorder['waybill'] != "")
  880. {
  881. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  882. }
  883. else
  884. {
  885. $oldwaybill = $fullorder['oldwaybill'];
  886. }
  887. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  888. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  889. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  890. {
  891. $type = 1;
  892. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  893. }
  894. }
  895. }
  896. }
  897. else
  898. {
  899. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  900. {
  901. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  902. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  903. }
  904. }
  905. **/
  906. }
  907. /**
  908. else if($fullorder['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  909. {
  910. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  911. if($barcode['c'] == 1)
  912. {
  913. $bctime = date('Ymd',$time);
  914. $Hwaybill = $barcode['data']['waybill'];
  915. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  916. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  917. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  918. {
  919. if($fullorder['waybill'] != "")
  920. {
  921. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  922. }
  923. else
  924. {
  925. $oldwaybill = $fullorder['oldwaybill'];
  926. }
  927. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  928. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  929. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  930. {
  931. $type = 1;
  932. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  933. }
  934. }
  935. }
  936. else
  937. {
  938. if(isset($barcode['data']))
  939. {
  940. $failed = $barcode['data'];
  941. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  942. }
  943. }
  944. }
  945. **/
  946. else if($fullorder['printcode'] == "USPS")
  947. {
  948. $barcode = $this->usps->get_data($fullorder);
  949. //改新的去掉
  950. if(isset($barcode[0]))
  951. {
  952. $barcode = $barcode[0];
  953. }
  954. if(isset($barcode['LabelImage']) || isset($barcode[0]['LabelImage']))
  955. //改新的去掉
  956. //if(isset($barcode['labelImage']))
  957. {
  958. $bctime = date('Ymd',$time);
  959. $Hwaybill = substr($barcode['BarcodeNumber'], 8); //改新的去掉 新的 Labellmage 改 labelImage
  960. // $Hwaybill = $barcode['trackingNumber'];
  961. // $Hyd = $this->_pdf($barcode['labelImage'],'y-'.$Hwaybill,$bctime);
  962. $Hyd = $this->_pdf($barcode['LabelImage'],'y-'.$Hwaybill,$bctime);
  963. if(isset($barcode['LabelImage']) && isset($Hwaybill))
  964. //if(isset($barcode['labelImage']) && isset($Hwaybill))
  965. {
  966. if($fullorder['waybill'] != "")
  967. {
  968. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  969. }
  970. else
  971. {
  972. $oldwaybill = $fullorder['oldwaybill'];
  973. }
  974. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  975. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  976. 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']
  977. {
  978. $type = 1;
  979. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  980. }
  981. }
  982. }
  983. else if(isset($barcode['error']))
  984. {
  985. //$failed = $barcode['Description'];//错误提示
  986. //if(stripos($failed,'The requested Mail') === false)
  987. //{
  988. //if($failed != 'false')
  989. //{
  990. $this->$fullorder_name->save(array('print'=>1,'failed'=>json_encode($barcode['error'])),$va[$n]);
  991. //}
  992. //}
  993. }
  994. /**
  995. else if(isset($barcode['error']['message']))
  996. {
  997. if(isset($barcode['error']['errors'][0]['detail']))
  998. {
  999. $failed = $barcode['error']['errors'][0]['detail'];//错误提示
  1000. }
  1001. else
  1002. {
  1003. $failed = $barcode['error']['message'];//错误提示
  1004. }
  1005. //if(stripos($failed,'The requested Mail') === false)
  1006. //{
  1007. if($failed != 'false')
  1008. {
  1009. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1010. }
  1011. //}
  1012. }
  1013. **/
  1014. else
  1015. {
  1016. $failed = json_encode($barcode);//错误提示
  1017. if($failed != 'false')
  1018. {
  1019. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1020. }
  1021. }
  1022. }
  1023. else if($fullorder['printcode'] == "FEDEXGF")//官方FEDEX接口
  1024. {
  1025. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  1026. //接口升级
  1027. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  1028. if($barcode['x'] == 1)
  1029. {
  1030. $bctime = date('Ymd',$time);
  1031. $Hwaybill = $barcode['waybill'];
  1032. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1033. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1034. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1035. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1036. if(isset($barcode['label']) && isset($Hwaybill))
  1037. {
  1038. if($fullorder['waybill'] != "")
  1039. {
  1040. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1041. }
  1042. else
  1043. {
  1044. $oldwaybill = $fullorder['oldwaybill'];
  1045. }
  1046. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1047. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1048. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1049. {
  1050. $type = 1;
  1051. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95,'fp'=>base_url().'data/pdf/'.$bctime.'/f-'.$Hwaybill.'.pdf');
  1052. }
  1053. }
  1054. }
  1055. else
  1056. {
  1057. if(isset($barcode['Description']))
  1058. {
  1059. if($barcode['Description'] != 'FEDEX_INTERNATIONAL_PRIORITY is not supported for the origin and destination pair.')
  1060. {
  1061. $failed = $barcode['Description'];//错误提示
  1062. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1063. }
  1064. else
  1065. {
  1066. $failed = 'FEDEX返回不正确信息';//错误提示
  1067. }
  1068. }
  1069. }
  1070. }
  1071. /**
  1072. else if($fullorder['printcode'] == "FEDEXCBY")//官方FEDEX接口许昌玉美桥
  1073. {
  1074. $barcode = $this->fedex_cby->get_data($fullorder);//获取联邦快递信息
  1075. if($barcode['x'] == 1)
  1076. {
  1077. $bctime = date('Ymd',$time);
  1078. $Hwaybill = $barcode['waybill'];
  1079. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1080. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1081. if(isset($barcode['label']) && isset($Hwaybill))
  1082. {
  1083. if($fullorder['waybill'] != "")
  1084. {
  1085. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1086. }
  1087. else
  1088. {
  1089. $oldwaybill = $fullorder['oldwaybill'];
  1090. }
  1091. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1092. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1093. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1094. {
  1095. $type = 1;
  1096. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1097. }
  1098. }
  1099. }
  1100. else
  1101. {
  1102. if(isset($barcode['Description']))
  1103. {
  1104. $failed = $barcode['Description'];//错误提示
  1105. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1106. }
  1107. }
  1108. }
  1109. **/
  1110. else if($fullorder['printcode'] == "DPD" || $fullorder['printcode'] == "FTFEDEX")
  1111. {
  1112. $barcode = $this->dpd->get_data($fullorder);//获取联邦快递信息
  1113. if($barcode['x'] == 1)
  1114. {
  1115. $bctime = date('Ymd',$time);
  1116. $Hwaybill = $barcode['waybill'];
  1117. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1118. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1119. {
  1120. if($fullorder['waybill'] != "")
  1121. {
  1122. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1123. }
  1124. else
  1125. {
  1126. $oldwaybill = $fullorder['oldwaybill'];
  1127. }
  1128. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1129. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1130. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1131. {
  1132. $type = 1;
  1133. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1134. }
  1135. }
  1136. else if(isset($barcode['yd']) && $Hwaybill == '' && $barcode['yd'] == '')
  1137. {
  1138. $oldwaybill = $fullorder['oldwaybill'];
  1139. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1140. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1141. {
  1142. $type = 2;
  1143. }
  1144. }
  1145. else
  1146. {
  1147. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1148. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1149. }
  1150. }
  1151. else
  1152. {
  1153. $failed = $barcode['Description'];//错误提示
  1154. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1155. }
  1156. }
  1157. else if($fullorder['printcode'] == "DPDIOSS" || $fullorder['printcode'] == "FTFEDEXIOSS")
  1158. {
  1159. $barcode = $this->dpdioss->get_data($fullorder);//获取联邦快递信息
  1160. /** 正常
  1161. if($barcode['x'] == 1)
  1162. {
  1163. $bctime = date('Ymd',$time);
  1164. $Hwaybill = $barcode['waybill'];
  1165. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1166. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1167. {
  1168. if($fullorder['waybill'] != "")
  1169. {
  1170. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1171. }
  1172. else
  1173. {
  1174. $oldwaybill = $fullorder['oldwaybill'];
  1175. }
  1176. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1177. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1178. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1179. {
  1180. $type = 1;
  1181. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1182. }
  1183. }
  1184. else
  1185. {
  1186. $failed = '平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1187. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1188. }
  1189. }
  1190. **/
  1191. //临时开始
  1192. if($barcode['x'] == 1)
  1193. {
  1194. $bctime = date('Ymd',$time);
  1195. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1196. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1197. {
  1198. $type = 2;
  1199. }
  1200. }
  1201. //临时结束
  1202. else
  1203. {
  1204. $failed = $barcode['Description'];//错误提示
  1205. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1206. }
  1207. }
  1208. // 只获取运单号不打印运单
  1209. else if($fullorder['printcode'] == "DPDXW" || $fullorder['printcode'] == "UKDHLXW" || $fullorder['printcode'] == "FTFEDEXXW")
  1210. {
  1211. $barcode = $this->dpdxw->get_data($fullorder);//获取联邦快递信息
  1212. if($barcode['x'] == 1)
  1213. {
  1214. $bctime = date('Ymd',$time);
  1215. $Hwaybill = $barcode['waybill'];
  1216. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1217. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1218. {
  1219. if($fullorder['waybill'] != "")
  1220. {
  1221. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1222. }
  1223. else
  1224. {
  1225. $oldwaybill = $fullorder['oldwaybill'];
  1226. }
  1227. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1228. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1229. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1230. {
  1231. $type = 1;
  1232. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1233. }
  1234. }
  1235. else
  1236. {
  1237. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1238. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1239. }
  1240. }
  1241. else
  1242. {
  1243. $failed = $barcode['Description'];//错误提示
  1244. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1245. }
  1246. }
  1247. /**
  1248. // 此DPD接口暂时不用
  1249. // DPD只获取运单号不打印运单
  1250. else if($fullorder['printcode'] == "DPD")
  1251. {
  1252. if($fullorder['zhou'] == '12')//欧洲
  1253. {
  1254. if($fullorder_name == 'fullordersmt')//速卖通9610
  1255. {
  1256. $fullorder['ysfs'] == '1921';
  1257. }
  1258. else if($fullorder_name == 'fullorder')//独立站9610
  1259. {
  1260. $fullorder['ysfs'] == '2021';
  1261. }
  1262. }
  1263. else if($fullorder['zhou'] == '13')//非洲
  1264. {
  1265. $fullorder['ysfs'] == '1881';
  1266. }
  1267. //$fullorder['ysfs'] == '2041';//欧洲全程不包双清、税
  1268. //$fullorder['ysfs'] == '1981';//欧洲速卖通非9610
  1269. //$fullorder['ysfs'] == '2001';//欧洲独立站非9610
  1270. $barcode = $this->dpd->get_data($fullorder);//获取信息
  1271. if($barcode['x'] == 1)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1272. {
  1273. $bctime = date('Ymd',$time);
  1274. $Hwaybill = $barcode['waybill'];//运单号
  1275. if($fullorder['waybill'] != "")
  1276. {
  1277. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1278. }
  1279. else
  1280. {
  1281. $oldwaybill = $fullorder['oldwaybill'];
  1282. }
  1283. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1284. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1285. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1286. {
  1287. $type = 2;
  1288. }
  1289. }
  1290. else
  1291. {
  1292. $failed = $barcode['Description'];
  1293. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1294. }
  1295. }
  1296. **/
  1297. /** 阿里仓联邦不打印运单模式
  1298. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1299. {
  1300. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1301. $barcode = $this->ali->get_data($fullorder);//获取DHL快递信息
  1302. //$Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1303. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1304. if($barcode['a'] == 2)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1305. {
  1306. $bctime = date('Ymd',$time);
  1307. $Hwaybill = $barcode['number'];//运单号
  1308. //$this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//目前不需要打印标签
  1309. if($fullorder['waybill'] != "")
  1310. {
  1311. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1312. }
  1313. else
  1314. {
  1315. $oldwaybill = $fullorder['oldwaybill'];
  1316. }
  1317. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1318. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1319. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1320. {
  1321. $type = 2;
  1322. }
  1323. }
  1324. else
  1325. {
  1326. $failed = $barcode['m'];
  1327. //$failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1328. //$failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1329. if($fullorder['print'] == 3)
  1330. {
  1331. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1332. }
  1333. else
  1334. {
  1335. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1336. }
  1337. }
  1338. }
  1339. **/
  1340. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1341. {
  1342. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1343. $barcode = $this->ali->get_data($fullorder);//获取快递信息
  1344. $Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1345. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1346. if($barcode['a'] == 2 && $Hyd['a'] == 2)
  1347. {
  1348. $bctime = date('Ymd',$time);
  1349. $Hwaybill = $barcode['number'];//运单号
  1350. $this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//上传PDF
  1351. if($fullorder['waybill'] != "")
  1352. {
  1353. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1354. }
  1355. else
  1356. {
  1357. $oldwaybill = $fullorder['oldwaybill'];
  1358. }
  1359. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1360. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1361. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1362. {
  1363. $type = 1;
  1364. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1365. }
  1366. }
  1367. else
  1368. {
  1369. //$failed = $barcode['m'];
  1370. $failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1371. $failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1372. if($fullorder['print'] == 3)
  1373. {
  1374. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1375. }
  1376. else
  1377. {
  1378. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1379. }
  1380. }
  1381. }
  1382. else if($fullorder['printcode'] == "UPS")//接口
  1383. {
  1384. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1385. if($barcode['x'] == 1)
  1386. {
  1387. $bctime = date('Ymd',$time);
  1388. $Hwaybill = $barcode['waybill'];
  1389. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1390. if(isset($barcode['label']) && isset($Hwaybill))
  1391. {
  1392. if($fullorder['waybill'] != "")
  1393. {
  1394. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1395. }
  1396. else
  1397. {
  1398. $oldwaybill = $fullorder['oldwaybill'];
  1399. }
  1400. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1401. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1402. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1403. {
  1404. $type = 1;
  1405. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1406. }
  1407. }
  1408. }
  1409. else
  1410. {
  1411. $failed = $barcode['Description'];//错误提示
  1412. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1413. }
  1414. }
  1415. else if($fullorder['printcode'] == "DPEX" || $fullorder['printcode'] == "FedEx_2day" || $fullorder['printcode'] == "usps_priority")//官方FEDEX接口
  1416. {
  1417. if($fullorder['waybillid'] != '')
  1418. {
  1419. $del = $this->cne->get_del($fullorder['waybillid']);
  1420. }
  1421. $barcode = $this->cne->get_data($fullorder);
  1422. if($barcode['x'] == 1)
  1423. {
  1424. $bctime = date('Ymd',$time);
  1425. $Hwaybill = $barcode['waybill'];
  1426. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1427. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1428. if(isset($barcode['yd']) && isset($Hwaybill))
  1429. {
  1430. if($fullorder['waybill'] != "")
  1431. {
  1432. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1433. }
  1434. else
  1435. {
  1436. $oldwaybill = $fullorder['oldwaybill'];
  1437. }
  1438. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1439. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1440. 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]))
  1441. {
  1442. $type = 1;
  1443. $pdfnum = ($fullorder['printcode'] == "DPEX")?2:1;
  1444. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1445. }
  1446. }
  1447. }
  1448. else
  1449. {
  1450. $failed = $barcode['Description'];//错误提示
  1451. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1452. }
  1453. }
  1454. 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")
  1455. {
  1456. $barcode = $this->hualeixw->get_data($fullorder);
  1457. $bctime = date('Ymd',$time);
  1458. if(!isset($barcode['x']))
  1459. {
  1460. print_r($barcode);exit;
  1461. }
  1462. if($barcode['x'] == 1)
  1463. {
  1464. if($barcode['ys'] == 1)
  1465. {
  1466. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1467. {
  1468. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1469. }
  1470. $bctime = date('Ymd',$time);
  1471. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1472. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1473. {
  1474. $type = 2;
  1475. }
  1476. }
  1477. else
  1478. {
  1479. $Hwaybill = $barcode['waybill'];
  1480. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1481. if(isset($barcode['label']) && isset($Hwaybill))
  1482. {
  1483. if($fullorder['waybill'] != "")
  1484. {
  1485. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1486. }
  1487. else
  1488. {
  1489. $oldwaybill = $fullorder['oldwaybill'];
  1490. }
  1491. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1492. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1493. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1494. {
  1495. if($fullorder['printcode'] == "HUALEIXW-FEDEX")
  1496. {
  1497. $type = 5;
  1498. }
  1499. else
  1500. {
  1501. $type = 2;
  1502. }
  1503. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1504. }
  1505. }
  1506. }
  1507. }
  1508. else
  1509. {
  1510. $failed = $barcode['Description'];//错误提示
  1511. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1512. }
  1513. /**
  1514. if($barcode['x'] == 1)
  1515. {
  1516. if($barcode['ys'] == 1)
  1517. {
  1518. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1519. {
  1520. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1521. }
  1522. }
  1523. $bctime = date('Ymd',$time);
  1524. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1525. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','waybill'=>$barcode['waybill'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1526. {
  1527. $type = 2;
  1528. }
  1529. }
  1530. else
  1531. {
  1532. $failed = $barcode['Description'];//错误提示
  1533. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1534. }
  1535. **/
  1536. }
  1537. 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')
  1538. {
  1539. $barcode = $this->hualei->get_data($fullorder);
  1540. $bctime = date('Ymd',$time);
  1541. if(!isset($barcode['x']))
  1542. {
  1543. print_r($barcode);exit;
  1544. }
  1545. if($barcode['x'] == 1)
  1546. {
  1547. if($barcode['ys'] == 1)
  1548. {
  1549. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualei','number'=>$fullorder['number'])))
  1550. {
  1551. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1552. }
  1553. $bctime = date('Ymd',$time);
  1554. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1555. $waybill2 = '';
  1556. if(isset($barcode['waybill2']))
  1557. {
  1558. $waybill2 = $barcode['waybill2'];
  1559. }
  1560. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1561. {
  1562. $type = 2;
  1563. }
  1564. }
  1565. else
  1566. {
  1567. $Hwaybill = $barcode['waybill'];
  1568. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1569. if(isset($barcode['label']) && isset($Hwaybill))
  1570. {
  1571. if($fullorder['waybill'] != "")
  1572. {
  1573. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1574. }
  1575. else
  1576. {
  1577. $oldwaybill = $fullorder['oldwaybill'];
  1578. }
  1579. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1580. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1581. $waybill2 = '';
  1582. if(isset($barcode['waybill2']))
  1583. {
  1584. $waybill2 = $barcode['waybill2'];
  1585. }
  1586. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1587. {
  1588. if($fullorder['printcode'] == "HUALEI-FEDEX" || $fullorder['printcode'] == "HUALEI-MLXY" )
  1589. {
  1590. //$type = 5;
  1591. $type = 1;
  1592. }
  1593. else if($fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-ARAMEX-S" || $fullorder['printcode'] == "HUALEI-GES-EU")
  1594. {
  1595. $type = 1;
  1596. }
  1597. else if($fullorder['printcode'] == "HUALEI-DHL")
  1598. {
  1599. //$type = 5;
  1600. $type = 1;
  1601. }
  1602. else
  1603. {
  1604. $type = 2;
  1605. }
  1606. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1607. }
  1608. }
  1609. }
  1610. }
  1611. else
  1612. {
  1613. $failed = $barcode['Description'];//错误提示
  1614. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1615. }
  1616. }
  1617. /** 云途开始**/
  1618. else if(($fullorder['printcode'] == "YunExpress")||($fullorder['printcode'] =='YunExpress_BaoXian'))
  1619. {
  1620. // echo "123";
  1621. // exit;
  1622. // if(!empty($fullorder['waybill']))
  1623. // {
  1624. // $label = $this->yuntu->get_label($fullorder['number']);
  1625. // if($label['x'] == 1){
  1626. // $bctime = date('Ymd',$time);
  1627. // $Hwaybill = $fullorder['waybill'];//运单号
  1628. // $this->_pdfurl($label['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1629. // $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1630. // if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3),$va[$n]))
  1631. // {
  1632. // $type = 1;
  1633. // $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1634. // }
  1635. // }
  1636. // }
  1637. // else{
  1638. $barcode = $this->yuntu->get_data($fullorder);//获取快递信息
  1639. // var_dump($barcode);
  1640. if($barcode['x'] == 1){
  1641. $bctime = date('Ymd',$time);
  1642. $Hwaybill = $barcode['waybill'];//运单号
  1643. $this->_pdfurl($barcode['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1644. if($fullorder['waybill'] != "")
  1645. {
  1646. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1647. }
  1648. else
  1649. {
  1650. $oldwaybill = $fullorder['oldwaybill'];
  1651. }
  1652. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1653. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1654. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1655. {
  1656. $type = 1;
  1657. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1658. }
  1659. }else{
  1660. $failed = $barcode['Description'].'123';//错误提示
  1661. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1662. }
  1663. //}
  1664. //die;
  1665. }
  1666. /*********云途结束 */
  1667. else
  1668. {
  1669. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  1670. }
  1671. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1672. {
  1673. $text['name'] = '速卖通';
  1674. }
  1675. else if($fullorder_name == 'fullordertt')
  1676. {
  1677. $text['name'] = 'TikTok';
  1678. }
  1679. else if($fullorder_name == 'fullorderamz')
  1680. {
  1681. $text['name'] = '亚马逊';
  1682. }
  1683. else if($fullorder_name == 'fullorderxw')
  1684. {
  1685. $text['name'] = '翔文';
  1686. }
  1687. else
  1688. {
  1689. $text['name'] = '独立站';
  1690. }
  1691. $text['express'] = $fullorder['express'];
  1692. $text['country'] = $fullorder['country'];
  1693. $text['orderinfo'] = $fullorder['orderinfo'];
  1694. $text['number'] = $fullorder['number'];
  1695. $text['shipremarks'] = $fullorder['shipremarks'];
  1696. $text['ts'] = $fullorder['ts'];
  1697. $text['time'] = $fullorder['times'];
  1698. $text['printnumber'] = $fullorder['printnumber'];
  1699. $text['pdfnum'] = $pdfnum;
  1700. $text['pt'] = $fullorder['pt'];
  1701. $text['warehouse'] = $fullorder['warehouse']['title'];
  1702. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1703. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1704. }
  1705. else if(($fullorder['printtype'] == 2 || $fullorder['printtype'] == 4) && $fullorder['library'] != 2)
  1706. {
  1707. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1708. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1709. {
  1710. $type = 2;
  1711. }
  1712. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1713. {
  1714. $text['name'] = '速卖通';
  1715. }
  1716. else
  1717. {
  1718. $text['name'] = '独立站';
  1719. }
  1720. $text['express'] = $fullorder['express'];
  1721. $text['country'] = $fullorder['country'];
  1722. $text['orderinfo'] = $fullorder['orderinfo'];
  1723. $text['number'] = $fullorder['number'];
  1724. $text['shipremarks'] = $fullorder['shipremarks'];
  1725. $text['ts'] = $fullorder['ts'];
  1726. $text['time'] = $fullorder['times'];
  1727. $text['printnumber'] = $fullorder['printnumber'];
  1728. $text['pdfnum'] = $pdfnum;
  1729. $text['pt'] = $fullorder['pt'];
  1730. $text['warehouse'] = $fullorder['warehouse']['title'];
  1731. $rows = array('type'=>$fullorder['printtype'],'n'=>$n-1,'data'=>$v,'text'=>$text);
  1732. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1733. }
  1734. else
  1735. {
  1736. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1737. {
  1738. $text['name'] = '速卖通';
  1739. }
  1740. else
  1741. {
  1742. $text['name'] = '独立站';
  1743. }
  1744. $text['express'] = $fullorder['express'];
  1745. $text['country'] = $fullorder['country'];
  1746. $text['orderinfo'] = $fullorder['orderinfo'];
  1747. $text['number'] = $fullorder['number'];
  1748. $text['shipremarks'] = $fullorder['shipremarks'];
  1749. $text['ts'] = $fullorder['ts'];
  1750. $text['time'] = $fullorder['times'];
  1751. $text['printnumber'] = $fullorder['printnumber'];
  1752. $text['pdfnum'] = $pdfnum;
  1753. $text['warehouse'] = $fullorder['warehouse']['title'];
  1754. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1755. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1756. }
  1757. }
  1758. }
  1759. public function _text($fullorder)
  1760. {
  1761. /** 发票地址信息暂时无用
  1762. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1763. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1764. $fullorder['baddress'][1] = $country['ename'];
  1765. **/
  1766. //获取所用相关信息
  1767. $warehouse = $this->warehouse->read($fullorder['type']);
  1768. $country = $this->country->read($fullorder['country']);//订单国家信息
  1769. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1770. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1771. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1772. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1773. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1774. $fullorder['country'] = $country['ename'];//订单国家名
  1775. $fullorder['zhou'] = $country['continent'];//所属州
  1776. $express = $this->express->read($fullorder['express']);
  1777. $fullorder['express'] = $express['servicename'];
  1778. $fullorder['account'] = $express['account'];
  1779. $fullorder['printcode'] = $express['printcode'];
  1780. $fullorder['time'] = date('Y-m-d',time());
  1781. $fullorder['times'] = date('Y-m-d H:i',time());
  1782. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1783. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1784. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1785. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1786. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1787. $shop = $this->shop->read($fullorder['shop']);
  1788. $fullorder['shop'] = $shop['shopname'];
  1789. $shoptype = $this->typeclass->read($shop['type']);
  1790. $fullorder['shoptype'] = $shoptype['classtitle'];
  1791. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1792. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1793. if(is_numeric($fullorder['pay']))
  1794. {
  1795. $pay = $this->typeclass->read($fullorder['pay']);
  1796. if($pay['classid'] == '4')
  1797. {
  1798. $fullorder['pay'] = $pay['title'];
  1799. }
  1800. }
  1801. if($fullorder['printcode'] != "USPS")
  1802. {
  1803. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1804. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1805. }
  1806. //增加退货单所需信息
  1807. $pt = '';
  1808. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1809. foreach ($fpdata as $v)
  1810. {
  1811. $p = explode('|',trim($v,'|'));
  1812. if(isset($p[1]) && isset($p[2]))
  1813. {
  1814. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1815. }
  1816. }
  1817. $fullorder['pt'] = $pt;
  1818. return $fullorder;
  1819. }
  1820. public function _pdf($pdf,$title,$bctime)
  1821. {
  1822. $pdf_path = './data/pdf/'.$bctime.'/';
  1823. $file_base64 = $pdf;
  1824. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1825. $file_base64 = base64_decode($file_base64);
  1826. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1827. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1828. return $bctime;
  1829. }
  1830. public function _pdfurl($pdf,$title,$bctime)
  1831. {
  1832. $pdf_path = './data/pdf/'.$bctime.'/';
  1833. $pdf = fopen($pdf,"r");
  1834. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1835. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1836. return $bctime;
  1837. }
  1838. public function _exceldy()
  1839. {
  1840. if(isset($_GET['fexcel']))
  1841. {
  1842. if(isset($_SESSION['api']))
  1843. {
  1844. $user = $this->user->get_api($_SESSION['api']);
  1845. $usp = $user;
  1846. $fgshop = "";$sid = "";$wid="";$wtype="";
  1847. $usersp = explode('|',trim($user['shop'],'|'));
  1848. $userwh = explode('|',trim($user['warehouse'],'|'));
  1849. foreach ($usersp as $value)
  1850. {
  1851. $fgshop .= " shop = ".$value." or";
  1852. $sid .= " id = ".$value." or";
  1853. }
  1854. foreach ($userwh as $value)
  1855. {
  1856. $wid .= " id = ".$value." or";
  1857. $wtype .= " type = ".$value." or";
  1858. }
  1859. }
  1860. $dowid = $this->input->get('a');
  1861. $wid = "";
  1862. if($dowid != "")
  1863. {
  1864. $id_arr = explode(',',rtrim($dowid,','));
  1865. foreach ($id_arr as $v)
  1866. {
  1867. $wid .= " id = '$v' or";
  1868. }
  1869. $wid = " and (".rtrim($wid,'or').")";
  1870. }
  1871. $page = $this->input->get('page',true);
  1872. $perpage = $this->input->get('perpage',true);
  1873. $timetk = $this->input->get('timetk',true);
  1874. $timetj = $this->input->get('timetj',true);
  1875. $shop = $this->input->get('shop',true);
  1876. $print = $this->input->get('print',true);
  1877. $express = $this->input->get('express',true);
  1878. $waybill = $this->input->get('waybill',true);
  1879. $printtype = $this->input->get('printtype',true);
  1880. $orderinfo = $this->input->get('orderinfo',true);
  1881. $number = $this->input->get('number',true);
  1882. $type = $this->input->get('type',true);
  1883. $lowe = $this->input->get('lowe',true);
  1884. $info = $this->input->get('info',true);
  1885. $ji = $this->input->get('ji',true);
  1886. $so = $this->input->get('so',true);
  1887. $timetk = strtotime($timetk);
  1888. $timetj = strtotime($timetj);
  1889. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1890. if($print == 3)
  1891. {
  1892. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  1893. }
  1894. else
  1895. {
  1896. $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)."'";
  1897. }
  1898. if($shop)
  1899. {
  1900. $where .= " and shop = '$shop'";
  1901. }
  1902. if($express)
  1903. {
  1904. $where .= " and express = '$express'";
  1905. }
  1906. if($printtype)
  1907. {
  1908. $where .= " and printtype = '$printtype'";
  1909. }
  1910. if($orderinfo)
  1911. {
  1912. $where .= " and orderinfo = '$orderinfo'";
  1913. }
  1914. if($number)
  1915. {
  1916. $where .= " and number = '$number'";
  1917. }
  1918. if($waybill)
  1919. {
  1920. $where .= " and waybill = '$waybill'";
  1921. }
  1922. if($type)
  1923. {
  1924. $where .= " and type = '$type'";
  1925. }
  1926. else
  1927. {
  1928. $where .= " and type != '16'";
  1929. }
  1930. /**
  1931. if($type)
  1932. {
  1933. if($type != '4')
  1934. {
  1935. $where .= " and type = '$type'";
  1936. $where2 = '';
  1937. $where3 = '';
  1938. }
  1939. else
  1940. {
  1941. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  1942. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  1943. }
  1944. $where_a = "";
  1945. $where_b = "";
  1946. }
  1947. else
  1948. {
  1949. $where .= " and type != '4'";
  1950. $where_a = "(";
  1951. $where_b = ")";
  1952. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  1953. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  1954. }
  1955. **/
  1956. if($lowe)
  1957. {
  1958. $where .= " and fpdata like '%-$lowe-%'";
  1959. }
  1960. if($ji)
  1961. {
  1962. $where .= " and shipremarks like '%急%'";
  1963. }
  1964. if($so)
  1965. {
  1966. $where .= " and shipremarks like '%$so%'";
  1967. }
  1968. //数据排序
  1969. $order_str = ($print != 3)?"id desc":"printtime desc";
  1970. //取得信息列表
  1971. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  1972. //格式化数据
  1973. foreach ($info_list as $key=>$value)
  1974. {
  1975. $shop = $this->shop->read($value['shop']);
  1976. $info_list[$key]['shop'] = $shop['shopname'];
  1977. if($value['waybill'] == '0')
  1978. {
  1979. $info_list[$key]['waybill'] = "";
  1980. }
  1981. $express = $this->express->read($value['express']);
  1982. $info_list[$key]['express'] = $express['servicename'];
  1983. $warehouse = $this->warehouse->read($value['type']);
  1984. $info_list[$key]['type'] = $warehouse['title'];
  1985. if($value['printtime'] == '0')
  1986. {
  1987. $info_list[$key]['printtime'] = '<em class="t"></em>';
  1988. }
  1989. else
  1990. {
  1991. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  1992. }
  1993. if($value['print'] == 1)
  1994. {
  1995. $info_list[$key]['print'] = '不可打印';
  1996. }
  1997. else if($value['print'] == 2)
  1998. {
  1999. $info_list[$key]['print'] = '未打印';
  2000. }
  2001. else if($value['print'] == 3)
  2002. {
  2003. $info_list[$key]['print'] = '已打印';
  2004. }
  2005. if($value['library'] == 1)
  2006. {
  2007. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2008. }
  2009. else if($value['library'] == 2)
  2010. {
  2011. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2012. }
  2013. else if($value['library'] == 3)
  2014. {
  2015. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2016. }
  2017. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2018. }
  2019. //取得信息列表
  2020. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  2021. //格式化数据
  2022. foreach ($info_listsmt as $key=>$value)
  2023. {
  2024. $shop = $this->shop->read($value['shop']);
  2025. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2026. if($value['waybill'] == '0')
  2027. {
  2028. $info_listsmt[$key]['waybill'] = "";
  2029. }
  2030. $express = $this->express->read($value['express']);
  2031. $info_listsmt[$key]['express'] = $express['servicename'];
  2032. $warehouse = $this->warehouse->read($value['type']);
  2033. $info_listsmt[$key]['type'] = $warehouse['title'];
  2034. if($value['printtime'] == '0')
  2035. {
  2036. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  2037. }
  2038. else
  2039. {
  2040. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2041. }
  2042. if($value['print'] == 1)
  2043. {
  2044. $info_listsmt[$key]['print'] = '不可打印';
  2045. }
  2046. else if($value['print'] == 2)
  2047. {
  2048. $info_listsmt[$key]['print'] = '未打印';
  2049. }
  2050. else if($value['print'] == 3)
  2051. {
  2052. $info_listsmt[$key]['print'] = '已打印';
  2053. }
  2054. if($value['library'] == 1)
  2055. {
  2056. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2057. }
  2058. else if($value['library'] == 2)
  2059. {
  2060. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2061. }
  2062. else if($value['library'] == 3)
  2063. {
  2064. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2065. }
  2066. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2067. }
  2068. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  2069. //格式化数据
  2070. foreach ($info_listtt as $key=>$value)
  2071. {
  2072. $shop = $this->shop->read($value['shop']);
  2073. $info_listtt[$key]['shop'] = $shop['shopname'];
  2074. if($value['waybill'] == '0')
  2075. {
  2076. $info_listtt[$key]['waybill'] = "";
  2077. }
  2078. $express = $this->express->read($value['express']);
  2079. $info_listtt[$key]['express'] = $express['servicename'];
  2080. $warehouse = $this->warehouse->read($value['type']);
  2081. $info_listtt[$key]['type'] = $warehouse['title'];
  2082. if($value['printtime'] == '0')
  2083. {
  2084. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  2085. }
  2086. else
  2087. {
  2088. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2089. }
  2090. if($value['print'] == 1)
  2091. {
  2092. $info_listtt[$key]['print'] = '不可打印';
  2093. }
  2094. else if($value['print'] == 2)
  2095. {
  2096. $info_listtt[$key]['print'] = '未打印';
  2097. }
  2098. else if($value['print'] == 3)
  2099. {
  2100. $info_listtt[$key]['print'] = '已打印';
  2101. }
  2102. if($value['library'] == 1)
  2103. {
  2104. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2105. }
  2106. else if($value['library'] == 2)
  2107. {
  2108. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2109. }
  2110. else if($value['library'] == 3)
  2111. {
  2112. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2113. }
  2114. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2115. }
  2116. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  2117. //格式化数据
  2118. foreach ($info_listamz as $key=>$value)
  2119. {
  2120. $shop = $this->shop->read($value['shop']);
  2121. $info_listamz[$key]['shop'] = $shop['shopname'];
  2122. if($value['waybill'] == '0')
  2123. {
  2124. $info_listamz[$key]['waybill'] = "";
  2125. }
  2126. $express = $this->express->read($value['express']);
  2127. $info_listamz[$key]['express'] = $express['servicename'];
  2128. $warehouse = $this->warehouse->read($value['type']);
  2129. $info_listamz[$key]['type'] = $warehouse['title'];
  2130. if($value['printtime'] == '0')
  2131. {
  2132. $info_listamz[$key]['printtime'] = '<em class="t"></em>';
  2133. }
  2134. else
  2135. {
  2136. $info_listamz[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2137. }
  2138. if($value['print'] == 1)
  2139. {
  2140. $info_listamz[$key]['print'] = '不可打印';
  2141. }
  2142. else if($value['print'] == 2)
  2143. {
  2144. $info_listamz[$key]['print'] = '未打印';
  2145. }
  2146. else if($value['print'] == 3)
  2147. {
  2148. $info_listamz[$key]['print'] = '已打印';
  2149. }
  2150. if($value['library'] == 1)
  2151. {
  2152. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2153. }
  2154. else if($value['library'] == 2)
  2155. {
  2156. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2157. }
  2158. else if($value['library'] == 3)
  2159. {
  2160. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2161. }
  2162. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2163. }
  2164. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,shipremarks,ts',$order_str);
  2165. //格式化数据
  2166. foreach ($info_listxw as $key=>$value)
  2167. {
  2168. $shop = $this->shop->read($value['shop']);
  2169. $info_listxw[$key]['shop'] = $shop['shopname'];
  2170. if($value['waybill'] == '0')
  2171. {
  2172. $info_listxw[$key]['waybill'] = "";
  2173. }
  2174. $express = $this->express->read($value['express']);
  2175. $info_listxw[$key]['express'] = $express['servicename'];
  2176. $warehouse = $this->warehouse->read($value['type']);
  2177. $info_listxw[$key]['type'] = $warehouse['title'];
  2178. if($value['printtime'] == '0')
  2179. {
  2180. $info_listxw[$key]['printtime'] = '<em class="t"></em>';
  2181. }
  2182. else
  2183. {
  2184. $info_listxw[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2185. }
  2186. if($value['print'] == 1)
  2187. {
  2188. $info_listxw[$key]['print'] = '不可打印';
  2189. }
  2190. else if($value['print'] == 2)
  2191. {
  2192. $info_listxw[$key]['print'] = '未打印';
  2193. }
  2194. else if($value['print'] == 3)
  2195. {
  2196. $info_listxw[$key]['print'] = '已打印';
  2197. }
  2198. if($value['library'] == 1)
  2199. {
  2200. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2201. }
  2202. else if($value['library'] == 2)
  2203. {
  2204. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2205. }
  2206. else if($value['library'] == 3)
  2207. {
  2208. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2209. }
  2210. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2211. }
  2212. $title = '订单出库-'.date('Ymd',time());
  2213. $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></table>";
  2214. $tail = "\n";
  2215. $filename = $title.".xls";
  2216. $this->excel->get_fz2(array_merge($info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  2217. }
  2218. }
  2219. public function _barcode()
  2220. {
  2221. $post = $this->input->post(NULL, TRUE);
  2222. if(isset($_SESSION['api']))
  2223. {
  2224. $user = $this->user->get_api($_SESSION['api']);
  2225. $usp = $user;
  2226. $fgshop = "";$sid = "";$wid="";$wtype="";
  2227. $usersp = explode('|',trim($user['shop'],'|'));
  2228. $userwh = explode('|',trim($user['warehouse'],'|'));
  2229. foreach ($usersp as $value)
  2230. {
  2231. $fgshop .= " shop = ".$value." or";
  2232. $sid .= " id = ".$value." or";
  2233. }
  2234. foreach ($userwh as $value)
  2235. {
  2236. $wid .= " id = ".$value." or";
  2237. $wtype .= " type = ".$value." or";
  2238. }
  2239. }
  2240. if(isset($post['page']))
  2241. {
  2242. $page = $this->input->post('page',true);
  2243. $perpage = $this->input->post('perpage',true);
  2244. $warehouse = $this->input->post('warehouse',true);
  2245. $sku = $this->input->post('sku ',true);
  2246. $title = $this->input->post('title',true);
  2247. $print = $this->input->post('print ',true);
  2248. $timetk = $this->input->post('timetk',true);
  2249. $timetj = $this->input->post('timetj',true);
  2250. $timetk = strtotime($timetk);
  2251. $timetj = strtotime($timetj);
  2252. $where = "time > '$timetk' and time < '$timetj'";
  2253. if($warehouse)
  2254. {
  2255. $where .= " and warehouse = '$warehouse'";
  2256. }
  2257. if($sku)
  2258. {
  2259. $where .= " and sku like '%$sku%'";
  2260. }
  2261. if($title)
  2262. {
  2263. $where .= " and title like '%$title%'";
  2264. }
  2265. if($print)
  2266. {
  2267. $where .= " and print = '$print'";
  2268. }
  2269. //数据排序
  2270. $order_str = "time desc";
  2271. if(empty($page))
  2272. {
  2273. $start = 0;
  2274. $perpage = 1;
  2275. }
  2276. else
  2277. {
  2278. $start = ($page - 1)*$perpage;
  2279. }
  2280. //取得信息列表
  2281. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  2282. //格式化数据
  2283. foreach ($info_list as $key=>$value)
  2284. {
  2285. if($value['printtime'] > 0)
  2286. {
  2287. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  2288. }
  2289. else
  2290. {
  2291. $info_list[$key]['printtime'] = '未打印';
  2292. }
  2293. }
  2294. $total = $this->whlabelbarcodeprint->find_count($where);
  2295. $pagenum = ceil($total/$perpage);
  2296. $over = $total-($start+$perpage);
  2297. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2298. echo json_encode($rows);exit;
  2299. }
  2300. if(isset($_SESSION['api']))
  2301. {
  2302. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2303. $this->data['warehouse'] = $warehouse;
  2304. }
  2305. $this->_Template('systemprint_barcode',$this->data);
  2306. }
  2307. public function _barcodedc()
  2308. {
  2309. if(isset($_GET['excel']))
  2310. {
  2311. $warehouse = $this->input->post('warehouse',true);
  2312. $sku = $this->input->post('sku ',true);
  2313. $title = $this->input->post('title',true);
  2314. $print = $this->input->post('print ',true);
  2315. $ktime = $this->input->post('timetk',true);
  2316. $jtime = $this->input->post('timetj',true);
  2317. $ktime = strtotime($ktime);
  2318. $jtime = strtotime($jtime);
  2319. $where = "time > '$timetk' and time < '$timetj'";
  2320. if($warehouse)
  2321. {
  2322. $where .= " and warehouse = '$warehouse'";
  2323. }
  2324. if($sku)
  2325. {
  2326. $where .= " and sku like '%$sku%'";
  2327. }
  2328. if($title)
  2329. {
  2330. $where .= " and title like '%$title%'";
  2331. }
  2332. if($print)
  2333. {
  2334. $where .= " and print = '$print'";
  2335. }
  2336. $order_str = "time desc";
  2337. if(empty($page))
  2338. {
  2339. $start = 0;
  2340. $perpage = 1;
  2341. }
  2342. else
  2343. {
  2344. $start = ($page - 1)*$perpage;
  2345. }
  2346. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  2347. $title = '标签-'.date('Y-m-d H-i-s',time());
  2348. $titlename = "<table border=1>
  2349. <tr align='center'>
  2350. <td>条码号</td>
  2351. <td>SKU</td>
  2352. <td>产品名称</td>
  2353. </tr>
  2354. </table>";
  2355. $filename = $title.".xls";
  2356. $tail = "";
  2357. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2358. }
  2359. }
  2360. public function _barcodedr()
  2361. {
  2362. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2363. $config['upload_path'] = '.'.$dir ;
  2364. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2365. $config['allowed_types'] = 'xls|xlsx|csv';
  2366. $config['max_size'] = 10240;
  2367. $this->load->library('upload', $config);
  2368. $this->upload->initialize($config);
  2369. if ($this->upload->do_upload('userfile'))
  2370. {
  2371. $full_path = $dir.$this->upload->data('file_name');
  2372. $fileName = '.' . $full_path;
  2373. if (!file_exists($fileName))
  2374. {
  2375. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2376. }
  2377. else
  2378. {
  2379. libxml_use_internal_errors(true);
  2380. require_once "./data/excel/PHPExcel/IOFactory.php";
  2381. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2382. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2383. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2384. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2385. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2386. ++$column;//如果列数大于26行
  2387. $list = array();
  2388. for ($i = 2; $i <= $row; $i++) // 行数循环
  2389. {
  2390. $data = array();
  2391. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2392. {
  2393. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2394. }
  2395. $list[] = $data;
  2396. }
  2397. }
  2398. $i = 0;$j = 0;$ed = array();
  2399. foreach ($list as $key=>$value)
  2400. {
  2401. $time = time();
  2402. if($value['0'] == "")
  2403. {
  2404. continue;
  2405. }
  2406. $label = $value['0'];
  2407. $sku = $value['1'];
  2408. $title = $value['2'];
  2409. $num = $value['3'];
  2410. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2411. if(!$d)//如果没有这个SKU
  2412. {
  2413. $ed[] = array($sku.'-库存中不存在此SKU');
  2414. $j++;
  2415. continue;
  2416. }
  2417. if($num < 1)
  2418. {
  2419. $ed[] = array($sku.'-数量错误!');
  2420. $j++;
  2421. continue;
  2422. }
  2423. unset($d['id']);
  2424. $d['time'] = $time;
  2425. $d['num'] = $num;
  2426. $this->whlabelbarcodeprint->insert($d);
  2427. }
  2428. if($j > 0)
  2429. {
  2430. $tt = date('Ymd',time());
  2431. $title = '库存导入错误信息-'.$tt;
  2432. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2433. $tail = "\n";
  2434. $filename = $title.".xls";
  2435. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2436. $dir = '/data/excel/'.$time.'/';
  2437. $file_name = 'error_'.$time.rand(1000,9999);
  2438. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2439. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2440. fwrite($myfile,$ecl);
  2441. fclose($myfile);
  2442. $error = $dir.$file_name.'.xls';
  2443. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2444. }
  2445. else
  2446. {
  2447. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2448. }
  2449. }
  2450. }
  2451. public function _yswaybill()
  2452. {
  2453. $data = $this->yswaybill->find_all("waybill = ''");
  2454. foreach ($data as $v)
  2455. {
  2456. $type = $v['type'];
  2457. $number = $v['number'];
  2458. $express = $v['express'];
  2459. $fullorder = $this->$type->get_number($number);
  2460. $fullorder = $this->_text($fullorder);
  2461. $barcode = $this->$express->get_hqwaybill($number);
  2462. if(!isset($barcode['x']))
  2463. {
  2464. continue;
  2465. }
  2466. if($barcode['x'] == 1)
  2467. {
  2468. if($barcode['ys'] != 1)
  2469. {
  2470. $this->db->trans_begin();
  2471. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2472. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2473. if ($this->db->trans_status() === TRUE)
  2474. {
  2475. $this->db->trans_commit();
  2476. }
  2477. else
  2478. {
  2479. $this->db->trans_rollback();
  2480. }
  2481. }
  2482. }
  2483. else
  2484. {
  2485. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2486. }
  2487. }
  2488. echo 1;
  2489. }
  2490. }