Systemprint.php 84 KB

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