Systemprint.php 86 KB

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