Systemprinttest.php 86 KB

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