123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Fullorderexcel extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $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_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_api','api');
- $this->load->_model('Model_apismt','apismt');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_systemwigsout','systemwigsout');
- $this->load->_model('Model_setting','setting');
- $this->load->_model('Model_customer','customer');
- $this->load->_model('Model_customersmt','customersmt');
- $this->load->_model('Model_orderurl','orderurl');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_whlabel_bh','whlabel_bh');
- $this->load->_model('Model_apiyy','apiyy');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_systemtransfer','systemtransfer');
- $this->load->_model('Model_transfer','transfer');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_whlabel_type','whlabel_type');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'excel')
- {
- $this->_excel();
- }
- else if($arg == 'add')
- {
- $this->_add();
- }
- else if($arg == 'edit')
- {
- $this->_edit($arg_array);
- }
- else if($arg == 'del')
- {
- $this->_del();
- }
- else if($arg == 'rows')
- {
- $this->_rows();
- }
- else if($arg == 'waybill')
- {
- $this->_waybill($arg_array);
- }
- else if($arg == 'order')
- {
- $this->_order($arg_array);
- }
- else if($arg == 'xxpl')//线下批量导入
- {
- $this->_xxpl();
- }
- else if($arg == 'cs')
- {
- $this->_cs();
- }
- else if($arg == 'scwd')
- {
- $this->_scwd();
- }
- else if($arg == 'jmexcel')
- {
- $this->_jmexcel();
- }
- else if($arg == 'classid')
- {
- $this->_classid();
- }
- else if($arg == 'classidadd')
- {
- $this->_classidadd();
- }
- else if($arg == 'classidedit')
- {
- $this->_classidedit($arg_array);
- }
- else
- {
- $this->_index();
- }
- }
- //管理
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $type = $this->input->post('type',true);
- $where = "1=1 ";
- //数据排序
- $order_str = "id asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- //取得信息列表
- $info_list = $this->fullorderexcel->find_all($where,'id,type,title',$order_str,$start,$perpage);
- foreach ($info_list as $k=>$v)
- {
- $classid = $this->fullorderexcelclassid->read($v['type']);
- $info_list[$k]['type'] = $classid['title'];
- }
- $total = $this->fullorderexcel->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $classid = $this->fullorderexcelclassid->find_all();
- $this->data['classid'] = $classid;
- $this->_Template('fullorderexcel',$this->data);
- }
- //添加
- public function _add()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['title']))
- {
- $post['title'] = $this->input->post('title',true);
- $post['type'] = $this->input->post('type',true);
- $post['content'] = $this->input->post('content',true);
- $post['contentzh'] = $this->input->post('contentzh',true);
- if($this->fullorderexcel->insert($post))
- {
- echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
- }
- }
- $classid = $this->fullorderexcelclassid->find_all();
- $this->data['classid'] = $classid;
- $this->_Template('fullorderexcel_add',$this->data);
- }
- //修改
- public function _edit($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $post['title'] = $this->input->post('title',true);
- $post['type'] = $this->input->post('type',true);
- $post['content'] = $this->input->post('content',true);
- $post['contentzh'] = $this->input->post('contentzh',true);
- if($this->fullorderexcel->save($post,$id))
- {
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
- }
- }
- $arg_array = $arg_array[0];
- $fullorderexcel = $this->fullorderexcel->read($arg_array);
- $this->data['fullorderexcel'] = $fullorderexcel;
- $classid = $this->fullorderexcelclassid->find_all();
- $this->data['classid'] = $classid;
- $this->_Template('fullorderexcel_edit',$this->data);
- }
- //删除
- public function _del()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $this->fullorderexcel->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- }
- //获取数据
- public function _rows()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $fullorderexcel = $this->fullorderexcel->read($id);
- $content = explode('|',rtrim($fullorderexcel['content'],'|'));
- $contentzh = explode('|',rtrim($fullorderexcel['contentzh'],'|'));
- $data = array();
- for($i=0;$i<count($content);$i++)
- {
- $a = explode('-',$content[$i]);
- $b = explode('-',$contentzh[$i]);
- $data[] = array(0=>$a[1],1=>$b[1]);
- }
- echo json_encode(array('rows'=>($data),'success'=>true));
- }
- }
- //导出订单excel
- public function _excel()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- if(isset($_GET['fexcel']))
- {
- $typeclass = array();
- $tclass = $this->typeclass->find_all();
- foreach ($tclass as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $dowid = $this->input->get('a');
- $wid = "";
- if($dowid != "")
- {
- $id_arr = explode(',',rtrim($dowid,','));
- $wid .= " id = 0 or";
- foreach ($id_arr as $v)
- {
- $wid .= " id = '$v' or";
- }
- $wid = " and".rtrim($wid,'or');
- }
- $fexcel = $this->input->get('fexcel',true);
- $page = $this->input->get('page',true);
- $perpage = $this->input->get('perpage',true);
- $warehouse = $this->input->get('warehouse',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $source = $this->input->get('source',true);
- $state = $this->input->get('state',true);
- $review = $this->input->get('review',true);
- $type = $this->input->get('type',true);
- $express = $this->input->get('express',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $user = $this->input->get('user',true);
- $client = $this->input->get('name',true);
- $waybill = $this->input->get('waybill',true);
- $number = $this->input->get('number',true);
- $email = $this->input->get('email',true);
- $dlz = $this->input->get('dlz',true);
- $library = $this->input->get('library',true);
- $libraryconfirm = $this->input->get('libraryconfirm',true);
- $print = $this->input->get('print',true);
- $timetkk = $this->input->get('timetkk',true);
- $timetjj = $this->input->get('timetjj',true);
- $xztime = $this->input->get('xztime',true);
- $country = $this->input->get('country',true);
- $zf = $this->input->get('zf',true);
- $pay = $this->input->get('pay',true);
- $phone = $this->input->get('phone',true);
- $so = $this->input->get('so',true);
- $sfxh = $this->input->get('sfxh',true);
- $xdcs = $this->input->get('xdcs',true);
- $xdcs = $this->input->get('xdcs',true);
- $dbapi = $this->input->get('dbapi',true);
- $orderurl = $this->input->get('orderurl',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $timetkk = strtotime($timetkk);
- $timetjj = strtotime($timetjj);
- $px = $this->input->get('px',true);
- $fexcel = $this->fullorderexcel->read($fexcel);
- $classid = $this->fullorderexcelclassid->read($fexcel['type']);
- $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($xztime)
- {
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($timetkk && $timetjj)
- {
- $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
- }
- }
- else
- {
- $where .= " and dtime > '$timetk' and dtime < '$timetj'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- if($source == '2d')
- {
- $where .= " and source >= '2'";
- }
- else
- {
- $where .= " and source = '$source'";
- }
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($review)
- {
- $where .= " and review = '$review'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($client)
- {
- $where .= " and client like '%$client%'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($email)
- {
- $where .= " and email = '$email'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($dlz)
- {
- $where .= " and waybill != '' and dlz = 0";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($pay)
- {
- $where .= " and pay = '$pay'";
- }
- if($phone)
- {
- $where .= " and phone = '$phone'";
- }
- if($sfxh != '')
- {
- $where .= " and sfxh = '$sfxh'";
- }
- if($orderurl)
- {
- $url = $this->orderurl->read($orderurl);
- $where .= " and link like '%".$url['url']."%'";
- }
- if($zf)
- {
- if($zf == 1)
- {
- $where .= " and paypal not like '%-%-%-%'";
- }
- else
- {
- $where .= " and paypal like '%-%-%-%'";
- }
- }
- $sj = $this->input->get('sj',true);
- if($sj)
- {
- $sj = $this->input->get('sj',true);
- }
- else
- {
- $sj = $classid['type'];
- }
-
- $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
- foreach ($fexceleq as $k=>$v)
- {
- $fexceleq[$k] = explode('-',$v);
- $num[$k] = $fexceleq[$k][0];
- }
- //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
- $feq = "";$kong = array();$sku9610 = '';
- foreach ($fexceleq as $k=>$v)
- {
- if(isset($v[1]))
- {
- if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
- {
- $feq .= 'klarnadata,';
- }
- if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
- {
- $feq .= 'fpdata,';
- }
- if($v[1] != 'kong')//空值去除
- {
- if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
- {
- if($v[1] == '9610sku')
- {
- $sku9610 = 1;
- }
- if($sj == 'fullordersmt')
- {
- $v[1] = 'sku';
- }
- else
- {
- $v[1] = 'issku';
- }
- }
- $feq .= $v[1].',';
- }
- else
- {
- $kong[$v[0]] = 1;
- }
- }
- }
- $feq = rtrim($feq,',');
- $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
- foreach ($fexcelzhw as $k=>$v)
- {
- $fexcelzhw[$k] = explode('-',$v);
- $numb[$k] = $fexcelzhw[$k][0];
- }
- //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
- $fexcelzh = array();
- foreach ($fexcelzhw as $k=>$v)
- {
- $fexcelzh[] = $v[1];
- }
- if($px)
- {
- $order_str = $px." desc";
- }
- else
- {
- $order_str = "id desc";
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str);
- //格式化数据
- $i = 1;$shouldmoney = 0;$hl=1;
- foreach ($info_list as $key=>$value)
- {
- $data = $this->$sj->read($value['id']);
- if(isset($value['email']) && $usp['excelpass'] == '1')
- {
- $emailpass = $this->setting->get_excelpass($value['email']);
- $info_list[$key]['email'] = $emailpass;
- }
- if(isset($value['phone']) && $usp['excelpass'] == '1')
- {
- $phonepass = $this->setting->get_excelpass($value['phone']);
- $info_list[$key]['phone'] = $phonepass;
- }
- if(isset($value['currencytitle']))
- {
- if($value['currencytitle'] != "CNY")
- {
- $hl=$value['hl'];
- }
- $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
- $budget=$budget+($value['budget']*$hl);
- $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
- $refund=$refund+($value['refund']*$hl);
- }
- if(isset($value['shop']))
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- if(isset($value['dtime']))
- {
- $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
- }
- if(isset($value['printtime']))
- {
- if($value['printtime'] > 0)
- {
- $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
- }
- }
- if(isset($value['sku']))
- {
- if($sku9610 == '1')
- {
- $aesku = explode(';',$value['sku']);
- $aesku = $aesku[0];
- $aesku = explode(':',$aesku);
- if(count($aesku) > 1)
- {
- $aesku = $aesku[1];
- $aesku = str_replace('--','~',$aesku);
- $aesku = explode('-',$aesku);
- $aesku = $aesku[0];
- $aesku = str_replace('~','--',$aesku);
- $info_list[$key]['sku'] = $aesku;
- }
- else
- {
- $info_list[$key]['sku'] = '';
- }
- }
- else
- {
- $info_list[$key]['sku'] = $value['sku'];
- }
- }
- if(isset($value['issku']))
- {
- $value['issku'] = str_replace(array('<','>'),array('<','>'),$value['issku']);
- if($sku9610 == '1')
- {
- $aesku = explode(';',$value['issku']);
- $aesku = $aesku[0];
- $aesku = str_replace('--','~',$aesku);
- $aesku = explode('-',$aesku);
- $aesku = $aesku[0];
- $aesku = str_replace('~','--',$aesku);
- $aesku = str_replace(array('<','>'),array('<','>'),$aesku);
- $info_list[$key]['issku'] = $aesku;
- }
- else
- {
- $value['issku'] = str_replace(array('<','>'),array('<','>'),$value['issku']);
- $info_list[$key]['issku'] = $value['issku'];
- }
-
- }
- if(isset($value['librarytime']))
- {
- if($value['librarytime'] > 0)
- {
- $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
- }
- }
- if(isset($value['buytime']))
- {
- if($value['buytime'] > 0)
- {
- $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
- }
- }
- if(isset($value['country']))
- {
- $country = $this->country->read($value['country']);
- $info_list[$key]['country'] = $country['name'];
- }
- if(isset($value['street']))//暂时用街道导出州二字码
- {
- if($data['country'] == 192)//如果是美国
- {
- $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');
- $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
- $data['province'] = trim($data['province'],' ');
- if(isset($ToState[strtolower($data['province'])]))
- {
- $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
- }
- else
- {
- $dataprovince = '';
- }
- $info_list[$key]['street'] = $dataprovince;
- }
- else
- {
- $info_list[$key]['street'] = '';
- }
- }
- if(isset($value['pay']))
- {
- $pay = $this->typeclass->read($value['pay']);
- $info_list[$key]['pay'] = $pay['title'];
- }
- if(isset($value['type']))
- {
- $type = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $type['title'];
- }
- if(isset($value['express']))
- {
- $express = $this->express->read($value['express']);
- if($express)
- {
- $info_list[$key]['express'] = $express['servicename'];
- }
- else
- {
- $info_list[$key]['express'] = '未选择';
- }
- }
- if(isset($value['ccfpdata']))
- {
- $ccfpdata = explode(';',$value['fpdata']);
- $inc = 0;
- foreach ($ccfpdata as $v)
- {
- if(stripos($v,',') !== false)
- {
- $cc = explode(',',$v);
- $inctype = $this->typeclass->read($cc[0]);
- if(is_numeric($inctype['spare']))
- {
- if($inctype['spare'] > $inc)
- {
- $inc = $inctype['spare'];
- }
- }
- }
- }
- $info_list[$key]['ccfpdata'] = $inc.'inch';
- }
- if(isset($value['printtype']))
- {
- if($value['printtype'] == 1)
- {
- $info_list[$key]['printtype'] = '运单';
- }
- else if($value['printtype'] == 2)
- {
- $info_list[$key]['printtype'] = '发货单';
- }
- else if($value['printtype'] == 3)
- {
- $info_list[$key]['printtype'] = '不打印单据';
- }
- else
- {
- $info_list[$key]['printtype'] = '未选择';
- }
- }
- if(isset($value['exstate']))
- {
- if($value['exstate'] == '99')
- {
- $info_list[$key]['exstate'] = '未获取到物流信息';
- }
- else if($value['exstate'] == '1')
- {
- $info_list[$key]['exstate'] = '已揽收';
- }
- else if($value['exstate'] == '2')
- {
- $info_list[$key]['exstate'] = '在途中';
- }
- else if($value['exstate'] == '3')
- {
- $info_list[$key]['exstate'] = '派送中';
- }
- else if($value['exstate'] == '4')
- {
- $info_list[$key]['exstate'] = '已签收';
- }
- else if($value['exstate'] == '5')
- {
- $info_list[$key]['exstate'] = '派送异常';
- }
- else
- {
- $info_list[$key]['exstate'] = '';
- }
- }
- if(isset($value['link']))
- {
- if($value['link'] != '')
- {
- $link = explode(',',$value['link']);
- $info_list[$key]['link'] = $link[0];
- }
- else
- {
- $info_list[$key]['link'] = '';
- }
- }
- if(isset($value['klarnabill']))
- {
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[2]))
- {
- $info_list[$key]['klarnabill'] = $klarnadata[2];
- }
- else
- {
- $info_list[$key]['klarnabill'] = '';
- }
- }
- if(isset($value['klarnaship']))
- {
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[3]))
- {
- $info_list[$key]['klarnaship'] = $klarnadata[3];
- }
- else
- {
- $info_list[$key]['klarnaship'] = '';
- }
- }
- if(isset($value['afterpaybill']))
- {
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[1]))
- {
- $info_list[$key]['afterpaybill'] = $klarnadata[1];
- }
- else
- {
- $info_list[$key]['afterpaybill'] = '';
- }
- }
- if(isset($value['afterpayship']))
- {
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[2]))
- {
- $info_list[$key]['afterpayship'] = $klarnadata[2];
- }
- else
- {
- $info_list[$key]['afterpayship'] = '';
- }
- }
- if(isset($value['PPname']))
- {
- $info_list[$key]['PPname'] = '';
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[1]))
- {
- $klarnadata = json_decode($klarnadata[1],true);
- if(isset($klarnadata['name']))
- {
- $info_list[$key]['PPname'] = $klarnadata['name'];
- }
- }
- }
- if(isset($value['PPemail']))
- {
- $info_list[$key]['PPemail'] = '';
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[1]))
- {
- $klarnadata = json_decode($klarnadata[1],true);
- if(isset($klarnadata['email']))
- {
- if($usp['excelpass'] == '1')
- {
- $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
- }
- else
- {
- $ppemailpass = $klarnadata['email'];
- }
- $info_list[$key]['PPemail'] = $ppemailpass;
- }
- }
- }
- if(isset($value['PPaddress']))
- {
- $info_list[$key]['PPaddress'] = '';
- $klarnadata = explode('|',$value['klarnadata']);
- if(isset($klarnadata[1]))
- {
- $klarnadata = json_decode($klarnadata[1],true);
- if(isset($klarnadata['address']))
- {
- $info_list[$key]['PPaddress'] = $klarnadata['address'];
- }
- }
- }
- if(isset($value['klarnadata']))
- {
- unset($info_list[$key]['klarnadata']);
- }
- if(isset($value['shippingmethod']))
- {
- $tax = explode('Tax:',$value['shippingmethod']);
- $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
- }
- if(isset($value['systemwigsout']))
- {
- $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
- $outread = '';
- if($out)
- {
- foreach ($out as $val)
- {
- $list = '';
- $rk = explode('|',trim($val['rk'],'|'));
- $rktime = explode('|',trim($val['rktime'],'|'));
- $zw = array();
- $t = $this->transfer->find_all("1=1");
- foreach ($t as $v)
- {
- $zw[$v['id']] = $v['title'];
- }
- if($val['rk'] != '' && count($rk) > 0)
- {
- for($i=0;$i<count($rk);$i++)
- {
- if(!isset($rktime[$i]))
- {
- $list .= $zw[$cz[$i]];
- }
- else
- {
- $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
- }
- }
- }
- $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
- }
- }
- else
- {
- $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
- if($systemwigsout)
- {
- foreach ($systemwigsout as $v)
- {
- $outread = '';
- if($v['czwarehouse'] == 37)
- {
- $outread .= '华荣厂';
- }
- else if($v['czwarehouse'] == 0)
- {
- $outread .= '龙盈厂';
- }
- $cz = explode('|',trim($v['cz'],'|'));
- $cztime = explode('|',trim($v['cztime'],'|'));
- $zw = $this->transfer->get_list();
- if($v['cz'] != '' && count($cz) > 0)
- {
- for($i=0;$i<count($cz);$i++)
- {
- if(!isset($cztime[$i]))
- {
- $outread .= $zw[$cz[$i]].' -> ';
- }
- else
- {
- $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -> ';
- }
- }
- $outread .= '<br>';
- }
- }
- }
- }
- $info_list[$key]['systemwigsout'] = $outread;
- }
- if(isset($value['sourcetype']))
- {
- if($value['sourcetype'] == '1')
- {
- $info_list[$key]['sourcetype'] = '网红单';
- }
- else if($value['sourcetype'] == '2')
- {
- $info_list[$key]['sourcetype'] = '批发单';
- }
- else if($value['sourcetype'] == '3')
- {
- $info_list[$key]['sourcetype'] = '线下单';
- }
- else if($value['sourcetype'] == '4')
- {
- $info_list[$key]['sourcetype'] = '售后单';
- }
- else if($value['sourcetype'] == '5')
- {
- $info_list[$key]['sourcetype'] = '其它';
- }
- else
- {
- $info_list[$key]['sourcetype'] = '';
- }
- }
- if(isset($value['js']))
- {
- if($value['js'] == '0')
- {
- $info_list[$key]['js'] = 'FIRST CLASS';
- }
- else if($value['js'] == '1')
- {
- $info_list[$key]['js'] = 'PRIORITY';
- }
- else if($value['js'] == '2')
- {
- $info_list[$key]['js'] = 'EXPRESS';
- }
- }
- if(isset($value['type']))
- {
- $type = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $type['title'];
- }
- if(isset($value['xdcs']))
- {
- if($sj == 'fullorder')
- {
- $xdcs = $this->customer->get_email($data['email'],$data['shop']);
- }
- else
- {
- $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
- }
- $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
- }
- if(isset($value['dbapi']) || isset($value['scapi']))
- {
- $jmlist = '';$shuliang = '';
- $classid = $this->classid->sku();
- $dbapi = explode(';',trim($value['fpdata'],';'));
- foreach ($dbapi as $va)
- {
- $pm = $classid;
- $jm = $classid;
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
- $ts = explode('|',trim($features,'|'));
- if(stripos($ts[0],',') !== false)
- {
- $ft = explode(',',$ts[0]);
- $features = explode('-',trim($ft[1],'-'));
- $features[] = $ft[0];
- }
- else
- {
- $features = explode('-',trim($ts[0],'-'));
- }
- foreach($features as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0 && isset($typeclass[$v]))
- {
- if($typeclass[$v]['classid'] == 13)
- {
- $dj = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 8)
- {
- $ys = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 15)
- {
- $hx = $typeclass[$v]['title'];
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $jmlist .= $jm.'<br>';
- $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- }
- if(isset($value['dbapi']))
- {
- $info_list[$key]['dbapi'] = $jmlist;
- }
- else
- {
- $info_list[$key]['scapi'] = $shuliang;
- }
- }
-
- if(isset($value['dbapi']) && isset($value['scapi']))
- {
- $jmlist = '';$shuliang = '';
- $classid = $this->classid->sku();
- $dbapi = explode(';',trim($value['fpdata'],';'));
- foreach ($dbapi as $va)
- {
- $pm = $classid;
- $jm = $classid;
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
- $ts = explode('|',trim($features,'|'));
- if(stripos($ts[0],',') !== false)
- {
- $ft = explode(',',$ts[0]);
- $features = explode('-',trim($ft[1],'-'));
- $features[] = $ft[0];
- }
- else
- {
- $features = explode('-',trim($ts[0],'-'));
- }
- foreach($features as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0 && isset($typeclass[$v]))
- {
- if($typeclass[$v]['classid'] == 13)
- {
- $dj = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 8)
- {
- $ys = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 15)
- {
- $hx = $typeclass[$v]['title'];
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $jmlist .= $jm.'<br>';
- $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- }
- $info_list[$key]['dbapi'] = $jmlist;
- $info_list[$key]['scapi'] = $shuliang;
- }
-
-
- if(isset($value['cpfpdata']))
- {
- $fpread = '';
- $cpfpdata = explode(';',trim($value['fpdata'],';'));
- foreach ($cpfpdata as $v)
- {
- $va = explode('|',trim($v,'|'));
- $fpread .= $va[1].'; ';
- }
- $info_list[$key]['cpfpdata'] = $fpread;
- }
- unset($info_list[$key]['id']);
- unset($info_list[$key]['fpdata']);
- }
-
- $fzh = "";
- foreach ($fexcelzh as $v)
- {
- $fzh .= "<td>".$v."</td>";
- }
- $data = array($shouldmoney.' CNY');
- $title = $fexcel['title'].'-'.date('Ymd',time());
- $titlename = "<table border=1>
- <tr>"
- .$fzh.
- "</tr>
- </table>";
- $tail = "\n";
- $filename = $title.".xls";
- $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
- }
- }
-
- //上传运单
- public function _waybill($arg_array)
- {
- $readid = $arg_array[0];
- $dataorder = array();$datashop = array();$dataex = array();$datack = array();
- /* 订单加入键值-k */
- $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
- foreach ($fdata as $v)
- {
- $dataorder[$v['orderinfo']] = $v;
- }
- $sdata = $this->fullordersmt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
- foreach ($sdata as $v)
- {
- $dataorder[$v['orderinfo']] = $v;
- }
- /* 订单加入键值-j */
- /* 店铺加入键值-j */
- $fshop = $this->shop->find_all('1=1');
- foreach ($fshop as $v)
- {
- $datashop[$v['id']] = $v;
- }
- /* 店铺加入键值-k */
- /* 快递加入键值-j */
- $fex = $this->express->find_all('1=1');
- foreach ($fex as $v)
- {
- $dataex[$v['id']] = $v;
- }
- /* 快递加入键值-k */
- /* 仓库加入键值-k */
- $fwh = $this->warehouse->find_all('1=1');
- foreach ($fwh as $v)
- {
- $datack[$v['id']] = $v;
- }
- /* 仓库加入键值-j */
- $fs = $this->notice->get_ordertatus(216);//216成功状态
- if(is_numeric($readid) == false || $readid < 1)
- {
- echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
- }
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- if($value['0'] == "")
- {
- continue;
- }
- $ddh = preg_replace('/\D/s','',$value['0']);
- $ydh = preg_replace('/\W/s','',$value['1']);
- $shop = $datashop[$readid];
- if($shop['type'] == '269')
- {
- $orid = $readid.$ddh;
- }
- else
- {
- $orid = $ddh;
- }
- if(isset($dataorder[$orid]))
- {
- $sp = $this->shop->read($arg_array[0]);
- if($sp['type'] == 269)//独立站前缀需要添加ID
- {
- $xg = $dataorder[$arg_array[0].$ddh];
- $ex = $dataex[$xg['express']];
- $warehouse = $datack[$xg['type']];
- if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
- {
- //独立站地址更新订单状态、物流信息
- $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
- if(!isset($gx['res']))
- {
- $ed[] = array($ddh.'-更新失败');
- $j++;
- continue;
- }
- $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
- if($gx['res'] == 1 && $fs)
- {
- $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
- }
- }
- else if($xg['source'] == 1 && $xg['state'] == '207')
- {
- $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
- if($fs)
- {
- $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
- }
- }
- else
- {
- $ed[] = array($ddh.'-状态错误');
- $j++;
- continue;
- }
- }
- else if($sp['type'] == 270)//速卖通对接发货声明
- {
- $xg = $dataorder[$ddh];
- $ex = $dataex[$xg['express']];
- $warehouse = $datack[$xg['type']];
- if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
- {
- $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
- if(isset($result['result_success']) && $result['result_success'] == "true")
- {
- $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
- /** 合并信息处理开始-发货声明 **/
- if($xg['merge'] != '0')
- {
- $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
- foreach ($hdata as $v)
- {
- $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
- if(isset($result['result_success']) && $result['result_success'] == "true")
- {
- $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
- }
- else
- {
- $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
- $j++;
- continue;
- }
- $l++;
- if($l > 10)
- {
- break;
- }
- }
- }
- /** 合并信息处理结束开始 **/
- }
- else
- {
- $ed[] = array($ddh.'-发货声明失败');
- $j++;
- continue;
- }
- }
- else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
- {
- $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
- if(isset($obtain['logistics_no']))
- {
- $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
- }
- if(isset($result['result_success']) && $result['result_success'] == "true")
- {
- $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
- /** 合并信息处理开始-修改声明 **/
- if($xg['merge'] != '0')
- {
- $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
- foreach ($hdata as $v)
- {
- $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
- if(isset($obtain['logistics_no']))
- {
- $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
- }
- if(isset($result['result_success']) && $result['result_success'] == "true")
- {
- $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
- }
- else
- {
- $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
- $j++;
- continue;
- }
- $l++;
- if($l > 10)
- {
- break;
- }
- }
- }
- /** 合并信息处理结束开始 **/
- }
- else
- {
- $ed[] = array($ddh.'-修改发货声明失败');
- $j++;
- continue;
- }
- }
- else if($xg['source'] == 1 && $xg['state'] == '207')
- {
- $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
- }
- else
- {
- $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
- }
- }
-
- }
-
- else
- {
- $ed[] = array($ddh.'-单号错误或重复操作');
- $i++;
- continue;
- }
- sleep(1);//停留1秒
- }
- if($i+$j > 0)
- {
- $time = date('Ymd',time());
- $title = '错误信息-'.$time;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
- //上传速卖通订单
- public function _order($arg_array)
- {
- $dataorder = array();$datashop = array();$dataex = array();$datack = array();
- /* 订单加入键值-k */
- $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
- foreach ($fdata as $v)
- {
- $dataorder[$v['orderinfo']] = $v;
- }
- /* 订单加入键值-j */
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();$tytime = time();
- foreach ($list as $key=>$value)
- {
- $value['2'] = preg_replace('/\D/s','',$value['2']);
- if($value['2'] && !isset($dataorder[$value['2']]))
- {
- $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
- $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
- $post['state'] = 207;//订单状态:207等待发货
- $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
- $post['reviewtime'] = $tytime;//审核时间
- $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
- $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
- $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
- if($post['print'] != 3)
- {
- $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
- }
- $value['1'] = trim($value['1'],' ');
- $shortname = explode('-',$value['1']);
- $shortname = $this->shop->get_shortname($shortname[0]);
- if(!$shortname)
- {
- $ed[] = array($value['1'].'-编码有问题');
- $i++;
- continue;
- }
- $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
- $post['user'] = '无';
- $post['number'] = $value['1'];//编号
- $post['orderinfo'] = $value['2'];//订单号
- $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
- $post['buytime'] = $tytime;//时间转UX
- $post['dtime'] = $tytime;//订单时间
- $post['gtime'] = date('Ymd',$tytime);//格式化时间
- //$post['pay'] = $this->input->post('pay',true);//支付方式
- $post['capital'] = 3;//资金状态
- $post['type'] = 5;//发货仓库
- $post['currency'] = 219;//币种
- $post['currencytitle'] = 'USD';//币种名称
- $post['freight'] = 0;//运费
- $post['expressmoney'] = 0;//物流金额
- $post['shouldmoney'] = 0;//应收金额
- $post['budget'] = 0;//应到金额*店铺到帐金额比
- $orderremarks = '';//订单备注
- $post['shipremarks'] = $value['12'];//仓库品名
- $post['email'] = '';//邮箱
- $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
- $post['phone'] = $value['10'];//电话
- $post['country'] = 192;//国家
- $ct = $this->country->get_ename($value['9']);//国家
- $post['al'] = $ct['lb'];//国家二字码
- $post['province'] = $value['8'];//省、州
- $post['city'] = $value['6'];//城市
- $post['zipcode'] = $value['7'];//邮编
- $post['address'] = $value['4'];//地址1
- $post['address2'] = $value['5']?$value['5']:'';//地址2
- $post['express'] = 2;//快递
- $post['printtype'] = 1;//打印类型
- $post['fpdata'] = '';//购买产品内容
- $post['sbpm'] = 'Hair Sample';//申报品名
- $post['zwpm'] = '假发';//中文品名
- $post['ts'] = $value['17'];//条数
- $post['dtsbjz'] = 15;//单条申报价
- $post['zsbjz'] = 15;//总申报价
- $post['zzl'] = 0.5;//总重量
- $post['zjs'] = 1;//总件数
- $post['quantity'] = 1;//数量
- $post['paypal'] = '';//支付号
- $post['guarantee'] = '';//卖家保障
- $post['zzl'] = $value['13'];//总重量
- $post['bx'] = $value['14'];//总重量
- $post['qm'] = $value['15'];//总重量
- $post['js'] = $value['16'];//总重量
- $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
- if(isset($barcode['Address']['Error']['Description']))
- {
- $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
- $i++;
- }
- else
- {
- $this->fullorder_smt->insert($post);
- }
- }
- else
- {
- $ed[] = array($value['1'].'-单号错误或重复操作');
- $i++;
- }
- sleep(2);//停留2秒
- }
- if($i+$j > 0)
- {
- $time = date('Ymd',time());
- $title = '错误信息-'.$time;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
- public function _email($content,$data,$shopname)
- {
- $express = $this->express->read($data['express']);
- $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
- $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
- $content = str_replace($t,$h,$content);
- $this->load->library('email');
- $config['protocol'] = 'smtp';
- $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
- $config['smtp_port'] = 465;
- $config['smtp_user'] = 'service@email.supernovahair.com';
- $config['smtp_pass'] = 'LONGyihair374';
- $config['smtp_crypto'] = 'ssl';
- $config['crlf'] = "\r\n";
- $config['newline'] = "\r\n";
- $this->email->initialize($config);
- $this->email->from('service@email.supernovahair.com',$shopname);
- $this->email->to($data['email']);//收件
- $this->email->subject('The product you purchased has a new progress');//标题
- $this->email->message($content);//内容
- if ( ! $this->email->send())
- {
- return 2;
- }
- else
- {
- return 1;
- }
- }
- //导出订单excel
- public function _cs()
- {
- if(isset($_GET['fexcel']))
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $dowid = $this->input->get('a');
- $wid = "";
- if($dowid != "")
- {
- $id_arr = explode(',',rtrim($dowid,','));
- foreach ($id_arr as $v)
- {
- $wid .= " id = 0 or";
- $wid .= " id = '$v' or";
- }
- $wid = " and".rtrim($wid,'or');
- }
- $fexcel = $this->input->get('fexcel',true);
- $page = $this->input->get('page',true);
- $perpage = $this->input->get('perpage',true);
- $warehouse = $this->input->get('warehouse',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $source = $this->input->get('source',true);
- $state = $this->input->get('state',true);
- $review = $this->input->get('review',true);
- $type = $this->input->get('type',true);
- $express = $this->input->get('express',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $user = $this->input->get('user',true);
- $client = $this->input->get('name',true);
- $waybill = $this->input->get('waybill',true);
- $number = $this->input->get('number',true);
- $email = $this->input->get('email',true);
- $dlz = $this->input->get('dlz',true);
- $library = $this->input->get('library',true);
- $libraryconfirm = $this->input->get('libraryconfirm',true);
- $print = $this->input->get('print',true);
- $timetkk = $this->input->get('timetkk',true);
- $timetjj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $timetkk = strtotime($timetkk);
- $timetjj = strtotime($timetjj);
- $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $timetj = $timetj+24*3600;
- $where .= " and dtime > '$timetk' and dtime < '$timetj'";
- }
- if($timetkk && $timetjj)
- {
- $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($review)
- {
- $where .= " and review = '$review'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($client)
- {
- $where .= " and client like '%$client%'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($email)
- {
- $where .= " and email = '$email'";
- }
- if($dlz)
- {
- $where .= " and waybill != '' and dlz = 0";
- }
- if($dlz)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- $fexcel = $this->fullorderexcel->read($fexcel);
- $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
- foreach ($fexceleq as $k=>$v)
- {
- $fexceleq[$k] = explode('-',$v);
- $num[$k] = $fexceleq[$k][0];
- }
- //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
- $feq = "";
- foreach ($fexceleq as $k=>$v)
- {
- $feq .= $v[1].',';
- }
- $feq = rtrim($feq,',');
- $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
- foreach ($fexcelzhw as $k=>$v)
- {
- $fexcelzhw[$k] = explode('-',$v);
- $numb[$k] = $fexcelzhw[$k][0];
- }
- //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
- $fexcelzh = array();
- foreach ($fexcelzhw as $k=>$v)
- {
- $fexcelzh[] = $v[1];
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
- //格式化数据
- $i = 1;$shouldmoney = 0;$hl=1;
- foreach ($info_list as $key=>$value)
- {
- if(isset($value['currencytitle']))
- {
- if($value['currencytitle'] != "CNY")
- {
- $hl=$value['hl'];
- }
- $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
- $budget=$budget+($value['budget']*$hl);
- $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
- $refund=$refund+($value['refund']*$hl);
- }
- if(isset($value['shop']))
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- if(isset($value['dtime']))
- {
- $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
- }
- if(isset($value['country']))
- {
- $country = $this->country->read($value['country']);
- $info_list[$key]['country'] = $country['name'];
- }
- if(isset($value['type']))
- {
- $type = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $type['title'];
- }
- if(isset($value['express']))
- {
- $express = $this->express->read($value['express']);
- if($express)
- {
- $info_list[$key]['express'] = $express['servicename'];
- }
- else
- {
- $info_list[$key]['express'] = '未选择';
- }
- }
- }
- echo $timetkk;
- }
- }
-
-
- public function _xxpl()
- {
- /* 订单加入键值-j */
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $j = 0;$ed = array();
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['title']] = $v['id'];
- }
- foreach ($list as $v)
- {
- $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
- if($w && isset($wt[$v[1]]))
- {
- foreach ($w as $val)
- {
- $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
- }
- }
- else
- {
- $ed[] = array($v[0],$v[1]);
- $j++;
- }
- }
-
-
- if($j > 0)
- {
- $time = date('Ymd',time());
- $title = '错误信息-'.$time;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>$cs,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
- public function _xxpl_b()
- {
- $dataorder = array();$datashop = array();$dataex = array();$datack = array();
- /* 订单加入键值-k */
- $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
- foreach ($fdata as $v)
- {
- $dataorder[$v['orderinfo']] = $v;
- }
- /* 订单加入键值-j */
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();$time = time();
- foreach ($list as $key=>$value)
- {
- $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
- if(!$shop)
- {
- $ed[] = array($value['0'].'-无此店铺');
- $i++;continue;
- }
- $post['buytime'] = strtotime($value['6']);//付款时间
- $value['0'] = preg_replace('/\D/s','',$value['0']);
- if($value['0'] && !isset($dataorder[$value['0']]))
- {
- $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
- $post['state'] = 207;//订单状态:207等待发货
- $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
- $post['reviewtime'] = $time;//审核时间
- $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
- $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
- $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
- $post['dtime'] = $time;//订单时间
- $post['capital'] = 3;//资金状态
- $post['currency'] = 219;//币种
- $post['currencytitle'] = 'USD';//币种名称
- $post['freight'] = 0;//运费
- $post['expressmoney'] = 0;//物流金额
- $post['shouldmoney'] = 0;//应收金额
- if($post['print'] != 3)
- {
- $post['librarynot'] = "订单未打印";//不能出库原因
- }
-
- $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
- $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
- $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
- $post['user'] = $shop['shopuser'];//店铺负责人
- $post['orderinfo'] = $value['0'];//订单号
- $post['type'] = $value['7'];//发货仓库
- $post['shop'] = $shop['id'];//店铺
- $post['shouldmoney'] = $value['3'];//订单金额
- $post['product'] = $value['4']?$value['4']:'';//商品名称
- $post['pay'] = $value['5'];//付款方式
- $post['paypal'] = $value['1']?$value['1']:'';//交易号
- $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
- $post['shipremarks'] = $value['9'];//仓库品名
- $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
- $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
- $post['phone'] = $value['12'];//电话
- $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
- if(!$ct)
- {
- $ed[] = array($value['0'].'-无此国家');
- $i++;continue;
- }
- $post['country'] = $ct['id'];//国家
- $post['al'] = $ct['lb'];//国家二字码
- $post['province'] = $value['14'];//省、州
- $post['city'] = $value['15'];//城市
- $post['zipcode'] = $value['16'];//邮编
- $post['address'] = $value['17'];//地址1
- $post['address2'] = $value['18']?$value['18']:'';//地址2
- $yga = $value['3'];$ygb = $shop['estimaterate'];
- $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
- $post['sbpm'] = $value['19'];//申报品名
- $post['zwpm'] = $value['20'];//中文品名
- $post['ts'] = $value['21'];//条数
- $post['dtsbjz'] = $value['22'];//单条申报价
- $post['zsbjz'] = $value['23'];//总申报价
- $post['zzl'] = $value['24'];//总重量
- $post['zjs'] = $value['25'];//总件数
- $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
- if(!$express)
- {
- $ed[] = array($value['0'].'-无此快递方式');
- $i++;continue;
- }
- $post['express'] = $express['id'];//快递
- $post['printtype'] = 1;//打印类型 1.运单.2.发货单
- $post['fpdata'] = '';//购买产品内容
- $this->fullordersmt->insert($post);
- }
- else
- {
- $ed[] = array($value['0'].'-单号错误或重复操作');
- $i++;
- }
- sleep(2);//停留2秒
- }
- if($i+$j > 0)
- {
- $time = date('Ymd',time());
- $title = '错误信息-'.$time;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
- public function _scwd()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['allowed_types'] = '*';
- $config['max_size'] = 102400;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
- public function _jmexcel()
- {
- $setting = $this->setting->get_settings();
- $excelpass = $setting['excelpass'];
- $excelusernum = $setting['excelusernum'];
- $exceljmnum = $setting['exceljmnum'];
- $user = $this->user->get_api($_SESSION['api']);
- if(!isset($user['exceltime']))
- {
- $this->session->sess_destroy();
- header("Location:/");
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['data']))
- {
- $data = $this->input->post('data',true);
- $data = str_replace("\n",",",$data);;
- $data = explode(',',trim($data,','));
- $d = '';$i = 0;
- foreach ($data as $v)
- {
- if($v == '')
- {
- continue;
- }
- $j = $this->setting->get_jmexcelpass($v);
- if($j == '')
- {
- $j = $v.' 信息不正确';
- }
- $d .= $j."<br />";
- $i++;
- }
- if($i > $exceljmnum)
- {
- echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
- }
- if($user['exceltime'] != date('Ymd',time()))
- {
- $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
- }
- else
- {
- if($user['excelnum'] > $excelusernum)
- {
- echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
- }
- else
- {
- $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
- }
- }
- echo json_encode(array('msg'=>$d,'success'=>true));exit;
- }
- $this->data['excelpass'] = $excelpass;
- $this->data['excelusernum'] = $excelusernum;
- $this->data['exceljmnum'] = $exceljmnum;
- $this->_Template('fullorderexcel_jmexcel',$this->data);
- }
-
- //管理
- public function _classid()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $type = $this->input->post('type',true);
- $where = "1=1 ";
- //数据排序
- $order_str = "id asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- //取得信息列表
- $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
- $total = $this->fullorderexcelclassid->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('fullorderexcel_classid',$this->data);
- }
- //添加
- public function _classidadd()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['title']))
- {
- if($this->fullorderexcelclassid->insert($post))
- {
- echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
- }
- }
- $this->_Template('fullorderexcel_classidadd',$this->data);
- }
- //修改
- public function _classidedit($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- if($this->fullorderexcelclassid->save($post,$id))
- {
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
- }
- }
- $arg_array = $arg_array[0];
- $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
- $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
- $this->_Template('fullorderexcel_classidedit',$this->data);
- }
- }
|