Systemprint.php 99 KB

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