Systemprint.php 97 KB

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