Systemprint.php 87 KB

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