12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357 |
- <?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']);
- 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;
- }
- }
-
- }
- ?>
|