Systemprint.php 85 KB

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