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