123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- header("Access-Control-Allow-Origin: *");
- class Systemfout extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_productprice','productprice');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorderamz','fullorderamz');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_outbound','outbound');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_dhlhz','dhlhz');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_fedex','fedex');
- $this->load->_model('Model_fedex_cby','fedex_cby');
- $this->load->_model('Model_ups','ups');
- $this->load->_model('Model_ali','ali');
- $this->load->_model('Model_dpd','dpd');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_user','user');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_specialstock','specialstock');
- $this->load->_model('Model_ck','ck');
- $this->load->_model('Model_whlabellabel','whlabellabel');
- $this->load->_model('Model_apiyy','apiyy');
- $this->load->helper('url');
- $this->load->_model('Model_whlabel_fc','whlabel_fc');
- $this->load->_model('Model_systemtransfer','systemtransfer');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_allocation','allocation');
- $this->load->_model('Model_fullorderxw','fullorderxw');
- $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
- $this->load->_model("Model_logic_ding","logic_ding");
- $this->load->_model("Model_fedexv1",'fedexv1');
- $this->load->_model("Model_zzquque_u9","zzquque_u9");
- $this->load->_model("Model_customsdeclaration","customsdeclaration");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'fedexhz')
- {
- $this->_fedexhz();
- }
- else if($arg == 'fout')
- {
- $this->_fout($arg_array);
- }
- else if($arg == 'fouthb')//合并出库的
- {
- $this->_fouthb($arg_array);
- }
- else if($arg == 'excel')
- {
- $this->_excel($arg_array);
- }
- else if($arg == 'cpexcel')
- {
- $this->_cpexcel($arg_array);
- }
- else if($arg == 'orderyz')
- {
- $this->_orderyz();
- }
- else if($arg == 'hwyz')
- {
- $this->_hwyz();
- }
- else if($arg == 'outnumber')
- {
- $this->_outnumber();
- }
- else if($arg == 'hb')
- {
- $this->_hb();
- }
- else if($arg == 'indexmc'){
- $this->_indexmc();
- }
- else
- {
- $this->_index();
- }
- }
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- $xw = '';
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- if($user['userid'] == 'xw')
- {
- $xw = 1;
- }
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $library = $this->input->post('library',true);
- $waybill = $this->input->post('waybill',true);
- $express = $this->input->post('express',true);
- $type = $this->input->post('type',true);
- $lowe = $this->input->post('lowe',true);
- $so = $this->input->post('so',true);
- $is_jiaji = $this->input->post('is_jiaji',true);
- $librarytime = $this->input->post('librarytime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $cxtime = 'id';
- $where = "library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")";
- if($timetk && $timetj && $library == 1)
- {
- $tmp_timetj = time();
- //$cxtime = 'reviewtime';
- $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$tmp_timetj '";
- $where .= " and state != 217";
-
- }
- else if($timetk && $timetj && $library == 2)
- {
- $cxtime = 'librarytime';
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($lowe)
- {
- $where .= " and shipremarks like '%$lowe%'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($is_jiaji >-1){
- $where .= " and is_jiaji = ".$is_jiaji." ";
- }
- //数据排序
- $order_str = $cxtime." desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_list[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_list[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_list[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_list[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_list[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_list[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
- }
- $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']);
- }
-
- $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listtt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listtt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listtt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listtt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listtt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listtt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listtt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listtt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
-
- $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listamz as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listamz[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listamz[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listamz[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listamz[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listamz[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listamz[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listamz[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
-
-
- $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listxw as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listxw[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listxw[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listxw[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listxw[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listxw[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listxw[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listxw[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listsmt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listsmt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listsmt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listsmt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listsmt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listsmt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listsmt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listsmt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->fullorder->find_count($where);
- $total += $this->fullordertt->find_count($where);
- $total += $this->fullorderamz->find_count($where);
- $total += $this->fullorderxw->find_count($where);
- $total += $this->fullordersmt->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
- echo json_encode($rows);exit;
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $this->data['xw'] = $xw;
- $this->_Template('systemfout',$this->data);
- }
- public function _indexmc()
- {
- $post = $this->input->post(NULL, TRUE);
- $xw = '';
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- if($user['userid'] == 'xw')
- {
- $xw = 1;
- }
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }else{
- //未登录不允许访问
- header("location:/");
- exit;
- }
- $this->data['xw'] = $xw;
- $this->_Template('systemfoutmc',$this->data);
- }
- public function _fout()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['order']))
- {
- $time = time();
- $order = $this->input->post('order',true);
- $weight = $this->input->post('weight',true);
- if(!isset($weight))//测试没问题后可以删
- {
- $weight = '';
- }
- if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
- {
- $order = substr($order,0,12);
- }
- if(strlen($order) == '34')//联邦杭州超长运单截取
- {
- $str = substr($order, 0,3);
- if($str == "420"){
- $order = substr($order,12);
- }else{
- $order = substr($order,22,12);
- }
-
- }
- if(!$order)
- {
- echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
- }
- if(strlen($order) == 30)
- {
- $order = substr($order, 8);
- }
- $fullorder_name = 'fullorder';$outtype = 1;
- $y = $this->fullorder->get_waybill($order);
- // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
- // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
- if(!$y)
- {
- $y = $this->fullorder->get_number($order);
- $outtype = 2;
- // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
- // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
- if(!$y)
- {
- $fullorder_name = 'fullordersmt';$outtype = 1;
- $y = $this->fullordersmt->get_waybill($order);
- if(!$y)
- {
- $y = $this->fullordersmt->get_number($order);
- $outtype = 2;
- if(!$y)
- {
- $fullorder_name = 'fullordertt';$outtype = 1;
- $y = $this->fullordertt->get_waybill($order);
- if(!$y)
- {
- $y = $this->fullordertt->get_number($order);
- $outtype = 2;
- if(!$y)
- {
- $fullorder_name = 'fullorderamz';$outtype = 1;
- $y = $this->fullorderamz->get_waybill($order);
- if(!$y)
- {
- $y = $this->fullorderamz->get_number($order);
- $outtype = 2;
- if(!$y){
-
- $fullorder_name = 'fullorderxw';$outtype = 1;
- $y = $this->fullorderxw->get_waybill($order);
- if(!$y)
- {
- $y = $this->fullorderxw->get_number($order);
- $outtype = 2;
- if(!$y)
- {
- echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
- }
- }
- }
- }
-
-
-
-
-
-
- }
- }
- }
-
- }
- }
- }
- if($y['mergeid'] == '1')
- {
- $y = $this->$fullorder_name->read($y['merge']);
- }
- //云尚-FedEx普货专线 如果出库时打印的快递面单超过6天,不允许出库
- if($y['express'] == 75 && $outtype == 1){
- $printtime = $y['printtime'];
- $set_time = 24 * 60 * 60 * 6;
- $time = time();
- if(($time - $set_time) > $printtime){
- //允许出库状态
- if($y['libraryconfirm'] == 2){
- echo json_encode(array('msg'=>"该单超时,请重新打印后再出库。".$y['number'],'success'=>false));exit;
- }else{
- echo json_encode(array('msg'=>"该单超时且禁止出库,请联系梦体做后续处理!".$y['number'],'success'=>false));exit;
- }
-
- }
- }
- // 66 云途(欧洲) 67 云途(欧洲)-带保险 如果是欧洲云途 需要检擦出库时间是否超过15天
- if(in_array($y['express'],[66,67])){
- if((time() - $y['printtime']) >= (15*24*3600)){
- echo json_encode(array('msg'=>'运单超时!请联系梦体处理!','success'=>false));exit;
- }
- }
- $express = $this->express->read($y['express']);
- if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
- {
- $y['librarynot'] = '客户已取消!';
- }
- if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
- {
- echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
- }
- if($y['library'] > 1)
- {
- echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
- }
- if($express['out'] != 3)
- {
- if($express['out'] != $outtype)
- {
- $smlx = ($express['out']=='1')?'运单':'发货单';
- echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
- }
- }
- if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
- {
- $y['waybill'] = trim($y['waybill'],' ');
- if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 51 && $y['express'] != 63 && $y['express'] != 70 && $y['express'] != 71 && $y['express'] != 73 && $y['express'] != 74 && $y['express'] != 75 && $y['express'] != 78 && $y['express'] != 79)
- {
- echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
- }
- else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42 && $y['express'] != 69 && $y['express'] != 78 && $y['express'] != 79)
- {
- echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
- }
- else if(strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67 && $y['express'] != 72 && $y['express'] != 2)
- {
- echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
- }
- else if(strlen($y['waybill']) == 16 && $y['express'] != 76 && $y['express'] != 77 )
- {
- echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-4','success'=>false));exit;
- }
- }
- if(stripos($weight,',') !== false){
- $tmp_arr = explode(",",$weight);
- $weight = end($tmp_arr);
-
- $numweight = (float)$weight;
- $weight = $numweight."kg";
- }
- $numweight = str_replace('kg','',$weight);
- // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
- // {
- // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
- // {
- // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
- // }
- // $yzweight = explode('.',$numweight);
- // if($yzweight[0] == '')
- // {
- // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
- // }
- // if($numweight < ($y['jweight']/1000))
- // {
- // echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
- // }
- // if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
- // {
- // echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
- // }
- // if($numweight > '0.98' && $y['express'] == '3')
- // {
- // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
- // }
- // if($numweight > '2' && $y['express'] == '37')
- // {
- // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
- // }
- // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
- // {
- // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
- // }
- // }
-
- //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
- //还有翔文仓库的 不执行
- //源代码是
- //所有快递必须称重
- //所有快递必须称重 翔文除外
-
-
- //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
- if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65,74])){
- if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
- {
- echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
- }
- $yzweight = explode('.',$numweight);
- if($yzweight[0] == '')
- {
- echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
- }
- if(empty($numweight)){
- echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
- }
- //$this->logic_ding->sendToDing("检测订单---------------------标记需要认证的东西".$y['number']);
- }
- //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']);
- $express_info = $this->express->read($y['express']);
- if(empty($express_info)){
- echo json_encode(array('msg'=>'该快递信息异常,请联系技术!','success'=>false));exit;
- }
- $weight_limit = $express_info['weight_limit']*1;
- if($weight_limit > 0){
-
- $yzweight = explode('.',$numweight);
- if($yzweight[0] == '')
- {
- echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
- }
- if($numweight < ($y['jweight']/1000)){
- echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
- }
- //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
- if(in_array($y['express'],[3,24,42])){
- //规定实际重量不允许超过 净重为1kg
- if($numweight -($y['jweight']/1000) > 1 )
- {
- echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false));exit;
- }
- }
-
- if($weight_limit < $numweight){
- echo json_encode(array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false));exit;
- }
- }
-
-
- if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
- {
- //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
- }
- if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
- {
- //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
- echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
- }
- if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
- {
- //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
- }
-
- $this->db->trans_begin();
- $warehouse = $this->warehouse->read($y['type']);
- $bdck = $warehouse['bdck'];
- if($warehouse['zd'] == '1')
- {
- if($warehouse['bdck'] == '')
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
- }
- $wh = $this->_fout_db($y,$warehouse,$bdck);
- if($wh['fh'] == 2)
- {
- $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
- if($kcyz['t'] == '0')
- {
- if($kcyz['fpdata'] != '')
- {
- $x['whlabel'] = $kcyz['whlabel'];
- $x['fpdata'] = $kcyz['fpdata'];
- $y['whlabel'] = $x['whlabel'];
- $this->$fullorder_name->save($x,$y['id']);
- }
- }
- $wh = $this->_fout_db($y,$warehouse,$bdck);
- if($wh['fh'] == 2)
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
- }
- }
- foreach ($wh['sj'] as $v)
- {
- $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
- }
-
- }
- /**
- if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
- {
- $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
- $cpsl = 0;
- $pp = explode('|',trim($y['whlabel'],'|'));
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- $cpsl += $num[1];
- }
- if(count($whlabel) != $cpsl)
- {
- echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
- }
- foreach ($whlabel as $v)
- {
- $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
- }
- }
- if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
- {
- $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
- $cpsl = 0;
- $pp = explode('|',trim($y['whlabel'],'|'));
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- if(stripos($num[2],'z') !== false)//如果是特殊库存
- {
- $cpsl += $num[1];
- }
- }
- if(count($wh) != $cpsl)
- {
- echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
- }
- foreach ($wh as $v)
- {
- if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
- {
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
- }
- }
- }
- **/
- /**
- if($y['dbapi'] == 99 && $y['scapi'] == 99)
- {
- $d = $this->apiyy->get_chd($y);
- if($d['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
- }
- }
- $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
- if(isset($systemtransfer[0]))
- {
- foreach ($systemtransfer as $v)
- {
- if($v['dbapi'] != 99)
- {
- echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
- }
- }
- $y['ts'] = count($systemtransfer);
- $d = $this->apiyy->get_chd($y);
- if($d['Data'][0]['m_isSucess'] != 1)
- {
- echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
- }
- }
- **/
-
- $shop = $this->shop->read($y['shop']);
- if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
- {
- $type = $this->typeclass->read($shop['type']);
- $y['shoptype'] = $type['title'];
- $y['weight'] = $weight;
- $d = $this->dhl->get_data_9610($y);
- if($d != 1)
- {
- $this->db->trans_rollback();
- $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
- echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
- }
- $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
- }
- if($fullorder_name == 'fullordersmt')
- {
- $stt = ($y['waybill']!='')?209:$y['state'];
- $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
- /**
- if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
- {
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
- }
- **/
- }
- else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
- {
- /**
- if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
- {
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
- }
- **/
- $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
- }
- else
- {
- /**
- if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
- {
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
- }
- **/
- $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
- }
- /**
- if($fullorder_name == 'fullorder')
- {
- $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
- $post['incrementId'] = $orderinfo;
- $post['trackingNumber'] = $y['waybill'];
- $ex = $this->express->read($y['express']);
- $post['carrier'] = $ex['iscode'];
- $url = 'https://www.romandhair.com/applepay/payment/addTrack';
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- if($res['success'] == 0)
- {
- $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
- }
- else
- {
- $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
- }
- }
- **/
- //开始录入执行u9队列的数据
-
- $queue_u9_list = [];
- $queue_u9_list[] = [
- 'platform'=>$fullorder_name,
- 'warehouse'=>$y['type'],
- 'type'=>($y['type'] == 5)?11:10, //5代表美仓
- 'order_no'=>$y['number'],
- 'status'=>0,
- 'create_time'=>time(),
- 'update_time'=>time(),
- ];
- //将要执行的队列数据添加进去
- foreach($queue_u9_list as $item){
- if($item['platform'] != 'fullorderxw'){
- // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
- // $this->zzquque_u9->insert($item);
- // }
- if( !in_array($item['warehouse'],[5,7,8,9]) ){
- $this->zzquque_u9->insert($item);
- }
- }
-
- }
- $this->logic_ding->sendToDing("u9小单队列监听数据".json_encode($queue_u9_list,JSON_UNESCAPED_UNICODE));
- if($outtype == 2 && $y['printnumber'] > 1)
- {
- $p = json_encode($post);
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
- }
- $this->$fullorder_name->save($post,$y['id']);
-
- //合并订单自动发货
- $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
- $post['waybill'] = $y['waybill'];
- $post['express'] = $y['express'];
- $post['printtype'] = $y['printtype'];
- $post['ioss'] = $y['ioss'];
- $post['review'] = 6;
- $post['bx'] = $y['bx'];
- $post['qm'] = $y['qm'];
- $post['js'] = $y['js'];
- //$post['state'] = 216;
- $post['print'] = $y['print'];
- $post['printtime'] = $y['printtime'];
- $post['library'] = 2;
- $post['librarytime'] = $time;
- $post['libraryconfirm'] = 2;
- $post['librarynot'] = '';
- foreach ($hb as $v)
- {
- $post['state'] = $v['state'];
- $vshop = $this->shop->read($v['shop']);
- $vwarehouse = $this->warehouse->read($v['type']);
- $this->$fullorder_name->save($post,$v['id']);
- //2025年1月25日发现翔文合并订单发现此问题
- if($warehouse['zd'] == '1'){
- $wh = $this->_fout_db($v,$warehouse,$bdck);
- foreach ($wh['sj'] as $vv)
- {
- $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
- }
- }
- }
-
-
-
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
-
- echo json_encode(array('success'=>true));
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
- }
- }
- }
-
- //之所以用订单已占的库存,就循环更新 为什么不用全部检索是因为牵扯到可能是工厂有可能直接生产后 带到成品库 不入成品库 可能会直接发走,所以只检索已占库存的订单 然后更新
- public function _outnumber()//对比占单是否正确
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['outnumber']))
- {
- $post = $this->input->post('post',true);
- $fullorder_name = $this->input->post('fullorder_name',true);
- $outnumber = $this->input->post('outnumber',true);
- $post = json_decode($post,true);
- $y = $this->$fullorder_name->read($outnumber);
- if(empty($y)){
- echo json_encode(array('msg'=>'订单异常不能出库','success'=>false));exit;
- }
- $warehouse = $this->warehouse->read($y['type']);
- if(empty($warehouse)){
- echo json_encode(array('msg'=>'仓库异常不能出库','success'=>false));exit;
- }
- if($y['library']== 2){
- echo json_encode(array('msg'=>'订单已出库,请勿重复出库','success'=>false));exit;
- }
- if($y['library']== 3){
- echo json_encode(array('msg'=>'订单已退库,请勿重复出库','success'=>false));exit;
- }
- $bdck = $warehouse['bdck'];
- if(!empty($bdck)){
-
- // $warehouse = $this->warehouse->read($y['type']);
- $list = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
- $this->db->trans_begin();
- foreach ($list as $v)
- {
- $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$post['librarytime'],'time'=>$post['librarytime']),$v['id']);
- }
- $this->$fullorder_name->save($post,$y['id']);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- if($fullorder_name != 'fullorderxw'){
- // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
- // $this->zzquque_u9->insert($item);
- // }
- $y = $this->$fullorder_name->read($outnumber);
- if( !in_array($y['type'],[5,7,8,9]) ){
- $data = [
- 'platform'=>$fullorder_name,
- 'warehouse'=>$y['type'],
- 'type'=>($y['type'] == 5)?11:10, //5代表美仓
- 'order_no'=>$y['number'],
- 'status'=>0,
- 'create_time'=>time(),
- 'update_time'=>time(),
- ];
- $this->zzquque_u9->insert($data);
- }
- }
- echo json_encode(array('success'=>true));
- die;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
- die;
- }
- }else{
- $this->$fullorder_name->save($post,$y['id']);
-
- if($fullorder_name != 'fullorderxw'){
- // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
- // $this->zzquque_u9->insert($item);
- // }
- $y = $this->$fullorder_name->read($outnumber);
- if( !in_array($y['type'],[5,7,8,9]) ){
- $data = [
- 'platform'=>$fullorder_name,
- 'warehouse'=>$y['type'],
- 'type'=>($y['type'] == 5)?11:10, //5代表美仓
- 'order_no'=>$y['number'],
- 'status'=>0,
- 'create_time'=>time(),
- 'update_time'=>time(),
- ];
- $this->zzquque_u9->insert($data);
- }
- }
- echo json_encode(array('success'=>true));
- die;
-
- }
-
-
-
-
- }else{
- echo json_encode(array('msg'=>'传参异常,请重试','success'=>false));
- die;
- }
- }
- public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
- {
-
- $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
- $cpsl = 0;
- $pp = explode('|',trim($y['whlabel'],'|'));
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- if(isset($num[2]))
- {
- if(stripos($num[2],$warehouse['hz']) !== false)
- {
- $cpsl += $num[1];
- }
- }
- }
- if(count($wh) == $cpsl)
- {
- return array('fh'=>1,'sj'=>$wh);
- }
- else
- {
- return array('fh'=>2);
- }
- }
-
- public function _fedexhz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $fullorder_name = $this->input->post('name',true);
- $express = $this->input->post('express',true);
- $express = $this->express->read($express);
- $fullorder = $this->$fullorder_name->read($id);
- if($fullorder['type'] == '2')
- {
- $fullorder['type'] = 1;
- }
- $time = time();
- $fullorder = $this->_text($fullorder);//获取所需信息
- $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
- $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
- $time = time();
- if($express['printcode'] == "FEDEXGF")
- {
- //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
- //升级的api
- $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
- if($barcode['x'] == 1)
- {
- $bctime = date('Ymd',$time);
- $Hwaybill = $barcode['waybill'];
- // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
- // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
- $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
- $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
- if(isset($barcode['label']) && isset($Hwaybill))
- {
- if($fullorder['waybill'] != "")
- {
- $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
- }
- else
- {
- $oldwaybill = $fullorder['oldwaybill'];
- }
- $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
- $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
- if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
- {
- $warehouse = $this->warehouse->read($fullorder['type']);
- $text = array();
- $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
- $text['number'] = $fullorder['number'];
- $text['mode'] = '95';
- $text['pdfnum'] = 1;
- $rows = array('text'=>$text);
- echo json_encode(array('rows'=>($rows),'success'=>true));exit;
- }
- else
- {
- echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
- }
- }
- }
- else
- {
- echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
- }
- }
- else if($express['printcode'] == "UPS")//接口UPS暂时不打
- {
- echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
- $barcode = $this->ups->get_data($fullorder);//获取快递信息
- if($barcode['x'] == 1)
- {
- $bctime = date('Ymd',$time);
- $Hwaybill = $barcode['waybill'];
- $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
- if(isset($barcode['label']) && isset($Hwaybill))
- {
- if($fullorder['waybill'] != "")
- {
- $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
- }
- else
- {
- $oldwaybill = $fullorder['oldwaybill'];
- }
- $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
- $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
- if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
- {
- $type = 1;
- $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
- }
- }
- }
- else
- {
- echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
- }
- }
- else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
- {
- $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
- if($barcode['c'] == 1)
- {
- $bctime = date('Ymd',$time);
- $Hwaybill = $barcode['data']['waybill'];
- $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
- $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
- if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
- {
- if($fullorder['waybill'] != "")
- {
- $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
- }
- else
- {
- $oldwaybill = $fullorder['oldwaybill'];
- }
- $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
- $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
- if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
- {
- $warehouse = $this->warehouse->read($fullorder['type']);
- $text = array();
- $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
- $text['number'] = $fullorder['number'];
- $text['mode'] = '95';
- $text['pdfnum'] = 1;
- $rows = array('text'=>$text);
- echo json_encode(array('rows'=>($rows),'success'=>true));exit;
- }
- }
- }
- else
- {
- echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
- }
- }
- }
-
- public function _text($fullorder)
- {
- /** 发票地址信息暂时无用
- $fullorder['baddress'] = explode(',',$fullorder['baddress']);
- $fullorder['baddress'] = array_reverse($fullorder['baddress']);
- $fullorder['baddress'][1] = $country['ename'];
- **/
- //获取所用相关信息
- $warehouse = $this->warehouse->read($fullorder['type']);
- $country = $this->country->read($fullorder['country']);//订单国家信息
- $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
- $warehouse['country'] = $fcountry['ename'];//仓库国家名
- $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
- $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
- $fullorder['lb'] = $country['lb'];//订单国家编码加入
- $fullorder['country'] = $country['ename'];//订单国家名
- $fullorder['zhou'] = $country['continent'];//所属州
- $express = $this->express->read($fullorder['express']);
- $fullorder['express'] = $express['servicename'];
- $fullorder['account'] = $express['account'];
- $fullorder['printcode'] = $express['printcode'];
- $fullorder['time'] = date('Y-m-d',time());
- $fullorder['times'] = date('Y-m-d H:i',time());
- //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
- // 修复报关编码问题
- $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
-
- $sbbm = "";
- if(empty($declara_info)){
- $sbbm = "";
- }else{
- $sbbm = $declara_info['bname'];
- }
-
- $fullorder['sbbm']= $sbbm;
-
- $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']);
- $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']);
- $shop = $this->shop->read($fullorder['shop']);
- $fullorder['shop'] = $shop['shopname'];
- return $fullorder;
- }
-
- public function _lowe()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['lowe']))
- {
- $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
- echo json_encode(array('msg'=>$lowe));exit;
- }
- }
- public function _pdf($pdf,$title,$bctime)
- {
- $pdf_path = './data/pdf/'.$bctime.'/';
- $file_base64 = $pdf;
- $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
- $file_base64 = base64_decode($file_base64);
- if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
- file_put_contents($pdf_path.$title.'.pdf',$file_base64);
- return $bctime;
- }
- public function _pdfurl($pdf,$title,$bctime)
- {
- $pdf_path = './data/pdf/'.$bctime.'/';
- $pdf = fopen($pdf,"r");
- if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
- file_put_contents($pdf_path.$title.'.pdf',$pdf);
- return $bctime;
- }
-
- public function _excel()
- {
- $xw = '';
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- if($user['userid'] == 'xw')
- {
- $xw = 1;
- }
- }
- if(isset($_GET['fexcel']))
- {
- $dowid = $this->input->get('a');
- $wid = "";
- if($dowid != "")
- {
- $id_arr = explode(',',rtrim($dowid,','));
- foreach ($id_arr as $v)
- {
- $wid .= " id = '$v' or";
- }
- $wid = " and".rtrim($wid,'or');
- }
- $t = $this->input->get('t',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);
- $orderinfo = $this->input->get('orderinfo',true);
- $number = $this->input->get('number',true);
- $library = $this->input->get('library',true);
- $waybill = $this->input->get('waybill',true);
- $express = $this->input->get('express',true);
- $type = $this->input->get('type',true);
- $so = $this->input->get('so',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
- if($timetk && $timetj && $library == 1)
- {
- //$cxtime = 'reviewtime';
- $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
- $where .= " and state != 217";
-
- }
- else if($timetk && $timetj && $library == 2)
- {
- $cxtime = 'librarytime';
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- /**
- $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
- if($timetk && $timetj && $library == 1)
- {
- //$cxtime = 'reviewtime';
- //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- else if($timetk && $timetj && $library == 2)
- {
- $cxtime = 'librarytime';
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- **/
- if(isset($_SESSION['api']))
- {
- if($type)
- {
- $where .= " and type = '$type'";
- }
- else
- {
- $uw = '';
- $u = $this->user->get_api($_SESSION['api']);
- $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
- foreach ($u['warehouse'] as $v)
- {
- $uw .= " type = '$v' or";
- }
- $uw = rtrim($uw,'or');
- $uw = " and (".ltrim($uw,' ').")";
- $where .= $uw;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- //数据排序
- //$order_str = ($print != 3)?"id desc":"librarytime desc";
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $typeclass = array();
- $tclass = $this->typeclass->find_all();
- foreach ($tclass as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_list[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_list[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_list[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_list[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_list[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_list[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
-
- $classid = $classid = $this->classid->sku();
- $dbapi = explode(';',trim($value['fpdata'],';'));
- $tmp_jm = "";
- $tmp_zh = "";
- 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);
- $tmp_jm .= $jm.";";
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- $tmp_zh .= $zh.";";
- }
- $info_list[$key]['jm'] = trim($tmp_jm,';');
- $info_list[$key]['zh'] = trim($tmp_zh,';');
- }
- //取得信息列表
- $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
- //格式化数据
- foreach ($info_listsmt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listsmt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listsmt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listsmt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listsmt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listsmt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listsmt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listsmt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $classid = $classid = $this->classid->sku();
- $dbapi = explode(';',trim($value['fpdata'],';'));
- $tmp_jm = "";
- $tmp_zh = "";
- 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);
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- $tmp_jm .= $jm.";";
- $tmp_zh .= $zh.";";
- }
- $info_listsmt[$key]['jm'] = trim($tmp_jm,';');
- $info_listsmt[$key]['zh'] = trim($tmp_zh,';');
-
- }
- //取得信息列表
- $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
- //格式化数据
- foreach ($info_listtt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listtt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listtt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listtt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listtt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listtt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listtt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listtt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $classid = $classid = $this->classid->sku();
- $tmp_jm = "";
- $tmp_zh = "";
- $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);
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- $tmp_jm .= $jm.";";
- $tmp_zh .= $zh.";";
- }
- $info_listtt[$key]['jm'] = trim($tmp_jm,';');
- $info_listtt[$key]['zh'] = trim($tmp_zh,';');
- }
-
-
- //取得信息列表
- $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
- //格式化数据
- foreach ($info_listamz as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listamz[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listamz[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listamz[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listamz[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listamz[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listamz[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listamz[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $classid = $classid = $this->classid->sku();
- $dbapi = explode(';',trim($value['fpdata'],';'));
- $tmp_jm = "";
- $tmp_zh = "";
- 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);
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- $tmp_jm .= $jm.";";
- $tmp_zh .= $zh.";";
- }
- $info_listamz[$key]['jm'] = trim($tmp_jm,';');
- $info_listamz[$key]['zh'] = trim($tmp_zh,';');
- }
-
-
-
-
- //取得信息列表
- $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
- //格式化数据
- foreach ($info_listxw as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listxw[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listxw[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listxw[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listxw[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listxw[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listxw[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listxw[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $classid = $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);
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- }
- $info_listxw[$key]['jm'] = $jm;
- $info_listxw[$key]['zh'] = $zh;
- }
- $title = '订单出库-'.date('Ymd',time());
- $t = str_replace("<td>运单号</td>","<td>运单号</td><td>转单号</td>",$t);
- $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
- }
- }
-
- public function _cpexcel()
- {
- 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['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $library = $this->input->get('library',true);
- $type = $this->input->get('type',true);
- $number = $this->input->get('number',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $so = $this->input->get('so',true);
- $number = $this->input->get('number',true);
- $express = $this->input->get('express',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = 0";
- if($timetk && $timetj && $library == 2)
- {
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- else
- {
- $where .= " and printtime > '$timetk' and printtime < '$timetj'";
- }
- if(isset($_SESSION['api']))
- {
- if($type)
- {
- $where .= " and type = '$type'";
- }
- else
- {
- $uw = '';
- $u = $this->user->get_api($_SESSION['api']);
- $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
- foreach ($u['warehouse'] as $v)
- {
- $uw .= " type = '$v' or";
- }
- $uw = rtrim($uw,'or');
- $uw = " and (".ltrim($uw,' ').")";
- $where .= $uw;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- else
- {
- $where .= " and ".$excelshop;
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- /* 匹配ID加入 */
- $tc = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- $tc[$v['id']] = $v['title'];
- }
- $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
- //取得信息列表
- $info_lista = $this->fullordersmt->find_all($where,'fpdata');
- $info_listb = $this->fullorder->find_all($where,'fpdata');
- $info_list = array_merge($info_lista,$info_listb);
- //格式化数据
- $i = 0;$cpexcel = array();
- foreach ($info_list as $key=>$value)
- {
- if(stripos($value['fpdata'],';') !== false)
- {
- $fpdata = explode(';',rtrim($value['fpdata'],';'));
- foreach ($fpdata as $ke=>$va)
- {
- $title = '';
- $fg = explode('|',$va);
- $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
- $cp = explode('-',rtrim($fg[0],'-'));
- $dj = $tc[$cp[2]];
- if(!isset($cp[3]))
- {
- $ys = json_encode($cp);
- }
- else
- {
- $ys = $tc[$cp[3]];
- }
- unset($cp[0],$cp[1],$cp[2],$cp[3]);
- foreach ($cp as $v)
- {
- $title .= $tc[$v].' ';
- }
- $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
- }
- }
- $i++;
- }
- $title = "统计信息";
- $titlename = "<table border=1>
- <tr>
- <td>尺寸</td>
- <td>等级</td>
- <td>颜色</td>
- <td>花型</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "\n";
- $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
- }
- }
- public function _orderyz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['yz']))
- {
- $yz = $this->input->post('yz',true);
- $number = $this->input->post('number',true);
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- $whlabel = explode('|',trim($y['whlabel'],'|'));
- foreach($whlabel as $k=>$v)
- {
- $w = explode('-',trim($v,'-'));
- $wldata[$w[0]] = $w;
- }
- $whlabellabel = $this->whlabellabel->get_label($yz);
- if(!$whlabellabel)
- {
- echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
- }
- else
- {
- if(isset($wldata[$whlabellabel['number']]))
- {
- if(!isset($wldata[$whlabellabel['number']][2]))
- {
- echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
- }
- else if($wldata[$whlabellabel['number']][2] == 0)
- {
- echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
- }
- echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
-
- }
- }
- if(isset($post['number']))
- {
- $number = $this->input->post('number',true);
- $f = 'fullorder';
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $f = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- if($y['librarytime'] > 0)
- {
- echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
- }
- $warehouse = $this->warehouse->read($y['type']);
- if(stripos($y['whlabel'],$warehouse['hz']) === false)
- {
- echo json_encode(array('msg'=>'pz','success'=>false));exit;
- }
- $data = explode('|',trim($y['whlabel'],'|'));
- $fpdata = explode(';',trim($y['fpdata'],';'));
- $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
- foreach($fpdata as $val)
- {
- $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $fp = explode('|',$val);
- $fp[0] = str_replace(',','-',$fp[0]);
- $value = explode('-',$fp[0]);
- foreach($value as $v)
- {
- $typeclass = $this->typeclass->read($v);
- $zh = explode('|',trim($typeclass['zh'],'|'));
- $pm[$typeclass['classid']] = $zh[0];
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- }
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $data[$i] = explode('-',$data[$i]);
- for($j=0;$j<$data[$i][1];$j++)
- {
- if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
- {
- $znum++;//只计算现货
- //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
- $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
- }
- else
- {
- //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
- $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
- }
- $x++;//所有数量
- }
- $i++;
- }
- //ksort($cp);//区别位置模式,暂不使用
- $cp = array_values($cp);
- if($this->$f->save(array('yhs'=>1),$y['id']))
- {
- echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
- }
- }
- if(isset($post['tid']))
- {
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach($tc as $v)
- {
- $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
- }
- $tid = $this->input->post('tid',true);
- $id = $this->input->post('id',true);
- $number = $this->input->post('n',true);
- $ful = 'fullorder';
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $ful = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- $wtid = $this->whlabellabel->get_label($tid);
- if(!$wtid)
- {
- echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
- }
- $whlabel = explode('|',trim($y['whlabel'],'|'));
- $fpdata = explode(';',trim($y['fpdata'],';'));
- $warehouse = $this->warehouse->read($y['type']);
- $zdkc = $warehouse['bdck'];
- $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
- $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
- if((count($ptc)+count($zsc)) < 1)
- {
- echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
- }
- $this->db->trans_begin();
- $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
- if($zsc)
- {
- $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
- $xrid = $zsc[0]['id'];
- }
- else if($ptc)
- {
- $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
- $xrid = $ptc[0]['id'];
- }
- $xr = $this->$zdkc->read($xrid);
- $features = explode('-',trim($xr['features'],'-'));
- $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
- foreach($features as $kk=>$v)
- {
- if($typeclass[$v]['classid'] == 14)
- {
- $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
- unset($kk);
- }
- }
- $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
- $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
- $wldata = array();
- $fdata = array();
- foreach($whlabel as $k=>$v)
- {
- $w = explode('-',trim($v,'-'));
- $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
- }
- if(!isset($wldata[$id]))
- {
- echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
- }
- if(isset($wldata[$wtid['number']]['sj']))
- {
- $tw = $wldata[$wtid['number']]['sj'];
- if($wtid['number'] != $id)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
- }
- else
- {
- if(isset($tw[2]) && $tw[2] != 0)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
- }
- }
- if($tw[1] > 1)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
- }
-
- }
- $thfpdata = $y['thfpdata'];
- $w = $wldata[$id]['sj'];
- $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
- $zdkc = $warehouse['bdck'];
- if($w[1] > 1)
- {
- if(isset($w[2]) && $w[2] != 0)
- {
- $hz = explode('~',trim($w[2],'~'));
- $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
- $zd = str_replace($hz[0],'',$w[2]);
- $zd = trim($zd,'~');
- $w[2] = $zd;
- }
- foreach($w as $kk=>$v)
- {
- if($kk == 1)
- {
- $v = $v-1;
- }
- $ww .= $v .'-';
- }
- $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
- foreach($f as $kk=>$v)
- {
- if($kk == 2)
- {
- $v = $v-1;
- $thff .= '1|';
- }
- else
- {
- $thff .= $v .'|';
- }
- $ff .= $v .'|';
- }
- $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
- $thfpdata .= trim($thff,'|');
- }
- else
- {
- $thfpdata .= $fpdata[$wldata[$id]['wz']];
- unset($whlabel[$wldata[$id]['wz']]);
- unset($fpdata[$wldata[$id]['wz']]);
- }
- $thfpdata .= '~'.$dataf;
- $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
- $fpdata = implode(";",$fpdata).';'.$dataf;
- $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
- }
- }
- if(isset($post['yhs']))
- {
- $f = 'fullorder';
- $number = $this->input->post('yhs',true);
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $f = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- }
- if($this->$f->save(array('yhs'=>0),$y['id']))
- {
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $this->_Template('systemfout_orderyz',$this->data);
- }
-
-
-
- public function _hwyz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['yz']))
- {
- $yz = $this->input->post('yz',true);
- $number = $this->input->post('number',true);
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- $whlabel = explode('|',trim($y['whlabel'],'|'));
- foreach($whlabel as $k=>$v)
- {
- $w = explode('-',trim($v,'-'));
- $wldata[$w[0]] = $w;
- }
- $whlabellabel = $this->whlabellabel->get_label($yz);
- if(!$whlabellabel)
- {
- echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
- }
- else
- {
- if(isset($wldata[$whlabellabel['number']]))
- {
- if(!isset($wldata[$whlabellabel['number']][2]))
- {
- echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
- }
- else if($wldata[$whlabellabel['number']][2] == 0)
- {
- echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
- }
- echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
-
- }
- }
- if(isset($post['number']))
- {
- $number = $this->input->post('number',true);
- $f = 'fullorder';
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $f = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- if($y['librarytime'] > 0)
- {
- echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
- }
- $warehouse = $this->warehouse->read($y['type']);
- $data = explode('|',trim($y['whlabel'],'|'));
- $fpdata = explode(';',trim($y['fpdata'],';'));
- $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
- foreach($fpdata as $val)
- {
- $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $fp = explode('|',$val);
- $fp[0] = str_replace(',','-',$fp[0]);
- $value = explode('-',$fp[0]);
- foreach($value as $v)
- {
- $typeclass = $this->typeclass->read($v);
- $zh = explode('|',trim($typeclass['zh'],'|'));
- $pm[$typeclass['classid']] = $zh[0];
- $scsku[$typeclass['classid']] = $typeclass['bqsku'];
- }
- $scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $scsku = str_replace('- ','-',trim($scsku,'-'));
- $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
- $data[$i] = explode('-',$data[$i]);
- for($j=0;$j<$data[$i][1];$j++)
- {
- if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
- {
- $znum++;//只计算现货
- //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
- $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
- }
- else
- {
- //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
- $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
- }
- $x++;//所有数量
- }
- $i++;
- }
- //ksort($cp);//区别位置模式,暂不使用
- $cp = array_values($cp);
- if($this->$f->save(array('yhs'=>1),$y['id']))
- {
- if(stripos($y['whlabel'],$warehouse['hz']) === false)
- {
- echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
- }
- echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
- }
- }
- if(isset($post['tid']))
- {
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach($tc as $v)
- {
- $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
- }
- $tid = $this->input->post('tid',true);
- $id = $this->input->post('id',true);
- $number = $this->input->post('n',true);
- $ful = 'fullorder';
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $ful = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- if(!$y)
- {
- echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
- }
- }
- $wtid = $this->whlabellabel->get_label($tid);
- if(!$wtid)
- {
- echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
- }
- $whlabel = explode('|',trim($y['whlabel'],'|'));
- $fpdata = explode(';',trim($y['fpdata'],';'));
- $warehouse = $this->warehouse->read($y['type']);
- $zdkc = $warehouse['bdck'];
- $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
- $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
- if((count($ptc)+count($zsc)) < 1)
- {
- echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
- }
- $this->db->trans_begin();
- $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
- if($zsc)
- {
- $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
- $xrid = $zsc[0]['id'];
- }
- else if($ptc)
- {
- $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
- $xrid = $ptc[0]['id'];
- }
- $xr = $this->$zdkc->read($xrid);
- $features = explode('-',trim($xr['features'],'-'));
- $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
- foreach($features as $kk=>$v)
- {
- if($typeclass[$v]['classid'] == 14)
- {
- $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
- unset($kk);
- }
- }
- $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
- $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
- $wldata = array();
- $fdata = array();
- foreach($whlabel as $k=>$v)
- {
- $w = explode('-',trim($v,'-'));
- $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
- }
- if(!isset($wldata[$id]))
- {
- echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
- }
- if(isset($wldata[$wtid['number']]['sj']))
- {
- $tw = $wldata[$wtid['number']]['sj'];
- if($wtid['number'] != $id)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
- }
- else
- {
- if(isset($tw[2]) && $tw[2] != 0)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
- }
- }
- if($tw[1] > 1)
- {
- echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
- }
-
- }
- $thfpdata = $y['thfpdata'];
- $w = $wldata[$id]['sj'];
- $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
- $zdkc = $warehouse['bdck'];
- if($w[1] > 1)
- {
- if(isset($w[2]) && $w[2] != 0)
- {
- $hz = explode('~',trim($w[2],'~'));
- $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
- $zd = str_replace($hz[0],'',$w[2]);
- $zd = trim($zd,'~');
- $w[2] = $zd;
- }
- foreach($w as $kk=>$v)
- {
- if($kk == 1)
- {
- $v = $v-1;
- }
- $ww .= $v .'-';
- }
- $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
- foreach($f as $kk=>$v)
- {
- if($kk == 2)
- {
- $v = $v-1;
- $thff .= '1|';
- }
- else
- {
- $thff .= $v .'|';
- }
- $ff .= $v .'|';
- }
- $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
- $thfpdata .= trim($thff,'|');
- }
- else
- {
- $thfpdata .= $fpdata[$wldata[$id]['wz']];
- unset($whlabel[$wldata[$id]['wz']]);
- unset($fpdata[$wldata[$id]['wz']]);
- }
- $thfpdata .= '~'.$dataf;
- $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
- $fpdata = implode(";",$fpdata).';'.$dataf;
- $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
- if ($this->db->trans_status() === TRUE)
- {
- $this->db->trans_commit();
- echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
- }
- }
- if(isset($post['yhs']))
- {
- $f = 'fullorder';
- $number = $this->input->post('yhs',true);
- $y = $this->fullorder->get_number($number);
- if(!$y)
- {
- $f = 'fullordersmt';
- $y = $this->fullordersmt->get_number($number);
- }
- if($this->$f->save(array('yhs'=>0),$y['id']))
- {
- echo json_encode(array('success'=>true));exit;
- }
- else
- {
- echo json_encode(array('success'=>false));exit;
- }
- }
- $this->_Template('systemfout_hwyz',$this->data);
- }
-
-
- public function _fouthb()
- {
- $post = $this->input->post(NULL, TRUE);
- $xw = '';
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- if($user['userid'] == 'xw')
- {
- $xw = 1;
- }
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $type = $this->input->post('type',true);
- $express = $this->input->post('express',true);
- $number = $this->input->post('number',true);
- $waybill = $this->input->post('waybill',true);
- $librarytime = $this->input->post('librarytime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = '1'";
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($number)
- {
- $where .= " and number like '$number%'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
- }
- $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listtt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listtt[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_listtt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listtt[$key]['type'] = $warehouse['title'];
- $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
-
-
- $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listamz as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listamz[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_listamz[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listamz[$key]['type'] = $warehouse['title'];
- $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
-
-
- $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listxw as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listxw[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_listxw[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listxw[$key]['type'] = $warehouse['title'];
- $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listsmt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listsmt[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_listsmt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listsmt[$key]['type'] = $warehouse['title'];
- $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- $total = $this->fullorder->find_count($where);
- $total += $this->fullordertt->find_count($where);
- $total += $this->fullorderamz->find_count($where);
- $total += $this->fullorderxw->find_count($where);
- $total += $this->fullordersmt->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
- echo json_encode($rows);exit;
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $this->data['xw'] = $xw;
- $this->_Template('systemfout_fouthb',$this->data);
- }
-
-
- public function _hb()
- {
- $post = $this->input->post(NULL, TRUE);
- $xw = '';
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " type = ".$value." or";
- }
- if($user['userid'] == 'xw')
- {
- $xw = 1;
- }
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $library = $this->input->post('library',true);
- $waybill = $this->input->post('waybill',true);
- $express = $this->input->post('express',true);
- $type = $this->input->post('type',true);
- $lowe = $this->input->post('lowe',true);
- $so = $this->input->post('so',true);
- $librarytime = $this->input->post('librarytime',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $cxtime = 'id';
- $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
- if($timetk && $timetj && $library == 1)
- {
- //$cxtime = 'reviewtime';
- $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
- $where .= " and state != 217";
-
- }
- else if($timetk && $timetj && $library == 2)
- {
- $cxtime = 'librarytime';
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($lowe)
- {
- $where .= " and shipremarks like '%$lowe%'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- //数据排序
- $order_str = $cxtime." desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_list[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_list[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_list[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_list[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_list[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_list[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
- }
- $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('<','>'),$value['orderremarks']);
- }
- $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listtt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listtt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listtt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listtt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listtt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listtt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listtt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listtt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
-
-
- $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listamz as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listamz[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listamz[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listamz[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listamz[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listamz[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listamz[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listamz[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
-
-
-
- $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listxw as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listxw[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listxw[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listxw[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listxw[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listxw[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listxw[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listxw[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_listsmt as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_listsmt[$key]['shop'] = $shop['shopname'];
- if($value['waybill'] == '0')
- {
- $info_listsmt[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_listsmt[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_listsmt[$key]['type'] = $warehouse['title'];
- if($value['print'] == 1)
- {
- $info_listsmt[$key]['print'] = '不可打印';
- }
- else if($value['print'] == 2)
- {
- $info_listsmt[$key]['print'] = '未打印';
- }
- else if($value['print'] == 3)
- {
- $info_listsmt[$key]['print'] = '已打印';
- }
- if($value['library'] == 1)
- {
- $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
- }
- else if($value['library'] == 2)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
- }
- else if($value['library'] == 3)
- {
- $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
- }
- if($value['librarytime'] == '0')
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->fullorder->find_count($where);
- $total += $this->fullordertt->find_count($where);
- $total += $this->fullorderamz->find_count($where);
- $total += $this->fullorderxw->find_count($where);
- $total += $this->fullordersmt->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt)));
- echo json_encode($rows);exit;
- }
- if(isset($_SESSION['api']))
- {
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['wlshop'] = $wlshop;
- $this->data['warehouse'] = $warehouse;
- }
- $this->data['xw'] = $xw;
- $this->_Template('systemfout_hb',$this->data);
- }
- }
|