1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734 |
- <?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_fullorderxw','fullorderxw');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_fullorderamz','fullorderamz');
- $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');
- $this->load->_model('Model_power','power');
- $this->load->_model('Model_productdescribe','productdescribe');
- $this->load->_model('Model_shopsku','shopsku');
- $this->load->_model('Model_is','is');
- $this->load->_model('Model_whlabel_qh','whlabel_qh');
- $this->load->_model('Model_emaildata','emaildata');
- $this->load->_model('Model_afspaypal','afspaypal');
- $this->load->_model('Model_producttitle','producttitle');
- $this->load->_model('Model_message','message');
- }
- //定义方法的调用规则 获取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 == 'copy'){
- $this->_copy($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 == 'skuzh')//sku转中文
- {
- $this->_skuzh();
- }
- 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'];
- $info_list[$k]['action'] = "<h9 class='window' data-h='/fullorderexcel/copy/".$v['id']."' style='color:#000'><span>复制表格</span></h9>";
- }
- $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);
- $addid = $this->fullorderexcel->insert($post);
- if($addid)
- {
- $adminid = $this->power->read(1);
- $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
- echo json_encode(array('msg'=>'添加成功'.$adminid['id'],'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 _copy($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
-
- $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);
- unset($post['id']);
- $addid =$this->fullorderexcel->insert($post);
-
-
- if($addid)
- {
- $adminid = $this->power->read(1);
- $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
- echo json_encode(array('msg'=>'添加成功'.$adminid['id'],'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_copy',$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'],'|'));
- if($user['excelshop'] == '')
- {
- echo "没有下载权限";exit;
- }
- 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 = "1 = 1 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;
- }
- }
- }
- //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
- if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false)){
- if(strpos($feq,'subtotal')!= false){
- $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
- }
- if(strpos($feq,'rowtotal')!= false){
- $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
- }
- }
- $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']);
- $data = str_replace(array("'"),array("’"),$data);
- 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['subtotal'])){
- $tmp_sub_str = "";
- $subtotal_list = json_decode($value['subtotal'],true);
- foreach($subtotal_list as $v){
- if(isset($v['sub_total'])){
- $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
- }else{
- $tmp_sub_str .= "0<br>";
- }
- }
- $info_list[$key]['subtotal'] = $tmp_sub_str;
- }
- if(isset($value['rowtotal'])){
- $tmp_sub_str = "";
- $subtotal_list = json_decode($value['rowtotal'],true);
- foreach($subtotal_list as $v){
- if(isset($v['row_total'])){
- $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
- }else{
- $tmp_sub_str .= "0<br>";
- }
- }
- $info_list[$key]['rowtotal'] = $tmp_sub_str;
- }
- 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'] = 'Ground Advantage';
- }
- else if($value['js'] == '1')
- {
- $info_list[$key]['js'] = 'PRIORITY';
- }
- else if($value['js'] == '2')
- {
- $info_list[$key]['js'] = 'EXPRESS';
- }
- else if($value['js'] == '3')
- {
- $info_list[$key]['js'] = 'IP';
- }
- else if($value['js'] == '4')
- {
- $info_list[$key]['js'] = 'FICP';
- }
- }
- 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,'|'));
- if(isset($va[1])){
- $fpread .= $va[1].'; ';
- }else{
- $fpread .="合并单没有产品异常标记";
- }
-
- }
- $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;
- }
- $tdata = $this->fullordertt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
- foreach ($tdata as $v)
- {
- $dataorder[$v['orderinfo']] = $v;
- }
- $xdata = $this->fullorderxw->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
- foreach ($xdata 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();$cscs = array();
- $this->db->trans_begin();
- foreach ($list as $key=>$value)
- {
- $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]))
- {
- if($shop['type'] == 269)//独立站前缀需要添加ID
- {
- $time = time();
- $xg = $dataorder[$orid];
- $oldw = $xg['waybill'];
- $ex = $dataex[$xg['express']];
- $warehouse = $datack[$xg['type']];
- $msg = $ydh;
- $xg['waybill'] = $ydh;
- $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
- if(isset($fs[0]))
- {
- $fs = $fs[0];
- $fs['email'] = $this->emaildata->read($fs['email']);
- if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
- {
- $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
- if($ck == 1)
- {
- $ckemail = '邮件发送成功,';
- $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
- }
- }
- }
- if($msg != $oldw)
- {
- if($xg['source'] != 1)
- {
- $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
- if(!isset($ms[0]))
- {
- $ms = $this->message->read(2);
- }
- else
- {
- $ms = $ms[0];
- }
- $ddh = substr($xg['orderinfo'],1);
- $shopifyid = $xg['shopify'];
- //独立站地址更新订单状态、物流信息
- $shopname = $shop['brandname']; //店铺名
- $buyername = $xg['bname']; //Bill Name
- $email_call = $shop['shopid']; //发货人邮箱;
- $phone = $shop['shopphone']; //发货人电话
- $track_type = $ex['title']; //快递名称
- $service = $ex['title']; //快递追踪名称
- $track_link = $ex['url']; //快递查询网址
- $logistics_number = $ydh; //运单号
- $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
- $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
- $remark = str_replace($t,$h,$ms['content']);
- @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
- }
- else if($xg['source'] == 1)
- {
- $gx['res'] = 3;
- $gx['state'] = 216;
- }
- }
- else
- {
- $gx['res'] = $xg['dlz'];
- $gx['state'] = $xg['state'];
- }
- $xg['iscode'] = $ex['title'];
- $xg['url'] = $shop['shopname'];
- @$chuanshu = $this->api->get_paypal($xg);
- //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
- $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['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($shop['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 ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_rollback();
- }
- else
- {
- $this->db->trans_commit();
- }
- 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 _gggs($sku,$s,$j,$k)
- {
- $companytitle = array(9=>3,10=>2,11=>1,12=>4);
- $this->load->database();
- $this->db->select('id');
- $this->db->from('crowd_whlabel');
- $this->db->where('warehouse', '5');
- $this->db->where('sku', $sku);
- $this->db->where('state', '0');
- $this->db->limit($s,$k);
- $query = $this->db->get();
- $ids = array_column($query->result_array(), 'id');
- if (!empty($ids))
- {
- // 更新
- $this->db->where_in('id', $ids);
- $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
- return $this->db->affected_rows();
- }
- }
- public function _xxpl()
- {
-
- $this->load->database();
- $data = ['type' => ''];
- $this->db->update('crowd_whlabel', $data);
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['title']] = $v['id'];
- }
-
- /* 订单加入键值-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;
- }
- }
- $wt = array();
- $whlabel_type = $this->whlabel_type->find_all();
- foreach ($whlabel_type as $v)
- {
- $wt[$v['title']] = $v['id'];
- }
- $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
- foreach ($list as $v)
- {
-
- $this->load->database();
- // 设置更新数据
- $data = ['type' => $wt[$v[1]]];
- // 添加条件:SKU 为 123456 且 warehouse 为 5
- $this->db->where('SKU', $v[0]);
- $this->db->where('warehouse', '5');
- // 批量更新
- $this->db->update('crowd_whlabel', $data);
- }
-
-
- /** 导入缺货
- $time = time();
-
- $whlabel = $this->whlabel->get_sku($v[0]);
- if($whlabel)
- {
- $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
- }
- else
- {
- $ed[] = $v['0'];
- $j++;
- }
- }
- **/
- /**
- 更换等级
- $this->load->database();
- // 设置更新数据
- $data = ['type' => $wt[$v[1]]];
- // 添加条件:SKU 为 123456 且 warehouse 为 5
- $this->db->where('SKU', $v[0]);
- $this->db->where('warehouse', '5');
- // 批量更新
- $this->db->update('crowd_whlabel', $data);
-
- **/
- /**
- $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($e > 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'=>'添加成功!'.$c,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
-
- public function _skuzh()
- {
- /* 订单加入键值-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;
- }
- }
- $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');
- $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');
- foreach ($productdescribe as $v)
- {
- $money[$v['number']] = array();
- }
- /* 价格加入 */
- /* 匹配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加入 */
- $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'],',');
- }
- }
- }
- /* 匹配ID结束 */
- $q = '1;';
- $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
- $shop = $this->shop->read(19);
- if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
- {
- $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
- }
- $ed = array();
- foreach ($list as $v)
- {
- $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
- $p = '';
- $product = explode(';',trim($r['product'],';'));
- if($r['title'] != '' && $product)
- {
- foreach ($product as $val)
- {
- $vc = explode('|',$val);
- if(isset($vc[1]))
- {
- $p .= $vc[1].'<br>';
- }
- }
- $r['title'] = str_replace(array('<','>'),array('<','>'),$r['title']);
- $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
- }
- else
- {
- $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
- }
- }
-
-
- $time = date('Ymd',time());
- $title = 'sku转换'.$time;
- $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'sku转换 '.$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'=>'转换成功!','error'=>$error,'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);
- }
- }
|