1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Ab extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_api','api');
- $this->load->_model('Model_apismt','apismt');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_customersmt','customersmt');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_hl','hl');
- $this->load->_model('Model_is','is');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_dhltest','dhltest');
- $this->load->_model('Model_customer','customer');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_productdescribe','productdescribe');
- $this->load->_model('Model_ljg','ljg');
- $this->load->_model('Model_commodityread','commodityread');
- $this->load->_model('Model_service','service');
- $this->load->_model('Model_fedex','fedex');
- $this->load->_model('Model_commodity','commodity');
- $this->load->_model('Model_fullordersmtorder','fullordersmtorder');
- $this->load->_model('Model_fullordersmthb','fullordersmthb');
- $this->load->_model('Model_allocation','allocation');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_reset','reset');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'jsf')
- {
- $this->_jsf($arg_array);
- }
- else if($arg == 'jsm')
- {
- $this->_jsm($arg_array);
- }
- else if($arg == 'sku')
- {
- $this->_sku($arg_array);
- }
- else if($arg == 'order')
- {
- $this->_order($arg_array);//查询获取到fullordersmtorder的单
- }
- else if($arg == 'data')
- {
- $this->_data($arg_array);//查询获取到fullordersmtorder的单
- }
- else if($arg == 'dataxr')
- {
- $this->_dataxr($arg_array);//查询获取到fullordersmtorder的单写入
- }
- else if($arg == 'cf')
- {
- $this->_cf($arg_array);//查询获取到fullordersmtorder的单
- }
- else if($arg == 'khjz')
- {
- $this->_khjz($arg_array);
- }
- else if($arg == 'khjzfs')
- {
- $this->_khjzfs($arg_array);
- }
- else if($arg == 'tbsmt')
- {
- $this->_tbsmt($arg_array);
- }
- else if($arg == 'xqcx')
- {
- $this->_xqcx($arg_array);
- }
- else if($arg == 'dpex')
- {
- $this->_dpex($arg_array);
- }
- else if($arg == 'fedexhz')
- {
- $this->_fedexhz($arg_array);
- }
- else if($arg == 'smtck')
- {
- $this->_smtck($arg_array);
- }
- else if($arg == 'xxfs')
- {
- $this->_xxfs($arg_array);//消息发送测试
- }
- else if($arg == 'smtprintout')
- {
- $this->_smtprintout($arg_array);//速卖通亚马逊操作出库
- }
- else if($arg == 'feite')
- {
- $this->_feite($arg_array);//飞特提取内容下载
- }
- else if($arg == 'rl')
- {
- $this->_rl($arg_array);//return label信息查找
- }
- else if($arg == 'cz')
- {
- $this->_cz($arg_array);//重置恢复打印、出库
- }
- else if($arg == 'paypal')
- {
- $this->_paypal($arg_array);//重置恢复打印、出库
- }
- else if($arg == 'qcfs')
- {
- $this->_qcfs($arg_array);//清除邮件发送信息
- }
- else if($arg == 'yd')
- {
- $this->_yd($arg_array);//测试运单
- }
- else if($arg == 'jzw')
- {
- $this->_jzw($arg_array);//矫正whlabel
- }
- else if($arg == 'qlzd')
- {
- $this->_qlzd($arg_array);//清除无效占单
- }
- }
-
- public function _qcfs($arg_array)
- {
- $a = $this->fullorder->get_number($arg_array[0]);
- $this->fullorder->save(array('zdstate'=>'','wltype'=>0,'wlcontent'=>'','wlfstime'=>''),$a['id']);
- }
-
- public function _jzw($arg_array)//矫正number和features不一致
- {
- $d = $this->whlabel->find_pc("1=1",'sku,features,warehouse','*');
- foreach ($d as $val)
- {
- $xd = $this->whlabel->find_all("sku = '".$val['sku']."' and features = '".$val['features']."' and warehouse = '".$val['warehouse']."'",'id,number,features,title,warehouse');
- foreach ($xd as $v)
- {
- $f = str_replace('-','',$v['features']);
- if($v['number'] != $f)
- {
- $this->whlabel->save(array("number"=>$f),$v['id']);
- }
- }
- }
- }
-
-
- public function _qlzd()//清除无效占单
- {
- $cw = array();$s = array();
- $wh = $this->whlabel->find_all("state = '0' and zd != ''");
- foreach ($wh as $v)
- {
- $d = $this->fullorder->get_number($v['zd']);
- if(!$d)
- {
- $d = $this->fullordersmt->get_number($v['zd']);
- if(!$d)
- {
- $d = $this->fullordertt->get_number($v['zd']);
- if(!$d)
- {
- $cw[] = $v['id'];
- continue;
- }
- }
- }
- if($d['state'] != 207 && $d['state'] != 209)
- {
- $s[] = $v['zd'];
- $this->whlabel->save(array("zd"=>''),$v['id']);
- }
- }
- echo "<pre>";
- print_r($s);
- }
-
-
- public function _smtprintout($arg_array)
- {
- $time = time();
- $a = $this->fullordersmt->get_number($arg_array[0]);
- if($a)
- {
- if($a['zsbjz'] < 1)
- {
- echo "9610要求必须要申报价值!";exit;
- }
- if($a['waybill'] != '' && $a['printtime'] == '0' && $a['librarytime'] == '0' && $a['warehouse'] == '3')
- {
- if($this->fullordersmt->save(array('review'=>5,'reviewtime'=>$time,'print'=>3,'printtime'=>$time,'printnumber'=>1,'library'=>2,'librarytime'=>$time,'libraryconfirm'=>2),$a['id']))
- {
- echo "操作已完成";
- }
- else
- {
- echo "操作失败,请重试";
- }
- }
- else
- {
- echo "操作失败,订单已操作完成或不符合条件";
- }
- }
- else
- {
- echo "找不到此编号";
- }
- }
-
- public function _smtck($arg_array)//测试SKU
- {
- $notice = $this->notice->read($arg_array[1]);
- $v = $this->fullorder->get_number($arg_array[0]);
- $shop = $this->shop->read($v['shop']);
- $express = $this->express->read($v['express']);
- $fs = $this->notice->get_god($v,$shop,$express,$notice['content'],$notice['message'],$notice['emailtitle']);
- }
- public function _sku($arg_array)//测试SKU
- {
- $gethl = $this->hl->get_hl();//获取即时汇率
- $dictionaries = $this->typeclass->find_all('ae!= "" and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)'); //产品人发类型颜色
- $dtc = array();
- foreach ($dictionaries as $v)
- {
- if(stripos($v['spare'],'|') !== false)//如果有多个值
- {
- $v['spare'] = explode('|',$v['spare']);
- foreach ($v['spare'] as $k=>$vs)
- {
- if(stripos($v['zh'],'|') !== false)
- {
- $vzh = explode('|',$v['zh']);
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
- }
- else
- {
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
- }
- }
- }
- else if(stripos($v['spare'],'|') !== false)//如果有多个值
- {
- $v['spare'] = explode('|',$v['spare']);
- foreach ($v['spare'] as $k=>$vs)
- {
- if(stripos($v['zh'],'|') !== false)
- {
- $vzh = explode('|',$v['zh']);
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
- }
- else
- {
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
- }
- }
- }
- else
- {
- $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
- }
-
- }
- $dictionaries2 = $this->typeclass->find_all();
- foreach ($dictionaries2 as $v)
- {
- $dtctitle[$v['id']] = $v['title'];
- }
- $dtc['Clip'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
- $dtc['Clip--D'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
- $dtc['Clip--L'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
- $dtc['with bangs'] = array('classid'=>999,'zh'=>'(带齐刘海)','id'=>0);
- $dtc['no bangs'] = array('classid'=>999,'zh'=>'(无刘海)','id'=>0);
- $dtc['right'] = array('classid'=>999,'zh'=>'右偏分(戴上后U型部分在右边)','id'=>0);
- $dtc['middle'] = array('classid'=>999,'zh'=>'中分(戴上后U型部分在中间)','id'=>0);
- $dtc['left'] = array('classid'=>999,'zh'=>'左偏分(戴上后U型部分在左边)','id'=>0);
- $dtc['freeeyelash'] = array('classid'=>999,'zh'=>'(送假睫毛)','id'=>0);
- $dtc['stwbob10'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 10寸','id'=>0);
- $dtc['stwbob12'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 12寸','id'=>0);
- $dtc['stwbob14'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 14寸','id'=>0);
- $dtc['HDTransparent'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
- $dtc['HDLight Brown'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
- $dtc['nwb'] = array('classid'=>15,'zh'=>'扁头 自然曲','id'=>111);//中文词不一样,ID一样
- $dtctitle[126] = 'Hair Weaving';
- $dtctitle[127] = 'Closure';
- $dtctitle[128] = 'Wigs';
- $dtctitle[130] = 'Clip-in Full Head';
- /* 匹配结束 */
- /* 价格加入 */
- $money = array();
- $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
- foreach ($productdescribe as $v)
- {
- $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
- }
- /* 价格加入 */
- /* 匹配ID加入 */
- $int = array();
- $intdata = $this->typeclass->find_all('classid=14','id,ae');
- foreach ($intdata as $v)
- {
- $v['spare'] = explode('|',$v['spare']);
- $int[$v['id']] = $v['spare'][0];
- }
- /* 匹配ID结束 */
- /* 匹配状态加入 */
- $zt = array();$ste = array();
- $ztdata = $this->typeclass->find_all('classid=29','id,classtitle');
- foreach ($ztdata as $v)
- {
- $zt[$v['classtitle']] = $v['id'];
- $ste[$v['id']] = $v['classtitle'];
- }
- /* 匹配状态结束 */
- /* 国家加入键值-k */
- $cuy = array();
- $cuydata = $this->country->find_all('1=1','al,lb,id');
- foreach ($cuydata as $v)
- {
- $cuy[$v['al']] = array('id'=>$v['id'],'lb'=>$v['lb']);//获取到国家ID
- }
- /* 国家加入键值-j */
- /* 币种加入键值-k */
- $typeclass = array();
- $tdata = $this->typeclass->find_all('classid=30','id,title');
- foreach ($tdata as $v)
- {
- $typeclass[$v['title']] = $v['id'];
- }
- /* 币种加入键值-j */
- $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
-
- $r = $this->api->matching('1;1','BW--3+13*6F-24 26 28-20',$dtc,$money,$int,$dtctitle);
- echo "<pre>";
- print_r($r);
- }
-
- public function _cf($arg_array) //速卖通订单拆分
- {
- $b = $this->fullordersmt->get_orderinfo($arg_array[0]);
- if($b['merge'] == $b['id'])
- {
- $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
- foreach ($data as $v)
- {
- $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
- if($a)
- {
- $this->fullordersmt->save($a,$v['id']);
- }
- }
- }
- }
-
- public function _khjzfs($arg_array)//独立站客户下单数量矫正
- {
- //@$this->allocation->insert(array('title'=>'khfs - '.date('Y-m-d H:i:s',time())));
- $customer = $this->customer->find_all("1=1",'id,email,shop','id asc',$arg_array[0],$arg_array[1]);
- foreach ($customer as $k=>$v)
- {
- $num = $this->fullorder->find_all("email = '".$v['email']."' and shop = '".$v['shop']."' and mergeid = 0","*","dtime desc");
- $money = sprintf("%01.2f",array_sum(array_column($num,'shouldmoney')));
- $n = count($num);
- if($n > 0)
- {
- $this->customer->save(array('num'=>$n,'money'=>$money,'time'=>$num[0]['dtime']),$v['id']);
- }
- else
- {
- $this->customer->save(array('num'=>$n),$v['id']);
- }
- }
- }
-
- public function _khjz($arg_array)//独立站客户下单数量矫正
- {
- $customer = $this->customer->find_count();
- $customer = ceil($customer/20000);
- for($i=0;$i<$customer;$i++)
- {
- $a = ($i=='0')?0:$i*20000;
- $b = ($i+1)*20000;
- $ch = curl_init();
- $url = 'http://a'.($i+10).'.wepolicy.cn/ab/khjzfs/'.$a.'/'.$b;
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_TIMEOUT,20);
- //设置post数据
- $post = array();
- $post['data'] = 1;
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- $res = curl_exec($ch);
- curl_close($ch);
- }
- }
-
- public function _tbsmt($arg_array)//同步速卖通新店
- {
- $ch = curl_init();
- $url = 'http://39.100.97.180/start/order';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- //设置post数据
- $post = array();
- $post['starttime'] = 1393606800;
- $post['endtime'] = 1590021229;
- $post['page'] = $arg_array[0];
- $post['size'] = 50;
- $post['state'] = '["IN_CANCEL","WAIT_SELLER_SEND_GOODS","SELLER_PART_SEND_GOODS","WAIT_BUYER_ACCEPT_GOODS","FUND_PROCESSING","IN_ISSUE","IN_FROZEN","WAIT_SELLER_EXAMINE_MONEY","RISK_CONTROL"]';
- $post['code'] = '50002100d409LZqwnvDc1iVenS9ysG7EbP4LuxhnfuHykTwEciGd1129c3d57tI3Sin';
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- echo "<pre>";
- print_r($res);
- }
-
- public function _xqcx($arg_array)
- {
- $cw = array();
- $class = array();$classdata = array();$lx = array();$pm = array();
- $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=15 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24');
- foreach ($a as $val)
- {
- $class[] = '-'.$val['id'].'-';
- }
- $b = $this->typeclass->find_all();
- foreach ($b as $val)
- {
- $classdata[$val['id']] = $val['title'];
- $lx[$val['id']] = $val['classid'];
- $pm[$val['id']] = $val['zh'];
- }
- //Closure wigs
- $dataa = $this->fullorder->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
- $data = array_merge($dataa,$datab);
-
- $p = $class;
- $resdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if((stripos($v,'-127-') !== false || stripos($v,'-128-') !== false) && stripos($v,'-57-') !== false)
- {
- $e = explode('|',$v);
- $d = str_replace($p,'-',$e[0]);
- $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
- $q = explode('-',trim($q,'-'));
- $c = explode(',',$e[0]);
- if(!isset($resdata[$d]))
- {
- if(stripos($v,'-127-') !== false)
- {
- if(isset($q[9]))
- {
- $s = ($q[9] != 68 && $q[9] != 69)?1:2;
- }
- else
- {
- $s = 1;
- }
- $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
- if($lx[$q[5]] == '27')//如果是发块类型
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
- }
- }
- else
- {
- if(isset($q[8]))
- {
- $s = ($q[8] != 68 && $q[8] != 69)?1:2;
- }
- else
- {
- $s = 1;
- }
- if($lx[$q[5]] == '18')//如果是头套种类
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
- }
- }
- }
- else
- {
- if(is_array($e[2]) || !is_numeric($e[2]))
- {
- $cw[] = $v;
- continue;
- }
- else
- {
- $resdata[$d][0] += $e[2];
- }
-
- }
- }
- }
- }
-
- $data = array();
- foreach ($resdata as $v)
- {
- if(isset($v[4]))
- {
- if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
- {
- $data[$v[1].$v[2].$v[3].$v[4]] = array($v[0],$v[1],$pm[$v[2]],$classdata[$v[3]],$v[4]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
- }
- }
- else
- {
- if(!isset($data[$v[1].$v[2].$v[3]]))
- {
- $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3]][0] += $v[0];
- }
- }
- }
- $list = array();
- foreach ($data as $v)
- {
- $x = (isset($v[4]))?$v[3]:$v[2];
- if(!isset($list[$v[2]]))
- {
- $list[$v[2]] = array();
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- else
- {
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- }
- foreach ($list as $key=>$val)
- {
- foreach ($val as $k=>$va)
- {
- $dd = array();
- foreach ($va as $v)
- {
- $ss = (!isset($v[4]))?$v[3]:$v[4];
- if(!isset($dd[$v['1']]))
- {
- $dd[$v['1']] = array();
- $dd[$v['1']][$ss] = $v;
- }
- else
- {
- $dd[$v['1']][$ss] = $v;
- }
- }
- ksort($dd);
- $list[$key][$k] = $dd;
- }
- }
- //echo count($list);
- //echo "<pre>";
- //print_r($list);
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- foreach ($list as $key=>$val)
- {
- $btnum = count($val);
- $str .= "<table border=1>
- <tr style='color: #F00;'><th colspan='".($btnum+$btnum*2)."' align='left'><h3>".$key."<h3></th></tr>
- <tr>";
- foreach ($val as $k=>$v)
- {
- $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k."</td>
- <td>中棕</td>
- <td>透明</td>";
- }
- $str .= "</tr>
- </table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
- foreach ($val as $k=>$v)
- {
- $str .= "<td><table border=1>";
- foreach ($v as $sk=>$s)
- {
- $xk1 = (isset($s[1]))?$s[1][0]:0;
- $xk2 = (isset($s[2]))?$s[2][0]:0;
- $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
- }
- $str .= "</table></td>";
- }
- $str .= "</table>";
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
-
- }
-
- public function _fedexhz($arg_array)
- {
- $fullorder = $this->fullorder->get_number($arg_array[0]);
- if(!$fullorder)
- {
- $fullorder = $this->fullordersmt->get_number($arg_array[0]);
- }
- $fullorder = $this->_text($fullorder);
- $data = $fullorder;
-
- $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU');
- $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
- $data['province'] = trim($data['province'],' ');
- $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
- $data['province'] = $dataprovince;
- //your account details here
- /**许昌联邦账号
- $key = 'L7Vtg0uUP0BxgNfp';
- $password = 'iOqmHwfjx12sxszdEZstGtRYs';
- $AccountNumber = '644155250';
- $MeterNumber = '250140772';
- **/
- //杭州联邦账号
- $key = 'Jx8Rq9QL34sMKJTK';
- $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
- $AccountNumber = '692362136';
- $MeterNumber = '250759448';
- $xml = '<?xml version="1.0" encoding="UTF-8"?>';
- $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v26="http://fedex.com/ws/ship/v26">';
- $xml.='<soapenv:Header/>';
- $xml.='<soapenv:Body>';
- $xml.='<v26:ProcessShipmentRequest>';
- $xml.='<v26:WebAuthenticationDetail>';
- $xml.='<v26:ParentCredential>';
- $xml.='<v26:Key>'.$key.'</v26:Key>';
- $xml.='<v26:Password>'.$password.'</v26:Password>';
- $xml.='</v26:ParentCredential>';
- $xml.='<v26:UserCredential>';
- $xml.='<v26:Key>'.$key.'</v26:Key>';
- $xml.='<v26:Password>'.$password.'</v26:Password>';
- $xml.='</v26:UserCredential>';
- $xml.='</v26:WebAuthenticationDetail>';
- $xml.='<v26:ClientDetail>';
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:MeterNumber>'.$MeterNumber.'</v26:MeterNumber>';
- $xml.='</v26:ClientDetail>';
- $xml.='<v26:TransactionDetail>';
- //$xml.='<v26:CustomerTransactionId>Ship_International_basic</v26:CustomerTransactionId>';
- $xml.='</v26:TransactionDetail>';
- $xml.='<v26:Version>';
- $xml.='<v26:ServiceId>ship</v26:ServiceId>';
- $xml.='<v26:Major>26</v26:Major>';
- $xml.='<v26:Intermediate>0</v26:Intermediate>';
- $xml.='<v26:Minor>0</v26:Minor>';
- $xml.='</v26:Version>';
- $xml.='<v26:RequestedShipment>';
- $xml.='<v26:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v26:ShipTimestamp>';
- $xml.='<v26:DropoffType>REGULAR_PICKUP</v26:DropoffType>';
- $xml.='<v26:ServiceType>FEDEX_INTERNATIONAL_PRIORITY</v26:ServiceType>';//FEDEX_INTERNATIONAL_PRIORITY、FEDEX_INTERNATIONAL_PRIORITY_EXPRESS也是优先。INTERNATIONAL_ECONOMY经济
- //超过重量需要换包装,现在不设置,超出也按0.4走
- if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
- {
- $xml.='<v26:PackagingType>FEDEX_PAK</v26:PackagingType>';
- }
- else
- {
- $xml.='<v26:PackagingType>FEDEX_BOX</v26:PackagingType>';
- }
- $xml.='<v26:Shipper>';//发货人信息开始
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>LONGYI</v26:PersonName>';//$data['warehouse']['company']
- $xml.='<v26:CompanyName>LONGYI</v26:CompanyName>';//$data['warehouse']['company']
- $xml.='<v26:PhoneNumber>18539006340</v26:PhoneNumber>';//$data['warehouse']['phone']
- //$xml.='<v26:EMailAddress>'.$data['warehouse']['name'].'</v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='<v26:Address>';
- $xml.='<v26:StreetLines>4703,building C,bodi center,ningwei street</v26:StreetLines>';//$data['warehouse']['address']
- $xml.='<v26:City>Hang Zhou</v26:City>';//$data['warehouse']['city']
- //$xml.='<v26:StateOrProvinceCode>TN</v26:StateOrProvinceCode>';
- $xml.='<v26:PostalCode>310000</v26:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
- $xml.='<v26:CountryCode>'.$data['warehouse']['lb'].'</v26:CountryCode>';
- $xml.='</v26:Address>';
- $xml.='</v26:Shipper>';
- $xml.='<v26:Recipient>';//收货人信息开始
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>'.$data['name'].'</v26:PersonName>';
- $xml.='<v26:CompanyName>'.$data['client'].'</v26:CompanyName>';
- $xml.='<v26:PhoneNumber>'.$data['phone'].'</v26:PhoneNumber>';
- //$xml.='<v26:EMailAddress>'.$data['name'].'</v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='<v26:Address>';
- $xml.='<v26:StreetLines>'.$data['address'].'</v26:StreetLines>';
- $xml.='<v26:StreetLines>'.$data['address2'].'</v26:StreetLines>';
- $xml.='<v26:City>'.$data['city'].'</v26:City>';
- $xml.='<v26:StateOrProvinceCode>'.$data['province'].'</v26:StateOrProvinceCode>';
- $xml.='<v26:PostalCode>'.$data['zipcode'].'</v26:PostalCode>';
- $xml.='<v26:CountryCode>'.$data['lb'].'</v26:CountryCode>';
- $xml.='</v26:Address>';
- $xml.='</v26:Recipient>';
- $xml.='<v26:ShippingChargesPayment>';
- $xml.='<v26:PaymentType>SENDER</v26:PaymentType>';
- $xml.='<v26:Payor>';
- $xml.='<v26:ResponsibleParty>';
- $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
- $xml.='<v26:Contact>';
- $xml.='<v26:PersonName>He Cong</v26:PersonName>';
- //$xml.='<v26:EMailAddress></v26:EMailAddress>';
- $xml.='</v26:Contact>';
- $xml.='</v26:ResponsibleParty>';
- $xml.='</v26:Payor>';
- $xml.='</v26:ShippingChargesPayment>';
- //ETD开始
- $xml.='<v26:SpecialServicesRequested>';
- $xml.='<v26:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v26:SpecialServiceTypes>';
- $xml.='<v26:EtdDetail>';
- $xml.='<v26:RequestedDocumentCopies>COMMERCIAL_INVOICE</v26:RequestedDocumentCopies>';
- $xml.='</v26:EtdDetail>';
- $xml.='</v26:SpecialServicesRequested>';
- //ETD结束
- $xml.='<v26:CustomsClearanceDetail>';
- $xml.='<v26:DutiesPayment>';
- $xml.='<v26:PaymentType>RECIPIENT</v26:PaymentType>';
- $xml.='<v26:Payor>';
- $xml.='<v26:ResponsibleParty>';
- $xml.='<v26:AccountNumber></v26:AccountNumber>';
- //$xml.='<v26:Tins>';
- //$xml.='<v26:TinType>BUSINESS_STATE</v26:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
- //$xml.='<v26:Number>213456</v26:Number>';//这里填税号
- //$xml.='</v26:Tins>';
- //$xml.='<v26:Contact>';
- //$xml.='<v26:ContactId>12345</v26:ContactId>';
- //$xml.='<v26:PersonName>INPUT YOUR INFORMATION</v26:PersonName>';
- //$xml.='</v26:Contact>';
- $xml.='</v26:ResponsibleParty>';
- $xml.='</v26:Payor>';
- $xml.='</v26:DutiesPayment>';
- $xml.='<v26:DocumentContent>DOCUMENTS_ONLY</v26:DocumentContent>';
- $xml.='<v26:CustomsValue>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>'.$data['zsbjz'].'</v26:Amount>';
- $xml.='</v26:CustomsValue>';
- //DESC1---:Commodities循环
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>satin bags-100PCS</v26:Description>';//品名和数量
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:HarmonizedCode>4202320000</v26:HarmonizedCode>';//海关编码
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.1</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0.2</v26:Amount>';//单条申报价值
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- //DESC2
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>hair accessories-100PCS</v26:Description>';//品名和数量
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:HarmonizedCode>9615110000</v26:HarmonizedCode>';//海关编码
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.1</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0.3</v26:Amount>';//单条申报价值
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- //DESC3
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>woven label-1000PCS</v26:Description>';//品名和数量
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:HarmonizedCode>5901101090</v26:HarmonizedCode>';//海关编码
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.2</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>1000</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0.05</v26:Amount>';//单条申报价值
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- /**
- //DESC4
- $xml.='<v26:Commodities>';
- $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
- $xml.='<v26:Description>satin bags-100PCS</v26:Description>';//品名和数量
- $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
- $xml.='<v26:HarmonizedCode>4202320000</v26:HarmonizedCode>';//海关编码
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';//重量:磅
- $xml.='<v26:Value>0.2</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
- $xml.='</v26:Weight>';
- $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
- $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
- $xml.='<v26:UnitPrice>';
- $xml.='<v26:Currency>USD</v26:Currency>';
- $xml.='<v26:Amount>0.2</v26:Amount>';//单条申报价值
- $xml.='</v26:UnitPrice>';
- $xml.='</v26:Commodities>';
- **/
- $xml.='<v26:ExportDetail>';
- $xml.='<v26:ExportComplianceStatement>30.37(f)</v26:ExportComplianceStatement>';
- $xml.='</v26:ExportDetail>';
- $xml.='</v26:CustomsClearanceDetail>';
- $xml.='<v26:LabelSpecification>';
- $xml.='<v26:LabelFormatType>COMMON2D</v26:LabelFormatType>';
- $xml.='<v26:ImageType>PDF</v26:ImageType>';
- $xml.='<v26:LabelStockType>STOCK_4X6.75</v26:LabelStockType>';
- $xml.='</v26:LabelSpecification>';
- //发票参数开始
- $xml.='<v26:ShippingDocumentSpecification>';
- $xml.='<v26:ShippingDocumentTypes>COMMERCIAL_INVOICE</v26:ShippingDocumentTypes>';
- //ETD
- $xml.='<v26:CommercialInvoiceDetail>';
- $xml.='<v26:Format>';
- $xml.='<v26:ImageType>PDF</v26:ImageType>';
- $xml.='<v26:StockType>PAPER_LETTER</v26:StockType>';
- $xml.='<v26:ProvideInstructions>true</v26:ProvideInstructions>';
- $xml.='</v26:Format>';
- $xml.='<v26:CustomerImageUsages>';
- $xml.='<v26:Type>LETTER_HEAD</v26:Type>';
- $xml.='<v26:Id>IMAGE_1</v26:Id>';
- $xml.='</v26:CustomerImageUsages>';
- $xml.='<v26:CustomerImageUsages>';
- $xml.='<v26:Type>SIGNATURE</v26:Type>';
- $xml.='<v26:Id>IMAGE_2</v26:Id>';
- $xml.='</v26:CustomerImageUsages>';
- //ETD
- $xml.='</v26:CommercialInvoiceDetail>';
- $xml.='</v26:ShippingDocumentSpecification>';
- //发票参数结束
- $xml.='<v26:RateRequestTypes>LIST</v26:RateRequestTypes>';//费率请求类型
- $xml.='<v26:PackageCount>'.$data['zjs'].'</v26:PackageCount>';//包装数量
- $xml.='<v26:RequestedPackageLineItems>';
- $xml.='<v26:SequenceNumber>1</v26:SequenceNumber>';
- //$xml.='<v26:InsuredValue><v26:Currency>USD</v26:Currency><v26:Amount>120.00</v26:Amount></v26:InsuredValue>';//保险金额
- $xml.='<v26:Weight>';
- $xml.='<v26:Units>KG</v26:Units>';
- $xml.='<v26:Value>0.4</v26:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
- $xml.='</v26:Weight>';
- //超过重量需要填尺寸,现在不设置,超出也按0.4走
- if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
- {
- $xml.='<v26:Dimensions>';
- $xml.='<v26:Length>4</v26:Length>';
- $xml.='<v26:Width>20</v26:Width>';
- $xml.='<v26:Height>30</v26:Height>';
- $xml.='<v26:Units>CM</v26:Units>';
- $xml.='</v26:Dimensions>';
- }
- //$xml.='<v26:ItemDescription>Book</v26:ItemDescription>';//阿联酋需要选择
- $xml.='<v26:CustomerReferences>';
- $xml.='<v26:CustomerReferenceType>CUSTOMER_REFERENCE</v26:CustomerReferenceType>';
- $xml.='<v26:Value>'.$data['number'].'</v26:Value>';
- $xml.='</v26:CustomerReferences>';
- //签名开始
- if($data['qm'] > 0)
- {
- $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
- $xml.='<v26:SpecialServicesRequested>';
- $xml.='<v26:SpecialServiceTypes>SIGNATURE_OPTION</v26:SpecialServiceTypes>';
- $xml.='<v26:SignatureOptionDetail>';
- $xml.='<v26:OptionType>'.$qm.'</v26:OptionType>';
- $xml.='</v26:SignatureOptionDetail>';
- $xml.='</v26:SpecialServicesRequested>';
- }
- //签名结束
- $xml.='</v26:RequestedPackageLineItems>';
- $xml.='</v26:RequestedShipment>';
- $xml.='</v26:ProcessShipmentRequest>';
- $xml.='</soapenv:Body>';
- $xml.='</soapenv:Envelope>';
-
- /**
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services/ship');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $result_xml = curl_exec($ch);
- $result_xml = str_replace(array(':','-'), '', $result_xml);
- @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
- **/
-
-
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/fedexhz.php';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- //设置post数据
- $post = array();
- $post['data'] = $xml;
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- $res = curl_exec($ch);
- curl_close($ch);
- $values = json_decode($res,true);
-
-
-
-
-
-
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
- {
- $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']);
- }
- else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
- {
- $a = '';
- if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
- {
- $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
- }
- else
- {
- foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
- {
- $a .= $v['LocalizedMessage'].'--';
- }
- }
- $g = array('x'=>'0','Description'=>$a);
- }
- else
- {
- $g = array('x'=>'0','Description'=>'未知错误');
- }
- echo "<pre>";
- print_r($g);
- }
-
- public function _text($fullorder)
- {
- /** 发票地址信息暂时无用
- $fullorder['baddress'] = explode(',',$fullorder['baddress']);
- $fullorder['baddress'] = array_reverse($fullorder['baddress']);
- $fullorder['baddress'][1] = $country['ename'];
- **/
- //获取所用相关信息
- $warehouse = $this->warehouse->read($fullorder['type']);
- $country = $this->country->read($fullorder['country']);//订单国家信息
- $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
- $warehouse['country'] = $fcountry['ename'];//仓库国家名
- $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
- $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
- $fullorder['lb'] = $country['lb'];//订单国家编码加入
- $fullorder['country'] = $country['ename'];//订单国家名
- $fullorder['zhou'] = $country['continent'];//所属州
- $express = $this->express->read($fullorder['express']);
- $fullorder['express'] = $express['servicename'];
- $fullorder['account'] = $express['account'];
- $fullorder['printcode'] = $express['printcode'];
- $fullorder['time'] = date('Y-m-d',time());
- $fullorder['times'] = date('Y-m-d H:i',time());
- $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
- $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
- $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';<br>',';<br>'),$fullorder['shipremarks']);
- $shop = $this->shop->read($fullorder['shop']);
- $fullorder['shop'] = $shop['shopname'];
- if(is_numeric($fullorder['pay']))
- {
- $pay = $this->typeclass->read($fullorder['pay']);
- if($pay['classid'] == '4')
- {
- $fullorder['pay'] = $pay['title'];
- }
- }
- if($fullorder['printcode'] != "USPS")
- {
- $fullorder['client'] = htmlspecialchars($fullorder['client']);
- $fullorder['name'] = htmlspecialchars($fullorder['name']);
- }
- //增加退货单所需信息
- $pt = '';
- $fpdata = explode(';',trim($fullorder['fpdata'],';'));
- foreach ($fpdata as $v)
- {
- $p = explode('|',trim($v,'|'));
- $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
- }
- $fullorder['pt'] = $pt;
- return $fullorder;
- }
-
- public function _dpex($arg_array)
- {
- $fullorder = $this->fullorder->get_number($arg_array[0]);
- if(!$fullorder)
- {
- $fullorder = $this->fullordersmt->get_number($arg_array[0]);
- }
- $fullorder = $this->_text($fullorder);
- /**
- $warehouse = $this->warehouse->read($fullorder['type']);
- $country = $this->country->read($fullorder['country']);//订单国家信息
- $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
- $warehouse['country'] = $fcountry['ename'];//仓库国家名
- $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
- $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
- $fullorder['lb'] = $country['lb'];//订单国家编码加入
- $fullorder['country'] = $country['ename'];//订单国家名
- $fullorder['zhou'] = $country['continent'];//所属州
- $express = $this->express->read($fullorder['express']);
- $fullorder['express'] = $express['servicename'];
- $fullorder['account'] = $express['account'];
- $fullorder['printcode'] = $express['printcode'];
- $fullorder['time'] = date('Y-m-d',time());
- $fullorder['times'] = date('Y-m-d H:i',time());
- $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
- $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
- $shop = $this->shop->read($fullorder['shop']);
- $fullorder['shop'] = $shop['shopname'];
- **/
- $fullorder['number'] = $fullorder['number'].'-1';//订单号重复修改新订单好
-
- $data = $fullorder;
- $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder";
- $Clientid = 'LYFZP';
- $Token = 'NGkJSDx3bAxojl1YN232';
- $code = array('DPEX'=>array('11','DPEX','1'),'ARAMEX'=>array('002','安迈世',0),'FEDEX'=>array('FEDEX_1CC','FEDEX_1CC',';lab10_10'),'UPS'=>array('04','UPS',0),'DHL'=>array('06','DHL',';lab10_10'),'FED-SN-IP'=>array('07','FED-SN-IP',';lab10_10'),'WML-FEDEX-ZZ'=>array('05','WML-FEDEX-ZZ',';lab10_10'),'FED-XS-F'=>array('03','FED-XS-F',';lab10_10'),'CNE'=>array('08','全球优先CNE','label10x10;0'),'TCNE'=>array('09','E速宝特惠','label10x10;0'));
- $printcode = $code[$data['printcode']];
- //创建并预报订单
- $count = array(
- 'Verify' => array(
- 'Clientid'=>$Clientid,
- 'Token'=>$Token
- ),
- 'OrderType' => '1',//1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。
- 'OrderDatas' => array(0=>array(
- 'CustomerNumber' => $data['number'],//订单号
- 'ChannelCode' => $printcode[0],//渠道代码
- 'CountryCode' => $data['lb'],//国家二字码
- 'TotalWeight' => $data['zzl'],//订单重量
- 'TotalValue' => $data['zsbjz'],//申报价值
- 'Number' => $data['zjs'],//件数
- 'Note' => $data['number'],//备注
- /**
- 'Insurance' => array(//是否购买保险
- 'Code' => '',//保险类型
- 'Value' => '',//保险金额
- ),
- **/
- 'FeePayData' => array(//运费支付信息
- 'FeePayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方]
- 'FeePayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
- 'FeePayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传
- 'FeePayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
- ),
- 'TaxPayData' => array(//税金/关税支付信息 OrderType 为 [快递制单] 时必传字段
- 'TaxPayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方]
- 'TaxPayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
- 'TaxPayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传
- 'TaxPayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
- ),
- 'Recipient' => array(//收件人信息
- 'Name' => $data['name'],//姓名
- 'Addres1' => $data['address'],//地址1
- 'Addres2' => $data['address2'],//地址2
- 'Mobile' => preg_replace('/\D/s','',$data['phone']),//手机
- 'Province' => $data['province'],//省/州
- 'City' => $data['city'],//城市
- 'Post' => trim($data['zipcode'],' '),//邮编
- ),
- 'OrderItems' => array(
- 0=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '化纤发',//产品中文名
- 'Enname' => 'synthetic hair*1',//产品英文名
- 'Price' => '10',//单价
- 'Weight' => '0.1',//重量
- 'Num' => 1,//数量
- 'CustomsCode'=>6704190000//海关编码
- ),
- 1=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '头饰',//产品中文名
- 'Enname' => 'hair accessories*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>9615110000//海关编码
- ),
- 2=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '小发刷',//产品中文名
- 'Enname' => 'Hairbrush*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>9603290090//海关编码
- ),
- 3=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '袋子',//产品中文名
- 'Enname' => 'Satin Bag*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>4202320000//海关编码
- ),
- 4=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '假睫毛',//产品中文名
- 'Enname' => 'Eyelashes*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>6704200000//海关编码
- ),
- /**
- 2=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '假睫毛',//产品中文名
- 'Enname' => 'Eyelashes*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>6704200000//海关编码
- ),
- 3=>array(//订单明细
- 'Money' => 'USD',//货币单位
- //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
- 'Cnname' => '袋子',//产品中文名
- 'Enname' => 'Satin Bag*1',//产品英文名
- 'Price' => '0.5',//单价
- 'Weight' => '0.1',//重量
- 'Num' => '1',//数量
- 'CustomsCode'=>4202320000//海关编码
- )
- **/
-
- ))
- )
- /**,
- 'Volumes' => array(//材积明细 (OrderType 为快递制单必传)
- 'Weight' => '123123',//实重
- 'Number' => '123123',//件数
- 'Length' => '123123',//长
- 'Width' => '123123',//宽
- 'Height' => '123123',//高
- ),
- **/
- );
- $count = json_encode($count,true);
-
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- if(!isset($res['returnDatas'][0]['corpBillid']))
- {
- $g = array('x'=>'0','Description'=>$res['returnDatas'][0]['message']);
- }
- else
- {
- $yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'],$printcode[2]);
- $fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'],$count);
- if($yd != 'c' && $fp != 'c')
- {
- $g = array('x'=>'1','waybillid'=>$res['returnDatas'][0]['corpBillid'],'waybill'=>$res['returnDatas'][0]['trackNumber'],'yd'=>'<a href="'.$yd.'" target="_blank">'.$yd.'</a>','fp'=>'<a href="'.$fp.'" target="_blank">'.$fp.'</a>');
- }
- else
- {
- $g = array('x'=>'0','Description'=>'换取运单失败,请重试');
- }
- }
- echo "<pre>";
- print_r($g);
- }
-
- public function get_dpex_yd($waybill,$PrintPaper)
- {
- $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel";
- $Clientid = 'LYFZP';
- $Token = 'NGkJSDx3bAxojl1YN232';
-
- $count = array(
- 'Verify' => array(
- 'Clientid'=>$Clientid,
- 'Token'=>$Token
- ),
- 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill)),
- 'OrderType'=> "1",//1:快件订单 2:快递制单 3:仓库订单
- 'PrintPaper'=> $PrintPaper,//打印纸张 快递制单只固定为:label 和 A4
- 'PrintContent'=> "1"//打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3
- );
-
- $count = json_encode($count,true);
-
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- if($res['statusCode'] == 'success')
- {
- return $res['url'];
- }
- else
- {
- return 'c';
- }
- }
-
- public function get_dpex_fp($waybill)
- {
- $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice";
- $Clientid = 'LYFZP';
- $Token = 'NGkJSDx3bAxojl1YN232';
-
- $count = array(
- 'Verify' => array(
- 'Clientid'=>$Clientid,
- 'Token'=>$Token
- ),
- 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill))
- );
-
- $count = json_encode($count,true);
-
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- if($res['statusCode'] == 'success')
- {
- return $res['url'];
- }
- else
- {
- return 'c';
- }
- }
-
-
- public function _feite($waybill)//飞特提取内容下载
- {
- $a = '{"data":{"items":[{"orderId":"F370142205310002","traceId":"1Z88F19Y0396934797","remark":"LY-Supernova-0531-FBA16QRN39JPU-4","importTime":"2022-05-31 15:57:25","sentTime":"2022-06-02 22:40:19","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205300001","traceId":"1Z287F0E6705824870","remark":"LY-AP-2022053009-FBA16QQ0TC4N","importTime":"2022-05-30 15:45:42","sentTime":"2022-05-31 19:10:01","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270006","traceId":"1Z88F19Y0303244340","remark":"LY-WK- 2022052701-FBA16QJXYP99","importTime":"2022-05-27 15:24:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270005","traceId":"1Z88F19Y0302468708","remark":"LY-SN-2022052701","importTime":"2022-05-27 15:23:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270001","traceId":"1Z88F19Y0301362654","remark":"LY-Wiggins-2022052705-FBA16QJHKJ5R","importTime":"2022-05-27 11:58:23","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205120001","traceId":"1Z88F19Y0312674270","remark":"LY-H-2022051203-FBA16PSVQ9YF","importTime":"2022-05-12 09:51:55","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220511000A","traceId":"1Z88F19Y0315997229","remark":"LY-Wiggins-2022051105-FBA16PRXMZ5L","importTime":"2022-05-11 15:01:31","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000M","traceId":"1Z88F19Y0399360286","remark":"LY-XCLY-20220510-024-FBA00001","importTime":"2022-05-10 14:55:18","sentTime":"2022-05-10 20:19:19","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000J","traceId":"1Z88F19Y0397487868","remark":"LY-WK-2022050703-","importTime":"2022-05-10 12:22:22","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000I","traceId":"1Z88F19Y0395774837","remark":"LY-Wiggins-2022050703-","importTime":"2022-05-10 12:22:23","sentTime":"2022-05-10 12:52:17","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000H","traceId":"1Z88F19Y0397543547","remark":"LY-AP-22050711-","importTime":"2022-05-10 12:22:19","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090002","traceId":"1Z88F19Y0397647720","remark":"LY-YMS-22050901-FBA16PNXD0GM","importTime":"2022-05-09 09:56:49","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090001","traceId":"1Z88F19Y0397194737","remark":"LY-AS-22050902-FBA16PNSGL89","importTime":"2022-05-09 08:39:18","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205080005","traceId":"1Z88F19Y0399894754","remark":"LY-YMS-22050805","importTime":"2022-05-08 12:19:57","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220427000I","traceId":"272474117028","remark":"SUPER-20426-004","importTime":"2022-04-27 16:01:08","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000H","traceId":"272474116466","remark":"QQS-20426-052","importTime":"2022-04-27 15:59:38","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000G","traceId":"272474117109","remark":"QQS-20426-001","importTime":"2022-04-27 15:59:34","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000F","traceId":"272474116352","remark":"QQS-20425-102","importTime":"2022-04-27 15:59:29","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220427000D","traceId":"272474117337","remark":"Y-20426-058","importTime":"2022-04-27 14:07:57","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F37014220427000B","traceId":"272474117017","remark":"KISS-20426-021","importTime":"2022-04-27 14:07:50","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"芬兰"},{"orderId":"F37014220427000A","traceId":"272474116341","remark":"ALIP-20423-217","importTime":"2022-04-27 14:07:36","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204270009","traceId":"272474117532","remark":"Y-20427-011","importTime":"2022-04-27 14:03:31","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"葡萄牙"},{"orderId":"F370142204270008","traceId":"272474116569","remark":"AAP-20426-030","importTime":"2022-04-27 14:03:20","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204270004","traceId":"272467942761","remark":"ALIP-20425-072","importTime":"2022-04-27 11:10:19","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270003","traceId":"272467945153","remark":"ALIP-20426-015","importTime":"2022-04-27 10:13:06","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204270002","traceId":"272467947649","remark":"KISS-20425-019","importTime":"2022-04-27 10:13:03","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270001","traceId":"272467946860","remark":"AAP-20425-002","importTime":"2022-04-27 10:12:51","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260009","traceId":"272419119163","remark":"KISS-20423-033","importTime":"2022-04-26 14:17:33","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260008","traceId":"272419119185","remark":"Y-20426-006","importTime":"2022-04-26 13:12:56","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260007","traceId":"272419119060","remark":"ALIP-20425-067","importTime":"2022-04-26 13:12:48","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260006","traceId":"272419118970","remark":"KISS-20425-023","importTime":"2022-04-26 13:12:39","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260005","traceId":"272467947351","remark":"ALIP-20424-090","importTime":"2022-04-26 13:12:30","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"丹麦"},{"orderId":"F370142204260004","traceId":"272419118671","remark":"ALIP-20424-074","importTime":"2022-04-26 13:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F370142204260003","traceId":"272419119233","remark":"ALIP-20423-157","importTime":"2022-04-26 13:12:13","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260002","traceId":"272419118248","remark":"AAP-20425-016","importTime":"2022-04-26 13:12:05","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260001","traceId":"272419118947","remark":"AAP-20425-023","importTime":"2022-04-26 10:59:31","sentTime":"2022-04-26 23:54:20","iossNumber":"FR76880693544","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000H","traceId":"272362120808","remark":"KISS-20423-063","importTime":"2022-04-25 14:12:43","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000G","traceId":"272362120896","remark":"ALIP-20423-111","importTime":"2022-04-25 14:12:39","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000F","traceId":"272362120234","remark":"KISS-20422-051","importTime":"2022-04-25 14:12:34","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000E","traceId":"272362120040","remark":"KISS-20417-041","importTime":"2022-04-25 14:12:27","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F37014220425000D","traceId":"272362119918","remark":"AAP-20424-006","importTime":"2022-04-25 14:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000C","traceId":"272362121285","remark":"Y-20423-049","importTime":"2022-04-25 11:54:54","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000B","traceId":"272362120223","remark":"ALIP-20419-117","importTime":"2022-04-25 11:48:14","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000A","traceId":"272362119540","remark":"ALIP-20422-137","importTime":"2022-04-25 11:42:36","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250009","traceId":"272362119653","remark":"ALIP-20423-100","importTime":"2022-04-25 11:42:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250008","traceId":"272362120061","remark":"ALIP-20422-191","importTime":"2022-04-25 11:42:20","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250006","traceId":"272362120495","remark":"AAP-20424-016","importTime":"2022-04-25 11:19:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250005","traceId":"272362119355","remark":"AAP-20424-025","importTime":"2022-04-25 11:02:10","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204250004","traceId":"272362120407","remark":"AAP-20423-017","importTime":"2022-04-25 10:55:58","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204250003","traceId":"272362120392","remark":"AAP-20423-006","importTime":"2022-04-25 10:55:42","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250002","traceId":"272362121171","remark":"Y-20423-003","importTime":"2022-04-25 09:21:30","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":51,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}';
- //发货页面当前页数量拉满
- //格式:{"data":{"items":[{"orderId":"F37014220102000D","traceId":"288335360044","remark":"ALIP-11230-109","importTime":"2022-01-02 13:48:27","sentTime":"2022-01-05 07:57:00","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":563,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}
- $a = json_decode($a,true);$b = array();
- foreach ($a['data']['items'] as $v)
- {
- //if($v['iossNumber'] == 'IM3800007691')
- //{
- $b[] = $v;
- //}
- }
- $title = "飞特";
- $titlename = "<table border=1>
- <tr>
- <td>订单号</td>
- <td>跟踪号</td>
- <td>编号</td>
- <td>导入时间</td>
- <td>发货时间</td>
- <td>IOSS</td>
- <td>快递方式</td>
- <td>国家</td>
- </table>";
- $filename = $title.".xls";
- $tail = "\n";
- $this->excel->get_fz2($b,$titlename,$filename,$tail);
- }
- public function _rl($arg_array)
- {
- $t = (1646064000-1635696000)/(24*3600);
- $list = array();
- for($i=0;$i<$t;$i++)
- {
- $time = ($i>0)?1635696000+($i*24*3600):1646064000;
- $time = date('Ymd',$time);
- $d = $this->fullorder->find_all("returndata like '%$time%'",'number,returndata,js,zzl');
- foreach ($d as $v)
- {
- $list[] = $v;
- }
- $s = $this->fullordersmt->find_all("returndata like '%$time%'",'number,returndata,js,zzl');
- foreach ($s as $v)
- {
- $list[] = $v;
- }
- }
- $data = array();
- foreach ($list as $k=>$v)
- {
- $js = ($v['js'] == '0')?'FIRST CLASS':'PRIORITY';
- $return = explode('/t-',$v['returndata']);
- $time = explode('/pdf/',$return[0]);
- $time = strtotime($time[1]);
- $return = explode('.pdf"',$return[1]);
- $data[] = array($v['number'],$return[0],$js,$v['zzl'],date('Y-m-d',$time));
- }
- $title = 'return';
- $titlename = "<table border=1>
- <tr>
- <td>编号</td>
- <td>return label 运单号</td>
- <td>服务类型</td>
- <td>重量</td>
- <td>return label 时间</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "\n";
- $this->excel->get_fz2($data,$titlename,$filename,$tail);
- echo "<pre>";
- print_r($data);
- }
-
- public function _cz($arg_array)
- {
- $f = 'fullorder';
- $d = $this->fullorder->get_number($arg_array[0]);
- if(!$d)
- {
- $f = 'fullordersmt';
- $d = $this->fullordersmt->get_number($arg_array[0]);
- if(!$d)
- {
- $f = 'fullordertt';
- $d = $this->fullordertt->get_number($arg_array[0]);
- }
- }
- if(!$d)
- {
- echo '找不到此编号';exit;
- }
- $cz = 'reset';
- $c = $this->$cz->find_all("number = '".$arg_array[0]."'",'*','id desc');
- if(!$c)
- {
- echo '找不到此编号';exit;
- }
- $c = $c[0];
- if($c['printtime'] != '无' && $c['librarytime'] != '无')
- {
- $this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'librarytime'=>strtotime($c['librarytime']),'library'=>2,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
- }
- else if($c['printtime'] != '无' && $c['librarytime'] == '无')
- {
- $this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
- }
- else if($c['printtime'] == '无' && $c['librarytime'] == '无' && $c['reviewtime'] != '无')
- {
- $this->$f->save(array('reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
- }
- else
- {
- echo '没有可恢复的状态';exit;
- }
- }
-
- public function _paypal($arg_array)//paypal用 返回头部数据
- {
- $f = $this->fullorder->get_number($arg_array[0]);
- $s = $this->shop->read($f['shop']);
- $client_id = $s['paypalname'];
- $secret_id = $s['paypalpass'];
-
- $url = 'https://api-m.paypal.com/v1/reporting/transactions?start_date='.date('Y-m-d',time()-26*24*3600).'T00:00:00-0700&end_date='.date('Y-m-d',time()+24*3600).'T23:59:59-0700&transaction_id='.$f['paypal'].'&fields=all&page_size=100&page=1';
- $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU');
- $ToState = array_flip($ToState);
- $header[] = "Content-Type: application/json";
- $header[] = "Authorization: Basic ".base64_encode($client_id.":".$secret_id);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPGET, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //TRUE 将curl_exec()获取的信息以字符串返回,而不是直接输出。
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_HEADER, true); //返回response头部信息
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- $result = curl_exec($ch);
- curl_getinfo($ch, CURLINFO_HEADER_OUT);
- curl_close($ch);
- echo "<pre>";
- echo $result;exit;
- }
-
- public function _yd($arg_array)
- {
- $fullorder = $this->fullorder->get_number($arg_array[0]);
- if(!$fullorder)
- {
- $fullorder = $this->fullordersmt->get_number($arg_array[0]);
- }
- if(!$fullorder)
- {
- echo "编号错误";exit;
- }
- /** 发票地址信息暂时无用
- $fullorder['baddress'] = explode(',',$fullorder['baddress']);
- $fullorder['baddress'] = array_reverse($fullorder['baddress']);
- $fullorder['baddress'][1] = $country['ename'];
- **/
- //获取所用相关信息
- $warehouse = $this->warehouse->read($fullorder['type']);
- $country = $this->country->read($fullorder['country']);//订单国家信息
- $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
- $warehouse['country'] = $fcountry['ename'];//仓库国家名
- $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
- $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
- $fullorder['lb'] = $country['lb'];//订单国家编码加入
- $fullorder['country'] = $country['ename'];//订单国家名
- $fullorder['zhou'] = $country['continent'];//所属州
- $express = $this->express->read($fullorder['express']);
- $fullorder['express'] = $express['servicename'];
- $fullorder['account'] = $express['account'];
- $fullorder['printcode'] = $express['printcode'];
- $fullorder['time'] = date('Y-m-d',time());
- $fullorder['times'] = date('Y-m-d H:i',time());
- $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
- $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
- $fullorder['shipremarks'] = str_replace(array('<','>'),array('<','>'),$fullorder['shipremarks']);
- $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';<br>',';<br>'),$fullorder['shipremarks']);
- $shop = $this->shop->read($fullorder['shop']);
- $fullorder['shop'] = $shop['shopname'];
- $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
- $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
- if(is_numeric($fullorder['pay']))
- {
- $pay = $this->typeclass->read($fullorder['pay']);
- if($pay['classid'] == '4')
- {
- $fullorder['pay'] = $pay['title'];
- }
- }
- if($fullorder['printcode'] != "USPS")
- {
- $fullorder['client'] = htmlspecialchars($fullorder['client']);
- $fullorder['name'] = htmlspecialchars($fullorder['name']);
- }
- //增加退货单所需信息
- $pt = '';
- $fpdata = explode(';',trim($fullorder['fpdata'],';'));
- foreach ($fpdata as $v)
- {
- $p = explode('|',trim($v,'|'));
- $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
- }
- $fullorder['pt'] = $pt;
- //$fullorder['printcode'] = 'HUALEIXW-FEDEX';
- //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- //$fullorder['sbbm']= 4202320000;//($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- //$fullorder['sbpm']= 'eyelashes';
- //$fullorder['zwpm']= '假睫毛';
- //$fullorder['sbpm']= 'Satin Bag';
- //$fullorder['zwpm']= '袋子';
- //$fullorder['hgbm']= 4202320000;
- //$fullorder['address'] = '1653 Treutlan Place';
- //$fullorder['address2'] = '';
- //$fullorder['qm'] = 2;
- //$notice = $this->notice->read(6);
- //$fcountry['warehouse']['name'] = 'Hair Me Please LLC';
- //$fullorder['cxcode'] = strtolower($express['cxcode']);
- //$barcode = $this->fedex->get_logistics($fullorder);//获取联邦快递信息
- //echo $fullorder['name'];
- //$b = $this->ups->get_data($fullorder);
- $barcode = $this->get_data($fullorder);
- //$b = $this->usps->get_logistics($fullorder);
-
- echo "<pre>";
- print_r($barcode);
- //echo "<pre>";
-
- //echo $barcode['Postage'];
-
-
-
- //$b = $this->_pdf($barcode['yd'],$barcode['waybill'],time());
-
- //header("Content-type: text/xml");
-
- //echo $barcode;
-
- //echo $Hyd;
- //echo "<pre>";
- //print_r($barcode);
- //print_r($barcode);
- /**
- $time = '1586232000';
- $bctime = date('Ymd',$time);
- $Hwaybill = $barcode['waybill'];
- $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
- $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);
- //header("Content-type:text/xml");
- echo 'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
- //echo "<pre>";
- //print_r($barcode);
- //$a = $this->whlabel->find_all(array('zd'=>'ASTE-00212-025'));//专属
- **/
- }
-
- public function get_data($data)
- {
- if($data['pay'] == 1)
- {
- $data['pay'] == 'PayPal';
- }
- else if($data['pay'] == 2)
- {
- $data['pay'] == 'Western Union';
- }
- else if($data['pay'] == 3)
- {
- $data['pay'] == '微信';
- }
- else if($data['pay'] == 4)
- {
- $data['pay'] == '支付宝';
- }
- else if($data['pay'] == 5)
- {
- $data['pay'] == '银行转账';
- }
- else if($data['pay'] == 6)
- {
- $data['pay'] == '现金收款';
- }
- else if($data['pay'] == 7)
- {
- $data['pay'] == 'PingPong金融';
- }
- $id = 'XUCHANGLONGY';
- $pass = 'dJ84as3ELr';
- //$sid = '603521441';//官方DHL
- $sid = '605062090';//官方DHL美国
- $xmend = "\n";
- $Pieces = '';
- for($i=0;$i<$data['zjs'];$i++)
- {
- $Pieces .= "<Piece>".$xmend;
- $Pieces .= "<PieceID>".($i+1)."</PieceID>".$xmend;
- $Pieces .= "<PackageType>EE</PackageType>".$xmend;
- $Pieces .= "<Weight>".$data['zzl']."</Weight>".$xmend;
- $Pieces .= "<Width>15</Width>".$xmend;
- $Pieces .= "<Height>3</Height>".$xmend;
- $Pieces .= "<Depth>5</Depth>".$xmend;
- $Pieces .= "</Piece>".$xmend;
- }
- /** 此内容是添加发票信息
- $dataadress = array();$baddress = '';$ba1 = '';$ba2 = '';
- for($i=5;$i<count($data['baddress']);$i++)
- {
- $dataadress[] = $data['baddress'][$i];
- }
-
- if(count($dataadress) > 1)
- {
- for($i=0;$i<count($dataadress);$i++)
- {
- if($i < 2)
- {
- $ba1 .= $dataadress[$i].',';
- }
- else
- {
- $ba2 .= $dataadress[$i].',';
- }
- }
- $baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;
- $baddress .= "<BillToAddressLine>".rtrim($ba2,',')."</BillToAddressLine>".$xmend;
- }
- else
- {
- for($i=0;$i<count($dataadress);$i++)
- {
- $ba1 .= $dataadress[$i].',';
- }
- $baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;
- }
- **/
- $hgbm = $data['sbbm'];
- if(isset($data['hgbm']))
- {
- if($data['hgbm'] != '')
- {
- $hgbm = $data['hgbm'];
- }
- }
- $xml = "";
- $xml .= "<?xml version='1.0' encoding='UTF-8'?>".$xmend;
- $xml .= "<req:ShipmentRequest xsi:schemaLocation='http://www.dhl.com ship-val-global-req.xsd' schemaVersion='10.0' xmlns:req='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>".$xmend;
- $xml .= "<Request>".$xmend;
- $xml .= "<ServiceHeader>".$xmend;
- $xml .= "<MessageTime>".date('c')."</MessageTime>".$xmend;
- //$rand = (strlen($data['orderinfo']) < 15)?rand(10000000,99999999):rand(100000,999999);
- //$xml .= "<MessageReference>".time().$data['orderinfo'].$rand."</MessageReference>".$xmend;
- $xml .= "<MessageReference>".time().time().rand(10000000,99999999)."</MessageReference>".$xmend;
- $xml .= "<SiteID>".$id."</SiteID>".$xmend;//DHL账号
- $xml .= "<Password>".$pass."</Password>".$xmend;//DHL密码
- $xml .= "</ServiceHeader>".$xmend;
- $xml .= "<MetaData>".$xmend;
- $xml .= "<SoftwareName>LongYi ERP</SoftwareName>".$xmend;
- $xml .= "<SoftwareVersion>V1.0.0</SoftwareVersion>".$xmend;
- $xml .= "</MetaData>".$xmend;
- $xml .= "</Request>".$xmend;
- $xml .= "<RegionCode>AP</RegionCode>".$xmend;//地区代码
- $xml .= "<LanguageCode>en</LanguageCode>".$xmend;//语言
- ///$xml .= "<PiecesEnabled>Y</PiecesEnabled>".$xmend;
- $xml .= "<Billing>".$xmend;
- $xml .= "<ShipperAccountNumber>".$sid."</ShipperAccountNumber>".$xmend;
- $xml .= "<ShippingPaymentType>S</ShippingPaymentType>".$xmend;
- $xml .= "<BillingAccountNumber>".$sid."</BillingAccountNumber>".$xmend;
- ///$xml .= "<DutyPaymentType>R</DutyPaymentType>".$xmend;//R为收件人付关税 S发件人付关税
- $xml .= "</Billing>".$xmend;
- $xml .= "<Consignee>".$xmend;
- $xml .= "<CompanyName>".$data['name']."</CompanyName>".$xmend;//收货人名称
- /**
- if(strlen($data['address'].$data['address2']) > 44)
- {
- $adl = $data['address'].$data['address2'];
- $adl1 = substr($adl,0,44);//截取44字符前内容
- $adlnum = strripos($adl1," ");//查找最后一次出现空格位置
- $adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
- $adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
- $xml .= "<AddressLine1>".$adl1."</AddressLine1>".$xmend;//收货人地址1
- $xml .= "<AddressLine2>".$adl2."</AddressLine2>".$xmend;//收货人地址2
- }
- **/
- if($data['address2'])
- {
- //$adl = $data['address'].$data['address2'];
- //$adl1 = substr($adl,0,44);//截取44字符前内容
- //$adlnum = strripos($adl1," ");//查找最后一次出现空格位置
- //$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
- //$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
- $xml .= "<AddressLine1>".$data['address']."</AddressLine1>".$xmend;//收货人地址1
- $xml .= "<AddressLine2>".$data['address2']."</AddressLine2>".$xmend;//收货人地址2
- }
- else
- {
- $xml .= "<AddressLine1>".$data['address'].$data['address2']."</AddressLine1>".$xmend;//收货人地址
- }
- if($data['street'] != '')
- {
- $xml .= "<AddressLine>".$data['street']."</AddressLine>".$xmend;//收货人街道
- }
- $xml .= "<City>".$data['city']."</City>".$xmend;//城市
- if($data['lb'] == 'US')
- {
- $xml .= "<DivisionCode>".$data['province']."</DivisionCode>".$xmend;//州代码,仅美国
- }
- $xml .= "<PostalCode>".trim($data['zipcode'],' ')."</PostalCode>".$xmend;//邮编
- $xml .= "<CountryCode>".$data['lb']."</CountryCode>".$xmend;//国家代码
- $xml .= "<CountryName>".$data['country']."</CountryName>".$xmend;//国家名称
- $xml .= "<Contact>".$xmend;
- $xml .= "<PersonName>".$data['client']."</PersonName>".$xmend;//名称
- $xml .= "<PhoneNumber>".preg_replace('/\D/s','',$data['phone'])."</PhoneNumber>".$xmend;//联系方式
- //$xml .= "<Email>".$data['email']."</Email>".$xmend;//联系邮箱
- $xml .= "</Contact>".$xmend;
- $xml .= "</Consignee>".$xmend;
- $xml .= "<Commodity>".$xmend;//多商品循环此外层标签及内层标签
- $xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//商品编码
- $xml .= "<CommodityName>".$data['sbpm']."</CommodityName>".$xmend;//商品名称
- $xml .= "</Commodity>".$xmend;
- $xml .= "<Dutiable>".$xmend;
- $xml .= "<DeclaredValue>".$data['zsbjz']."</DeclaredValue>".$xmend;//申报价值
- $xml .= "<DeclaredCurrency>".$data['currencytitle']."</DeclaredCurrency>".$xmend;//货币代码
- $xml .= "<TermsOfTrade>DAP</TermsOfTrade>".$xmend;//贸易条款
- $xml .= "</Dutiable>".$xmend;
- /** 发票信息开始 **/
- $xml .= "<UseDHLInvoice>Y</UseDHLInvoice>".$xmend;
- $xml .= "<DHLInvoiceLanguageCode>en</DHLInvoiceLanguageCode>".$xmend;
- $xml .= "<DHLInvoiceType>CMI</DHLInvoiceType>".$xmend;
- $xml .= "<ExportDeclaration>".$xmend;
- $xml .= "<ExportReasonCode>P</ExportReasonCode>".$xmend;
- if(strlen($data['paypal']) > 30)
- {
- $xml .= "<InvoiceNumber>".str_replace(array('-'),array(''),$data['paypal'])."</InvoiceNumber>".$xmend;
- }
- else
- {
- $xml .= "<InvoiceNumber>".$data['paypal'].' '.$data['pay']."</InvoiceNumber>".$xmend;
- }
- $xml .= "<InvoiceDate>".date('Y-m-d',time())."</InvoiceDate>".$xmend;
- /**
- $xml .= "<BillToContactName>".$data['client']."</BillToContactName>".$xmend;
- $xml .= "<BillToContanctName>".$data['client']."</BillToContanctName>".$xmend;//账单名称
- $xml .= "<BillToAddressLine1><BillToAddressLine1>";//地址1
- $xml .= "<BillToAddressLine2><BillToAddressLine2>";//地址2
- $xml .= "<BillToCity>".$data['baddress'][4]."</BillToCity>".$xmend;//城市
- $xml .= "<BillToPostcode>".$data['baddress'][2]."</BillToPostcode>".$xmend;//邮编
- $xml .= "<BillToSuburb/>".$xmend;//所在郊区
- if($data['baddress'][1] == 'United States')
- {
- $xml .= "<BillToState>".$data['baddress'][3]."</BillToState>".$xmend;//省、州
- }
- $xml .= "<BillToCountryName>".$data['baddress'][1]."</BillToCountryName>".$xmend;//国家
- $xml .= "<BillToPhoneNumber>".preg_replace('/\D/s','',$data['baddress'][0])."</BillToPhoneNumber>".$xmend;//号码
- **/
- $xml .= "<ExportLineItem>".$xmend;
- $xml .= "<LineNumber>1</LineNumber>".$xmend;//顺序号
- $xml .= "<Quantity>".$data['ts']."</Quantity>".$xmend;//数量
- $xml .= "<QuantityUnit>PCS</QuantityUnit>".$xmend;//单位
- $xml .= "<Description>".$data['sbpm']."</Description>".$xmend;//品名
- $xml .= "<Value>".$data['dtsbjz']."</Value>".$xmend;//单价
- $xml .= "<IsDomestic>Y</IsDomestic>".$xmend;//是否国产,Y本国,N国外
- $xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//品名编码
- $xml .= "<Weight>".$xmend;
- $xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//净重
- $xml .= "<WeightUnit>K</WeightUnit>".$xmend;//重量单位,K千克
- $xml .= "</Weight>".$xmend;
- $xml .= "<GrossWeight>".$xmend;
- $xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//毛重
- $xml .= "<WeightUnit>K</WeightUnit>".$xmend;//毛重单位,K千克
- $xml .= "</GrossWeight>".$xmend;
- $xml .= "<ManufactureCountryCode>CN</ManufactureCountryCode>".$xmend;//原产国国家代码
- $xml .= "<ManufactureCountryName>CHINA</ManufactureCountryName>".$xmend;//原产国名称
- $xml .= "</ExportLineItem>".$xmend;
- $xml .= "<PlaceOfIncoterm>PEK PORT</PlaceOfIncoterm>".$xmend;//适用港口
- $xml .= "</ExportDeclaration>".$xmend;
- /** 发票信息结束 **/
- $xml .= "<Reference>".$xmend;
- $xml .= "<ReferenceID>".$data['number']."</ReferenceID>".$xmend;
- $xml .= "</Reference>".$xmend;
- $xml .= "<ShipmentDetails>".$xmend;
- ///$xml .= "<NumberOfPieces>".$data['zjs']."</NumberOfPieces>".$xmend;
- $xml .= "<Pieces>".$xmend;
- $xml .= $Pieces;
- $xml .= "</Pieces>".$xmend;
- ///$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;
- $xml .= "<WeightUnit>K</WeightUnit>".$xmend;
- $xml .= "<GlobalProductCode>P</GlobalProductCode>".$xmend;
- $xml .= "<LocalProductCode>P</LocalProductCode>".$xmend;
- $xml .= "<Date>".date('Y-m-d',time())."</Date>".$xmend;
- $xml .= "<Contents>".$data['sbpm']."</Contents>".$xmend;//内容
- ///$xml .= "<DoorTo>DD</DoorTo>".$xmend;
- $xml .= "<DimensionUnit>C</DimensionUnit>".$xmend;
- ///$xml .= "<InsuredAmount>".$data['bx']."</InsuredAmount>".$xmend;//保险金额
- $xml .= "<PackageType>EE</PackageType>".$xmend;
- $xml .= "<IsDutiable>Y</IsDutiable>".$xmend;
- $xml .= "<CurrencyCode>".$data['currencytitle']."</CurrencyCode>".$xmend;//货币代码
- $xml .= "</ShipmentDetails>".$xmend;
- $xml .= "<Shipper>".$xmend;
- $xml .= "<ShipperID>".$sid."</ShipperID>".$xmend;
- $xml .= "<CompanyName>LongYing</CompanyName>".$xmend;//发货公司名称
- $xml .= "<AddressLine1>LongYingShiYe, Yinghao Rd.</AddressLine1>".$xmend;//发货地址
- $xml .= "<AddressLine2>Shangji Economic Development Zone</AddressLine2>".$xmend;//发货地址
- $xml .= "<City>".$data['warehouse']['city']."</City>".$xmend;//发货城市
- $xml .= "<PostalCode>".$data['warehouse']['zipcode']."</PostalCode>".$xmend;
- $xml .= "<CountryCode>CN</CountryCode>".$xmend;//发货国家代码
- $xml .= "<CountryName>CHINA</CountryName>".$xmend;//发货国家名称
- $xml .= "<Contact>".$xmend;
- $xml .= '<PersonName>GeMengTi</PersonName>'.$xmend;//发货人 '.$data['warehouse']['company'].'
- $xml .= '<PhoneNumber>15939964739</PhoneNumber>'.$xmend;
- $xml .= "</Contact>".$xmend;
-
- $xml .= "<RegistrationNumbers>".$xmend;
- $xml .= "<RegistrationNumber>".$xmend;
- $xml .= '<Number>91411002MA3X46XC9K</Number>'.$xmend;
- $xml .= '<NumberTypeCode>VAT</NumberTypeCode>'.$xmend;
- $xml .= '<NumberIssuerCountryCode>CN</NumberIssuerCountryCode>'.$xmend;
- $xml .= "</RegistrationNumber>".$xmend;
- $xml .= "</RegistrationNumbers>".$xmend;
-
- $xml .= "</Shipper>".$xmend;
- /** 无纸化 PLT 开始 **/
- $xml .= "<SpecialService>".$xmend;
- $xml .= "<SpecialServiceType>WY</SpecialServiceType>".$xmend;
- $xml .= "</SpecialService>".$xmend;
- /** 无纸化 PLT 结束 **/
- if($data['bx'] > 0)
- {
- $xml .= "<SpecialService>".$xmend;
- $xml .= "<SpecialServiceType>II</SpecialServiceType>".$xmend;
- $xml .= "<ChargeValue>".$data['bx']."</ChargeValue>".$xmend;
- $xml .= "<CurrencyCode>USD</CurrencyCode>".$xmend;
- $xml .= "</SpecialService>".$xmend;
- }
- $xml .= "<LabelImageFormat>PDF</LabelImageFormat>".$xmend;
- /** 无纸化 PLT 启用这个 **/
- $xml .= "<RequestArchiveDoc>N</RequestArchiveDoc>".$xmend;
- /** 无纸化 PLT 启用这个 **/
- /** 无纸化 PLT 关闭这个 **/
- //$xml .= "<RequestArchiveDoc>Y</RequestArchiveDoc>".$xmend;
- //$xml .= "<NumberOfArchiveDoc>1</NumberOfArchiveDoc>".$xmend;
- /** 无纸化 PLT 关闭这个 **/
- $xml .= "<Label>".$xmend;
- $xml .= "<HideAccount>N</HideAccount>".$xmend;
- $xml .= "<LabelTemplate>8X4_PDF</LabelTemplate>".$xmend;
- $xml .= "<CustomsInvoiceTemplate>COMMERCIAL_INVOICE_P_10</CustomsInvoiceTemplate>".$xmend;
- $xml .= "<Resolution>200</Resolution>".$xmend;
- $xml .= "</Label>".$xmend;
- $xml .= "</req:ShipmentRequest>".$xmend;
- echo "<pre>";
- echo $xml;
- exit;
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,'https://xml-api.dhl.com/XMLShippingServlet');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);
- $data = curl_exec($ch);
- curl_close($ch);
- $data = utf8_encode($data);
- libxml_disable_entity_loader(true);
- @$values = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
- }
-
-
- public function _xx()
- {
- $shop = $this->shop->read(57);
- if($shop['apitoken_time'] > time())
- {
- $token = $shop['apitoken'];
- }
- else
- {
- $res = $this->shop->hq_token($shop);
- $token = $res;
- }
- $data = '?';
- //$data .= '&searchCriteria[filterGroups][0][filters][0][conditionType]=ConditionType';//字段类型
- $data .= 'searchCriteria[sortOrders][0][field]=created_at';
- $data .= '&searchCriteria[sortOrders][0][direction]=DESC';
- $data .= '&searchCriteria[pageSize]=200';
- $data .= '&searchCriteria[currentPage]=1';
- $data .= '&searchCriteria[filterGroups][0][filters][0][field]=status';//字段名称
- $data .= '&searchCriteria[filterGroups][0][filters][0][value]=processing';//字段内容
- $url = 'https://pc.bilisar.com/rest/V1/orders'.$data;//订单
- $res = $this->su_curl('',$url,$header=array("Authorization: Bearer ".$token,"Content-Type: application/json"),$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
- $res = json_decode($res,true);
- foreach ($res['items'] as $read)
- {
- $productNames = '';//产品名称
- $sku = '';
- $parameters = '';
- $quantity = '';
- $orderid = '';
- $link = '';
- foreach ($read['items'] as $list)
- {
- $productNames .= $list['name'].',';
- $sku .= $list['sku'].',';
- $link .= $list['extension_attributes']['product_url'].',';
- if(isset($list['extension_attributes']['select_options']))
- {
- foreach ($list['extension_attributes']['select_options'] as $s)
- {
- $p = json_decode($s,true);
- $parameters .= $p['label'].':'.$p['value'].'---';
- }
- }
- $parameters = trim($parameters,'---').';';
- $quantity .= $list['qty_ordered'].';';
- $orderid = $list['order_id'];
- }
- $sku = str_replace(array('<','>'),array('<','>'),$sku);
- $bill_street = '';//街道地址
- foreach ($read['billing_address']['street'] as $s)
- {
- $bill_street .= $s.' ';
- }
- $ship_street = '';//街道地址
- foreach ($read['billing_address']['street'] as $s)
- {
- $ship_street .= $s.' ';
- }
- $ly = isset($read['extension_attributes']['osc_order_comment'])?addslashes($read['extension_attributes']['osc_order_comment']):'';//留言
- $thatDayOrder[] = array
- (
- 'orderid' => $orderid,
- 'order_id' => $read['increment_id'],
- 'insurance' => $read['extension_attributes']['amextrafee_base_fee_amount'],//运费险
- 'product_name' => trim($productNames,','),
- 'purchased_on' => $read['created_at'],
- 'name' => (isset($read['customer_firstname'])?$read['customer_firstname']:'').' '.(isset($read['customer_lastname'])?$read['customer_lastname']:''),
- 'bill_to_name' => $read['billing_address']['firstname'].' '.$read['billing_address']['lastname'],
- 'ship_to_name' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['firstname'].' '.$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['lastname'],
- 'billing_address' => trim($bill_street,' '). ',' .$read['billing_address']['city']. ',' .(isset($read['billing_address']['region'])?$read['billing_address']['region']. ',':'') .$read['billing_address']['postcode']. ',' .$read['billing_address']['country_id']. ',' .$read['billing_address']['telephone'],
- 'shipping_address' => trim($ship_street,' '). ',' . $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city']. ',' .(isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'].',':'').$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
- 'country' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id'],
- 'region' => isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region']:'',
- 'city' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city'],
- 'street' => $ship_street,
- 'telephone' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
- 'postcode' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode'],
- 'email' =>$read['billing_address']['email'],
- 'global_currency_code' => $read['global_currency_code'],
- 'base_grand_total' => $read['base_grand_total'],
- 'grand_total' => $read['order_currency_code'].$read['grand_total'],
- 'isstatus' => $read['status'],
- 'isparameter' => trim($parameters,';'),
- 'sku' => trim($sku,','),
- 'order_quantity' => trim($quantity,';'),
- 'order_comment' => $ly,
- 'paypal_num' => isset($read['payment']['last_trans_id'])?$read['payment']['last_trans_id']:'',
- 'pay' => $read['payment']['method'],
- 'paypal_protection_eligibility' => isset($read['payment']['additional_information']['9'])?$read['payment']['additional_information']['9']:'',
- 'shippingmethod'=> ($read['base_shipping_amount'] > 0 || $read['tax_amount'] > 0)?$read['shipping_description'].' '.$read['base_shipping_amount'].' Tax:'.$read['tax_amount'].';':$read['shipping_description'].' '.$read['base_shipping_amount'].' Tax:'.$read['tax_amount'],
- 'link'=>trim($link,','),
- 'author_id' => '',
- 'source_content_id' => '',
- );
- }
- echo "<pre>";
- print_r($thatDayOrder);
- exit;
- }
- public function _a()
- {
- $where = "dlz < '1' and state = '207' and (express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 7:00:0",strtotime("-20 day")))."' and librarytime < '".strtotime(date("Y-m-d 7:00:0",time()))."'";
- $fdata = $this->fullorder->find_count($where);
-
- echo "<pre>";
- echo $fdata;
- //print_r($fdata);
- exit;
-
-
-
-
-
-
- $sid = '';$sd = array();
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $sid .= " id = '$value' or";
- }
- $sid = " and (".rtrim($sid,'or').")";
- }
- $post = $this->input->post(NULL, TRUE);
- $api = $this->input->get('api',true);
- $dshop = $this->input->get('dshop',true);
- //@$gethl = $this->hl->get_hl();//获取即时汇率
- $gethl = array();
- /* 订单号加入键值-k */
- /**
- $dataorder = array();
- $fdata = $this->fullorder->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
- foreach ($fdata as $v)
- {
- $dataorder[$v['orderinfo']] = "";//获取到单号
- }
- **/
- /* 订单号加入键值-j */
- /* 匹配加入 */
- $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
- // and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
- $dtc = array();
- foreach ($dictionaries as $v)
- {
- if(stripos($v['spare'],'|') !== false)//如果有多个值
- {
- $v['spare'] = explode('|',$v['spare']);
- foreach ($v['spare'] as $k=>$vs)
- {
- if(stripos($v['zh'],'|') !== false)
- {
- $vzh = explode('|',$v['zh']);
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
- }
- else
- {
- $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
- }
- }
- }
- else
- {
- $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
- }
-
- }
- $dictionaries2 = $this->typeclass->find_all();
- foreach ($dictionaries2 as $v)
- {
- $dtctitle[$v['id']] = $v['title'];
- }
- /* 匹配结束 */
- /* 价格加入 */
- /**
- $money = array();
- $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
- foreach ($productdescribe as $v)
- {
- $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
- }
- **/
- /* 价格加入 */
- /* 匹配ID加入 */
- $int = array();
- $intdata = $this->typeclass->find_all('classid=14','id,spare');
- foreach ($intdata as $v)
- {
- $v['spare'] = explode('|',$v['spare']);
- $int[$v['id']] = $v['spare'][0];
- }
- /* 匹配ID结束 */
- /* 国家加入键值-k */
- $cuy = array();
- $cuydata = $this->country->find_all('1=1','lb,id');
- foreach ($cuydata as $v)
- {
- $cuy[$v['lb']] = $v['id'];//获取到国家ID
- }
- /* 国家加入键值-j */
- /* 币种加入键值-k */
- $typeclass = array();
- $tdata = $this->typeclass->find_all('classid=30','id,title');
- foreach ($tdata as $v)
- {
- $typeclass[$v['title']] = $v['id'];
- }
- /* 币种加入键值-j */
- /* 支付方式-k */
- $pay = array();
- $tdata = $this->typeclass->find_all('classid=4','id,spare');
- foreach ($tdata as $v)
- {
- $paytype = $this->pay->get_typeclass($v['id']);
- if(isset($paytype['estimaterate']))
- {
- $estimaterate = $paytype['estimaterate'];
- }
- else
- {
- $estimaterate = 0;
- }
- if(stripos($v['spare'],'|') !== false)//如果有多个值
- {
- $v['spare'] = explode('|',$v['spare']);
- foreach ($v['spare'] as $k=>$vs)
- {
- $pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
- }
- }
- else
- {
- $pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
- }
- }
- $pay['stripeios'] = $pay['stripe_payments'];
- /* 支付方式-j */
- /* 新增SKU-k */
- $zjsku = array();
- $shopsku = $this->shopsku->find_all();
- foreach ($shopsku as $val)
- {
- $ss = explode(',',trim($val['shop'],','));
- foreach ($ss as $v)
- {
- if(isset($zjsku[$v]))
- {
- $zjsku[$v] .= ','.trim($val['sku'],',');
- }
- else
- {
- $zjsku[$v] = trim($val['sku'],',');
- }
- }
- }
- /* 新增SKU-j */
- $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
- $value = $this->shop->read(57);
- $setting = $this->setting->get_settings();
- $this->db->trans_begin();
- $res = $this->_xx($value['brandname'],$value['shopadmin'],$value);
- $sd[] = $res;
- $sjc = $setting['sctime'];//时间差 之前是3600 现在为0
- if($res)
- {
- foreach ($res as $v)
- {
- if($value['token'] == 'SU')
- {
- $time = $v['purchased_on']-7*3600-$sjc;//之前是+$sjc
- }
- else if($value['program'] == 'Shopify')
- {
- $time = $v['purchased_on'];
- }
- else
- {
- if($value['id'] == 1)
- {
- $time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
- }
- else
- {
- $time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
- }
- }
- $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
- $order_id = $value['id'].$v['order_id'];
- $tc = isset($typeclass[$v['global_currency_code']])?$typeclass[$v['global_currency_code']]:0;
- $dataorder = $this->fullorder->get_orderinfo($order_id);
- $hmdid = '';
- if($value['program'] == 'Shopify' && isset($dataorder['id']))
- {
- if($v['order_comment'] != $dataorder['clientremarks'])
- {
- $this->fullorder->save(array('clientremarks'=>$v['order_comment']),$dataorder['id']);
- }
- }
- if(!isset($dataorder['id']))
- //现在为所有订单都获取。!$ord && strcasecmp($v['isstatus'],'processing') == 0如果没有此订单并且订单状态为等待发货则继续
- {
- if(!isset($cuy[$v['country']]))
- {
- $cuy[$v['country']] = 1004;
- }
- $post = $this->api->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
- $kn = explode('-',$post['paypal']);
- if($post['pay'] == 23 && $value['klarnaname'] != '' && $value['klarnapass'] != '')
- {
- $klarna = $this->_klarnadata($post['paypal'],$value['klarnaname'],$value['klarnapass']);
- if($klarna != '')
- {
- $post['klarnadata'] = $klarna;
- }
-
- }
- if($post['pay'] == 26 && $value['afterpayname'] != '' && $value['afterpaypass'] != '')
- {
- $afterpay = $this->_afterpay($post['paypal'],$value['afterpayname'],$value['afterpaypass']);
- if($afterpay != '')
- {
- $post['klarnadata'] = $afterpay;
- }
-
- }
- if($post['pay'] == 27 && $value['clearpayname'] != '' && $value['clearpaypass'] != '')
- {
- $clearpay = $this->_clearpay($post['paypal'],$value['clearpayname'],$value['clearpaypass']);
- if($clearpay != '')
- {
- $post['klarnadata'] = $clearpay;
- }
-
- }
- if($post['pay'] == '28' && $post['state'] != '207')
- {
- continue;
- }
- if($post['state'] == '217' || $post['state'] == '203')
- {
- continue;
- }
- /**
- else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
- {
- $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
- if($paypal != '')
- {
- $post['klarnadata'] = $paypal;
- }
-
- }
- **/
-
- /** 启用自动分配仓库 **/
- $warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
- foreach ($warehouse as $v)
- {
- if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
- {
- continue;
- }
- $yx = 'get_yx_'.$v['bdck'];
- $post['express'] = 0;
- $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
- if($kczd['t'] == 0)
- {
- $country = $this->country->read($post['country']);//获取国家中配置物流
- if($country['express'] != 0)
- {
- $post['express'] = $country['express'];
- }
- if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
- {
- $post['express'] = $v['express'];
- }
- $post['type'] = $v['id'];
- $post['whlabel'] = $kczd['whlabel'];
- $post['fpdata'] = $kczd['fpdata'];
- if(stripos($kczd['whlabel'],$v['hz']) !== false)
- {
- break 1;
- }
- }
- }
- $qdw = $this->warehouse->read($post['type']);
- $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
- $post['sfxh'] = $fl['sfxh'];
- $post['ckfl'] = $fl['ckfl'];
- $zipcode = substr($post['zipcode'],0,1);
- if($post['type'] == 5 && $zipcode > 6)
- {
- $post['express'] = 63;
- }
- //自动写位置 开始
- $zclp = array();$pxsl = array();
- $slpx = explode('|',$post['slpx']);//排序
- foreach ($slpx as $k=>$v)
- {
- $v = explode('-',$v);
- if(!isset($v[1]))
- {
- $v[1] == 1;
- }
- for($i=$v[0];$i<$v[1];$i++)
- {
- $pxsl[$i] = $k;
- }
- }
- $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
- if($qdw['wz'] == 1)
- {
- $pm = explode(';',trim($post['shipremarks'],';'));
- foreach ($pm as $k=>$vv)
- {
- $vv = trim($vv,' ');
- $lp = $this->typeclass->find_all("zh = '$vv'");
- if(isset($lp[0]['classid']))
- {
- $zclp[] = $vv;
- unset($pm[$k]);
- }
- }
- $pm = array_values($pm);
- $w = explode('|',trim($post['whlabel'],'|'));
- foreach ($w as $k=>$val)
- {
- $hwm = '';
- if(stripos($val,$qdw['hz']) !== false)
- {
- $num = explode('-',trim($val,'-'));
- $xq = explode('~',trim($num[2],'~'));
- $pmxq = '(';
- foreach ($xq as $v)
- {
- $zdidjl .= '('.trim($v,$qdw['hz']).')';
- $h = $this->$mc->read(trim($v,$qdw['hz']));
- if($h['details'] != '')
- {
- $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
- }
- }
- $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
- if(isset($pxsl[$k]))
- {
- if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
- {
- $pm[$pxsl[$k]] .= trim($pmxq,',').')';
- }
- }
- $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
- }
- }
- if($zclp)
- {
- $zclp = ';'.implode(";",$zclp);
- }
- else
- {
- $zclp = '';
- }
- $post['shipremarks'] = implode(";",$pm).$zclp;
- $post['contents'] = $zdidjl.' - '.$zdwzjl;
- }
- //自动写位置 结束
- //条数及申报
- $ts = 0;
- $dtsbjz = 0;
- $zsbjz = 0;
- $w = explode('|',trim($post['whlabel'],'|'));
- foreach ($w as $k=>$val)
- {
- $num = explode('-',trim($val,'-'));
- $ts += $num[1];
- }
- if($ts > 0 && $ts < 6 && $post['country'] == 192)
- {
- $dtsbjz = ($ts==3)?sprintf("%.1f",100/$ts):100/$ts;
- $zsbjz = sprintf("%.2f",$dtsbjz*$ts);
- }
- $post['ts'] = $ts;
- $post['dtsbjz'] = $dtsbjz;
- $post['zsbjz'] = $zsbjz;
- /** **/
- //合并重复项
- $hbcfw = explode('|',trim($post['whlabel'],'|'));
- $hbcff = explode(';',trim($post['fpdata'],';'));
- $c = 0;
- $hbw = array();
- $hbf = array();
- for($i=0;$i<count($hbcfw);$i++)
- {
- $w = explode('-',$hbcfw[$i]);
- $f = explode('|',$hbcff[$i]);
- $w2 = ($w[2]==0)?0:'';
- if(!isset($hbw[$w[0].$w2]))
- {
- $hbw[$w[0].$w2] = $hbcfw[$i];
- $hbf[$w[0].$w2] = $hbcff[$i];
- }
- else
- {
- $c++;
- $cw = explode('-',$hbw[$w[0].$w2]);
- $cf = explode('|',$hbf[$w[0].$w2]);
- if($cw[2] != 0 && $w[2] != 0)
- {
- $cf[2] += $f[2];
- $cf[9] .= '~'.$f[9];
- $hbf[$w[0].$w2] = implode("|",$cf);
- $cw[1] += $f[2];
- $cw[2] .= '~'.$f[9];
- $hbw[$w[0].$w2] = implode("-",$cw);
- }
- else if($cw[2] == 0 && $w[2] == 0)
- {
- $cf[2] += $f[2];
- $hbf[$w[0].$w2] = implode("|",$cf);
- $cw[1] += $f[2];
- $hbw[$w[0].$w2] = implode("-",$cw);
- }
- else
- {
- $hbw[] = $hbcfw[$i];
- $hbf[] = $hbcff[$i];
- }
- }
- }
- if($c > 0)
- {
- $post['fpdata'] = implode(";",$hbf).';';
- $post['whlabel'] = '|'.implode("|",$hbw).'|';
- }
- //合并重复项结束
- //非占单设置为禁止占单开始
- $hbw = explode('|',trim($post['whlabel'],'|'));
- $hbf = explode(';',trim($post['fpdata'],';'));
- foreach ($hbw as $k=>$val)
- {
- $w = explode('-',$val);
- $f = explode('|',$hbf[$k]);
- if(!isset($w[2]) || $w[2] == 0)
- {
- $w[2] = "DNOTO";
- $f[9] = "DNOTO";
- $hbf[$k] = implode("|",$f);
- $hbw[$k] = implode("-",$w);
- }
- }
- $post['fpdata'] = implode(";",$hbf).';';
- $post['whlabel'] = '|'.implode("|",$hbw).'|';
- //非占单设置为禁止占单结束
- //查询净重开始
- $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
- $post['zzl'] = ($post['jweight']+100)/1000;
- if($post['express'] == 2)
- {
- $post['zzl'] = intval(($post['jweight']+100)*0.035);
- }
- //查询净重结束
- $tjid = $this->fullorder->insert($post);
-
- /**
- if($post['shop'] == '1' || $post['shop'] == '2' || $post['shop'] == '6' || $post['shop'] == '5')
- {
- $this->_znxc($post,$order_id,$lkh);
- }
- else
- {
- $this->_znx($post,$order_id,$lkh);
- }
- **/
- }//else{}如果有此订单
- }
- }
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_commit();
- }
- else
- {
- $this->db->trans_commit();
- }
-
- echo json_encode(array('msg'=>'OK!','success'=>true));exit;
-
- }
- }
|