123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358 |
- <?php
- /**
- * lionfish 商城系统
- *
- *
- * @author fish
- *
- */
- namespace Seller\Controller;
- use Admin\Model\OrderModel;
- class OrderController extends CommonController{
-
- protected function _initialize(){
- parent::_initialize();
-
- }
-
- public function index(){
- $time = I('request.time');
-
- $s_time_start = I('request.time_start');
- $s_time_end = I('request.time_end');
-
- //var_dump($s_time,2);die();
-
- if( isset($s_time_start) && !empty($s_time_start) )
- {
- $time['start'] = $s_time_start;
- $time['end'] = $s_time_end;
- }
-
- $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
- $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
-
-
-
- $this->searchfield = I('request.searchfield','');
- $this->keyword = I('request.keyword','');
- $this->searchtime = I('request.searchtime','');
- $this->delivery = I('request.delivery','');
- $this->starttime = $starttime;
- $this->endtime = $endtime;
- $this->time = $time;
-
- //重置缓存
- $day_time = strtotime( date('Y-m-d '.'00:00:00') );
- $day_key = 'new_ordernotice_'.$day_time;
- S( $day_key, array() );
-
- $order_status_id = I('request.order_status_id',0);
-
- $order_status_arr = D('Seller/Order')->get_order_status_name();
-
- $this->order_status_arr = $order_status_arr;
-
- $is_soli_type = I('request.type', '');// isset($_GPC['type']) && $_GPC['type'] == 'soli' ? 1: 0;
-
- $is_soli = 0;
- if($is_soli_type == 'soli')
- {
- $is_soli = 1;
- }
- //soli
- $_GPC['is_soli'] = $is_soli;
- $_GET['type'] = 'normal';
- $is_presale_order = 0;
- if( isset($_GET['presale_order']) && $_GET['presale_order'] == 1 )
- {
- $is_presale_order = 1;
- }
- $is_virtualcard_order = 0;
- if( isset($_GET['virtualcard_order']) && $_GET['virtualcard_order'] == 1 )
- {
- $is_virtualcard_order = 1;
- }
- $this->is_soli = $is_soli;
- $this->is_presale_order = $is_presale_order;
- $this->is_virtualcard_order = $is_virtualcard_order;
- $need_data = D('Seller/Order')->load_order_list();
- $cur_controller = 'order/index';
- $total = $need_data['total'];
- $total_money = $need_data['total_money'];
- $list = $need_data['list'];
- $pager = $need_data['pager'];
- $all_count = $need_data['all_count'];
- $count_status_1 = $need_data['count_status_1'];
- $count_status_3 = $need_data['count_status_3'];
- $count_status_4 = $need_data['count_status_4'];
- $count_status_5 = $need_data['count_status_5'];
- $count_status_7 = $need_data['count_status_7'];
- $count_status_11 = $need_data['count_status_11'];
- $count_status_14 = $need_data['count_status_14'];
- $count_status_express = $need_data['count_status_express'];
-
-
- $this->cur_controller = $cur_controller;
- $this->total = $total;
- $this->total_money = $total_money;
- $this->list = $list;
- $this->pager = $pager;
- $this->all_count = $all_count;
- $this->count_status_1 = $count_status_1;
- $this->count_status_3 = $count_status_3;
- $this->count_status_4 = $count_status_4;
- $this->count_status_5 = $count_status_5;
- $this->count_status_7 = $count_status_7;
- $this->count_status_11 = $count_status_11;
- $this->count_status_14 = $count_status_14;
- $this->count_status_express = $count_status_express;
-
- $this->order_status_id = $order_status_id;
- $this->is_community = I('request.is_community', 0);
- $this->headid = I('request.headid', 0);
-
- $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
-
- if( empty($open_feier_print) )
- {
- $open_feier_print = 0;
- }
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $is_open_supply_print = D('Home/Front')->get_config_by_name('is_open_supply_print' );
- if( empty($is_open_supply_print) )
- {
- $open_feier_print = 0;
- }else{
- $supper_info = get_agent_logininfo();
- $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print'.$supper_info['id'] );
- if( empty($open_feier_print) )
- {
- $open_feier_print = 0;
- }
- }
-
- }
-
-
- $this->open_feier_print = $open_feier_print;
-
- $is_can_look_headinfo = true;
- $is_can_nowrfund_order = true;
-
- $is_can_confirm_delivery = true;
- $is_can_confirm_receipt = true;
- $is_can_third_delivery = true;
-
-
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
-
- $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
-
-
- $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
-
- $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
- $supply_third_delivery_service = D('Home/Front')->get_config_by_name('supply_third_delivery_service');
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
- {
- $is_can_look_headinfo = false;
- }
- if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
- {
- $is_can_nowrfund_order = false;
- }
-
-
- if( isset($supply_can_confirm_delivery) && $supply_can_confirm_delivery == 2 )
- {
- $is_can_confirm_delivery = false;
- }
- if( isset($supply_can_confirm_receipt) && $supply_can_confirm_receipt == 2 )
- {
- $is_can_confirm_receipt = false;
- }
-
- }
- if( isset($supply_third_delivery_service) && $supply_third_delivery_service == 1){
- $is_can_third_delivery = true;
- }else{
- $is_can_third_delivery = false;
- }
-
- $s_id = 1 ;
- if(SELLERUID != 1)
- {
- $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
-
- $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
- $perms1 = str_replace('.','/',$perms_arr['perms2']);
-
- $perms2 = explode(",", $perms1);
- if(in_array("user/user/index", $perms2)){
- $s_id = 1 ;
- } else {
- $s_id = 0 ;
- }
- }
- $this->s_id = $s_id;
- $is_localtown_imdada_status = D('Home/Front')->get_config_by_name('is_localtown_imdada_status');
- $is_localtown_sf_status = D('Home/Front')->get_config_by_name('is_localtown_sf_status');
- //是否开启蜂鸟即配
- $is_localtown_ele_status = D('Home/Front')->get_config_by_name('is_localtown_ele_status');
- $is_localtown_ele_status = isset($is_localtown_ele_status) ? $is_localtown_ele_status : 0;
- //是否开启码科配送
- $is_localtown_mk_status = D('Home/Front')->get_config_by_name('is_localtown_mk_status');
- $is_localtown_mk_status = isset($is_localtown_mk_status) ? $is_localtown_mk_status : 0;
- //码科预览价格
- $is_make_prequery_status = D('Home/Front')->get_config_by_name('is_make_prequery_status');
- $is_make_prequery_status = isset($is_make_prequery_status) ? $is_make_prequery_status : 0;
- $is_imdada_prequery_status = D('Home/Front')->get_config_by_name('is_imdada_prequery_status');
- $is_sf_prequery_status = D('Home/Front')->get_config_by_name('is_sf_prequery_status');
- $localtown_modifypickingname = D('Home/Front')->get_config_by_name('localtown_modifypickingname');
- $localtown_modifypickingname = !empty($localtown_modifypickingname) ? $localtown_modifypickingname: '包装费';
- $this->is_can_look_headinfo = $is_can_look_headinfo;
- $this->is_can_nowrfund_order = $is_can_nowrfund_order;
- $this->is_can_confirm_delivery = $is_can_confirm_delivery;
- $this->is_can_confirm_receipt = $is_can_confirm_receipt;
- $this->is_localtown_imdada_status = $is_localtown_imdada_status;
- $this->is_localtown_sf_status = $is_localtown_sf_status;
- $this->is_localtown_mk_status = $is_localtown_mk_status;
- $this->is_localtown_ele_status = $is_localtown_ele_status;
- $this->is_make_prequery_status = $is_make_prequery_status;
- $this->localtown_modifypickingname = $localtown_modifypickingname;
- $this->is_can_third_delivery = $is_can_third_delivery;
- if($is_localtown_imdada_status == 1 && $is_imdada_prequery_status == 1){
- $this->is_imdada_prequery_status = 1;
- }else{
- $this->is_imdada_prequery_status = 0;
- }
- if($is_localtown_sf_status == 1 && $is_sf_prequery_status == 1){
- $this->is_sf_prequery_status = 1;
- }else{
- $this->is_sf_prequery_status = 0;
- }
- $data = D('Seller/Config')->get_all_config();
- $this->data = $data;
- $this->display('Order/index');
- }
-
- public function opremarksaler()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
- if (IS_POST) {
- $remark = I('request.remark');
-
- M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( array('remarksaler' => $remark) );
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $this->item = $item;
- $this->id = $item['order_id'];
- include $this->display();
- }
- private function check_order_data()
- {
-
-
- $id = I('request.id',0);
-
- $item = M('lionfish_comshop_order')->where( array('order_id' => $id) )->find();
-
- if (empty($item)) {
-
- show_json(0, '未找到订单!');
-
- }
- return array('id' => $id, 'item' => $item);
- }
-
- public function opsendcancel()
- {
-
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
-
- $sendtype = I('request.sendtype','');
- $gpc = I('request.');
- if (($item['order_status_id'] != 4) ) {
- show_json(0, '订单未发货,不需取消发货!');
- }
- if (IS_POST) {
-
- $remark = trim($gpc['remark']);
- $data = array('express_time' => 0,'shipping_no' =>'','shipping_method' => 0);
- $data['order_status_id'] = 1;
-
- M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save($data);
-
- $history_data = array();
- $history_data['order_id'] = $item['order_id'];
- $history_data['order_status_id'] = 1;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单取消发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'];
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
-
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $sendgoods = array();
- $bundles = array();
- $this->id = $item['order_id'];
- $this->item = $item;
- $this->sendtype = $sendtype;
- include $this->display();
- }
-
-
- public function opchangeaddress()
- {
- $_GPC = I('request.');
- $opdata = $this->check_order_data();
- extract($opdata);
-
-
- $new_area = 0;
- $address_street = 0;
- $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
- if (IS_POST) {
- $realname = $_GPC['realname'];
- $mobile = $_GPC['mobile'];
- $province = $_GPC['province'];
- $city = $_GPC['city'];
- $area = $_GPC['area'];
- $street = $_GPC['street'];
- $changead = intval($_GPC['changead']);
- $address = trim($_GPC['address']);
-
-
-
- if (!(empty($id))) {
- if (empty($realname)) {
- $ret = '请填写收件人姓名!';
- //show_json(0, array('msg' => $ret) );
- show_json(0, $ret);
- }
- if (empty($mobile)) {
- $ret = '请填写收件人手机!';
- show_json(0, $ret);
- }
- if ($changead) {
- if ($province == '请选择省份') {
- $ret = '请选择省份!';
- show_json(0, $ret);
- }
- if (empty($address)) {
- $ret = '请填写详细地址!';
- show_json(0, $ret);
- }
- }
- $address_array = array();
- $address_array['shipping_name'] = $realname;
- $address_array['shipping_tel'] = $mobile;
-
- if ($changead) {
-
-
-
-
- $province_info = M('lionfish_comshop_area')->where("name like '%{$province}%' ")->find();
-
- if( !empty($province_info))
- {
- $province_id = $province_info['id'];
- }else{
- $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
-
- $area_data = array();
- $area_data['name'] = $province;
- $area_data['pid'] = 0;
- $area_data['code'] = $max_dp['code']+1;
-
- $province_id = M('lionfish_comshop_area')->add($area_data);
-
- $up_data = array();
- $up_data['code'] = $province_id;
-
- M('lionfish_comshop_area')->where( array('id' => $province_id ) )->save($up_data);
-
- }
-
- //$city_info = M('lionfish_comshop_area')->where("name like '%{$city}%'")->find();
- $guding_arr = ['鞍山市'];
- if( in_array($city , $guding_arr) )
- {
- $city_info = M('lionfish_comshop_area')->where("name = '{$city}'")->find();
- }else{
- $city_info = M('lionfish_comshop_area')->where("name like '%{$city}%'")->find();
- }
-
- if( !empty($city_info))
- {
- $city_id = $city_info['id'];
- }else{
-
- $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
-
- $area_data = array();
- $area_data['name'] = $city;
- $area_data['pid'] = $province_id;
- $area_data['code'] = $max_dp['code']+1;
-
- $city_id = M('lionfish_comshop_area')->add( $area_data);
-
- $up_data = array();
- $up_data['code'] = $city_id;
-
- M('lionfish_comshop_area')->where( array('id' => $city_id ) )->save($up_data);
-
- }
-
- //city_name: 东莞市
- if( empty($area) )
- {
- if( $city == '东莞市' )
- {
- $area = '东莞';
- }
- if( $city == '中山市' )
- {
- $area = '中山';
- //453
- }
- }
-
- $country_info = M('lionfish_comshop_area')->where( "name like '%{$area}%' " )->find();
-
- if( $area == '中山' )
- {
-
- $country_info = M('lionfish_comshop_area')->where( array('id' => 453 ) )->find();
- //
- }
-
-
- if( !empty($country_info))
- {
- $country_id = $country_info['id'];
- }else{
-
- $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
-
- $area_data = array();
- $area_data['name'] = $area;
- $area_data['pid'] = $city_id;
- $area_data['code'] = $max_dp['code']+1;
-
- $country_id = M('lionfish_comshop_area')->add( $area_data );
-
- $up_data = array();
- $up_data['code'] = $country_id;
-
- M('lionfish_comshop_area')->where( array('id' => $country_id ) )->save( $up_data );
-
- }
-
-
- $address_array['shipping_province_id'] = $province_id;
- $address_array['shipping_city_id'] = $city_id;
- $address_array['shipping_country_id'] = $country_id;
-
- $address_array['shipping_address'] = $address;
-
- if( $item['delivery'] == 'tuanz_send' )
- {
- $address_array['tuan_send_address'] = $address;
- }
- }
-
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( $address_array );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- }
-
- $this->id = $item['order_id'];
- $this->item = $item;
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
-
- $this->display();
- }
-
- //确认送达团长
- public function opsend_tuanz_over()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
- //express_tuanz_time D('Home/Frontorder')->send_order_operate($order_info['order_id']);
-
- D('Seller/Order')->do_tuanz_over($item['order_id']);
- //D('Seller/Frontorder')->send_order_operate($item['order_id']);
-
-
-
- D('Home/Frontorder')->send_order_operate($item['order_id']);
-
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
-
- public function all_opprint()
- {
- $_GPC = I('request.');
-
- $order_arr = $_GPC['order_arr'];
-
- $cache_key = md5(time().mt_rand(100,1000));
-
- S('_all_opprintquene_'.$cache_key, $order_arr);
-
-
- $this->cache_key = $cache_key;
- $this->_GPC = $_GPC;
-
- $this->display();
- }
-
-
- public function do_opprint_quene()
- {
- $_GPC = I('request.');
-
-
- $cache_key = $_GPC['cache_key'];
-
- $quene_order_list = S('_all_opprintquene_'.$cache_key);
-
- $order_id = array_shift($quene_order_list);
-
- S('_all_opprintquene_'.$cache_key, $quene_order_list);
-
-
- $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array( 'order_id' => $order_id ) )->find();
-
-
- $print_model = D('Seller/Printaction');
-
- $result = $print_model->check_print_order( $order_id );
- $result2 =$print_model->check_print_order2( $order_id );
-
- if( $result['code'] == 1 || $result2['code'] == 1 )
- {
-
- M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('is_print_suc' => 1) );
-
- }
-
- if( empty($quene_order_list) )
- {
- echo json_encode( array('code' => 2) );
- die();
- }
-
- //清单编号
-
- echo json_encode( array('code' => 0, 'msg' => '订单编号:'.$order_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理") );
- die();
- }
-
-
- public function opprint()
- {
- $_GPC = I('request.');
-
- $order_id = $_GPC['id'];
-
- $print_model = D('Seller/Printaction');
-
- $result = $print_model->check_print_order( $order_id );
- $result2 = $print_model->check_print_order2( $order_id );
- if( $result['code'] == 1 || $result2['code'] == 1 )
- {
- M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('is_print_suc' => 1) );
-
- show_json(1, array('msg' => '打印成功!' ) );
- }else{
- $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
- if(!empty($open_feier_print) && ( $open_feier_print == 2 || $open_feier_print == 1 ) )
- {
- show_json(0, array('msg' => $result['msg'] ) );
- }else{
- show_json(0, array('msg' => $result2['msg'] ) );
- }
-
- }
-
- }
-
-
-
- public function oprefund_goods_do()
- {
- $_GPC = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
- $weixin_model = D('Home/Weixin');
-
- $id = $_GPC['id'];
-
- $order_goods_id = $_GPC['order_goods_id'];
- /**
- id : 3864
- order_goods_id : 4442
- **/
- //付款总额
-
- $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
-
- $this->order_goods_info = $order_goods_info;
-
- $goods_images = tomedia( $order_goods_info['goods_images'] );
-
- $this->goods_images = $goods_images;
-
- $free_tongji = $order_goods_info['total']-$order_goods_info['voucher_credit']-$order_goods_info['fullreduction_money'] - $order_goods_info['score_for_money'] - $order_goods_info['has_refund_money'];
- $integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'orderbuy', 'order_goods_id' => $order_goods_id ) )->find();
-
- $use_score = 0;
-
- if( !empty($integral_flow) )
- {
- $use_score = $integral_flow['score'];
- }
-
- $this->use_score = $use_score;
-
- $total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($id,$order_goods_id);
-
- $this->total_quantity = $total_quantity;
-
- $has_refund_quantity = D('Seller/Commonorder')->refund_order_goods_quantity($id,$order_goods_id);
-
- $this->has_refund_quantity = $has_refund_quantity;
-
- $has_refund_money = D('Seller/Commonorder')->get_order_goods_refund_money($id,$order_goods_id);
-
- $this->has_refund_money = $has_refund_money;
-
- $shipping_fare = $order_goods_info['shipping_fare'];
-
- $delivery = $opdata['item']['delivery'];
-
- $this->delivery = $delivery;
- //预售订单begin
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
- $presale_info = [];
- if( $presale_result['code'] == 0 )
- {
- $presale_info = $presale_result['data'];
- }
- $this->presale_info = $presale_info;
- //end
- $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
-
- $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
-
- if( $is_has_refund_deliveryfree == 1 && $item['type'] != 'integral')
- {
- //后台设置退运费了
- //退回运费,导致佣金出错问题修改
- //$free_tongji += $shipping_fare;
- }
- if($item['delivery'] == 'hexiao'){
- $used_total = D('Home/Salesroom')->get_hexiao_order_goods_used_total($id,$order_goods_id);
- $free_tongji = $free_tongji - $used_total;
- }
-
- $this->shipping_fare = $shipping_fare;
- $this->is_has_refund_deliveryfree = $is_has_refund_deliveryfree;
- $this->free_tongji = $free_tongji;
- $this->_GPC = $_GPC;
-
- $commiss_state = '未结算';
-
- $commiss_info = M('lionfish_community_head_commiss_order')->where( array('order_id' => $id, 'order_goods_id' =>$order_goods_id,'type' => 'orderbuy' ) )->find();
-
- if( !empty($commiss_info) && $commiss_info['state'] == 1 )
- {
- $commiss_state = '已结算';
- }
-
- $this->commiss_info =$commiss_info;
- $this->commiss_state = $commiss_state;
- $this->payment_code = $item['payment_code'];
-
- if ( IS_POST ) {
- if(!$this->checkLocalTownOrderCanRefund($item)){
- show_json(0, array('message' => '同城配送订单配送中不能退款') );
- }
-
- $refund_money = isset($_GPC['refund_money']) && $_GPC['refund_money'] >0 ? floatval($_GPC['refund_money']) : 0;
-
- $is_refund_shippingfare = isset($_GPC['is_refund_shippingfare']) ? $_GPC['is_refund_shippingfare'] : 0;//退运费
- $is_back_sellcount = isset($_GPC['is_back_sellcount']) ? $_GPC['is_back_sellcount'] : 0;//退库存
- $is_back_scorecount = isset($_GPC['is_back_scorecount']) ? $_GPC['is_back_scorecount'] : 0;//退积分
-
- //$free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
- $free_tongji = $order_goods_info['total']-$order_goods_info['voucher_credit']-$order_goods_info['fullreduction_money'] - $order_goods_info['score_for_money'] - $order_goods_info['has_refund_money'];
-
- $refund_quantity = isset($_GPC['refund_quantity']) && $_GPC['refund_quantity'] >0 ? floatval($_GPC['refund_quantity']) : 0;
-
- $real_refund_quantity = isset($_GPC['real_refund_quantity']) && $_GPC['real_refund_quantity'] >0 ? intval($_GPC['real_refund_quantity']) : 0;
-
- //已退商品数量
- $refund_total_quantity = M('lionfish_comshop_order_goods_refund')->where( "order_id={$id} and order_goods_id={$order_goods_id} " )->sum('quantity');
-
-
-
- //部分退款计算运费
- if($refund_quantity + $refund_total_quantity < $order_goods_info['quantity']){
- $shipping_fare = round($refund_quantity/$order_goods_info['quantity']*$shipping_fare,2);
- }else{
- //$shipping_fare = round($refund_quantity/$order_goods_info['quantity']*$shipping_fare,2);
- $shipping_fare = $shipping_fare - $refund_total_quantity * round( 1/$order_goods_info['quantity'] * $shipping_fare,2);
- }
-
-
- $pay_total_money = $free_tongji ;
- $refund_shipping_fare = 0;
- $wx_refund_money = $refund_money;
- if( $is_refund_shippingfare == 1)
- {
- $free_tongji += $shipping_fare;
- $refund_shipping_fare = $shipping_fare;
- $wx_refund_money = $wx_refund_money + $shipping_fare;
- }
-
-
-
- $can_free_tongji = $opdata['item']['total'] + $opdata['item']['shipping_fare'] -$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
- if( $item['type'] == 'integral' )
- {
- $can_free_tongji = $opdata['item']['total'] -$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
-
- }
- $can_refund_quantity = 0;
- if($item['delivery'] == 'hexiao'){
- $can_refund_quantity = D('Home/Salesroom')->get_hexiao_order_goods_can_refund_quantity($id,$order_goods_id);
- }
-
- //以及退款了多少钱了 has_refund_money
-
- if($refund_money + $has_refund_money > $can_free_tongji){
- show_json(0, array('message' => '总退款金额大于可退款金额') );
- }
- else if( $refund_money < 0 )
- {
- show_json(0, array('message' => '填写正确的退款金额') );
- }
- else if( $is_back_sellcount == 1 && $refund_quantity > $total_quantity )
- {
- show_json(0, array('message' => '填写正确的退库存数量,最大'.$total_quantity.'个' ) );
- }else if($item['delivery'] == 'hexiao' && $can_refund_quantity < $refund_quantity){
- show_json(0, array('message' => '核销商品退款数量大于可退款数量'.$refund_quantity.'个' ) );
- }
- else{
-
- if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
- {
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => 0) );
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$order_goods_id ) )->save( array('shipping_fare' => 0) );
- }
-
- //is_back_sellcount
- //$res = $weixin_model->refundOrder($id,$refund_money,0,$order_goods_id,$is_back_sellcount, $refund_quantity,1);
- $res = $weixin_model->refundOrder($id,$wx_refund_money,0,$order_goods_id,$is_back_sellcount, $refund_quantity,1);
-
- if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
- {
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => $opdata['item']['shipping_fare'] ) );
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$order_goods_id ) )->save( array('shipping_fare' => $order_goods_info['shipping_fare']) );
-
- }
-
-
-
-
- if( $res['code'] == 0 )
- {
- show_json(0, array('message' => $res['msg'] ) );
- }else{
-
- //开始插入本次退款的情况
- //存储当前这笔退款 影响到的以后佣金情况
-
-
-
- //is_back_scorecount
- if( $is_back_scorecount == 1 )
- {
- $refund_score = 0;
- $refund_score = intval( ($use_score / $order_goods_info['quantity']) * $refund_quantity);
-
-
- D('Seller/Commonorder')->refund_order_goods_intrgral( $id, $order_goods_id ,$refund_score );
-
- }else{
- $refund_score = 0;
-
- D('Seller/Commonorder')->refund_order_goods_intrgral( $id, $order_goods_id ,0 );
- }
- //退回运费,导致佣金出错问题修改
- $order_goods_refundid = D('Seller/Commonorder')->ins_order_goods_refund($id, $order_goods_id,$pay_total_money,$real_refund_quantity, $refund_quantity,$refund_money,$is_back_sellcount,$refund_shipping_fare);
- //$order_goods_refundid = D('Seller/Commonorder')->ins_order_goods_refund($id, $order_goods_id,$pay_total_money,$real_refund_quantity, $refund_quantity,$refund_money,$is_back_sellcount);
-
-
-
- //如果这个商品没有数量了。就改变他的状态为已退款的状态
- $new_total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($id,$order_goods_id);
- if( $new_total_quantity <=0 )
- {
- D('Seller/Commonorder')->check_refund_order_goods_status($id, $order_goods_id, $refund_money,$is_back_sellcount,$real_refund_quantity, $refund_quantity,$is_refund_shippingfare);
-
- $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->select();
- $is_all_refund = true;
-
- foreach($order_goods_list as $val )
- {
- if($val['is_refund_state'] != 1)
- {
- $is_all_refund = false;
- }
- }
-
- $or_gd_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
- if(($or_gd_info['is_refund_state'] == 1) && ($is_all_refund == false) ){
-
- $or_gd_info = M('lionfish_comshop_order_goods')->field('name')->where( array('order_goods_id' => $order_goods_id ) )->find();
- $order_history = array();
- $order_history['order_id'] = $id;
- $order_history['order_status_id'] = 19;
- $order_history['notify'] = 0;
-
- if( $item['type'] == 'integral' ){
- $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款积分'.$refund_money.'积分';
- }else{
- $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款金额'.$refund_money.'元';
- }
- $order_history['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $order_history );
-
- }
-
- }else{
-
- $or_gd_info = M('lionfish_comshop_order_goods')->field('name')->where( array('order_goods_id' => $order_goods_id ) )->find();
-
- $order_history = array();
- $order_history['order_id'] = $id;
- $order_history['order_status_id'] = 19;
- $order_history['notify'] = 0;
- if( $item['type'] == 'integral' ){
- $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款积分'.$refund_money.'积分,';
- }else{
- $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款金额'.$refund_money.'元,';
- }
- if($is_refund_shippingfare == 1)
- {
- $order_history['comment'] .= '. 退配送费:'.$refund_shipping_fare.'元';
- }
-
- $order_history['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $order_history );
- }
- //核销订单操作
- if($item['delivery'] == 'hexiao'){
- //核销商品订单退款
- D('Home/Salesroom')->hexiao_refund_action($id,$order_goods_id,$refund_quantity);
- //操作核销订单是否完成
- D('Seller/Order')->hexiao_finished($id, '未核销商品退款,订单完成');
- }
- //礼品卡退款
- D('Seller/VirtualCard')->refundOrder($id);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- }
- }
-
- if( $item['type'] == 'integral' )
- {
- include $this->display('Order/oprefund_goods_dointegral');
- }else{
- include $this->display();
- }
-
-
- }
-
-
- public function oprefund_do()
- {
- $_GPC = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
-
- $id = $_GPC['id'];
-
- //付款总额
- $free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
-
- $total_quantity = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->sum('quantity');
-
- $has_refud_money = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $id ) )->sum('money');
-
- $this->has_refud_money = $has_refud_money;
-
- $has_refund_quantity = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $id ) )->sum('quantity');
-
- $total_quantity = $total_quantity - $has_refund_quantity;
-
- $buy_score_total = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'orderbuy' , 'order_id' => $id ) )->sum('score');
-
- $has_refund_buy_score_total = M('lionfish_comshop_member_integral_flow')->where(array('type' => 'refundorder' , 'order_id' => $id ))->sum('score');
-
- if(!empty($has_refund_buy_score_total) && $has_refund_buy_score_total > 0)
- $buy_score_total = $buy_score_total - $has_refund_buy_score_total;
-
- $this->buy_score_total = $buy_score_total;
-
- $shipping_fare = $opdata['item']['shipping_fare'];
-
- $delivery = $opdata['item']['delivery'];
-
- $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
-
- $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
-
- if( $is_has_refund_deliveryfree == 1)
- {
- //后台设置退运费了
- //退回运费,导致佣金出错问题修改
- $free_tongji += $opdata['item']['shipping_fare'];
- }
- $hx_used_total = 0;
- if($item['delivery'] == 'hexiao'){
- $used_quantity = D('Home/Salesroom')->get_hexiao_order_used_quantity($id);
- $hx_used_total = D('Home/Salesroom')->get_hexiao_order_used_total($id);
- $total_quantity = $total_quantity - $used_quantity;
- $free_tongji = $free_tongji - $hx_used_total;
- }
- //判断是否有预售 begin
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
- $presale_info = [];
- if( $presale_result['code'] == 0 )
- {
- $presale_info = $presale_result['data'];
- $free_tongji = $free_tongji - $presale_info['presale_for_ordermoney'];
- }
- //end
- $this->presale_info = $presale_info;
- $this->is_has_refund_deliveryfree = $is_has_refund_deliveryfree;
- $this->shipping_fare = $shipping_fare;
- $this->total_quantity = $total_quantity;
- $this->delivery = $delivery;
- $this->hx_used_total = $hx_used_total;
- if( IS_POST )
- {
- if(!$this->checkLocalTownOrderCanRefund($item)){
- show_json(0, array('message' => '同城配送订单配送中不能退款') );
- }
- $refund_money = isset($_GPC['refund_money']) && $_GPC['refund_money'] >0 ? floatval($_GPC['refund_money']) : 0;
-
- $is_refund_shippingfare = isset($_GPC['is_refund_shippingfare']) ? $_GPC['is_refund_shippingfare'] : 0;//退运费
- $is_back_sellcount = isset($_GPC['is_back_sellcount']) ? $_GPC['is_back_sellcount'] : 0;//退库存
- $is_back_buyscore = isset($_GPC['is_back_buyscore']) ? $_GPC['is_back_buyscore'] : 0;//退积分
-
-
- $wx_refund_money = $refund_money;
- $free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
- //已经退款运费
- $refund_shipping_fare_amount = M('lionfish_comshop_order_goods_refund')->where( array('order_id' =>$id ) )->sum('refund_shipping_fare');
- if( empty($refund_shipping_fare_amount) )
- {
- $refund_shipping_fare_amount = 0;
- }
- if( $is_refund_shippingfare == 1 && $opdata['item']['type'] != 'integral' )
- {
- if($refund_shipping_fare_amount < $shipping_fare) {
- $shipping_fare = $shipping_fare - $refund_shipping_fare_amount;
- $this->shipping_fare = $shipping_fare;
- //$free_tongji += $shipping_fare;
- $wx_refund_money += $shipping_fare - $opdata['item']['fare_shipping_free'];
- $is_back_buyscore = 2;//退运费
- }
- }
-
- $free_tongji = $free_tongji - $has_refud_money;
-
- if( $refund_money - $free_tongji >= 0.01 ){
- show_json(0, array('message' => '填写金额大于总退款金额' ) );
- }
- else if( $refund_money < 0 )
- {
- show_json(0, array('message' => '填写正确的退款金额' ) );
- }
- else{
-
- $weixin_model = D('Home/Weixin');
-
- $id = $_GPC['id'];
-
- $model = M('lionfish_comshop_order');
- //$model->startTrans(); // 开启事务
- $order_info = $model->where(array('order_id'=>$id))->find();
- if( $order_info['order_status_id'] != 7 )
- {
- if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
- {
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => 0) );
- }
-
- //$res = $weixin_model->refundOrder($id,$refund_money,0,0,$is_back_sellcount);
- $res = $weixin_model->refundOrder($id,$wx_refund_money,0,0,$is_back_sellcount);
-
- if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
- {
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => $opdata['item']['shipping_fare'] ) );
- }
- $model->commit(); // 开启事务
- if( $res['code'] == 0 )
- {
- show_json(0, array('message' => $res['msg']) );
- }else{
-
-
- //integral
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $id ) )->find();
-
- $comment = '后台操作立即退款,退款金额:'.$refund_money.'元';
-
- if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
- {
- $comment = '后台操作立即退款,退款积分:'.$refund_money.'积分';
- }
-
-
- if( $order_info['type'] == 'integral' )
- {
- $comment = '后台操作立即退款,退还积分:'.$refund_money.'积分';
- //$comment = '后台操作立即退款,退款金额:'.$refund_money.'元';
- }
-
- if($is_refund_shippingfare == 1)
- {
- if( $order_info['type'] == 'integral' ){
-
- $refund_shipping_fare_amount2 = M('lionfish_comshop_order_goods_refund')->where( array('order_id' =>$id ) )->sum('refund_shipping_fare');
- if( empty($refund_shipping_fare_amount2) )
- {
- $refund_shipping_fare_amount2 = 0;
- }
-
- $new_shipping_fare = $opdata['item']['shipping_fare'] - $refund_shipping_fare_amount2;
-
- $comment .= '. 退配送费:'.$new_shipping_fare.'元';
- }else{
- $comment .= '. 退配送费:'.$opdata['item']['shipping_fare'].'元';
- }
-
- }
-
- if($is_back_sellcount == 1)
- {
- $comment .= '. 退库存:'.$total_quantity;
- }else{
- $comment .= '. 不退库存,不减销量';
- }
-
- $history_data = array();
- $history_data['order_id'] = $id;
- $history_data['order_status_id'] = 7;
- $history_data['notify'] = 0;
- $history_data['comment'] = $comment;
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
-
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('order_status_id' => 7) );
- //将所有在退款中的状态,全部重置成已退款成功
- M('lionfish_comshop_order_refund')->where( array('order_id' => $id, 'state' => 0) )->save( array('state' => 3) );
-
- //将退款中的 申请订单,全部改成已退款
-
- $refund_all = M('lionfish_comshop_order_refund')->where( array('order_id' =>$id, 'state' => 0 ) )->select();
-
- if( !empty($refund_all) )
- {
- foreach( $refund_all as $val )
- {
- $ins_data = array();
-
- $ins_data['ref_id'] = $val['ref_id'];
- $ins_data['order_id'] = $val['order_id'];
- $ins_data['order_goods_id'] = $val['order_goods_id'];
- $ins_data['message'] = '平台同意退款 ,退款成功';
- $ins_data['type'] = 2;
- $ins_data['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add( $ins_data );
-
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $val['ref_id']) )->save( array('state' => 3) );
-
- }
- }
-
-
- //$data[''] = isset($data['is_print_admin_cancleorder']) ? $data['is_print_admin_cancleorder'] : 0;
- $is_print_admin_cancleorder = D('Home/Front')->get_config_by_name('is_print_admin_cancleorder');
-
- D('Seller/Commonorder')->refund_one_order( $id , $is_back_buyscore);
-
-
- if( isset($is_print_admin_cancleorder) && $is_print_admin_cancleorder == 1 )
- {
- D('Seller/Printaction')->check_print_order($id,'后台操作取消订单');
- D('Seller/Printaction')->check_print_order2($id,'后台操作取消订单');
- }
- sellerLog('订单['.$order_info['order_num_alias'].']退款成功操作', 2);
- //核销订单操作
- if($item['delivery'] == 'hexiao'){
- D('Home/Salesroom')->hexiao_order_refund_action($id);
- }
- //礼品卡退款
- D('Seller/VirtualCard')->refundOrder($id);
- show_json(1, array('message' => '退款成功!') );
- }
-
- }else{
- //$model->rollback(); // 回滚
- show_json(0, array('message' => '请勿重复提交'));
- }
-
- }
-
- }
-
- $this->id = $id;
- $this->free_tongji = $free_tongji;
- $this->item = $item;
-
- $commiss_state = '未结算';
-
- $commiss_info = M('lionfish_community_head_commiss_order')->where( array('order_id' => $id, 'type' => 'orderbuy' ) )->find();
-
- if( !empty($commiss_info) && $commiss_info['state'] == 1 )
- {
- $commiss_state = '已结算';
- }
-
- $this->commiss_state = $commiss_state;
-
- if( $item['type'] == 'integral' )
- {
- $this->display('Order/oprefund_do_integral');
- }else{
- $this->display();
- }
-
-
-
- }
-
-
- function test()
- {
- //D('Seller/Printaction')->check_print_order(63);
- // lionfish_comshop_order
-
- $shop_name = D('Home/Front')->get_config_by_name('shoname');
-
-
- $this->shop_name = $shop_name;
- $order_id = 174;
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
-
-
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->select();
-
- $need_order_goods = array();
-
-
- foreach($order_goods as $key => $value)
- {
- $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
-
- $need_order_goods[$key] = $value;
- }
-
- $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
- $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id'] ) )->find();
-
-
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
- $this->member = $member;
-
- $this->order_info = $order_info;
- $this->need_order_goods = $need_order_goods;
- $this->display('forms');
- }
-
- /**
- 打印配送单
- **/
- public function order_print_dan()
- {
- $order_id = I('get.id');
-
- $shop_name = D('Home/Front')->get_config_by_name('shoname');
-
-
- $this->shop_name = $shop_name;
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
-
-
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->select();
-
- $need_order_goods = array();
-
- $total = 0;
- foreach($order_goods as $key => $value)
- {
- $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
-
- $need_order_goods[$key] = $value;
- }
- $total = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->sum('total');
- $legal_amount = D('Seller/Order')->num_to_rmb($total);
-
- $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
- $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
- sellerLog('订单['.$order_info['order_num_alias'].']打印配送单', 2);
- $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
-
- $order_note_name = isset($order_note_name) && !empty($order_note_name) ? $order_note_name :'店名';
- $this->order_note_name = $order_note_name;
-
- $this->legal_amount = $legal_amount;
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
- $this->member = $member;
-
- $this->order_info = $order_info;
- $this->need_order_goods = $need_order_goods;
- $this->display('forms');
- }
-
- //配送团长
- public function opsend_tuanz()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
- D('Seller/Order')->do_send_tuanz($item['order_id']);
- $order_num_alias = M('lionfish_comshop_order')->where( array('order_id' => $item['order_id'] ) )->find();
- D('Seller/Operatelog')->addOperateLog('detailed_list','配送团长--订单编号'.$order_num_alias['order_num_alias']);
- //后台自动送达团长
- D('Seller/Order')->order_auto_service($item,'后台自动确认送达团长');
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- //同城配送,确认开始配送流程
- public function opsend_localtown()
- {
- $opdata = $this->check_order_data();
- extract($opdata);
- $count = D('Seller/Order')->do_send_localtown($item['order_id']);
- show_json(1, array('url' => $_SERVER['HTTP_REFERER'], 'count' => $count));
- }
- public function opsend()
- {
- $_GPC = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
- if (empty($item['address_id'])) {
- show_json(0, array('message' => '无收货地址,无法发货!'));
- }
- if ($item['order_status_id'] == 3) {
- show_json(0, array('message' => '订单未付款,无法发货!'));
- }
- if (IS_POST) {
-
- //express shipping_no $express_info['name'] dispatchname
-
- if (!(empty($_GPC['shipping_no'])) && empty($_GPC['shipping_no'])) {
- show_json(0, array('message' => '请输入快递单号!') );
- }
-
- if ( empty($_GPC['express']) ) {
- show_json(0, array('message' => '请选择快递公司!'));
- }
-
-
- if (!(empty($item['transid']))) {
- }
- $express_info = D('Seller/Express')->get_express_info($_GPC['express']);
-
- $time = time();
- $data = array(
- 'shipping_method' => trim($_GPC['express']),
- 'shipping_no' => trim($_GPC['shipping_no']),
- 'dispatchname' => $express_info['name'],
- 'express_time' => $time
- );
-
- $data['order_status_id'] = 4;
-
-
- M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( $data );
-
-
-
- $history_data = array();
- $history_data['order_id'] = $item['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $_GPC['shipping_no'];
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
-
- D('Home/Frontorder')->send_order_operate($item['order_id']);
- sellerLog('订单['.$item['order_num_alias'].']订单发货操作', 2);
- //TODO...发送已经发货的消息通知
- //m('notice')->sendOrderMessage($item['id']);
- //plog('order.op.send', '订单发货 ID: ' . $item['id'] . ' 订单号: ' . $item['ordersn'] . ' <br/>快递公司: ' . $_GPC['expresscom'] . ' 快递单号: ' . $_GPC['expresssn']);
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $noshipped = array();
- $shipped = array();
- $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
-
- $order_goods = M()->query('select og.order_goods_id as id,og.name as title,og.goods_images as thumb from ' .
- C('DB_PREFIX'). 'lionfish_comshop_order_goods as og where og.order_id= '.$item['order_id']);
-
-
- $express_list = D('Seller/Express')->load_all_express();
-
-
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
- $this->order_goods = $order_goods;
- $this->item = $item;
- $this->express_list = $express_list;
- $this->id = $item['order_id'];
-
- $this->display();
- }
-
- // 11 已完成
- public function opfinish()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
-
- M('lionfish_comshop_order')->where(array('order_id' => $item['order_id']) )->save( array('order_status_id' => 11,
- 'finishtime' => time()) );
-
- $history_data = array();
- $history_data['order_id'] = $item['order_id'];
- $history_data['order_status_id'] = 11;
- $history_data['notify'] = 0;
- $history_data['comment'] = '后台操作,已完成' ;
- $history_data['date_added'] = time();
- sellerLog('订单['.$item['order_num_alias'].']订单完成操作', 2);
- M('lionfish_comshop_order_history')->add($history_data);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- public function export_form()
- {
- $_GPC = I('request.');
-
-
- /**
- order_status_id:
- type: normal
- searchtime:
- time[start]: 2019-12-23 00:00:00
- time[end]: 2019-12-23 23:59:59
- delivery:
- searchfield: ordersn
- keyword:
- export: 0
- **/
- unset($_GPC['controller']);
- unset($_GPC['export']);
-
- $post_data = array();
- $post_data['order_status_id'] = $_GPC['order_status_id'];
- $post_data['type'] = $_GPC['type'];
- $post_data['searchtime'] = $_GPC['searchtime'];
- $post_data['time[start]'] = $_GPC['time']['start'];
- $post_data['time[end]'] = $_GPC['time']['end'];
-
- $post_data['headid'] = $_GPC['headid'];
- $post_data['delivery'] = $_GPC['delivery'];
- $post_data['searchfield'] = $_GPC['searchfield'];
- $post_data['keyword'] = $_GPC['keyword'];
-
- $post_data['export'] = 1;
- $note_content = D('Home/Front')->get_config_by_name('order_note_name');
- $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
- $columns = array(
- array('title' => '订单流水号', 'field' => 'day_paixu', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '订单编号', 'field' => 'order_num_alias', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '会员昵称', 'field' => 'name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '会员手机号', 'field' => 'telephone', 'width' => 12, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '会员备注', 'field' => 'member_content', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '收货姓名(或自提人)', 'field' => 'shipping_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '联系电话', 'field' => 'shipping_tel', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '收货地址', 'field' => 'address_province_city_area', 'width' => 12, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '供应商名称/类型', 'field' => 'supply_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '提货详细地址', 'field' => 'address_address', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '商品名称', 'field' => 'goods_title', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '商品分类', 'field' => 'goods_category', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '商品价格', 'field' => 'goods_rprice2', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '商品数量', 'field' => 'quantity', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '支付方式', 'field' => 'paytype', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '配送方式', 'field' => 'delivery', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '预计送达时间', 'field' => 'expected_delivery_time', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '团长配送送货详细地址', 'field' => 'tuan_send_address', 'width' => 22, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '商品规格', 'field' => 'goods_optiontitle', 'width' => 12, 'sort' => 0, 'is_check' => 1),
-
- array('title' => '商品单价', 'field' => 'goods_price1', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '收货时间', 'field' => 'receive_time', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '快递单号', 'field' => 'expresssn', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '下单时间', 'field' => 'createtime', 'width' => 24, 'sort' => 0, 'is_check' => 1),
- array('title' => '小区名称', 'field' => 'community_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '团长姓名', 'field' => 'head_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '团长电话', 'field' => 'head_mobile', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '退款商品数量', 'field' => 'has_refund_quantity', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '退款金额', 'field' => 'has_refund_money', 'width' => 12, 'sort' => 0, 'is_check' => 1),
- array('title' => '微信支付交易单号', 'field' => 'transaction_id', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '商品编码', 'field' => 'goods_goodssn', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => 'openid', 'field' => 'openid', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '运费', 'field' => 'dispatchprice', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '积分抵扣', 'field' => 'score_for_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '满额立减', 'field' => 'fullreduction_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '优惠券优惠', 'field' => 'voucher_credit', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '应收款(该笔订单总款)', 'field' => 'price', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '状态', 'field' => 'status', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '团长佣金', 'field' => 'head_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '会员佣金', 'field' => 'member_commissmoney', 'width' => 12, 'sort' => 0, 'is_check' => 0),
- array('title' => '付款时间', 'field' => 'paytime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '发货时间', 'field' => 'sendtime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '完成时间', 'field' => 'finishtime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '快递公司', 'field' => 'expresscom', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '完整地址', 'field' => 'fullAddress', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '订单备注', 'field' => 'remark', 'width' => 36, 'sort' => 0, 'is_check' => 0),
- array('title' => '卖家订单备注', 'field' => 'remarksaler', 'width' => 36, 'sort' => 0, 'is_check' => 0),
- array('title' => '商品成本价', 'field' => 'costprice', 'width' => 36, 'sort' => 0, 'is_check' => 0),
- array('title' => '省市区', 'field' => 'province', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- array('title' => '商品重量', 'field' => 'goods_weight', 'width' => 24, 'sort' => 0, 'is_check' => 0),
- );
- if($order_note_open == 1){
- if(empty($note_content)){
- $note_content= '店名';
- }
- $columns[] = array('title' => $note_content, 'field' => 'note_content', 'width' => 24, 'sort' => 0, 'is_check' => 0);
- }
-
-
- //load_model_class('config')->update( array('modify_export_fields' => $modify_explode_arr ) );
- sellerLog('订单excel导出操作', 2);
- $modify_explode_json = D('Home/Front')->get_config_by_name('modify_export_fields');
-
- if( !empty($modify_explode_json) )
- {
- $modify_explode_arr = json_decode($modify_explode_json, true);
-
- foreach( $columns as $key => $val )
- {
- if( in_array($val['field'], array_keys($modify_explode_arr) ) )
- {
- $val['is_check'] =1;
- $val['sort'] = $modify_explode_arr[$val['field']];
- }else{
-
- $val['is_check'] =0;
- $val['sort'] = 0;
- }
- $columns[$key] = $val;
- }
-
- $last_index_sort = array_column($columns,'sort');
- array_multisort($last_index_sort,SORT_DESC,$columns);
-
- }
- $this->post_data = $post_data;
- $this->columns = $columns;
- $this->_GPC = $_GPC;
- $this->display();
-
-
-
- }
-
-
- public function oppay()
- {
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- show_json(0, array('message' => '您无此权限') );
- }
-
- $order_id = I('request.id');
-
-
- $res_arr = D('Seller/Order')->admin_pay_order($order_id);
-
-
- if( $res_arr['code'] == 0)
- {
- show_json(0, array('message' => $res_arr['msg']) );
- }else{
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- }
-
- public function detail()
- {
- $id = I('get.id');
- $item = M('lionfish_comshop_order')->where( array('order_id' => $id ) )->find();
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
- if($supply_can_look_headinfo != 1){
- $item['ziti_name'] = D('Seller/Order')->desensitize($item['ziti_name'],1,1);
- $item['ziti_mobile'] = D('Seller/Order')->desensitize($item['ziti_mobile'],3,4);
- }
- }
-
- switch ($item['delivery']){
- case 'pickup':$item['delivery_text'] = '社区自提';break;
- case 'express':$item['delivery_text'] = '快递';break;
- case 'tuanz_send':$item['delivery_text'] = '团长配送';break;
- case 'hexiao':$item['delivery_text'] = '到店核销';break;
- }
- //预收订单信息begin
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
- if( $presale_result['code'] == 0 )
- {
- $item['presale_info'] = $presale_result['data'];
- }else{
- $item['presale_info'] = [];
- }
- //预收订单信息end
- if($item['type'] == 'pintuan'){
-
- $pin_order = M('lionfish_comshop_pin_order')->field('pin_id')->where( array('order_id' => $id ) )->find();
-
- $pin_id = $pin_order['pin_id'];
-
- $this->pin_id = $pin_id;
- }
-
- $order_goods = array();
-
-
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id) )->select();
-
- $need_order_goods = array();
-
- $shipping_fare = 0;
- $fullreduction_money = 0;
- $voucher_credit = 0;
- $total = 0;
- $order_head_status = 0 ;
- foreach($order_goods as $key => $value)
- {
- // lionfish_community_head_commiss_order
- $value['name'] = htmlspecialchars_decode(stripslashes($value['name']));
- $head_commission_order_info = M('lionfish_community_head_commiss_order')->where( array('order_goods_id' => $value['order_goods_id'],'order_id' => $item['order_id']) )->select();
- if( !empty($head_commission_order_info) )
- {
-
- foreach( $head_commission_order_info as &$vv)
- {
- if($vv['state'] == 1){
- $order_head_status =1;
- }
- $head_info_tp = M('lionfish_community_head')->field('head_name')->where( array('id' => $vv['head_id'] ) )->find();
-
- $vv['head_name'] = $head_info_tp['head_name'];
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
- if($supply_can_look_headinfo != 1){
- $vv['head_name'] = D('Seller/Order')->desensitize($vv['head_name'],1,1);
- }
- }
-
-
- //退配送费
- $refund_shipping_fare = 0;
- if($vv['type'] == 'orderbuy' && $vv['add_shipping_fare'] > 0){
- $refund_shipping_sql = "SELECT sum(refund_shipping_fare) as refund_shipping_fare "
- . " FROM ".C('DB_PREFIX')."lionfish_comshop_order_goods_refund "
- . " WHERE order_id=".$vv['order_id'].' and order_goods_id='.$vv['order_goods_id'];
- $refund_shippings = M()->query($refund_shipping_sql);
-
- if(!empty($refund_shippings)){
- $refund_shipping_fare = $refund_shippings[0]['refund_shipping_fare'];
- }
- $vv['add_shipping_fare'] = $vv['add_shipping_fare'] - $refund_shipping_fare;
- $vv['money'] = $vv['money'];
- }else{
- $vv['add_shipping_fare'] = $vv['add_shipping_fare'];
- }
- if($vv['state'] == 2){//分佣订单已取消,分佣金额为0
- $vv['money'] = 0;
- }
- }
- unset($vv);
- }
- if( $value['is_refund_state'] == 1 || $value['has_refund_money'] > 0)
- {
- $refund_info = M('lionfish_comshop_order_refund')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->order('ref_id desc')->find();
- $value['refund_info'] = $refund_info;
- $goods_refund_shipping_fare = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->sum('refund_shipping_fare');
- $value['goods_refund_shipping_fare'] = $goods_refund_shipping_fare;
- }
- if( $item['is_commission'] == 1 )
- {
- $member_commission_list = M('lionfish_comshop_member_commiss_order')->where( array('order_goods_id' => $value['order_goods_id'],'order_id' => $item['order_id']) )->order('id asc')->select();
-
- if( !empty($member_commission_list) )
- {
- foreach( $member_commission_list as $kk => $vv )
- {
- $tmp_if = M('lionfish_comshop_member')->field('username')->where( array('member_id' => $vv['member_id'] ) )->find();
-
- $vv['username'] = $tmp_if['username'];
-
- $member_commission_list[$kk] = $vv;
- }
-
- }
-
-
-
- $value['member_commission_list'] = $member_commission_list;
- }
-
-
- $value['head_commission_order_info'] = $head_commission_order_info;
-
-
- $value['option_sku'] = D('Seller/Order')->get_order_option_sku($item['order_id'], $value['order_goods_id']);
-
- //退款商品价格
-
- $has_refund_money = M('lionfish_comshop_order_goods')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->find();
-
- $value['has_refund_money'] = $has_refund_money['has_refund_money'];
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $supper_info = get_agent_logininfo();
- if($supper_info['id'] != $value['supply_id'])
- {
- continue;
- }
- }
-
- if( $value['supply_id'] > 0 )
- {
- $supply_info = D('Home/Front')->get_supply_info($value['supply_id']);
- $value['supply_name'] = $supply_info['shopname'];
- $value['supply_type'] = $supply_info['type'] == 1 ? '独立' :'自营';
- }else{
- $value['supply_name'] = '平台自营';
- $value['supply_type'] = '自营';
- }
-
- $shipping_fare += $value['shipping_fare'];
- $fullreduction_money += $value['fullreduction_money'];
- $voucher_credit += $value['voucher_credit'];
- $total += $value['total'];
-
- if($item['delivery'] == 'hexiao'){
- $value['hx_info'] = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->find();
- if(!empty($value['hx_info'])){
- if($value['hx_info']['is_hexiao_over'] == 1 || $value['hx_info']['is_hexiao_over'] == 2){
- $value['hx_info']['is_can_refund'] = 0;
- }else if($value['hx_info']['is_hexiao_over'] == 0){
- //$can_refund_quantity = floor($value['hx_info']['remain_hexiao_count']/$value['hx_info']['one_hexiao_count']);
- $can_refund_quantity = floor($value['hx_info']['hexiao_count']/$value['hx_info']['one_hexiao_count']);
- // var_dump($can_refund_quantity);
- if($can_refund_quantity >= 1){
- $value['hx_info']['is_can_refund'] = 1;
- }else{
- $value['hx_info']['is_can_refund'] = 0;
- }
- }
- $record_count = M('lionfish_comshop_order_goods_saleshexiao_record')->where(array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->count();
- $value['hx_info']['record_count'] = $record_count;
- }
- }
-
- $need_order_goods[$key] = $value;
- }
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $item['shipping_fare'] = $shipping_fare;
- $item['fullreduction_money'] = $fullreduction_money;
- $item['voucher_credit'] = $voucher_credit;
- $item['total'] = $total;
- }
-
- $order_goods = $need_order_goods;
- if (empty($item)) {
- $this->message('抱歉,订单不存在!', $_SERVER['HTTP_REFERER'], 'error');
- }
-
- $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id'] ) )->find();
-
-
- $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
-
- $express_info = array();
- if( !empty($item['shipping_method']) )
- {
- $express_info = D('Seller/Express')->get_express_info($item['shipping_method']);
- }
- $this->express_info = $express_info;
-
- $coupon = array();
- //voucher_id voucher_credit
- //ims_
- if( $item['voucher_id'] > 0 )
- {
- $coupon = array();
-
- //$coupon = pdo_fetch("select * from ".tablename('lionfish_comshop_coupon_list')." where uniacid=:uniacid and id=:id ",
- //array(':uniacid' => $_W['uniacid'], ':id' => $item['voucher_id']));
- }
- if( $item['delivery'] == 'localtown_delivery' && ($item['order_status_id'] != 3 && $item['order_status_id'] != 5 ) )
- {
- $item['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $item['order_id'] ) )->find();
- if( !empty($item['orderdistribution_order']) && $item['orderdistribution_order'] > 0 )
- {
- if($item['orderdistribution_order']['orderdistribution_id'] > 0){
- $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $item['orderdistribution_order']['orderdistribution_id'] ) )->find();
- $item['orderdistribution_order']['username'] = $orderdistribution['username'];
- }else{
- /*if($item['orderdistribution_order']['orderdistribution_id'] == -1){
- $item['orderdistribution_order']['username'] = "系统默认配送员";
- }else{*/
- if($item['orderdistribution_order']['third_distribution_type'] == 'imdada'){
- $item['orderdistribution_order']['username'] = "达达平台配送";
- }else if($item['orderdistribution_order']['third_distribution_type'] == 'sf'){
- $item['orderdistribution_order']['username'] = "顺丰同城配送";
- }else if($item['orderdistribution_order']['third_distribution_type'] == 'uupt'){
- $item['orderdistribution_order']['username'] = "UU跑腿配送";
- }else if($item['orderdistribution_order']['third_distribution_type'] == 'dianwoda'){
- $item['orderdistribution_order']['username'] = "点我达配送";
- }
- //}
- }
- }
- }
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
- if($supply_can_look_headinfo != 1){
- if( $item['delivery'] == 'pickup' ){
-
- $shipping_stree = D('Home/Front')->get_area_info($item['shipping_stree_id']);
- $tuan_address = $province_info['name'].$city_info['name'].$area_info['name'];
- $tuan_address2= str_replace($tuan_address, '',$item['shipping_address']);
- $str = $tuan_address2;
- strlen($str);
- $i = mb_strlen($str,"UTF-8");
- $tuan_address2 = D('Seller/Order')->desensitize($tuan_address2,1,$i-2);
- $item['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$tuan_address2;
- }
- }
- }
-
- //售后期
- $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
- //天数
- $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
- $order_settlement =" ";
-
- //订单状态
- if($item['order_status_id'] ==5 || $item['order_status_id'] ==7 ){
- //已失效
- $order_status = 2;
-
- }else{
- //待结算
- $order_status = $order_head_status;
- if(($item['order_status_id'] ==6 || $item['order_status_id'] ==11) ){
- if($item['order_status_id'] ==6){
- $order_settlement = $item['receive_time'] + $open_aftersale_time*86400;
- }
- if($item['order_status_id'] ==11){
- $order_settlement = $item['finishtime'] + $open_aftersale_time*86400;
- }
- }
-
-
- }
- $this->open_aftersale = $open_aftersale;
- $this->order_status = $order_status;
- $this->open_aftersale_time = $open_aftersale_time;
- $this->order_settlement = $order_settlement;
-
- $this->id = $id;
- $this->item = $item;
- $this->order_goods = $order_goods;
- $this->member = $member;
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
-
-
- $history_list = M('lionfish_comshop_order_history')->where( array('order_id' => $id ) )->order('order_history_id asc')->select();
-
- $order_status_arr = D('Seller/Order')->get_order_status_name();
-
- //$order_history['order_status_id'] = 18;
-
- $order_status_arr[18] = '已结算';
- $order_status_arr[19] = '商品部分退款';
- $order_status_arr[20] = '拒绝商品部分退款';
- $order_status_arr[15] = '预售支付定金';
- foreach( $history_list as &$val )
- {
- if( $val[''] == '订单改价' )
- {
- $val['order_status_name'] = 'comment';
- }
- else{
- $val['order_status_name'] = $order_status_arr[$val['order_status_id']];
- }
- }
- unset($val);
-
- $this->history_list = $history_list;
- $this->order_status_arr = $order_status_arr;
-
- $is_can_look_headinfo = true;
- $is_can_nowrfund_order = true;
- $is_can_confirm_delivery = true;
- $is_can_confirm_receipt = true;
-
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
-
- $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
- $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
- $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
- {
- $is_can_look_headinfo = false;
- }
- if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
- {
- $is_can_nowrfund_order = false;
- }
- if( isset($supply_can_confirm_delivery) && $supply_can_confirm_delivery == 2 )
- {
- $is_can_confirm_delivery = false;
- }
- if( isset($supply_can_confirm_receipt) && $supply_can_confirm_receipt == 2 )
- {
- $is_can_confirm_receipt = false;
- }
- }
- $s_id = 1 ;
- if(SELLERUID != 1)
- {
- $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
-
- $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
- $perms1 = str_replace('.','/',$perms_arr['perms2']);
-
- $perms2 = explode(",", $perms1);
- if(in_array("user/user/index", $perms2)){
- $s_id = 1 ;
- } else {
- $s_id = 0 ;
- }
- }
- $this->s_id = $s_id;
- //预售判断 begin
- $is_presale = 0;
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
- $presale_for_ordermoney = 0;
- if( $presale_result['code'] == 0 )
- {
- if( $presale_result['data']['presale_deduction_money'] > 0 )
- {
- $presale_for_ordermoney = $presale_result['data']['presale_for_ordermoney'];
- }
- $is_presale = 1;
- }
- $this->is_presale = $is_presale;
- $this->presale_for_ordermoney = $presale_for_ordermoney;
- //预售end
- //礼品卡begin
- $is_virtualcard = 0;
- $virtualcard_result = D('Seller/VirtualCard')->getVirtualCardOrderInfO( $id );
- if( $virtualcard_result['code'] == 0 )
- {
- $is_virtualcard = 1;
- $this->virtualcard_info = $virtualcard_result['data'];
- }
- $this->is_virtualcard = $is_virtualcard;
- //礼品卡end
- //订单表单信息
- $order_form_data = D('Home/Allform')->getOrderFormInfo($id, $item['member_id']);
- $this->order_form_data = $order_form_data;
- $is_order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
-
- $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
-
- $order_note_name = isset($order_note_name) && !empty($order_note_name) ? $order_note_name :'店名';
-
- $open_admin_payment = D('Home/Front')->get_config_by_name('open_admin_payment');
- $this->open_admin_payment = $open_admin_payment;
- $localtown_modifypickingname = D('Home/Front')->get_config_by_name('localtown_modifypickingname');
- $localtown_modifypickingname = !empty($localtown_modifypickingname) ? $localtown_modifypickingname: '包装费';
- $this->is_order_note_open = $is_order_note_open;
- $this->order_note_name = $order_note_name;
- $this->is_can_look_headinfo = $is_can_look_headinfo;
- $this->is_can_nowrfund_order = $is_can_nowrfund_order;
- $this->is_can_confirm_delivery = $is_can_confirm_delivery;
- $this->is_can_confirm_receipt = $is_can_confirm_receipt;
- $this->localtown_modifypickingname = $localtown_modifypickingname;
- $this->display();
- }
-
- //查看物流
- public function express(){
- $_GPC = I('request.');
- $order_id = $_GPC['order_id'];
-
- $express_list = D('Seller/Order')->goods_express($order_id);
-
- if($express_list['code'] == 2){
- $code = $express_list['code'];
- $reason = $express_list['Reason'];
- $this->code = $code;
- $this->reason = $reason;
- }
-
-
- $new_array = json_decode(json_encode($express_list['order_info']['shipping_traces']), true);
- $new_array = array_reverse($new_array);
- $this->list = $new_array;
- $this->display();
- }
-
- public function refund_mult()
- {
- $_GPC = I('request.');
-
- $ids_arr = $_GPC['ids_arr'];
-
- $cache_key = md5(time().count($ids_arr).'_sendmulutrefund');
-
- $quene_order_list = array();
-
- //限定配送数组
- S('_multrefund_'.$cache_key, $ids_arr);
-
- $this->_GPC = $_GPC;
- $this->cache_key = $cache_key;
-
- $this->display();
- }
-
-
- public function refund_mult_do()
- {
- $_GPC = I('request.');
-
-
- $cache_key = $_GPC['cache_key'];
-
- $quene_order_list = S('_multrefund_'.$cache_key);
-
- $order_id = array_shift($quene_order_list);
-
- S('_multrefund_'.$cache_key, $quene_order_list);
-
-
- //...
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- $weixin_model = D('Home/Weixin');
-
- $title = '订单编号:'.$order_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理";
-
- //order_status_id
- if( in_array($order_info['order_status_id'], array(1,4,6,10,11,12,14)) ){
-
- $res = $weixin_model->refundOrder($order_id);
-
- if( $res['code'] == 0 )
- {
- $title = '订单编号:'.$order_info['order_num_alias']." 退款失败,还剩余".count($quene_order_list)."个清单未处理";
- }else{
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- $comment = '群接龙批量退款,全额退款';
-
- $order_history = array();
-
- $order_history['order_id'] = $order_id;
- $order_history['order_status_id'] = 7;
- $order_history['notify'] = 0;
- $order_history['comment'] = $comment;
- $order_history['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $order_history );
-
- M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('order_status_id' => 7) );
-
- $refund_all = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id, 'state' => 0 ) )->select();
-
- if( !empty($refund_all) )
- {
- foreach( $refund_all as $val )
- {
- $ins_data = array();
-
- $ins_data['ref_id'] = $val['ref_id'];
- $ins_data['order_id'] = $val['order_id'];
- $ins_data['order_goods_id'] = $val['order_goods_id'];
- $ins_data['message'] = '群接龙批量退款 ,退款成功';
- $ins_data['type'] = 2;
- $ins_data['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add( $ins_data );
-
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $val['ref_id']) )->save( array('state' => 3) );
- }
- }
-
- $is_print_admin_cancleorder = D('Home/Front')->get_config_by_name('is_print_admin_cancleorder');
-
- if( isset($is_print_admin_cancleorder) && $is_print_admin_cancleorder == 1 )
- {
- sellerLog('群接龙后台取消订单', 2);
- D('Seller/Printaction')->check_print_order($id,'群接龙后台取消订单');
- D('Seller/Printaction')->check_print_order2($id,'群接龙后台取消订单');
- }
- }
-
- }
-
- if( empty($quene_order_list) )
- {
- echo json_encode( array('code' => 2) );
- die();
- }
-
- //清单编号
-
- echo json_encode( array('code' => 0, 'msg' => $title ) );
- die();
- }
-
-
-
-
- public function opreceive()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
- //检查订单是否能确认收货(存在售后未完成无法确认收货)
- $result = D('Seller/Order')->check_order_receive($item['order_id']);
- if($result['status'] == 0){
- show_json(0, array('msg'=>"该订单处于售后处理中,请处理后再确认收货!"));
- }
- if($item['delivery'] == 'localtown_delivery') {
- $result = D('Seller/Order')->check_localtown_order_receive($item['order_id']);
- if ($result['status'] == 0) {
- show_json(0, array('msg' => "该订单未有配送员接单或还未指定配送员,无法确认收货!"));
- }
- }
- //pdo_update('lionfish_comshop_order', array('order_status_id' => 6, 'receive_time' => time()), array('order_id' => $item['order_id'], 'uniacid' => $_W['uniacid']));
- if( $item['delivery'] == 'localtown_delivery' )
- {
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $item['order_id']) )->save( array('state' => 4) );
- D('Home/LocaltownDelivery')->write_distribution_log( $item['order_id'], 0 , 4 , "后台操作,确认收货" );
- }
- D('Seller/Order')->receive_order($item['order_id']);
-
- M('lionfish_comshop_order_history')->where( array('order_id' => $item['order_id'],'order_status_id' => 6) )->save( array( 'comment' => '后台操作,确认收货') );
- if( $item['delivery'] == 'localtown_delivery' )
- {
- //D('Home/LocaltownDelivery')->distribution_deliverying_order( $item['order_id'] );
- D('Home/LocaltownDelivery')->distribution_arrived_order( $item['order_id'] ,0 );
- }
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- public function orderaftersales()
- {
- //$_GPC['order_status_id'] = 12;
-
- $gpc = I('request.');
- $this->gpc = $gpc;
- $this->_GPC = $gpc;
- $time = I('request.time');
-
- $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
- $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
-
-
- $this->searchfield = I('request.searchfield','');
- $this->keyword = I('request.keyword','');
- $this->searchtime = I('request.searchtime','');
- $this->delivery = I('request.delivery','');
- $this->starttime = $starttime;
- $this->endtime = $endtime;
- $this->time = $time;
-
-
- $order_status_arr = D('Seller/Order')->get_order_status_name();
- $this->order_status_arr = $order_status_arr;
-
- $need_data = D('Seller/Order')->load_afterorder_list();//改造原来的加载方法
-
- $this->need_data = $need_data;
-
- $cur_controller = 'order/order';
- $total = $need_data['total'];
- $total_money = $need_data['total_money'];
- $list = $need_data['list'];
- $pager = $need_data['pager'];
- $all_count = $need_data['all_count'];
- $count_status_1 = $need_data['count_status_1'];
- $count_status_3 = $need_data['count_status_3'];
- $count_status_4 = $need_data['count_status_4'];
- $count_status_5 = $need_data['count_status_5'];
- $count_status_7 = $need_data['count_status_7'];
- $count_status_11 = $need_data['count_status_11'];
- $count_status_14 = $need_data['count_status_14'];
-
- $this->cur_controller = $cur_controller;
- $this->total = $total;
- $this->total_money = $total_money;
- $this->list = $list;
- $this->pager = $pager;
- $this->all_count = $all_count;
- $this->count_status_1 = $count_status_1;
- $this->count_status_3 = $count_status_3;
- $this->count_status_4 = $count_status_4;
- $this->count_status_5 = $count_status_5;
- $this->count_status_7 = $count_status_7;
- $this->count_status_11 = $count_status_11;
- $this->count_status_14 = $count_status_14;
-
-
- $s_id = 1 ;
- if(SELLERUID != 1)
- {
- $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
-
- $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
- $perms1 = str_replace('.','/',$perms_arr['perms2']);
-
- $perms2 = explode(",", $perms1);
- if(in_array("user/user/index", $perms2)){
- $s_id = 1 ;
- } else {
- $s_id = 0 ;
- }
- }
- $this->s_id = $s_id;
-
-
- $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
-
- if( empty($open_feier_print) )
- {
- $open_feier_print = 0;
- }
-
- $this->open_feier_print = $open_feier_print;
-
- //退款状态:0申请中,1商家拒绝,2平台介入,3退款成功,4退款失败,5:撤销申请
- $order_refund_state = array(0=>'申请中',1=>'商家拒绝', 2=>'平台介入',3=>'退款成功',4=>'退款失败',5=>'撤销申请');
-
- $this->order_refund_state = $order_refund_state;
-
- $is_can_look_headinfo = true;
- $is_can_nowrfund_order = true;
-
- $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
-
- $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
- if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
- {
- $is_can_look_headinfo = false;
- }
- if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
- {
- $is_can_nowrfund_order = false;
- }
- }
-
- $this->is_can_look_headinfo = $is_can_look_headinfo;
- $this->is_can_nowrfund_order = $is_can_nowrfund_order;
-
- $this->display();
- }
-
- public function oprefund_doform()
- {
- $_GPC = I('request.');
-
- $ref_id = $_GPC['ref_id'];
- $refund_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
-
- $this->ref_id = $ref_id;
- $this->refund_info = $refund_info;
-
- if (IS_POST) {
-
- $order_history = array();
- $order_history['order_id'] = $refund_info['order_id'];
-
- $order_history['order_status_id'] = 0;
- $order_history['notify'] = 0;
- $order_history['comment'] = '';
- $order_history['date_added'] = time();
-
-
- $remarkrefund = $_GPC['remarkrefund'];
- $is_forbidden = $_GPC['is_forbidden'];
-
- $cansub = $_GPC['cansub'];
-
- if( isset($_GPC['is_forbidden']) && $_GPC['is_forbidden'] > 0 )
- {
- //添加
- $refund_disable = M('lionfish_comshop_order_refund_disable')->where( array('ref_id' => $ref_id ) )->find();
-
- if( empty($refund_disable) )
- {
- //插入
- $ins_data = array();
- $ins_data['ref_id'] = $ref_id;
- $ins_data['order_id'] = $refund_info['order_id'];
- $ins_data['order_goods_id'] = $refund_info['order_goods_id'];
- $ins_data['addtime'] = time();
-
- M('lionfish_comshop_order_refund_disable')->add($ins_data);
- }
-
- }else{
- //删除
- M('lionfish_comshop_order_refund_disable')->where( array('ref_id' => $ref_id ) )->delete();
-
- }
-
- if($cansub == 1)
- {
- //确认退款 remarkrefund
-
- $weixin_model = D('Home/Weixin');
-
- $order_refund = M('lionfish_comshop_order_refund')->field('ref_money,real_refund_quantity,ref_shipping_fare')->where( array('ref_id' => $ref_id ) )->find();
-
-
- //$order_info['total']
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->find();
-
- if( $order_info['type'] == 'integral' || $order_info['type'] == 'normal' )
- {
- //M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('shipping_fare' => $order_refund['ref_shipping_fare'] ) );
-
- if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->find();
-
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->save( array('shipping_fare' => $order_refund['ref_shipping_fare'] ) );
- }
- }
-
- if( $order_refund['real_refund_quantity'] > 0 )
- {
- //部分商品退款
- $res = $weixin_model->refundOrder($refund_info['order_id'], $order_refund['ref_money'],0,$refund_info['order_goods_id'],1, $order_refund['real_refund_quantity'],1);
- }else{
-
- $res = $weixin_model->refundOrder($refund_info['order_id'], $order_refund['ref_money'],0,$refund_info['order_goods_id']);
-
- }
- if( $order_info['type'] == 'integral' || $order_info['type'] == 'normal')
- {
- //M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('shipping_fare' => $order_info['shipping_fare'] ) );
-
- if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
- {
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->save( array('shipping_fare' => $order_goods['shipping_fare'] ) );
- }
-
- }
-
- if($res['code'] == 1)
- {
-
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] , 'order_id' => $refund_info['order_id'] ) )->find();
-
- if( $order_refund['real_refund_quantity'] <= 0 )
- {
- $order_refund['real_refund_quantity'] = $order_goods['quantity'] - $order_goods['has_refund_quantity'];
-
- }
-
- $pay_total_money = $order_goods['total']-$order_goods['voucher_credit']-$order_goods['fullreduction_money'] - $order_goods['score_for_money'];
-
- $buy_usescore = D('Seller/Commonorder')->get_order_goods_buyscore($refund_info['order_id'], $refund_info['order_goods_id']);
- if( !empty($buy_usescore) && $buy_usescore > 0 )
- {
- $res_score= ceil( $buy_usescore * ( $order_refund['real_refund_quantity']/ $order_goods['quantity']) );
-
- D('Seller/Commonorder')->refund_order_goods_intrgral( $refund_info['order_id'], $refund_info['order_goods_id'] ,$res_score );
- }
-
- if($order_refund['ref_money']-$order_refund['ref_shipping_fare'] <= 0){
- $refund_money = 0;
- }else{
- $refund_money = $order_refund['ref_money']-$order_refund['ref_shipping_fare'];
- }
-
- if( $order_info['type'] == 'integral'){
- $refund_money = $order_refund['ref_money'];
- }
-
- //退款配送费问题
- D('Seller/Commonorder')->ins_order_goods_refund($refund_info['order_id'], $refund_info['order_goods_id'],$pay_total_money,$order_refund['real_refund_quantity'], $order_refund['real_refund_quantity'],$refund_money,1,$order_refund['ref_shipping_fare']);
-
- //如果这个商品没有数量了。就改变他的状态为已退款的状态
- $new_total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($refund_info['order_id'],$refund_info['order_goods_id'] );
- $ref_count = M('lionfish_comshop_order_refund')->where( array('order_id' => $refund_info['order_id'], 'state' => 0 ) )->count();
-
- if( $new_total_quantity <=0 && $ref_count <= 1)
- {
- D('Seller/Commonorder')->check_refund_order_goods_status($refund_info['order_id'],$refund_info['order_goods_id'], $order_refund['ref_money'],1,$order_refund['real_refund_quantity'], $order_refund['real_refund_quantity'],1,'平台同意退款,');
-
- }else{
-
- $order_history = array();
- $order_history['uniacid'] = 0;
- $order_history['order_id'] = $refund_info['order_id'];
- $order_history['order_goods_id'] = $refund_info['order_goods_id'];
- $order_history['notify'] = 0;
- $order_history['order_status_id'] = 19;
-
- if( $order_info['type'] == 'integral' )
- {
- $order_history['comment'] = '平台同意退款,子订单退款,退款商品:'.$order_refund['real_refund_quantity'] .'个,退库存/销量数量'.$order_refund['real_refund_quantity'].'个,退款积分'.$order_refund['ref_money'].'积分';
- if( !empty($order_refund['ref_shipping_fare']) ){
- $order_history['comment'] .= '. 退配送费:'.$order_refund['ref_shipping_fare'].'元';
-
- }
-
-
- }else{
- $order_history['comment'] = '平台同意退款,子订单退款,退款商品:'.$order_refund['real_refund_quantity'] .'个,退库存/销量数量'.$order_refund['real_refund_quantity'].'个,退款金额'.$order_refund['ref_money'].'元';
- }
- $order_history['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $order_history );
-
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] ) )->save( array('is_refund_state' => 0 ) );
- }
-
-
- //D('Seller/Commonorder')->ins_order_goods_refund($order_id, $order_goods_id,$pay_total_money,$real_refund_quantity, $refund_quantity,$refund_money, $is_back_sellcount);
-
-
- $order_refund_history = array();
- $order_refund_history['ref_id'] = $ref_id;
- $order_refund_history['order_id'] = $refund_info['order_id'];
- $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
-
- $order_refund_history['message'] = '平台同意退款'.' '.$remarkrefund.' ,退款成功';
- $order_refund_history['type'] = 2;
- $order_refund_history['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
-
- //通过 lionfish_comshop_order_refund
- sellerLog('同意'.$remarkrefund.'退款成功操作', 2);
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 3,'modify_time' => time(),'remarkrefund' => $remarkrefund) );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }else{
-
- if( empty($res['msg']) )
- {
- $res['msg'] = '请检查商户号与cert证书';
- }
-
- $order_refund_history = array();
- $order_refund_history['ref_id'] = $ref_id;
- $order_refund_history['order_id'] = $refund_info['order_id'];
- $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
-
- $order_refund_history['message'] = '平台同意退款'.' '.$remarkrefund.' ,但是退款失败:'.$res['msg'];
- $order_refund_history['type'] = 2;
- $order_refund_history['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
-
- show_json(0, array('message' => $res['msg']) );
- }
-
- }else if($cansub == 2){
- //拒绝退款
- $order_refund_history = array();
- $order_refund_history['ref_id'] = $ref_id;
- $order_refund_history['order_id'] = $refund_info['order_id'];
- $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
-
- $order_refund_history['message'] = '平台拒绝退款'.' '.$remarkrefund;
- $order_refund_history['type'] = 2;
- $order_refund_history['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
-
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 1,'modify_time' => time(),'remarkrefund' => $remarkrefund ) );
-
- $item = M('lionfish_comshop_order')->field('order_status_id,last_refund_order_status_id')->where( array('order_id' => $refund_info['order_id'] ) )->find();
-
- $order_history['order_status_id'] = 20;
-
- //如果是部分退款,那么就不是12了
- if( $item['order_status_id'] == 12)
- {
- $order_history['order_status_id'] = 12;
- if( $item['last_refund_order_status_id'] > 0 )
- {
- $order_history['order_status_id'] = $item['last_refund_order_status_id'];
-
- M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('order_status_id' => $item['last_refund_order_status_id']) );
-
- $order_history['order_status_id'] = $item['last_refund_order_status_id'];
- $order_history['comment'] = '商家拒绝退款,订单回退上一状态';
- }else{
- $order_history['comment'] = '商家拒绝退款';
- }
- }
-
- if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
- {
-
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] ) )->save( array('is_refund_state' => 0) );
-
- }
-
- //拒绝 order_status_id
- sellerLog($order_history['comment'].'操作', 2);
- M('lionfish_comshop_order_history')->add( $order_history );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
-
- }
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
-
- $this->display();
- }
-
-
- public function oprefund()
- {
- $_GPC = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
-
- $ref_id = $_GPC['ref_id'];
-
- $ref_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
-
-
- $step_array = array();
- $step_array[1]['step'] = 1;
- $step_array[1]['title'] = '客户发起退款';
- $step_array[1]['time'] = $ref_info['addtime'];
- $step_array[1]['done'] = 1;
- $step_array[2]['step'] = 2;
- $step_array[2]['title'] = '平台处理维权申请';
- $step_array[2]['done'] = 0;
- $step_array[2]['time'] = '';
- $step_array[3]['step'] = 3;
- $step_array[3]['done'] = 0;
- $step_array[3]['title'] = '商家处理退款完成';
- $step_array[3]['time'] = '';
-
- $ref_id = I('request.ref_id');
- $this->ref_id = $ref_id;
-
- $this->ref_info = $ref_info;
-
- $order_goods_id = $ref_info['order_goods_id'];
-
- if( !empty($order_goods_id) && $order_goods_id > 0 )
- {
- $goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id, 'order_id' => $id ) )->select();
- }else{
-
- $goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->select();
- }
-
-
- $total_fare = 0;
-
- $total_shipping_fare = 0;
- $total_voucher_credit =0;
- $total_fullreduction_money = 0;
- $total_total_fare = 0;
-
- $total_score_for_money = 0;
-
- /**
- php echo number_format($item['total']+$item['shipping_fare']-$item['voucher_credit']-$item['fullreduction_money'],2)
- **/
-
-
- foreach($goods as &$value)
- {
- $value['option_sku'] = D('Seller/Order')->get_order_option_sku($item['order_id'], $value['order_goods_id']);
-
- $total_fare += $value['total'];
- $total_shipping_fare += $value['shipping_fare'];
- $total_voucher_credit += $value['voucher_credit'];
- $total_fullreduction_money += $value['fullreduction_money'];
- $total_score_for_money += $value['score_for_money'];
-
- $total_total_fare += $value['total']+$value['shipping_fare']-$value['voucher_credit']-$value['fullreduction_money']-$value['score_for_money'];
-
- }
- $this->goods = $goods;
-
- $this->total_fare = $total_fare;
- $this->total_shipping_fare = $total_shipping_fare;
- $this->total_voucher_credit = $total_voucher_credit;
- $this->total_fullreduction_money = $total_fullreduction_money;
- $this->total_score_for_money = $total_score_for_money;
- $this->total_total_fare = $total_total_fare;
- unset($r);
- $item['goods'] = $goods;
-
- $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id']) )->find();
-
-
- $this->member = $member;
-
-
- $express_list = array();
-
- $r_type = array(1=>'仅退款',2 => '退款退货');
- //ims_
- $this->r_type =$r_type;
-
- $order_refund = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->find();
-
-
- $this->order_refund = $order_refund;
-
- if($order_refund['modify_time'] != 0 && $order_refund['state']== 3)
- {
- $step_array[3]['done'] = 1;
- $step_array[3]['time'] = $order_refund['modify_time'];
- }
-
-
-
- $refund_imgs = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id'] ) )->select();
-
- $this->refund_imgs = $refund_imgs;
-
- /**
- if( !empty($order_goods_id) && $order_goods_id > 0 )
- {
- $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' =>$id,'order_goods_id' => $order_goods_id ) )->order('addtime asc')->select();
- }
- else{
-
- $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' =>$id ) )->order('addtime asc')->select();
- }
- **/
- $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('ref_id' => $ref_id ) )->order('addtime asc')->select();
-
- $i = 1;
-
- foreach($order_refund_history as $key => $val)
- {
- if( $i == 1 && $val['type'] == 2 )
- {
- $step_array[2]['done'] = 1;
- $step_array[2]['time'] = time();
- $i++;
- }
- $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
-
-
- switch($val['type'])
- {
- case 1:
- $val['type'] = '用户反馈';
- break;
- case 2:
- $val['type'] = '商家反馈';
- break;
- case 3:
- $val['type'] = '平台反馈';
- break;
-
- }
-
-
- $order_refund_history_image = M('lionfish_comshop_order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
-
- if(!empty($order_refund_history_image))
- {
- foreach($order_refund_history_image as $kk => $vv)
- {
- $vv['thumb_image'] = resize ($vv['image'], 200,200);
- $order_refund_history_image[$kk] = $vv;
- }
- }
- $val['order_refund_history_image'] = $order_refund_history_image;
- $order_refund_history[$key] = $val;
- }
-
- $this->step_array = $step_array;
-
- $this->order_refund_history = $order_refund_history;
- $this->item = $item;
- $this->display();
- }
-
-
- public function oprefund_submit()
- {
- $gpc = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
- if (IS_POST) {
-
- $id = $gpc['id'];
- //refundstatus message refundcontent
-
- $refundstatus = $gpc['refundstatus'];
- $message = $gpc['message'];
- $refundcontent = $gpc['refundcontent'];
-
- $ref_id = $gpc['refundid'];
-
- /**
- int(37)
- string(1) "1"
- string(0) ""
- string(15) "天天来退货"
- **/
- //1 ,3
-
- $comment = '';
-
- switch( $refundstatus )
- {
- case 1:
- $comment = $refundcontent;
- break;
- case 3:
- $comment = $message;
- break;
- }
-
- $ref_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
-
- $result = array('code' =>1);
-
- $order_refund_history = array();
- $order_refund_history['order_id'] = $ref_info['order_id'];
- $order_refund_history['order_goods_id'] = $ref_info['order_goods_id'];
- $order_refund_history['message'] = htmlspecialchars($comment);
- $order_refund_history['type'] = 2;
- $order_refund_history['addtime'] = time();
-
- M('lionfish_comshop_order_refund_history')->add($order_refund_history);
-
-
-
- $order_history = array();
- $order_history['order_id'] = $id;
- $order_history['order_status_id'] = 0;
- $order_history['notify'] = 0;
- $order_history['comment'] = '';
- $order_history['date_added'] = time();
-
- if($refundstatus ==1)
- {
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 1) );
-
- //id item $order_info $item
-
- $item = M('lionfish_comshop_order')->field('order_status_id,last_refund_order_status_id')->where( array('order_id' => $id ) )->find();
-
-
- //如果是部分退款,那么就不是12了
- if( $item['order_status_id'] == 12)
- {
- $order_history['order_status_id'] = 12;
- if( $item['last_refund_order_status_id'] > 0 )
- {
- $order_history['order_status_id'] = $item['last_refund_order_status_id'];
-
- M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('order_status_id' =>$item['last_refund_order_status_id'] ) );
-
- $order_history['order_status_id'] = $item['last_refund_order_status_id'];
- }
-
- }
-
- if( !empty($ref_info['order_goods_id']) && $ref_info['order_goods_id'] > 0 )
- {
- M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $ref_info['order_goods_id'] ) )->save( array('is_refund_state' =>0 ) );
- }
-
- //拒绝 order_status_id
- $order_history['comment'] = '商家拒绝退款,订单回退上一状态';
-
- M('lionfish_comshop_order_history')->add( $order_history );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- } else {
-
- $weixin_model = D('Home/Weixin');
-
- $order_refund = M('lionfish_comshop_order_refund')->field('ref_money')->where( array('ref_id' => $ref_id) )->find();
-
-
- $res = $weixin_model->refundOrder($id, $order_refund['ref_money'],0,$ref_info['order_goods_id']);
-
-
- //array('code' => 0, 'msg' => $res['err_code_des']);
- if($res['code'] == 1)
- {
- $order_history['order_status_id'] = 7;
- $order_history['comment'] = '商家同意退款';
-
- M('lionfish_comshop_order_history')->add( $order_history );
-
- //通过 lionfish_comshop_order_refund
-
- M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 3) );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }else{
- if( empty($res['msg']) )
- {
- $res['msg'] = '请检查商户号与cert证书';
- }
-
- show_json(0, array('message' => $res['msg']) );
- }
- }
-
-
- }
-
- $r_type = array(1=>'仅退款',2 => '退款退货');
- //ims_
-
- $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $id) )->find();
-
- $refund_imgs = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id']) )->find();
-
- $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $id) )->order('addtime asc')->select();
-
- foreach($order_refund_history as $key => $val)
- {
- $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
- switch($val['type'])
- {
- case 1:
- $val['type'] = '用户反馈';
- break;
- case 2:
- $val['type'] = '商家反馈';
- break;
- case 3:
- $val['type'] = '平台反馈';
- break;
-
- }
-
-
- $order_refund_history_image = M('lionfish_comshop_order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
-
- if(!empty($order_refund_history_image))
- {
- foreach($order_refund_history_image as $kk => $vv)
- {
- $vv['thumb_image'] = resize ($vv['image'], 200,200);
- $order_refund_history_image[$kk] = $vv;
- }
- }
- $val['order_refund_history_image'] = $order_refund_history_image;
- $order_refund_history[$key] = $val;
- }
-
- $this->order_refund = $order_refund;
- $this->r_type = $r_type;
- $this->item = $item;
- $this->display();
- }
- public function ordercomment_gift()
- {
- if (IS_POST) {
- $data = array();
- $data = I('request.data');
- $data['open_comment_gift'] = trim($data['open_comment_gift']);
- $data['comment_gift_score'] = trim($data['comment_gift_score']);
- $data['comment_gift_time'] = trim($data['comment_gift_time']);
- $data['comment_gift_max_score'] = trim($data['comment_gift_max_score']);
- $data['comment_gift_publish'] = trim($data['comment_gift_publish']);
- D('Seller/Config')->update($data);
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
- if(empty($data['comment_gift_publish'])){
- $data['comment_gift_publish'] = "参与好评有礼活动,好评成功并且后台审核通过以后可获得获得活动积分";
- }
- $this->data = $data;
- $this->display();
- }
- public function ordercomment_config()
- {
-
-
- if (IS_POST) {
- $data = array();
-
- $data = I('request.data');
- $data['open_comment_shenhe'] = trim($data['open_comment_shenhe']);
-
- D('Seller/Config')->update($data);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
-
- $this->data = $data;
- $this->display();
- }
-
- public function ordercomment()
- {
-
- $condition = ' 1 ';//0
- $pindex = I('request.page', 1);
- $psize = 20;
-
- $keyword = I('request.keyword');
- $this->keyword = $keyword;
-
- if (!empty($keyword)) {
- $condition .= ' and content like '.'"%' . $keyword . '%" ';
- }
-
-
- $label = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_order_comment
- WHERE " . $condition . ' order by comment_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
-
-
- $total = M('lionfish_comshop_order_comment')->where($condition)->count();
-
- $pager = pagination2($total, $pindex, $psize);
-
- $this->pager = $pager;
- $this->total = $total;
- $this->label = $label;
- $this->display();
- }
-
- public function deletecomment()
- {
-
- $id = I('request.id');
- if (empty($id)) {
- $ids = I('request.ids');
- $id = (is_array($ids) ? implode(',', $ids) : 0);
- }
- $items = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('comment_id' => array('in',$id) ) )->select();
- if (empty($item)) {
- $item = array();
- }
- foreach ($items as $item) {
- M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->delete();
- }
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- public function commentstate()
- {
-
- $id = I('request.id');
- if (empty($id)) {
- $ids = I('request.ids');
- $id = (is_array($ids) ? implode(',', $ids) : 0);
- }
- $items = pdo_fetchall('SELECT comment_id FROM ' . tablename('lionfish_comshop_order_comment') . '
- WHERE comment_id in( ' . $id . ' ) ' );
-
- $items = M('lionfish_comshop_order_comment')->where( array() )->select();
- if (empty($item)) {
- $item = array();
- }
- foreach ($items as $item) {
- pdo_update('lionfish_comshop_order_comment', array('state' => intval($_GPC['state'])), array('comment_id' => $item['comment_id']));
- }
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
-
- }
-
- public function config()
- {
- if (IS_POST) {
- $data = array();
-
- $data = I('request.data');
- $data['open_admin_payment'] = trim($data['open_admin_payment']);
- $data['open_auto_receive'] = trim($data['open_auto_receive']);
- $data['shop_limit_buy_distance'] = trim($data['shop_limit_buy_distance']);
- $data['is_open_order_message'] = trim($data['is_open_order_message']);
- $data['is_hidden_orderlist_phone'] = trim($data['is_hidden_orderlist_phone']);
- $data['order_pay_after_share_img'] = save_media($data['order_pay_after_share_img']);
-
- //-----begin
-
- if( $data['shop_limit_buy_distance'] == 1)
- {
- if( empty($data['shop_buy_distance']) || $data['shop_buy_distance'] <= 0 )
- {
- show_json(0, array('msg' => '开启限制购买距离,购买距离不能为空') );
- }
- }
- if( $data['open_auto_delete'] == 1)
- {
- if( empty($data['auto_cancle_order_time']) || $data['auto_cancle_order_time'] <= 0 )
- {
- show_json(0, array('msg' => '开启自动取消订单,自动取消订单时间不能为空') );
- }
- }
-
- //open_aftersale
- if( $data['open_auto_recive_order'] == 1)
- {
- if( empty($data['auto_recive_order_time']) || $data['auto_recive_order_time'] <= 0 )
- {
- show_json(0, array('msg' => '开启系统自动签收,自动签收天数不能为空') );
- }
- }
-
-
- $open_aftersale = isset($data['open_aftersale']) ? $data['open_aftersale']:0;
-
- $open_aftersale_time = isset($data['open_aftersale_time']) ? $data['open_aftersale_time']:0;
-
- if( $open_aftersale == 1 && ($open_aftersale_time ==0 || empty($open_aftersale_time) ) )
- {
- show_json(0, array('msg' => '开启售后期,请填写售后期天数') );
- }
-
-
- if( $data['open_redis_server'] == 1)
- {
- if( empty($data['redis_host']))
- {
- show_json(0, array('msg' => '开启redis服务,redis-host不能为空') );
- }
- if( empty($data['redis_port']))
- {
- show_json(0, array('msg' => '开启redis服务,redis-port不能为空') );
- }
- }
-
-
- $open_feier_print = isset($data['open_feier_print']) ? $data['open_feier_print']:0;
- if(empty($open_feier_print) || $open_feier_print == 0)
- {
- $data['open_feier_print'] = $open_feier_print;
-
- }else if($open_feier_print == 1){
- $feier_print_sn = isset($data['feier_print_sn']) ? $data['feier_print_sn']:'';
- $feier_print_key = isset($data['feier_print_key']) ? $data['feier_print_key']:'';
-
- $data['open_feier_print'] = $open_feier_print;
- $data['feier_print_sn'] = $feier_print_sn;
- $data['feier_print_key'] = $feier_print_key;
-
- $feier_print_sn_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_sn') )->find();
-
- $feier_print_sn_old = $feier_print_sn_old_arr['value'];
-
- $feier_print_key_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_key') )->find();
-
- $feier_print_key_old = $feier_print_key_old_arr['value'];
-
- if($feier_print_sn_old != $feier_print_sn || $feier_print_key_old != $feier_print_key)
- {
- //开始添加打印机
- //printaction
- $print_model = D('Seller/Printaction');
- $snlist = "{$feier_print_sn}#{$feier_print_key}";
-
- $print_model->addprinter($snlist);
-
- }
- //...todo测试订单自动打印
- }else if($open_feier_print == 2){
- $yilian_machine_code = isset($data['yilian_machine_code']) ? $data['yilian_machine_code']:'';
-
- $yilian_msign = isset($data['yilian_msign']) ? $data['yilian_msign']:'';
- $yilian_client_id = isset($data['yilian_client_id']) ? $data['yilian_client_id']:'';
- $yilian_client_key = isset($data['yilian_client_key']) ? $data['yilian_client_key']:'';
-
-
- $data['open_feier_print'] = $open_feier_print;
- $data['yilian_machine_code'] = $yilian_machine_code;
- $data['yilian_msign'] = $yilian_msign;
- $data['yilian_client_id'] = $yilian_client_id;
- $data['yilian_client_key'] = $yilian_client_key;
-
- $yilian_client_id_old = D('Home/Front')->get_config_by_name('yilian_client_id');
-
- $yilian_machine_code_old = D('Home/Front')->get_config_by_name('yilian_machine_code');
-
- $yilian_msign_old = D('Home/Front')->get_config_by_name('yilian_msign');
-
-
-
- if(true || $yilian_client_id != $yilian_client_id_old || $yilian_machine_code_old != $yilian_machine_code || $yilian_msign_old != $yilian_msign)
- {
-
- //开始添加打印机
- //printaction
- $print_model = D('Seller/Printaction');
-
- $res = $print_model->addyilianyunprinter($yilian_client_id,$yilian_client_key,$yilian_machine_code, $yilian_msign );
-
- if($res != 0)
- {
- show_json(0, array('msg' => '添加易联云打印机失败!'));
- }
- }
-
- //...todo测试订单自动打印
-
- }
- //----end
- $data['is_print_auto'] = $data['is_print_auto'] == 1 ? 0 : 1;
- $data['is_print_cancleorder'] = isset($data['is_print_cancleorder']) ? $data['is_print_cancleorder'] : 0;
- $data['is_print_admin_cancleorder'] = isset($data['is_print_admin_cancleorder']) ? $data['is_print_admin_cancleorder'] : 0;
- $data['is_print_dansupply_order'] = isset($data['is_print_dansupply_order']) ? $data['is_print_dansupply_order'] : 0;
-
-
-
-
- //----------redis begin
- $data['open_redis_server'] = intval($data['open_redis_server']);
- if($data['open_redis_server'] == 1 && !class_exists('Redis')){
- $data['open_redis_server'] = 0;
- }
- //----------redis end
-
- $data['is_has_refund_deliveryfree'] = isset($data['is_has_refund_deliveryfree']) ? $data['is_has_refund_deliveryfree'] : 0;
-
-
- //订单自动发货
- $data['is_localtown_auto_delivery'] = isset($data['is_localtown_auto_delivery']) ? $data['is_localtown_auto_delivery'] : 0;
- $data['is_communityhead_auto_delivery'] = isset($data['is_communityhead_auto_delivery']) ? $data['is_communityhead_auto_delivery'] : 0;
- $data['is_communityhead_auto_service'] = isset($data['is_communityhead_auto_service']) ? $data['is_communityhead_auto_service'] : 0;
- $data['is_ziti_auto_delivery'] = isset($data['is_ziti_auto_delivery']) ? $data['is_ziti_auto_delivery'] : 0;
- $data['is_ziti_auto_service'] = isset($data['is_ziti_auto_service']) ? $data['is_ziti_auto_service'] : 0;
-
- D('Seller/Config')->update($data);
-
- //将商品库存写入redis
- if($data['open_redis_server'] == 1 )
- D('Seller/Redisorder')->sysnc_allgoods_total();
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
-
- $this->data = $data;
-
- $this->display();
-
- }
-
- public function opclose()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
- if ($item['order_status_id'] == 5) {
- show_json(0, '订单已关闭,无需重复关闭!');
- }
- else if (3 != $item['order_status_id']) {
- show_json(0, '订单已付款,不能关闭!');
- }
- if (IS_POST) {
-
-
- //load_model_class('frontorder')->cancel_order($item['order_id']);
- D('Home/Frontorder')->cancel_order($item['order_id'], false, '后台操作,取消订单');
-
-
- /**
-
- $time = time();
- pdo_update('lionfish_comshop_order', array('order_status_id' => 5, 'canceltime' => $time), array('order_id' => $item['order_id'], 'uniacid' => $_W['uniacid'])) ;
- //'remarkclose' => $_GPC['remark']),
-
- $history_data = array();
- $history_data['uniacid'] = $_W['uniacid'];
- $history_data['order_id'] = $item['order_id'];
- $history_data['order_status_id'] = 5;
- $history_data['notify'] = 0;
- $history_data['comment'] = '后台操作,取消订单' ;
- $history_data['date_added'] = time();
-
- pdo_insert('lionfish_comshop_order_history', $history_data);
-
- **/
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
-
- }
- $this->item = $item;
- $this->display();
- }
-
- //--begin
- public function ordersendall()
- {
- $_GPC = I('request.');
-
- $express_list = D('Seller/Express')->load_all_express();
-
- $this->_GPC = $_GPC;
-
- if( IS_POST )
- {
-
- $type = isset($_GPC['type']) && !empty($_GPC['type']) ? $_GPC['type']:'normal';
-
-
- $fext = substr($_FILES['excelfile']['name'], strrpos($_FILES['excelfile']['name'], '.') + 1);
-
-
-
-
- $express = trim($_GPC['express']);
- $expresscom = trim($_GPC['expresscom']);
-
-
- if( $fext == 'csv' )
- {
- $file_name = $_FILES['excelfile']['tmp_name'];
- $file = fopen($file_name,'r');
-
- $rows = array();
- $i =0;
- while ($data = fgetcsv($file)) {
-
- $rows[] = eval('return '.iconv('gbk','utf-8',var_export($data,true)).';');
-
- }
-
- //var_dump( $rows );
- //die();
- }else{
-
- $rows = D('Seller/Excel')->import('excelfile');
- }
-
- $num = count($rows);
- $time = time();
-
- $express_arr = array();
-
- foreach($express_list as $val)
- {
- $express_arr[ $val['id'] ] = $val['name'];
- }
-
- $i = 0;
- $err_array = array();
-
- $quene_order_list = array();
-
- $cache_key = md5(time().count($rows));
-
- $j =0;
- foreach ($rows as $rownum => $col)
- {
- $order_id = trim($col[0]);
-
- if (empty($order_id)) {
- $err_array[] = $order_id;
- continue;
- }
- if($j == 0)
- {
- $j++;
- continue;
- }
-
- $quene_order_list[] = array('order_num_alias' => $order_id , 'shipping_no' => $col[1], 'express' => $express,'expresscom' => $expresscom );
-
- }
-
- S('_orderquene_'.$cache_key, $quene_order_list);
-
- $this->cache_key = $cache_key;
- $this->type = $type;
-
- $this->display('Order/oploadexcelorder');
- die();
- }
-
-
-
-
- $this->express_list = $express_list;
- $this->type = I('request.type');
- $this->display();
- }
-
- public function do_order_quene()
- {
- $_GPC = I('request.');
-
- $type = $_GPC['type'];
- $cache_key = $_GPC['cache_key'];
-
- $quene_order_list = S('_orderquene_'.$cache_key);
-
- $tmp_info = array_shift($quene_order_list);
-
- S('_orderquene_'.$cache_key, $quene_order_list);
-
- $express = $tmp_info['express'];
- $expresscom = $tmp_info['expresscom'];
- $shipping_no = $tmp_info['shipping_no'];
-
- $tmp_info['order_num_alias'] = trim($tmp_info['order_num_alias']);
-
-
- $tmp_info['order_num_alias'] = preg_replace("/(\s|\ \;| |\xc2\xa0)/","",$tmp_info['order_num_alias']);
-
-
-
- //$rows = D('Seller/Excel')->import('excelfile');
-
- $order_info = M('lionfish_comshop_order')->where( array('order_num_alias' => $tmp_info['order_num_alias'] ) )->find();
-
-
- if(!empty($order_info) && $order_info['order_status_id'] == 1)
- {
- if( $type == 'mult' && $order_info['delivery'] == 'express' )
- {
- $ex_info = D('Seller/Express')-> get_express_info($express);
-
-
- $data = array();
-
- $data['express_time'] = time();
-
- $data['order_status_id'] = 4;
- $data['shipping_no'] = $shipping_no;
- $data['shipping_method'] = $express;
- $data['dispatchname'] = $ex_info['name'];
-
- M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save( $data );
-
- $history_data = array();
-
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单快递已发货,后台导入批量发货';
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
- //TODO..发送已发货的模板消息
- D('Home/Frontorder')->send_order_operate($order_info['order_id']);
- }
- else {
-
- if($order_info['delivery'] != 'express')
- {
- /*if($order_info['delivery'] == 'localtown_delivery'){
- M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id']) )->save( array('order_status_id' => 4,'express_time' => time(), 'express_tuanz_time' => time()) );
- //todo ... send member msg goods is ing
- $history_data = array();
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单配送中,使用表格发货';
- $history_data['date_added'] = time();
- M('lionfish_comshop_order_history')->add( $history_data );
- D('Home/LocaltownDelivery')->change_distribution_order_state( $order_info['order_id'], 0, 1);
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id']) )->save( array('delivery_type' => 1) );
- D('Home/Frontorder')->send_order_operate($order_info['order_id']);
- //给配送员发送公众号消息
- $count = D('Seller/Redisorder')->set_distribution_delivery_message($order_info['order_id']);
- }else{*/
- if($order_info['delivery'] != 'localtown_delivery' && $order_info['delivery'] != 'hexiao') {
- $data = array();
- $data['express_time'] = time();
- $data['order_status_id'] = 14;
- M('lionfish_comshop_order')->where(array('order_id' => $order_info['order_id']))->save($data);
- $history_data = array();
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 14;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单配送中,使用表格发货';
- $history_data['date_added'] = time();
- M('lionfish_comshop_order_history')->add($history_data);
- }
- //}
- }
- }
- //TODO...发送已经发货给团长的消息通知
-
- }
- if($type =='mult_send_tuanz' && $order_info['delivery'] != 'express' && $order_info['order_status_id'] == 14 )
- {
- //订单批量团长签收 2019012749451499751
-
- $history_data = array();
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '后台批量导入发货到团长';
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $history_data );
-
- D('Home/Frontorder')->send_order_operate($order_info['order_id']);
-
- }
-
- if($type =='mult_member_receive_order' && $order_info['order_status_id'] == 4 )
- {
- /*if($order_info['delivery'] == 'localtown_delivery'){
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id']) )->save( array('state' => 4,'orderdistribution_id'=> -1) );
- D('Seller/Order')->receive_order($order_info['order_id']);
- M('lionfish_comshop_order_history')->where( array('order_id' => $order_info['order_id'],'order_status_id' => 6) )->save( array( 'comment' => '系统自动收货,等待结算佣金') );
- }else{*/
- if($order_info['delivery'] != 'localtown_delivery' && $order_info['delivery'] != 'hexiao') {
- //批量用户确认收货
- D('Home/Frontorder')->receive_order($order_info['order_id'], true);
- }
- //}
- }
-
- if( empty($quene_order_list) )
- {
- echo json_encode( array('code' => 2) );
- die();
- }
-
- echo json_encode( array('code' => 0, 'msg' => '订单号:'.$tmp_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理") );
- die();
-
- }
-
- //--end
-
- public function ordersendall2()
- {
-
-
- if( IS_POST )
- {
-
- $type = I('request.type', 'normal');
- $express = I('request.express', '');
- $expresscom = I('request.expresscom', '');
-
- $rows = D('Seller/Excel')->import('excelfile');
-
- $num = count($rows);
- $time = time();
-
- $express_arr = array();
-
- foreach($express_list as $val)
- {
- $express_arr[ $val['id'] ] = $val['name'];
- }
-
- $i = 0;
- $err_array = array();
-
- $j =0;
- foreach ($rows as $rownum => $col) {
- $order_id = trim($col[0]);
-
- if (empty($order_id)) {
- $err_array[] = $order_id;
- continue;
- }
- if($j == 0)
- {
- $j++;
- continue;
- }
-
-
- $order_info = M('lionfish_comshop_order')->where( array('order_num_alias' => $order_id ) )->find();
-
- if(!empty($order_info) && $order_info['order_status_id'] == 1)
- {
-
- //判断是否快递类型 type //normal mult
-
-
- if( $type == 'mult' && $order_info['delivery'] == 'express' )
- {
-
-
- $data = array();
-
- $data['express_time'] = time();
-
- $data['order_status_id'] = 4;
- $data['shipping_no'] = $col[1];
- $data['shipping_method'] = $express;
- $data['dispatchname'] = $expresscom;
-
- M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save( $data );
-
- $history_data = array();
-
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单快递已发货';
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
- //TODO..发送已发货的模板消息
- D('Home/Frontorder')->send_order_operate($order_info['order_id']);
-
- }else {
- if($order_info['delivery'] != 'express')
- {
- $data = array();
- $data['express_time'] = time();
- $data['order_status_id'] = 14;
- M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save($data);
- $history_data = array();
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 14;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单配送中';
- $history_data['date_added'] = time();
- M('lionfish_comshop_order_history')->add($history_data);
- }
-
- }
-
- //TODO...发送已经发货给团长的消息通知
-
-
- ++$i;
- }
-
- if($type =='mult_send_tuanz' && $order_info['delivery'] != 'express' && $order_info['order_status_id'] == 14 )
- {
- //订单批量团长签收 2019012749451499751
- D('Home/Frontorder')->send_order_operate($order_info['order_id']);
- ++$i;
- }
-
- if($type =='mult_member_receive_order' && $order_info['order_status_id'] == 4 )
- {
- //批量用户确认收货
-
- D('Home/Frontorder')->receive_order($order_info['order_id'], true);
-
- ++$i;
- }
-
- }
-
- $tip = '';
-
- if($type =='mult_send_tuanz')
- {
- $msg = $i . '个订单批量送达团长成功!';
- }
- else if($type == 'mult_member_receive_order')
- {
- $msg = $i . '个订单批量用户确认收货!';
- }
- else{
- $msg = $i . '个订单发货成功!';
- }
- if ($i < $num) {
- $url = '';
- if (!empty($err_array)) {
- $j = 1;
-
-
- if($type =='mult_send_tuanz')
- {
- $tip .= '<br>' . count($err_array) . '个订单批量送达团长失败,失败的订单编号: <br>';
- }else if($type == 'mult_member_receive_order'){
- $tip .= '<br>' . count($err_array) . '个订单批量用户确认收货,失败的订单编号: <br>';
- }
- else{
- $tip .= '<br>' . count($err_array) . '个订单发货失败,失败的订单编号: <br>';
- }
-
- foreach ($err_array as $k => $v) {
- $tip .= $v . ' ';
- if (($j % 2) == 0) {
- $tip .= '<br>';
- }
- ++$j;
- }
- }
- }
- else {
- $url = U('order/ordersendall', array('type' => $type) );
- }
- $redirect = $url;
-
- $this->message = $msg.$tip;
- $this->redirect = $redirect;
- $this->display('Public/_message');
- die();
-
- }
-
- $express_list = D('Seller/Express')->load_all_express();
-
-
- $this->express_list = $express_list;
- $this->type = I('request.type');
- $this->display();
- }
-
- public function opchangeexpress()
- {
- $_GPC = I('request.');
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
- $changeexpress = 1;
- $sendtype = intval($_GPC['sendtype']);
- $edit_flag = 1;
- if (IS_POST) {
-
- if (!(empty($_GPC['shipping_no'])) && empty($_GPC['shipping_no'])) {
- show_json(0, array('msg' => '请输入快递单号!') );
- }
- if (!(empty($item['transid']))) {
- }
-
- $express_info = D('Seller/Express')->get_express_info($_GPC['express']);
-
- $time = time();
- $data = array(
- 'shipping_method' => trim($_GPC['express']),
- 'dispatchname' => $express_info['name'],
- 'shipping_no' => trim($_GPC['shipping_no']),
- 'express_time' => $time
- );
-
- M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( $data );
-
- $history_data = array();
- $history_data['order_id'] = $item['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '修改发货物流,订单发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $_GPC['shipping_no'];
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add( $history_data );
-
- //TODO...发送已经发货的消息通知
- //m('notice')->sendOrderMessage($item['id']);
- //plog('order.op.send', '订单发货 ID: ' . $item['id'] . ' 订单号: ' . $item['ordersn'] . ' <br/>快递公司: ' . $_GPC['expresscom'] . ' 快递单号: ' . $_GPC['expresssn']);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $noshipped = array();
- $shipped = array();
- $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
-
- $order_goods = M('lionfish_comshop_order_goods')->field('order_goods_id as id,name as title,goods_images as thumb')->where( array('order_id' => $item['order_id']) )->select();
-
- $express_list = D('Seller/Express')->load_all_express();
-
- $this->id = $item['order_id'];
- $this->item = $item;
- $this->province_info = $province_info;
- $this->city_info = $city_info;
- $this->area_info = $area_info;
- $this->order_goods = $order_goods;
- $this->express_list = $express_list;
-
-
- $this->display('Order/opsend');
- }
-
- public function batchsend_import()
- {
- global $_W;
- global $_GPC;
-
- $type = I('request.type','normal');
-
- $this->type = $type;
-
- $columns = array();
- $columns[] = array('title' => '订单编号', 'field' => '', 'width' => 32);
- //$columns[] = array('title' => '快递单号', 'field' => '', 'width' => 32);
-
- if($type == 'normal')
- {
- D('Seller/Excel')->temp('批量发货数据模板', $columns);
- }else{
- $columns[] = array('title' => '快递单号', 'field' => '', 'width' => 32);
-
- D('Seller/Excel')->temp('批量发货数据模板', $columns);
- }
-
-
- }
-
- /**
- * 上传订单Excel批量发货
- */
- function sendexpress_excel_done()
- {
- set_time_limit(0);
- if(isset($_FILES["file"]) && ($_FILES["file"]["error"] == 0)){
-
- $excel_dir = ROOT_PATH.'Uploads/image/'.date('Y-m-d');
- $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
- RecursiveMkdir( $excel_dir );
-
- $path = $excel_dir.'/'.md5($_FILES['file']['name'].mt_rand(1, 999)).'.'.$extension;
- $rs = move_uploaded_file($_FILES["file"]["tmp_name"],$path);
-
-
- $notify_model = D('Home/Weixinnotify');
- //
-
- $result = importExecl($path);
- if(!empty($result)) {
- $order_ids = array();
- //开始导入数据库,并发货
- foreach($result as $val){
- if(empty($val[0]))
- {
- continue;
- }
- $order_info = M('order')->field('order_id,order_status_id,delivery')->where( array('order_num_alias' => trim($val[0])) )->find();
- //order_status_id 1
- if($order_info['order_status_id'] != 1)
- {
- continue;
- }
- //['delivery'] == 'pickup'
- $order_ids[] = $order_info['order_id'];
- if($order_info['delivery'] == 'pickup')
- {
- M('order')->where( array('order_id' => $order_info['order_id'] ) )->save( array('order_status_id' => 4) );
- } else {
- M('order')->where( array('order_id' => $order_info['order_id'] ) )->save( array('shipping_method' =>$val[5],'shipping_no' =>$val[6],'order_status_id' => 4) );
- }
-
- $oh = array();
- $oh['order_id']=$order_info['order_id'];
- $oh['order_status_id']=4;
- $oh['notify'] = 0;
- $oh['comment']='导入excel批量发货';
- $oh['date_added']=time();
- $oh_id=M('OrderHistory')->add($oh);
-
- }
- foreach($order_ids as $order_id) {
-
- $order_info = M('order')->field('delivery')->where( array('order_id' => $order_id) )->find();
-
- if($order_info['delivery'] == 'pickup')
- {
- $notify_model->sendPickupMsg($order_id);
- } else {
- $notify_model->sendExpressMsg($order_id);
- }
-
- }
- }
- }
- echo json_encode( array('code' => 1) );
- die();
- }
-
-
-
- function sendexpress()
- {
- $this->breadcrumb2='批量发货';
- $this->display();
- }
- function print_order(){
- $model=new OrderModel();
-
- $this->order=$model->order_info(I('id'));
- $this->print=true;
- $this->display('./Themes/Home/default/Mail/order.html');
- }
-
- public function refunddone()
- {
- $id = I('get.id',0,'intval');
- $comment = I('post.comment');
- $order_refund_type = I('post.order_refund_type',0,'intval');
- $result = array('code' =>1);
-
- $order_refund_history = array();
- $order_refund_history['order_id'] = $id;
- $order_refund_history['message'] = htmlspecialchars($comment);
- $order_refund_history['type'] = 2;
- $order_refund_history['addtime'] = time();
-
- M('order_refund_history')->add($order_refund_history);
-
-
- $order_history = array();
- $order_history['order_id'] = $id;
- $order_history['order_status_id'] = 0;
- $order_history['notify'] = 0;
- $order_history['comment'] = '';
- $order_history['date_added'] = time();
-
- if($order_refund_type ==1)
- {
- //拒绝
- M('order_refund')->where( array('order_id' => $id) )->save( array('state' => 1) );
- $order_history['order_status_id'] = 12;
- $order_history['comment'] = '商家拒绝退款';
- M('order_history')->add($order_history);
-
- } else {
-
- $order_history['order_status_id'] = 12;
- $order_history['comment'] = '商家统一退款';
- M('order_history')->add($order_history);
-
- $weixin_model = D('Home/Weixin');
- //通过
- M('order_refund')->where( array('order_id' => $id) )->save( array('state' => 3) );
- $order_refund = M('order_refund')->where( array('order_id' => $id) )->find();
- $weixin_model->refundOrder($id, $order_refund['ref_money']);
-
-
- }
- echo json_encode($result);
- die();
-
- }
- public function show_refund()
- {
- $this->crumbs='订单退款详情';
-
- $model=new OrderModel();
-
- $data = $model->order_info(I('id'));
-
- $order_statuses = $data['order_statuses'];
-
- $need_status = array();
- foreach($order_statuses as $key => $val)
- {
- if( in_array($val['order_status_id'], array(4)) )
- {
- $need_status[$key] = $val;
- }
- }
- $data['order_statuses'] = $need_status;
-
- $refund_reason = array(
- '97' =>'商品有质量问题',
- '98' =>'没有收到货',
- '99' =>'商品少发漏发发错',
- '100' =>'商品与描述不一致',
- '101' =>'收到商品时有划痕或破损',
- '102' =>'质疑假货',
- '111' =>'其他',
- );
- $order_refund = M('order_refund')->where( array('order_id' =>I('id')) )->find();
- //ref_type
- $order_refund['ref_type'] = $order_refund['ref_type'] ==1 ? '仅退款': '退款退货';
- $order_refund['ref_name'] = empty($refund_reason[$order_refund['ref_name']]) ? $order_refund['ref_name']: $refund_reason[$order_refund['ref_name']] ;
-
- $refund_state = array(
- 0 => '申请中',
- 1 => '商家拒绝',
- 2 => '平台介入',
- 3 => '退款成功',
- 4 => '退款失败',
- 5 => '撤销申请',
- );
- $order_refund['state'] = $refund_state[$order_refund['state']];
-
- $this->order_refund = $order_refund;
- $order_refund_image = M('order_refund_image')->where( array('ref_id' => $order_refund['ref_id']) )->select();
- $refund_images = array();
-
- if(!empty($order_refund_image))
- {
- foreach($order_refund_image as $refund_image)
- {
- $refund_image['thumb_image'] = resize($refund_image['image'], 100, 100);
- $refund_images[] = $refund_image;
- }
- }
-
- $order_refund_history = M('order_refund_history')->where( array('order_id' => I('id')) )->order('addtime asc')->select();
-
- foreach($order_refund_history as $key => $val)
- {
- $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
- switch($val['type'])
- {
- case 1:
- $val['type'] = '用户反馈';
- break;
- case 2:
- $val['type'] = '商家反馈';
- break;
- case 3:
- $val['type'] = '平台反馈';
- break;
-
- }
- $order_refund_history_image = M('order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
- if(!empty($order_refund_history_image))
- {
- foreach($order_refund_history_image as $kk => $vv)
- {
- $vv['thumb_image'] = resize($vv['image'], 100, 100);
- $order_refund_history_image[$kk] = $vv;
- }
- }
- $val['order_refund_history_image'] = $order_refund_history_image;
- $order_refund_history[$key] = $val;
- }
-
- $this->order_refund_history = $order_refund_history;
- $this->refund_images = $refund_images;
- $this->data = $data;
- $this->display('refund');
- }
- public function show_order(){
-
- $this->crumbs='订单详情';
- //is_ziti/1 commiss_list
- $is_ziti = I('get.is_ziti', 0);
- if($is_ziti == 1)
- {
- $this->breadcrumb1='自提管理';
- $this->breadcrumb2='自提管理';
- }
- $model=new OrderModel();
-
- $data = $model->order_info(I('id'));
-
- $order_statuses = $data['order_statuses'];
-
- $need_status = array();
- foreach($order_statuses as $key => $val)
- {
- if( in_array($val['order_status_id'], array(1,2,3,4,5,6,7,8,11,12,13)) )
- {
- $need_status[$key] = $val;
- }
- }
- $data['order_statuses'] = $need_status;
-
- //$data['order']
- if($data['order']['type'] == 'integral')
- {
- $integral_order = M('integral_order')->where( array('order_id' => I('id') ) )->find();
- $this->integral_order = $integral_order;
- }
-
- $this->data = $data;
-
- $pick_order_info = array();
- $pick_up = array();
- if($data['order']['delivery'] == 'pickup')
- {
- $pick_order_info = M('pick_order')->where( array('order_id' => $data['order']['order_id']) )->find();
- $pick_up = M('pick_up')->where( array('id' => $pick_order_info['pick_id']) )->find();
- }
-
- $this->pick_order_info = $pick_order_info;
- $this->pick_up = $pick_up;
-
- $sql="select s.* from ".C('DB_PREFIX')."seller_express as s, ".C('DB_PREFIX')."seller_express_relat as ser
- where s.id = ser.express_id and ser.store_id = ".SELLERUID;
- $express_list= M()->query($sql);
-
- $this->express_list = $express_list;
-
- //$data['order']['order_id']
- $order_goods_haitao = M('order_goods_haitao')->where( array('order_id' => $data['order']['order_id']) )->find();
- $this->order_goods_haitao = $order_goods_haitao;
- $this->display('show');
- }
- function history(){
- $model=new OrderModel();
-
- if(IS_POST){
-
- if(I('order_status_id')==C('cancel_order_status_id')){
- $Order = new \Home\Model\OrderModel();
- $Order->cancel_order($_GET['id']);
- storage_user_action(session('user_auth.uid'),session('user_auth.username'),C('BACKEND_USER'),'取消了订单 '.$_GET['id']);
- $result=true;
- }else{
- //order_status_id 4
-
- if($_POST['order_status_id'] != 4)
- {
- unset($_POST['shipping_no']);
- unset($_POST['shipping_method']);
- die();
- }else {
-
- }
- $result=$model->addOrderHistory($_GET['id'],$_POST);
- }
- if($result){
- $this->success='新增成功!!';
- }else{
- $this->error='新增失败!!';
- }
- }
-
- $results = $model->getOrderHistories($_GET['id']);
-
- foreach ($results as $result) {
- $histories[] = array(
- 'notify' => $result['notify'] ? '是' : '否',
- 'status' => $result['status'],
- 'comment' => nl2br($result['comment']),
- 'date_added' => date('Y/m/d H:i:s', $result['date_added'])
- );
- }
-
- $this->histories=$histories;
-
- $this->display();
- }
-
- function del(){
- $model=new OrderModel();
- $return=$model->del_order(I('get.id'));
- $this->osc_alert($return);
- }
-
- //begin
- public function printconfig()
- {
-
- if (defined('ROLE') && ROLE == 'agenter' )
- {
-
- $supper_info = get_agent_logininfo();
-
-
- if (IS_POST) {
-
- $_GPC = I('request.');
-
- $data = array();
-
- $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
-
- //$supper_info['id']
- $open_feier_print = isset($data['open_feier_print'.$supper_info['id']]) ? $data['open_feier_print'.$supper_info['id']]:0;
- if(empty($open_feier_print) || $open_feier_print == 0)
- {
- $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
-
- }else if($open_feier_print == 1){
- $feier_print_sn = isset($data['feier_print_sn'.$supper_info['id']]) ? $data['feier_print_sn'.$supper_info['id']]:'';
- $feier_print_key = isset($data['feier_print_key'.$supper_info['id']]) ? $data['feier_print_key'.$supper_info['id']]:'';
-
- $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
- $data['feier_print_sn'.$supper_info['id']] = $feier_print_sn;
- $data['feier_print_key'.$supper_info['id']] = $feier_print_key;
-
- $feier_print_sn_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_sn'.$supper_info['id'] ) )->find();
-
- $feier_print_sn_old = $feier_print_sn_old_arr['value'];
-
- $feier_print_key_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_key'.$supper_info['id'] ) )->find();
-
- $feier_print_key_old = $feier_print_key_old_arr['value'];
-
- if($feier_print_sn_old != $feier_print_sn || $feier_print_key_old != $feier_print_key)
- {
- //开始添加打印机
- //printaction
- $print_model = D('Seller/Printaction');
- $snlist = "{$feier_print_sn}#{$feier_print_key}";
-
- $print_model->addprinter($snlist);
-
- }
-
- //...todo测试订单自动打印
- }else if($open_feier_print == 2){
- $yilian_machine_code = isset($data['yilian_machine_code'.$supper_info['id']]) ? $data['yilian_machine_code'.$supper_info['id']]:'';
-
- $yilian_msign = isset($data['yilian_msign'.$supper_info['id']]) ? $data['yilian_msign'.$supper_info['id']]:'';
- $yilian_client_id = isset($data['yilian_client_id'.$supper_info['id']]) ? $data['yilian_client_id'.$supper_info['id']]:'';
- $yilian_client_key = isset($data['yilian_client_key'.$supper_info['id']]) ? $data['yilian_client_key'.$supper_info['id']]:'';
-
-
- $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
- $data['yilian_machine_code'.$supper_info['id']] = $yilian_machine_code;
- $data['yilian_msign'.$supper_info['id']] = $yilian_msign;
- $data['yilian_client_id'.$supper_info['id']] = $yilian_client_id;
- $data['yilian_client_key'.$supper_info['id']] = $yilian_client_key;
-
- $yilian_client_id_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_client_id'.$supper_info['id'] ) )->find();
-
- $yilian_client_id_old = $yilian_client_id_old_arr['value'];
-
- $yilian_machine_code_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_machine_code'.$supper_info['id'] ) )->find();
-
- $yilian_machine_code_old = $yilian_machine_code_old_arr['value'];
-
- $yilian_msign_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_msign'.$supper_info['id'] ) )->find();
-
- $yilian_msign_old = $yilian_msign_old_arr['value'];
-
-
- if(true || $yilian_client_id != $yilian_client_id_old || $yilian_machine_code_old != $yilian_machine_code || $yilian_msign_old != $yilian_msign)
- {
-
- //开始添加打印机
- //printaction
- $print_model = D('Seller/Printaction');
-
- $res = $print_model->addyilianyunprinter($yilian_client_id,$yilian_client_key,$yilian_machine_code, $yilian_msign );
-
- if($res != 0)
- {
- show_json(0, array('msg' => '添加易联云打印机失败!' ) );
- }
- }
-
- //...todo测试订单自动打印
- }
-
- D('Seller/Config')->update($data);
- show_json(1);
- }
- $data = D('Seller/Config')->get_all_config();
-
- $this->supper_info = $supper_info;
- $this->data = $data;
-
- include $this->display();
- }
- }
- public function express_list(){
- $this->type = I('request.type','');
- $this->order_id = I('request.order_id','');
- $express_list = D('Seller/Express')->load_kdn_express();
- $this->express_list = $express_list;
- $this->display();
- }
- public function kdn_print_log_list(){
- $log_list = M('lionfish_comshop_order_kdniao_print_log')->order('id desc')->limit(5)->select();
- $this->log_list = $log_list;
- $this->display();
- }
- /**
- * 判断快递鸟寄件人信息
- * @param $express_code
- */
- public function check_kdn_sender($express_code){
- $result = array();
- $result['status'] = 1;
- $data = D('Seller/Config')->get_all_config();
- if(empty($data['kdn_sender_name'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人未配置';
- return $result;
- }
- if(empty($data['kdn_sender_mobile'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人联系电话未配置';
- return $result;
- }
- if(empty($data['kdn_province_id'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人省份未配置';
- return $result;
- }
- if(empty($data['kdn_city_id'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人城市未配置';
- return $result;
- }
- if(empty($data['kdn_area_id'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人区域未配置';
- return $result;
- }
- if(empty($data['kdn_sender_address'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人详细地址未配置';
- return $result;
- }
- $code_list = array('EMS','YZPY','YZBK');
- if(in_array($express_code,$code_list)){
- if(empty($data['kdn_sender_postcode'])){
- $result['status'] = 0;
- $result['msg'] = '寄件人邮编未配置';
- return $result;
- }
- }
- return $result;
- }
- //打印面单
- public function kdniao_order(){
- $result = array();
- $order_id = I('request.order_id','');
- $express_code = I('request.express_code','');
- if(empty($order_id)){
- $result['status'] = 1;
- $result['message'] = "订单号不存在";
- }else if(empty($express_code)){
- $result['status'] = 1;
- $result['message'] = "快递公司不存在";
- }else{
- $sender_result = $this->check_kdn_sender($express_code);
- if($sender_result['status'] == 1){
- $kdNiao = new \Lib\KdApiEOrder();
- $config_data = D('Seller/Config')->get_all_config();
- $result = $kdNiao->printOrder($order_id,$express_code,$config_data);
- }else{
- $result['status'] = 3;
- $result['message'] = $sender_result['msg'];
- }
- }
- echo json_encode($result);
- }
- //打印多条订单面单
- public function kdniao_print_orders(){
- $print_type = I('request.print_type','');
- $order_id = I('request.order_id','');
- $express_code = I('request.express_code','');
- $order_id_list = array();
- $order_list = array();
- $order_kdn_status = array();
- if($print_type == "select"){
- $order_list = M('lionfish_comshop_order')->field('order_id,is_kdn_print')->where("order_status_id = 1 and delivery = 'express' and order_id in (".$order_id.")")->select();
- }else if($print_type == "all"){
- $order_list = M('lionfish_comshop_order')->field('order_id,is_kdn_print')->where("order_status_id = 1 and delivery = 'express' ")->select();
- }
- foreach($order_list as $k=>$v){
- $order_id_list[] = $v['order_id'];
- $order_kdn_status[$v['order_id']] = $v['is_kdn_print'];
- }
- $time = time();
- $print_count = count($order_id_list);
- //保存快递鸟打印日志
- $kd_data = array();
- $kd_data['addtime'] = $time;
- $kd_data['print_count'] = $print_count;
- $kdn_id = M('lionfish_comshop_order_kdniao_print_log')->add( $kd_data );
- $succ_count = 0;
- $fail_count = 0;
- $fail_result = array();
- $kdNiao = new \Lib\KdApiEOrder();
- $config_data = D('Seller/Config')->get_all_config();
- $sender_result = $this->check_kdn_sender($express_code);
- if($sender_result['status'] == 1){
- foreach($order_id_list as $v){
- if($order_kdn_status[$v] == 1){
- $succ_count++;
- }else{
- $result = $kdNiao->printOrder($v,$express_code,$config_data);
- if($result['status'] == 0){//打印成功
- $succ_count++;
- }else{//打印失败
- $fail_count++;
- $fail_result[] = $result['message'];
- }
- }
- }
- }else{
- $result['status'] = 3;
- $result['message'] = $sender_result['msg'];
- }
- $fail_reason = json_encode(array_unique($fail_result));
- //打印完成更新快递鸟打印日志
- $kdn_data = array();
- $kdn_data['succ_count'] = $succ_count;
- $kdn_data['fail_count'] = $fail_count;
- $kdn_data['fail_reason'] = $fail_reason;
- $kdn_data['status'] = 1;
- M('lionfish_comshop_order_kdniao_print_log')->where(array('id' => $kdn_id))->save($kdn_data);
- $kdn_order_ids = implode(",",$order_id_list);
- echo json_encode(array('status'=>0,'order_ids'=>$kdn_order_ids));
- }
- //检查是否配置快递鸟接口参数
- public function check_kdniao(){
- $config_data = D('Seller/Config')->get_all_config();
- if(isset($config_data['kdniao_id']) && !empty($config_data['kdniao_id']) && isset($config_data['kdniao_api_key']) && !empty($config_data['kdniao_api_key'])){
- show_json(1);
- }else{
- show_json(0, array('msg' => '快递鸟未配置!' ) );
- }
- }
- public function kdn_info(){
- $this->order_id = I('request.order_id','');
- $kdn_info = M('lionfish_comshop_order_kdniao_info')->where( array('order_id' => $this->order_id,'status'=>1) )->find();
- $this->kdn_info = $kdn_info;
- $this->display();
- }
- public function kdn_orders_info(){
- $this->order_ids = I('request.order_ids','');
- $kdn_list_info = M('lionfish_comshop_order_kdniao_info')->where("order_id in (".$this->order_ids.") and status = 1")->select();
- $this->kdn_list_info = $kdn_list_info;
- $this->display();
- }
-
- /**
- * 快递鸟打印成功订单发货
- */
- public function kdn_send(){
- $order_id = I('request.id','');
- $order_ids = I('request.ids','');
- if(!empty($order_id)){
- $item = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
- if (empty($item)) {
- show_json(0, '未找到订单!');
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
- if(!empty($order_info)) {
- if ($order_info['order_status_id'] == 1 && $order_info['delivery'] == 'express' && $order_info['is_kdn_print'] == 1) {
- $express_info = D('Seller/Express')->get_express_info($order_info['shipping_method']);
- $data = array();
- $data['order_status_id'] = 4;
- M('lionfish_comshop_order')->where(array('order_id' => $order_id))->save($data);
- $history_data = array();
- $history_data['order_id'] = $order_id;
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单发货 ID: ' . $order_id . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $item['shipping_no'];
- $history_data['date_added'] = time();
- M('lionfish_comshop_order_history')->add($history_data);
- D('Home/Frontorder')->send_order_operate($item['order_id']);
- } else {
- show_json(0, '待发货快递订单才能发货成功!');
- }
- }else{
- show_json(0, '未找到订单!');
- }
- }else if(!empty($order_ids)){
- $ids = explode(",",$order_ids);
- foreach($ids as $k=>$v){
- $order_id = $v;
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
- if (empty($order_info)) {
- show_json(0, '未找到订单!');
- }
- if(!empty($order_info)) {
- if ($order_info['order_status_id'] == 1 && $order_info['delivery'] == 'express' && $order_info['is_kdn_print'] == 1) {
- $express_info = D('Seller/Express')->get_express_info($order_info['shipping_method']);
- $data = array();
- $data['order_status_id'] = 4;
- M('lionfish_comshop_order')->where(array('order_id' => $order_id))->save($data);
- $history_data = array();
- $history_data['order_id'] = $order_id;
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '订单发货 ID: ' . $order_id . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $item['shipping_no'];
- $history_data['date_added'] = time();
- M('lionfish_comshop_order_history')->add($history_data);
- D('Home/Frontorder')->send_order_operate($item['order_id']);
- } else {
- show_json(0, '待发货快递订单才能发货成功!');
- }
- }else{
- show_json(0, '未找到订单!');
- }
- }
- }else{
- show_json(0, '未找到订单!');
- }
- show_json(1);
- }
- /**
- * 修改订单价格
- */
- public function change_order(){
- $_GPC = I('request.');
- $opdata = $this->check_order_data();
- extract($opdata);
- $id = I('request.id',0);
- if( IS_POST )
- {
- $_GPC = I('request.');
- $order_id = $_GPC['id'];
- $order_goods_ids = $_GPC['order_goods_id'];
- $change_prices = $_GPC['change_price'];
- $count = 0;
- foreach($change_prices as $v){
- if(empty(trim($v))){
- $count++;
- }
- }
- if($count == count($change_prices)){
- show_json(0, array('message' => '未填写涨价或减价金额!'));
- }
- //改价后的商品实付价格不能低于0.1元
- foreach($order_goods_ids as $k=>$order_goods_id){
- $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' =>$order_goods_id ) )->find();
- $total = $order_goods_info['total'];
- $fullreduction_money = $order_goods_info['fullreduction_money'];
- $voucher_credit = $order_goods_info['voucher_credit'];
- $score_for_money = $order_goods_info['score_for_money'];
- $total = round($total - $fullreduction_money - $voucher_credit - $score_for_money,2);
- if(!empty($change_prices[$k])){
- $change_price = $change_prices[$k];
- $total = floatval($total) + floatval($change_price);
- if(bccomp($total, '0.1', 2) == -1){
- show_json(0, array('message' => '改价后的商品实付价格不能低于0.1元'));
- }
- }
- }
- $change_amount = 0;
- foreach($order_goods_ids as $k=>$order_goods_id){
- $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' =>$order_goods_id ) )->find();
- $total = $order_goods_info['total'];
- $update_data = array();
- if(!empty($change_prices[$k])){
- $change_amount = $change_amount + $change_prices[$k];
- $change_price = $change_prices[$k];
- $update_data['total'] = round(floatval($total) + floatval($change_price),2);
- $update_data['is_change_price'] = 1;
- M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' => $order_goods_id ) )->save( $update_data);
- }
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$id) )->find();
- $order_total = $order_info['total'];
- $order_data = array();
- $order_data['total'] = round(floatval($order_total) + floatval($change_amount),2);
- $order_data['is_change_price'] = 1;
- M('lionfish_comshop_order')->where( array('order_id' =>$id) )->save($order_data);
- $oh = array();
- $oh['order_id'] = $id;
- $oh['order_status_id']=15;
- $oh['comment']='订单改价';
- $oh['date_added']=time();
- M('lionfish_comshop_order_history')->add($oh);
- show_json(1);
- }
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id) )->select();
- foreach($order_goods as $k=>$v){
- $order_goods[$k]['goods_img_url'] = tomedia($v['goods_images']);
- }
- $this->item = $opdata['item'];
- $this->order_goods = $order_goods;
- $this->display();
- }
- //检查是否配置第三方配送接口参数
- public function check_delivery_config(){
- $_GPC = I('request.');
- $config_data = D('Seller/Config')->get_all_config();
- $data_type = $_GPC['data_type'];
- if($data_type == 'imdada'){
- if(isset($config_data['localtown_imdada_merchant_id']) && !empty($config_data['localtown_imdada_shop_no']) && isset($config_data['localtown_imdada_appkey']) && !empty($config_data['localtown_imdada_appsecret'])){
- show_json(1);
- }else{
- show_json(0, array('msg' => '达达配送平台参数未配置!' ) );
- }
- }else if($data_type == 'sf'){
- if(isset($config_data['localtown_sf_dev_id']) && !empty($config_data['localtown_sf_dev_key']) && isset($config_data['localtown_sf_store_id'])){
- show_json(1);
- }else{
- show_json(0, array('msg' => '顺丰同城参数未配置!' ) );
- }
- }else if($data_type == 'make'){
- if(isset($config_data['localtown_mk_token']) && !empty($config_data['localtown_mk_token']) ){
- show_json(1);
- }else{
- show_json(0, array('msg' => '码科配送参数未配置!' ) );
- }
- }else if($data_type == 'ele'){
- if(isset($config_data['localtown_ele_app_id']) && !empty($config_data['localtown_ele_secret_key']) && isset($config_data['localtown_ele_store_code']) && !empty($config_data['localtown_ele_transport_name'])
- && !empty($config_data['localtown_ele_transport_address']) && !empty($config_data['localtown_ele_transport_longitude']) && !empty($config_data['localtown_ele_transport_latitude'])
- && !empty($config_data['localtown_ele_transport_tel']) && !empty($config_data['localtown_ele_position_source'])
- ){
- show_json(1);
- }else{
- show_json(0, array('msg' => '蜂鸟即配平台参数未配置!' ) );
- }
- }
- }
- /**
- * 将订单推送给第三方配送
- */
- public function thirth_delivery_order(){
- $_GPC = I('request.');
- $data_type = $_GPC['data_type'];
- $order_id = $_GPC['order_id'];
- if(empty($data_type)){
- show_json(0, array('msg' => '未选择第三方配送' ) );
- }
- if(empty($order_id)){
- show_json(0, array('msg' => '订单号不存在' ) );
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
- if(empty($order_info)){
- show_json(0, array('msg' => '订单不存在' ) );
- }
- //店铺地址
- if($order_info['store_id'] > 0) {
- $store_data = D('Home/Order')->getOrderStoreAddress($order_info);
- $order_info['store_data'] = $store_data;
- }
- //商品信息
- $sql = "select og.goods_id,og.name as goods_name,og.quantity,og.price,og.total,og.rela_goodsoption_valueid,g.weight as goods_weight from "
- . C('DB_PREFIX')."lionfish_comshop_order_goods as og left join ".C('DB_PREFIX')."lionfish_comshop_goods as g on og.goods_id=g.id "
- ." where og.order_id = ".$order_id;
- $goods_list = M()->query($sql);
- $goods_count = 0;
- $goods_weight = 0;
- $goods_type_count = 0;
- foreach($goods_list as $k=>$v){
- $goods_count = $goods_count + $v['quantity'];
- if(!empty($v['rela_goodsoption_valueid'])){
- $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('option_item_ids' => $v['rela_goodsoption_valueid'],'goods_id' => $v['goods_id']) )->find();
- if(!empty($goods_option_mult_value)){
- $v['goods_weight'] = $goods_option_mult_value['weight'];
- }
- }
- $goods_weight = $goods_weight + $v['quantity'] * $v['goods_weight'];
- $goods_type_count = $goods_type_count + 1;
- }
- if(empty($goods_weight)){
- $goods_weight = 100;//默认100克
- }
- $order_info['goods_list'] = $goods_list;
- //商品种类
- $order_info['goods_type_count'] = $goods_type_count;
- //商品数量
- $order_info['goods_count'] = $goods_count;
- //商品重量
- $order_info['goods_weight'] = $goods_weight;
- //订单总金额
- $order_info['order_total'] = $order_info['total']+$order_info['packing_fare']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare']-$order_info['fare_shipping_free'];
- //收货人地址
- $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
- $order_info['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$order_info['shipping_address'];
- //收货人经纬度
- $order_distribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- //收货人地址纬度
- $order_info['shipping_lat'] = $order_distribution_info['member_lat'];
- //收货人地址经度
- $order_info['shipping_lng'] = $order_distribution_info['member_lon'];
- //商城名称
- $shoname = D('Home/Front')->get_config_by_name('shoname');
- $order_info['shoname'] = $shoname;
- if($data_type == 'imdada'){
- $imdada = new \Lib\Localtown\Imdada();
- $result = $imdada->addOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = $result['result']['fee'];
- $express_info = array();
- $express_info['delivery_fee'] = $delivery_fee;
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if($data_type == 'sf'){
- $sfexpress = new \Lib\Localtown\Sfexpress();
- $result = $sfexpress->addOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = round($result['result']['total_price']/100,2);
- //顺丰订单号
- $delivery_order_id = $result['result']['sf_order_id'];
- //顺丰运单号
- $delivery_bill_id = $result['result']['sf_bill_id'];
- $express_info = array();
- $express_info['delivery_fee'] = $delivery_fee;
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = $delivery_bill_id;
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
-
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if( $data_type == 'make' )
- {
- //$store_data = D('Home/Make')->getOrderStoreAddress($order_info);
- $result = D('Home/Make')->addOrder($order_info);
- if( $result['code'] == 0 )
- {
- //码科订单号
- $delivery_order_id = $result['order_number'];
- $express_info = array();
- $express_info['delivery_fee'] = $order_distribution_info['shipping_money'];
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = '';
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{
- show_json(0, array('msg' => $result['message'] ) );
- }
- }else if($data_type == 'ele'){//蜂鸟即配
- $eleDistribution = new \Lib\Localtown\EleDistribution();
- $order_code = build_order_no(session('user_auth.uid'));
- //保存蜂鸟即配商户订单号
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->save(['order_code'=>$order_code]);
- $order_info['order_num_alias'] = $order_code;
- $result = $eleDistribution->addOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = round($result['result']['total_price']/100,2);
- //蜂鸟即配订单号
- $delivery_order_id = $result['result']['sf_order_id'];
- //蜂鸟即配运单号
- $delivery_bill_id = $result['result']['sf_bill_id'];
- $express_info = array();
- $express_info['delivery_fee'] = $delivery_fee;
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = $delivery_bill_id;
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else{
- show_json(0, array('msg' => '不存在第三方配送' ) );
- }
- }
- /**
- * 将订单重新推送给第三方配送
- */
- public function thirth_renew_delivery_order(){
- $_GPC = I('request.');
- $data_type = $_GPC['data_type'];
- $order_id = $_GPC['order_id'];
- if(empty($data_type)){
- show_json(0, array('msg' => '未选择第三方配送' ) );
- }
- if(empty($order_id)){
- show_json(0, array('msg' => '订单号不存在' ) );
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
- if(empty($order_info)){
- show_json(0, array('msg' => '订单不存在' ) );
- }
- //店铺地址
- if($order_info['store_id'] > 0) {
- $store_data = D('Home/Order')->getOrderStoreAddress($order_info);
- $order_info['store_data'] = $store_data;
- }
-
- //商品信息
- $sql = "select og.goods_id,og.name as goods_name,og.quantity,og.rela_goodsoption_valueid,g.weight as goods_weight from "
- . C('DB_PREFIX')."lionfish_comshop_order_goods as og left join ".C('DB_PREFIX')."lionfish_comshop_goods as g on og.goods_id=g.id "
- ." where og.order_id = ".$order_id;
- $goods_list = M()->query($sql);
- $goods_count = 0;
- $goods_weight = 0;
- $goods_type_count = 0;
- foreach($goods_list as $k=>$v){
- $goods_count = $goods_count + $v['quantity'];
- if(!empty($v['rela_goodsoption_valueid'])){
- $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('option_item_ids' => $v['rela_goodsoption_valueid'],'goods_id' => $v['goods_id']) )->find();
- if(!empty($goods_option_mult_value)){
- $v['goods_weight'] = $goods_option_mult_value['weight'];
- }
- }
- $goods_weight = $goods_weight + $v['quantity'] * $v['goods_weight'];
- $goods_type_count = $goods_type_count + 1;
- }
- if(empty($goods_weight)){
- $goods_weight = 100;//默认100克
- }
- $order_info['goods_list'] = $goods_list;
- //商品种类
- $order_info['goods_type_count'] = $goods_type_count;
- //商品数量
- $order_info['goods_count'] = $goods_count;
- //商品重量
- $order_info['goods_weight'] = $goods_weight;
- //订单总金额
- $order_info['order_total'] = $order_info['total']+$order_info['packing_fare']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare']-$order_info['fare_shipping_free'];
- //收货人地址
- $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
- $order_info['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$order_info['shipping_address'];
- //收货人经纬度
- $order_distribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- //收货人地址纬度
- $order_info['shipping_lat'] = $order_distribution_info['member_lat'];
- //收货人地址经度
- $order_info['shipping_lng'] = $order_distribution_info['member_lon'];
- //商城名称
- $shoname = D('Home/Front')->get_config_by_name('shoname');
- $order_info['shoname'] = $shoname;
- if($data_type == 'imdada'){
- $imdada = new \Lib\Localtown\Imdada();
- $result = $imdada->reAddOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = array();
- $delivery_fee['delivery_fee'] = $result['result']['fee'];
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$delivery_fee);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if($data_type == 'sf'){
- $sfexpress = new \Lib\Localtown\Sfexpress();
- $result = $sfexpress->addOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = round($result['result']['total_price']/100,2);
- //顺丰订单号
- $delivery_order_id = $result['result']['sf_order_id'];
- //顺丰运单号
- $delivery_bill_id = $result['result']['sf_bill_id'];
- $express_info = array();
- $express_info['delivery_fee'] = $delivery_fee;
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = $delivery_bill_id;
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if($data_type == 'make')
- {
- $result = D('Home/Make')->addOrder($order_info);
- if( $result['code'] == 0 )
- {
- //码科订单号
- $delivery_order_id = $result['order_number'];
- $express_info = array();
- $express_info['delivery_fee'] = $order_distribution_info['shipping_money'];
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = '';
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{
- show_json(0, array('msg' => $result['message'] ) );
- }
- }else if($data_type == 'ele'){//蜂鸟即配
- $eleDistribution = new \Lib\Localtown\EleDistribution();
- $order_code = build_order_no(session('user_auth.uid'));
- //保存蜂鸟即配商户订单号
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->save(['order_code'=>$order_code]);
- $order_info['order_num_alias'] = $order_code;
- $result = $eleDistribution->addOrder($order_info);
- if($result['status'] == 1){//成功
- //配送费用
- $delivery_fee = round($result['result']['total_price']/100,2);
- //蜂鸟即配订单号
- $delivery_order_id = $result['result']['sf_order_id'];
- //蜂鸟即配运单号
- $delivery_bill_id = $result['result']['sf_bill_id'];
- $express_info = array();
- $express_info['delivery_fee'] = $delivery_fee;
- $express_info['delivery_order_id'] = $delivery_order_id;
- $express_info['delivery_bill_id'] = $delivery_bill_id;
- D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }
- else{
- show_json(0, array('msg' => '不存在第三方配送' ) );
- }
- }
- public function third_cancel_reason(){
- $order_id = I('request.order_id','');
- $third_distribution_type = I('request.third_distribution_type','');
- $this->order_id = $order_id;
- $this->third_distribution_type = $third_distribution_type;
- $this->display();
- }
- /**
- * 取消第三方配送订单
- */
- public function thirth_cancel_delivery_order(){
- $_GPC = I('request.');
- $order_id = $_GPC['order_id'];
- if(empty($order_id)){
- show_json(0, array('msg' => '订单号不存在' ) );
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
- if(empty($order_info)){
- show_json(0, array('msg' => '订单不存在' ) );
- }
- $orderdistribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' =>$order_id) )->find();
- if(empty($orderdistribution_info)){
- show_json(0, array('msg' => '配送订单不存在' ) );
- }
- $cancel_reason_id = $_GPC['cancel_reason_id'];
- $cancel_reason = $_GPC['cancel_reason'];
- $data_type = $orderdistribution_info['third_distribution_type'];
- if($orderdistribution_info['state'] == 0 || $orderdistribution_info['state'] == 1 || $orderdistribution_info['state'] == 2){
- if($data_type == 'imdada'){
- $imdada = new \Lib\Localtown\Imdada();
- $result = $imdada->cancelOrder($order_info,$cancel_reason_id,$cancel_reason);
- if($result['status'] == 1){//成功
- $deduct_fee = $result['result']['deduct_fee'];
- $other_data = array();
- $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
- $other_data['cancel_reason'] = $cancel_reason;
- $other_data['now_deduct_fee'] = $deduct_fee;
- D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
-
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if($data_type == 'sf'){
- $sfexpress = new \Lib\Localtown\Sfexpress();
- $result = $sfexpress->cancelOrder($orderdistribution_info,$cancel_reason);
- if($result['status'] == 1){//成功
- $other_data = array();
- if(empty($cancel_reason)){
- $cancel_reason = "商家取消";
- }
- $other_data['cancel_reason'] = $cancel_reason;
- $deduct_fee = round($result['result']['deduction_detail']['deduction_fee']/100,2);
- $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
- $other_data['now_deduct_fee'] = $deduct_fee;
- D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
-
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }else if( $data_type == 'make' )
- {
- //$orderdistribution_info
- $third_order_id = $orderdistribution_info['third_order_id'];
- $result = D('Home/Make')->cancelOrder( $third_order_id );
- if( $result['code'] == 0 )
- {
- $other_data = array();
- if(empty($cancel_reason)){
- $cancel_reason = "商家取消";
- }
- $other_data['cancel_reason'] = $cancel_reason;
- $deduct_fee = 0;
- $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
- $other_data['now_deduct_fee'] = $deduct_fee;
- D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- //D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
- //load_model_class('supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{
- show_json(0, array('msg' => $result['message'] ) );
- }
- }else if($data_type == 'ele'){
- $eleDistribution = new \Lib\Localtown\EleDistribution();
- $result = $eleDistribution->cancelOrder($orderdistribution_info,$cancel_reason_id,$cancel_reason);
- if($result['status'] == 1){//成功
- $other_data = array();
- if(empty($cancel_reason)){
- $cancel_reason = "商家取消";
- }
- $other_data['cancel_reason'] = $cancel_reason;
- $deduct_fee = round($result['result']['deduction_detail']['deduction_fee']/100,2);
- $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
- $other_data['now_deduct_fee'] = $deduct_fee;
- D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
- $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
- show_json(1);
- }else{//失败
- show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
- }
- }
- }else{
- show_json(0, array('msg' => '配送订单无法取消' ) );
- }
- }
- /**
- * 达达平台模拟取货
- */
- public function orderFetch(){
- $_GPC = I('request.');
- $order_sn = $_GPC['order_sn'];
- $type = $_GPC['type'];
- $imdada = new \Lib\Localtown\Imdada();
- if($type == 1){
- $imdada->orderFetch($order_sn);//模拟取货
- }else if($type == 2){
- $imdada->orderFinish($order_sn);//完成订单
- }else if($type == 3){
- $imdada->orderCancel($order_sn);//取消订单
- }else if($type == 4){
- $imdada->orderAbnormal($order_sn);//异常妥投物品返还中
- }
- }
- public function third_delivery_log_list(){
- $order_id = I('request.order_id','');
- $orderdistribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' =>$order_id) )->find();
- $distribution_type = $orderdistribution_info['third_distribution_type'];
- $log_list = M('lionfish_comshop_orderdistribution_thirth_log')->where( array('order_id' =>$order_id,'third_distribution_type'=>$distribution_type) )->order('addtime desc')->select();
- $third_name = "";
- if($distribution_type == 'imdada'){
- $third_name = '达达平台';
- }else if($distribution_type == 'sf'){
- $third_name = '顺丰同城';
- }else if($distribution_type == 'make'){
- $third_name = '码科配送';
- }else if($distribution_type == 'uupt'){
- $third_name = 'UU跑腿';
- }else if($distribution_type == 'dianwoda'){
- $third_name = '点我达';
- }
- $this->third_name = $third_name;
- $this->log_list = $log_list;
- $this->orderdistribution_info = $orderdistribution_info;
- $this->display();
- }
- //end
- /**
- * 订单核销
- */
- public function order_hexiao()
- {
-
- $opdata = $this->check_order_data();
- extract($opdata);
-
- if( $item['delivery'] == 'hexiao' )
- {
- D('Seller/Order')->hexiao_all_orders($item['order_id']);
- }
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- /**
- * 商品按订单核销
- */
- public function order_goods_hexiao(){
- $opdata = $this->check_order_data();
- extract($opdata);
- $order_goods_id = I('request.order_goods_id','');
-
- $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id, 'order_goods_id' => $order_goods_id) )->find();
- if (empty($order_hexiao_info)) {
- show_json(0, '未找到核销订单!');
- }
- D('Seller/Order')->hexiao_order_goods($order_hexiao_info,0);
- D('Seller/Order')->hexiao_finished($id,'后台确认使用,订单完成');
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- /**
- * 查看核销记录
- */
- public function view_hexiao_history(){
- $opdata = $this->get_goods_saleshexiao();
- extract($opdata);
-
- $data = D('Seller/Order')->get_goods_hexiao_record();
-
- $this->order_hexiao_info = $order_hexiao_info;
- $this->hx_list = $data['hx_list'];
- $this->display("hexiao_history");
- }
- /**
- * 按次数核销商品
- */
- public function hexiao_times(){
- $opdata = $this->get_goods_saleshexiao();
- extract($opdata);
-
- $data = D('Seller/Order')->get_goods_hexiao_record();
-
- $this->order_hexiao_info = $order_hexiao_info;
- $this->hx_list = $data['hx_list'];
- $this->hx_count = $data['hx_count'];
- $this->display();
- }
-
- /**
- * 获取商品核销信息
- * @return
- */
- public function get_goods_saleshexiao(){
- $opdata = $this->check_order_data();
- extract($opdata);
- $order_goods_id = I('request.order_goods_id','');
-
- $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id, 'order_goods_id' => $order_goods_id) )->find();
- if (empty($order_hexiao_info)) {
- show_json(0, '未找到核销订单!');
- }
- $order_goods_info = M('lionfish_comshop_order_goods')->where(array('order_goods_id'=>$order_hexiao_info['order_goods_id']))->field('goods_id,name as goods_name,goods_images,quantity')->find();
- $order_hexiao_info['goods_id'] = $order_goods_info['goods_id'];
- $order_hexiao_info['goods_name'] = $order_goods_info['goods_name'];
- $order_hexiao_info['goods_images'] = tomedia($order_goods_info['goods_images']);
- $order_hexiao_info['quantity'] = $order_goods_info['quantity'];
- return array('order_hexiao_info' => $order_hexiao_info);
- }
- /**
- * 核销商品使用
- */
- public function hexiao_goods(){
- $hx_id = I('request.hx_id','');
- $hx_count = I('request.hx_count','');
- if(empty($hx_id)){
- show_json(0, '核销商品数据错误!');
- }
- if(empty($hx_count)){
- show_json(0, '核销商品数量错误!');
- }
- $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('id' => $hx_id) )->find();
- if (empty($order_hexiao_info)) {
- show_json(0, '未找到核销订单!');
- }
- D('Seller/Order')->hexiao_order_goods($order_hexiao_info,$hx_count);
- D('Seller/Order')->hexiao_finished($order_hexiao_info['order_id'],'后台确认使用,订单完成');
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- /**
- * 查看商品指定核销信息
- */
- public function hexiao_goods_assign_salesroom(){
- $goods_id = I('request.goods_id','');
- $order_goods_id = I('request.order_goods_id','');
- if(empty($goods_id)){
- show_json(0, '商品信息错误!');
- }
- if(empty($order_goods_id)){
- show_json(0, '核销商品信息错误!');
- }
- $order_goods_info = M('lionfish_comshop_order_goods')->where(array('order_goods_id'=>$order_goods_id))->field('goods_id,name as goods_name,goods_images,quantity')->find();
-
- $goods_salesroom_info = D('Seller/Order')->get_goods_assign_salesroom($goods_id);
- $this->salesroom_list = $goods_salesroom_info['salesroom_list'];
- $this->smember_list = $goods_salesroom_info['smember_list'];
- $this->goods_info = $order_goods_info;
- $this->display();
- }
- public function checkLocalTownOrderCanRefund($item){
- if($item['delivery'] == 'localtown_delivery'){//同城配送订单
- if($item['order_status_id'] == 4){//已发货不能退款
- return false;
- }else{
- return true;
- }
- }else{
- return true;
- }
- }
-
- }
- ?>
|