Systemprintbak.php 90 KB

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