OrderController.class.php 179 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author fish
  7. *
  8. */
  9. namespace Seller\Controller;
  10. use Admin\Model\OrderModel;
  11. class OrderController extends CommonController{
  12. protected function _initialize(){
  13. parent::_initialize();
  14. }
  15. public function index(){
  16. $time = I('request.time');
  17. $s_time_start = I('request.time_start');
  18. $s_time_end = I('request.time_end');
  19. //var_dump($s_time,2);die();
  20. if( isset($s_time_start) && !empty($s_time_start) )
  21. {
  22. $time['start'] = $s_time_start;
  23. $time['end'] = $s_time_end;
  24. }
  25. $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  26. $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  27. $this->searchfield = I('request.searchfield','');
  28. $this->keyword = I('request.keyword','');
  29. $this->searchtime = I('request.searchtime','');
  30. $this->delivery = I('request.delivery','');
  31. $this->starttime = $starttime;
  32. $this->endtime = $endtime;
  33. $this->time = $time;
  34. //重置缓存
  35. $day_time = strtotime( date('Y-m-d '.'00:00:00') );
  36. $day_key = 'new_ordernotice_'.$day_time;
  37. S( $day_key, array() );
  38. $order_status_id = I('request.order_status_id',0);
  39. $order_status_arr = D('Seller/Order')->get_order_status_name();
  40. $this->order_status_arr = $order_status_arr;
  41. $is_soli_type = I('request.type', '');// isset($_GPC['type']) && $_GPC['type'] == 'soli' ? 1: 0;
  42. $is_soli = 0;
  43. if($is_soli_type == 'soli')
  44. {
  45. $is_soli = 1;
  46. }
  47. //soli
  48. $_GPC['is_soli'] = $is_soli;
  49. $_GET['type'] = 'normal';
  50. $is_presale_order = 0;
  51. if( isset($_GET['presale_order']) && $_GET['presale_order'] == 1 )
  52. {
  53. $is_presale_order = 1;
  54. }
  55. $is_virtualcard_order = 0;
  56. if( isset($_GET['virtualcard_order']) && $_GET['virtualcard_order'] == 1 )
  57. {
  58. $is_virtualcard_order = 1;
  59. }
  60. $this->is_soli = $is_soli;
  61. $this->is_presale_order = $is_presale_order;
  62. $this->is_virtualcard_order = $is_virtualcard_order;
  63. $need_data = D('Seller/Order')->load_order_list();
  64. $cur_controller = 'order/index';
  65. $total = $need_data['total'];
  66. $total_money = $need_data['total_money'];
  67. $list = $need_data['list'];
  68. $pager = $need_data['pager'];
  69. $all_count = $need_data['all_count'];
  70. $count_status_1 = $need_data['count_status_1'];
  71. $count_status_3 = $need_data['count_status_3'];
  72. $count_status_4 = $need_data['count_status_4'];
  73. $count_status_5 = $need_data['count_status_5'];
  74. $count_status_7 = $need_data['count_status_7'];
  75. $count_status_11 = $need_data['count_status_11'];
  76. $count_status_14 = $need_data['count_status_14'];
  77. $count_status_express = $need_data['count_status_express'];
  78. $this->cur_controller = $cur_controller;
  79. $this->total = $total;
  80. $this->total_money = $total_money;
  81. $this->list = $list;
  82. $this->pager = $pager;
  83. $this->all_count = $all_count;
  84. $this->count_status_1 = $count_status_1;
  85. $this->count_status_3 = $count_status_3;
  86. $this->count_status_4 = $count_status_4;
  87. $this->count_status_5 = $count_status_5;
  88. $this->count_status_7 = $count_status_7;
  89. $this->count_status_11 = $count_status_11;
  90. $this->count_status_14 = $count_status_14;
  91. $this->count_status_express = $count_status_express;
  92. $this->order_status_id = $order_status_id;
  93. $this->is_community = I('request.is_community', 0);
  94. $this->headid = I('request.headid', 0);
  95. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  96. if( empty($open_feier_print) )
  97. {
  98. $open_feier_print = 0;
  99. }
  100. if (defined('ROLE') && ROLE == 'agenter' )
  101. {
  102. $is_open_supply_print = D('Home/Front')->get_config_by_name('is_open_supply_print' );
  103. if( empty($is_open_supply_print) )
  104. {
  105. $open_feier_print = 0;
  106. }else{
  107. $supper_info = get_agent_logininfo();
  108. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print'.$supper_info['id'] );
  109. if( empty($open_feier_print) )
  110. {
  111. $open_feier_print = 0;
  112. }
  113. }
  114. }
  115. $this->open_feier_print = $open_feier_print;
  116. $is_can_look_headinfo = true;
  117. $is_can_nowrfund_order = true;
  118. $is_can_confirm_delivery = true;
  119. $is_can_confirm_receipt = true;
  120. $is_can_third_delivery = true;
  121. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  122. $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
  123. $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
  124. $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
  125. $supply_third_delivery_service = D('Home/Front')->get_config_by_name('supply_third_delivery_service');
  126. if (defined('ROLE') && ROLE == 'agenter' )
  127. {
  128. if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
  129. {
  130. $is_can_look_headinfo = false;
  131. }
  132. if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
  133. {
  134. $is_can_nowrfund_order = false;
  135. }
  136. if( isset($supply_can_confirm_delivery) && $supply_can_confirm_delivery == 2 )
  137. {
  138. $is_can_confirm_delivery = false;
  139. }
  140. if( isset($supply_can_confirm_receipt) && $supply_can_confirm_receipt == 2 )
  141. {
  142. $is_can_confirm_receipt = false;
  143. }
  144. }
  145. if( isset($supply_third_delivery_service) && $supply_third_delivery_service == 1){
  146. $is_can_third_delivery = true;
  147. }else{
  148. $is_can_third_delivery = false;
  149. }
  150. $s_id = 1 ;
  151. if(SELLERUID != 1)
  152. {
  153. $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
  154. $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  155. $perms1 = str_replace('.','/',$perms_arr['perms2']);
  156. $perms2 = explode(",", $perms1);
  157. if(in_array("user/user/index", $perms2)){
  158. $s_id = 1 ;
  159. } else {
  160. $s_id = 0 ;
  161. }
  162. }
  163. $this->s_id = $s_id;
  164. $is_localtown_imdada_status = D('Home/Front')->get_config_by_name('is_localtown_imdada_status');
  165. $is_localtown_sf_status = D('Home/Front')->get_config_by_name('is_localtown_sf_status');
  166. //是否开启蜂鸟即配
  167. $is_localtown_ele_status = D('Home/Front')->get_config_by_name('is_localtown_ele_status');
  168. $is_localtown_ele_status = isset($is_localtown_ele_status) ? $is_localtown_ele_status : 0;
  169. //是否开启码科配送
  170. $is_localtown_mk_status = D('Home/Front')->get_config_by_name('is_localtown_mk_status');
  171. $is_localtown_mk_status = isset($is_localtown_mk_status) ? $is_localtown_mk_status : 0;
  172. //码科预览价格
  173. $is_make_prequery_status = D('Home/Front')->get_config_by_name('is_make_prequery_status');
  174. $is_make_prequery_status = isset($is_make_prequery_status) ? $is_make_prequery_status : 0;
  175. $is_imdada_prequery_status = D('Home/Front')->get_config_by_name('is_imdada_prequery_status');
  176. $is_sf_prequery_status = D('Home/Front')->get_config_by_name('is_sf_prequery_status');
  177. $localtown_modifypickingname = D('Home/Front')->get_config_by_name('localtown_modifypickingname');
  178. $localtown_modifypickingname = !empty($localtown_modifypickingname) ? $localtown_modifypickingname: '包装费';
  179. $this->is_can_look_headinfo = $is_can_look_headinfo;
  180. $this->is_can_nowrfund_order = $is_can_nowrfund_order;
  181. $this->is_can_confirm_delivery = $is_can_confirm_delivery;
  182. $this->is_can_confirm_receipt = $is_can_confirm_receipt;
  183. $this->is_localtown_imdada_status = $is_localtown_imdada_status;
  184. $this->is_localtown_sf_status = $is_localtown_sf_status;
  185. $this->is_localtown_mk_status = $is_localtown_mk_status;
  186. $this->is_localtown_ele_status = $is_localtown_ele_status;
  187. $this->is_make_prequery_status = $is_make_prequery_status;
  188. $this->localtown_modifypickingname = $localtown_modifypickingname;
  189. $this->is_can_third_delivery = $is_can_third_delivery;
  190. if($is_localtown_imdada_status == 1 && $is_imdada_prequery_status == 1){
  191. $this->is_imdada_prequery_status = 1;
  192. }else{
  193. $this->is_imdada_prequery_status = 0;
  194. }
  195. if($is_localtown_sf_status == 1 && $is_sf_prequery_status == 1){
  196. $this->is_sf_prequery_status = 1;
  197. }else{
  198. $this->is_sf_prequery_status = 0;
  199. }
  200. $data = D('Seller/Config')->get_all_config();
  201. $this->data = $data;
  202. $this->display('Order/index');
  203. }
  204. public function opremarksaler()
  205. {
  206. $opdata = $this->check_order_data();
  207. extract($opdata);
  208. if (IS_POST) {
  209. $remark = I('request.remark');
  210. M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( array('remarksaler' => $remark) );
  211. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  212. }
  213. $this->item = $item;
  214. $this->id = $item['order_id'];
  215. include $this->display();
  216. }
  217. private function check_order_data()
  218. {
  219. $id = I('request.id',0);
  220. $item = M('lionfish_comshop_order')->where( array('order_id' => $id) )->find();
  221. if (empty($item)) {
  222. show_json(0, '未找到订单!');
  223. }
  224. return array('id' => $id, 'item' => $item);
  225. }
  226. public function opsendcancel()
  227. {
  228. $opdata = $this->check_order_data();
  229. extract($opdata);
  230. $sendtype = I('request.sendtype','');
  231. $gpc = I('request.');
  232. if (($item['order_status_id'] != 4) ) {
  233. show_json(0, '订单未发货,不需取消发货!');
  234. }
  235. if (IS_POST) {
  236. $remark = trim($gpc['remark']);
  237. $data = array('express_time' => 0,'shipping_no' =>'','shipping_method' => 0);
  238. $data['order_status_id'] = 1;
  239. M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save($data);
  240. $history_data = array();
  241. $history_data['order_id'] = $item['order_id'];
  242. $history_data['order_status_id'] = 1;
  243. $history_data['notify'] = 0;
  244. $history_data['comment'] = '订单取消发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'];
  245. $history_data['date_added'] = time();
  246. M('lionfish_comshop_order_history')->add($history_data);
  247. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  248. }
  249. $sendgoods = array();
  250. $bundles = array();
  251. $this->id = $item['order_id'];
  252. $this->item = $item;
  253. $this->sendtype = $sendtype;
  254. include $this->display();
  255. }
  256. public function opchangeaddress()
  257. {
  258. $_GPC = I('request.');
  259. $opdata = $this->check_order_data();
  260. extract($opdata);
  261. $new_area = 0;
  262. $address_street = 0;
  263. $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
  264. $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
  265. $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
  266. if (IS_POST) {
  267. $realname = $_GPC['realname'];
  268. $mobile = $_GPC['mobile'];
  269. $province = $_GPC['province'];
  270. $city = $_GPC['city'];
  271. $area = $_GPC['area'];
  272. $street = $_GPC['street'];
  273. $changead = intval($_GPC['changead']);
  274. $address = trim($_GPC['address']);
  275. if (!(empty($id))) {
  276. if (empty($realname)) {
  277. $ret = '请填写收件人姓名!';
  278. //show_json(0, array('msg' => $ret) );
  279. show_json(0, $ret);
  280. }
  281. if (empty($mobile)) {
  282. $ret = '请填写收件人手机!';
  283. show_json(0, $ret);
  284. }
  285. if ($changead) {
  286. if ($province == '请选择省份') {
  287. $ret = '请选择省份!';
  288. show_json(0, $ret);
  289. }
  290. if (empty($address)) {
  291. $ret = '请填写详细地址!';
  292. show_json(0, $ret);
  293. }
  294. }
  295. $address_array = array();
  296. $address_array['shipping_name'] = $realname;
  297. $address_array['shipping_tel'] = $mobile;
  298. if ($changead) {
  299. $province_info = M('lionfish_comshop_area')->where("name like '%{$province}%' ")->find();
  300. if( !empty($province_info))
  301. {
  302. $province_id = $province_info['id'];
  303. }else{
  304. $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
  305. $area_data = array();
  306. $area_data['name'] = $province;
  307. $area_data['pid'] = 0;
  308. $area_data['code'] = $max_dp['code']+1;
  309. $province_id = M('lionfish_comshop_area')->add($area_data);
  310. $up_data = array();
  311. $up_data['code'] = $province_id;
  312. M('lionfish_comshop_area')->where( array('id' => $province_id ) )->save($up_data);
  313. }
  314. //$city_info = M('lionfish_comshop_area')->where("name like '%{$city}%'")->find();
  315. $guding_arr = ['鞍山市'];
  316. if( in_array($city , $guding_arr) )
  317. {
  318. $city_info = M('lionfish_comshop_area')->where("name = '{$city}'")->find();
  319. }else{
  320. $city_info = M('lionfish_comshop_area')->where("name like '%{$city}%'")->find();
  321. }
  322. if( !empty($city_info))
  323. {
  324. $city_id = $city_info['id'];
  325. }else{
  326. $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
  327. $area_data = array();
  328. $area_data['name'] = $city;
  329. $area_data['pid'] = $province_id;
  330. $area_data['code'] = $max_dp['code']+1;
  331. $city_id = M('lionfish_comshop_area')->add( $area_data);
  332. $up_data = array();
  333. $up_data['code'] = $city_id;
  334. M('lionfish_comshop_area')->where( array('id' => $city_id ) )->save($up_data);
  335. }
  336. //city_name: 东莞市
  337. if( empty($area) )
  338. {
  339. if( $city == '东莞市' )
  340. {
  341. $area = '东莞';
  342. }
  343. if( $city == '中山市' )
  344. {
  345. $area = '中山';
  346. //453
  347. }
  348. }
  349. $country_info = M('lionfish_comshop_area')->where( "name like '%{$area}%' " )->find();
  350. if( $area == '中山' )
  351. {
  352. $country_info = M('lionfish_comshop_area')->where( array('id' => 453 ) )->find();
  353. //
  354. }
  355. if( !empty($country_info))
  356. {
  357. $country_id = $country_info['id'];
  358. }else{
  359. $max_dp = M('lionfish_comshop_area')->order('code desc')->find();
  360. $area_data = array();
  361. $area_data['name'] = $area;
  362. $area_data['pid'] = $city_id;
  363. $area_data['code'] = $max_dp['code']+1;
  364. $country_id = M('lionfish_comshop_area')->add( $area_data );
  365. $up_data = array();
  366. $up_data['code'] = $country_id;
  367. M('lionfish_comshop_area')->where( array('id' => $country_id ) )->save( $up_data );
  368. }
  369. $address_array['shipping_province_id'] = $province_id;
  370. $address_array['shipping_city_id'] = $city_id;
  371. $address_array['shipping_country_id'] = $country_id;
  372. $address_array['shipping_address'] = $address;
  373. if( $item['delivery'] == 'tuanz_send' )
  374. {
  375. $address_array['tuan_send_address'] = $address;
  376. }
  377. }
  378. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( $address_array );
  379. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  380. }
  381. }
  382. $this->id = $item['order_id'];
  383. $this->item = $item;
  384. $this->province_info = $province_info;
  385. $this->city_info = $city_info;
  386. $this->area_info = $area_info;
  387. $this->display();
  388. }
  389. //确认送达团长
  390. public function opsend_tuanz_over()
  391. {
  392. $opdata = $this->check_order_data();
  393. extract($opdata);
  394. //express_tuanz_time D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  395. D('Seller/Order')->do_tuanz_over($item['order_id']);
  396. //D('Seller/Frontorder')->send_order_operate($item['order_id']);
  397. D('Home/Frontorder')->send_order_operate($item['order_id']);
  398. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  399. }
  400. public function all_opprint()
  401. {
  402. $_GPC = I('request.');
  403. $order_arr = $_GPC['order_arr'];
  404. $cache_key = md5(time().mt_rand(100,1000));
  405. S('_all_opprintquene_'.$cache_key, $order_arr);
  406. $this->cache_key = $cache_key;
  407. $this->_GPC = $_GPC;
  408. $this->display();
  409. }
  410. public function do_opprint_quene()
  411. {
  412. $_GPC = I('request.');
  413. $cache_key = $_GPC['cache_key'];
  414. $quene_order_list = S('_all_opprintquene_'.$cache_key);
  415. $order_id = array_shift($quene_order_list);
  416. S('_all_opprintquene_'.$cache_key, $quene_order_list);
  417. $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array( 'order_id' => $order_id ) )->find();
  418. $print_model = D('Seller/Printaction');
  419. $result = $print_model->check_print_order( $order_id );
  420. $result2 =$print_model->check_print_order2( $order_id );
  421. if( $result['code'] == 1 || $result2['code'] == 1 )
  422. {
  423. M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('is_print_suc' => 1) );
  424. }
  425. if( empty($quene_order_list) )
  426. {
  427. echo json_encode( array('code' => 2) );
  428. die();
  429. }
  430. //清单编号
  431. echo json_encode( array('code' => 0, 'msg' => '订单编号:'.$order_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理") );
  432. die();
  433. }
  434. public function opprint()
  435. {
  436. $_GPC = I('request.');
  437. $order_id = $_GPC['id'];
  438. $print_model = D('Seller/Printaction');
  439. $result = $print_model->check_print_order( $order_id );
  440. $result2 = $print_model->check_print_order2( $order_id );
  441. if( $result['code'] == 1 || $result2['code'] == 1 )
  442. {
  443. M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('is_print_suc' => 1) );
  444. show_json(1, array('msg' => '打印成功!' ) );
  445. }else{
  446. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  447. if(!empty($open_feier_print) && ( $open_feier_print == 2 || $open_feier_print == 1 ) )
  448. {
  449. show_json(0, array('msg' => $result['msg'] ) );
  450. }else{
  451. show_json(0, array('msg' => $result2['msg'] ) );
  452. }
  453. }
  454. }
  455. public function oprefund_goods_do()
  456. {
  457. $_GPC = I('request.');
  458. $opdata = $this->check_order_data();
  459. extract($opdata);
  460. $weixin_model = D('Home/Weixin');
  461. $id = $_GPC['id'];
  462. $order_goods_id = $_GPC['order_goods_id'];
  463. /**
  464. id : 3864
  465. order_goods_id : 4442
  466. **/
  467. //付款总额
  468. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
  469. $this->order_goods_info = $order_goods_info;
  470. $goods_images = tomedia( $order_goods_info['goods_images'] );
  471. $this->goods_images = $goods_images;
  472. $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'];
  473. $integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'orderbuy', 'order_goods_id' => $order_goods_id ) )->find();
  474. $use_score = 0;
  475. if( !empty($integral_flow) )
  476. {
  477. $use_score = $integral_flow['score'];
  478. }
  479. $this->use_score = $use_score;
  480. $total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($id,$order_goods_id);
  481. $this->total_quantity = $total_quantity;
  482. $has_refund_quantity = D('Seller/Commonorder')->refund_order_goods_quantity($id,$order_goods_id);
  483. $this->has_refund_quantity = $has_refund_quantity;
  484. $has_refund_money = D('Seller/Commonorder')->get_order_goods_refund_money($id,$order_goods_id);
  485. $this->has_refund_money = $has_refund_money;
  486. $shipping_fare = $order_goods_info['shipping_fare'];
  487. $delivery = $opdata['item']['delivery'];
  488. $this->delivery = $delivery;
  489. //预售订单begin
  490. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
  491. $presale_info = [];
  492. if( $presale_result['code'] == 0 )
  493. {
  494. $presale_info = $presale_result['data'];
  495. }
  496. $this->presale_info = $presale_info;
  497. //end
  498. $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
  499. $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
  500. if( $is_has_refund_deliveryfree == 1 && $item['type'] != 'integral')
  501. {
  502. //后台设置退运费了
  503. //退回运费,导致佣金出错问题修改
  504. //$free_tongji += $shipping_fare;
  505. }
  506. if($item['delivery'] == 'hexiao'){
  507. $used_total = D('Home/Salesroom')->get_hexiao_order_goods_used_total($id,$order_goods_id);
  508. $free_tongji = $free_tongji - $used_total;
  509. }
  510. $this->shipping_fare = $shipping_fare;
  511. $this->is_has_refund_deliveryfree = $is_has_refund_deliveryfree;
  512. $this->free_tongji = $free_tongji;
  513. $this->_GPC = $_GPC;
  514. $commiss_state = '未结算';
  515. $commiss_info = M('lionfish_community_head_commiss_order')->where( array('order_id' => $id, 'order_goods_id' =>$order_goods_id,'type' => 'orderbuy' ) )->find();
  516. if( !empty($commiss_info) && $commiss_info['state'] == 1 )
  517. {
  518. $commiss_state = '已结算';
  519. }
  520. $this->commiss_info =$commiss_info;
  521. $this->commiss_state = $commiss_state;
  522. $this->payment_code = $item['payment_code'];
  523. if ( IS_POST ) {
  524. if(!$this->checkLocalTownOrderCanRefund($item)){
  525. show_json(0, array('message' => '同城配送订单配送中不能退款') );
  526. }
  527. $refund_money = isset($_GPC['refund_money']) && $_GPC['refund_money'] >0 ? floatval($_GPC['refund_money']) : 0;
  528. $is_refund_shippingfare = isset($_GPC['is_refund_shippingfare']) ? $_GPC['is_refund_shippingfare'] : 0;//退运费
  529. $is_back_sellcount = isset($_GPC['is_back_sellcount']) ? $_GPC['is_back_sellcount'] : 0;//退库存
  530. $is_back_scorecount = isset($_GPC['is_back_scorecount']) ? $_GPC['is_back_scorecount'] : 0;//退积分
  531. //$free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
  532. $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'];
  533. $refund_quantity = isset($_GPC['refund_quantity']) && $_GPC['refund_quantity'] >0 ? floatval($_GPC['refund_quantity']) : 0;
  534. $real_refund_quantity = isset($_GPC['real_refund_quantity']) && $_GPC['real_refund_quantity'] >0 ? intval($_GPC['real_refund_quantity']) : 0;
  535. //已退商品数量
  536. $refund_total_quantity = M('lionfish_comshop_order_goods_refund')->where( "order_id={$id} and order_goods_id={$order_goods_id} " )->sum('quantity');
  537. //部分退款计算运费
  538. if($refund_quantity + $refund_total_quantity < $order_goods_info['quantity']){
  539. $shipping_fare = round($refund_quantity/$order_goods_info['quantity']*$shipping_fare,2);
  540. }else{
  541. //$shipping_fare = round($refund_quantity/$order_goods_info['quantity']*$shipping_fare,2);
  542. $shipping_fare = $shipping_fare - $refund_total_quantity * round( 1/$order_goods_info['quantity'] * $shipping_fare,2);
  543. }
  544. $pay_total_money = $free_tongji ;
  545. $refund_shipping_fare = 0;
  546. $wx_refund_money = $refund_money;
  547. if( $is_refund_shippingfare == 1)
  548. {
  549. $free_tongji += $shipping_fare;
  550. $refund_shipping_fare = $shipping_fare;
  551. $wx_refund_money = $wx_refund_money + $shipping_fare;
  552. }
  553. $can_free_tongji = $opdata['item']['total'] + $opdata['item']['shipping_fare'] -$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
  554. if( $item['type'] == 'integral' )
  555. {
  556. $can_free_tongji = $opdata['item']['total'] -$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
  557. }
  558. $can_refund_quantity = 0;
  559. if($item['delivery'] == 'hexiao'){
  560. $can_refund_quantity = D('Home/Salesroom')->get_hexiao_order_goods_can_refund_quantity($id,$order_goods_id);
  561. }
  562. //以及退款了多少钱了 has_refund_money
  563. if($refund_money + $has_refund_money > $can_free_tongji){
  564. show_json(0, array('message' => '总退款金额大于可退款金额') );
  565. }
  566. else if( $refund_money < 0 )
  567. {
  568. show_json(0, array('message' => '填写正确的退款金额') );
  569. }
  570. else if( $is_back_sellcount == 1 && $refund_quantity > $total_quantity )
  571. {
  572. show_json(0, array('message' => '填写正确的退库存数量,最大'.$total_quantity.'个' ) );
  573. }else if($item['delivery'] == 'hexiao' && $can_refund_quantity < $refund_quantity){
  574. show_json(0, array('message' => '核销商品退款数量大于可退款数量'.$refund_quantity.'个' ) );
  575. }
  576. else{
  577. if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
  578. {
  579. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => 0) );
  580. M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$order_goods_id ) )->save( array('shipping_fare' => 0) );
  581. }
  582. //is_back_sellcount
  583. //$res = $weixin_model->refundOrder($id,$refund_money,0,$order_goods_id,$is_back_sellcount, $refund_quantity,1);
  584. $res = $weixin_model->refundOrder($id,$wx_refund_money,0,$order_goods_id,$is_back_sellcount, $refund_quantity,1);
  585. if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
  586. {
  587. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => $opdata['item']['shipping_fare'] ) );
  588. M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$order_goods_id ) )->save( array('shipping_fare' => $order_goods_info['shipping_fare']) );
  589. }
  590. if( $res['code'] == 0 )
  591. {
  592. show_json(0, array('message' => $res['msg'] ) );
  593. }else{
  594. //开始插入本次退款的情况
  595. //存储当前这笔退款 影响到的以后佣金情况
  596. //is_back_scorecount
  597. if( $is_back_scorecount == 1 )
  598. {
  599. $refund_score = 0;
  600. $refund_score = intval( ($use_score / $order_goods_info['quantity']) * $refund_quantity);
  601. D('Seller/Commonorder')->refund_order_goods_intrgral( $id, $order_goods_id ,$refund_score );
  602. }else{
  603. $refund_score = 0;
  604. D('Seller/Commonorder')->refund_order_goods_intrgral( $id, $order_goods_id ,0 );
  605. }
  606. //退回运费,导致佣金出错问题修改
  607. $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);
  608. //$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);
  609. //如果这个商品没有数量了。就改变他的状态为已退款的状态
  610. $new_total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($id,$order_goods_id);
  611. if( $new_total_quantity <=0 )
  612. {
  613. 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);
  614. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->select();
  615. $is_all_refund = true;
  616. foreach($order_goods_list as $val )
  617. {
  618. if($val['is_refund_state'] != 1)
  619. {
  620. $is_all_refund = false;
  621. }
  622. }
  623. $or_gd_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
  624. if(($or_gd_info['is_refund_state'] == 1) && ($is_all_refund == false) ){
  625. $or_gd_info = M('lionfish_comshop_order_goods')->field('name')->where( array('order_goods_id' => $order_goods_id ) )->find();
  626. $order_history = array();
  627. $order_history['order_id'] = $id;
  628. $order_history['order_status_id'] = 19;
  629. $order_history['notify'] = 0;
  630. if( $item['type'] == 'integral' ){
  631. $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款积分'.$refund_money.'积分';
  632. }else{
  633. $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款金额'.$refund_money.'元';
  634. }
  635. $order_history['date_added'] = time();
  636. M('lionfish_comshop_order_history')->add( $order_history );
  637. }
  638. }else{
  639. $or_gd_info = M('lionfish_comshop_order_goods')->field('name')->where( array('order_goods_id' => $order_goods_id ) )->find();
  640. $order_history = array();
  641. $order_history['order_id'] = $id;
  642. $order_history['order_status_id'] = 19;
  643. $order_history['notify'] = 0;
  644. if( $item['type'] == 'integral' ){
  645. $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款积分'.$refund_money.'积分,';
  646. }else{
  647. $order_history['comment'] = '后台子订单退款,退款商品:'.$or_gd_info['name'].','.$real_refund_quantity.'个,退库存/销量数量'.$refund_quantity.'个,退款金额'.$refund_money.'元,';
  648. }
  649. if($is_refund_shippingfare == 1)
  650. {
  651. $order_history['comment'] .= '. 退配送费:'.$refund_shipping_fare.'元';
  652. }
  653. $order_history['date_added'] = time();
  654. M('lionfish_comshop_order_history')->add( $order_history );
  655. }
  656. //核销订单操作
  657. if($item['delivery'] == 'hexiao'){
  658. //核销商品订单退款
  659. D('Home/Salesroom')->hexiao_refund_action($id,$order_goods_id,$refund_quantity);
  660. //操作核销订单是否完成
  661. D('Seller/Order')->hexiao_finished($id, '未核销商品退款,订单完成');
  662. }
  663. //礼品卡退款
  664. D('Seller/VirtualCard')->refundOrder($id);
  665. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  666. }
  667. }
  668. }
  669. if( $item['type'] == 'integral' )
  670. {
  671. include $this->display('Order/oprefund_goods_dointegral');
  672. }else{
  673. include $this->display();
  674. }
  675. }
  676. public function oprefund_do()
  677. {
  678. $_GPC = I('request.');
  679. $opdata = $this->check_order_data();
  680. extract($opdata);
  681. $id = $_GPC['id'];
  682. //付款总额
  683. $free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
  684. $total_quantity = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->sum('quantity');
  685. $has_refud_money = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $id ) )->sum('money');
  686. $this->has_refud_money = $has_refud_money;
  687. $has_refund_quantity = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $id ) )->sum('quantity');
  688. $total_quantity = $total_quantity - $has_refund_quantity;
  689. $buy_score_total = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'orderbuy' , 'order_id' => $id ) )->sum('score');
  690. $has_refund_buy_score_total = M('lionfish_comshop_member_integral_flow')->where(array('type' => 'refundorder' , 'order_id' => $id ))->sum('score');
  691. if(!empty($has_refund_buy_score_total) && $has_refund_buy_score_total > 0)
  692. $buy_score_total = $buy_score_total - $has_refund_buy_score_total;
  693. $this->buy_score_total = $buy_score_total;
  694. $shipping_fare = $opdata['item']['shipping_fare'];
  695. $delivery = $opdata['item']['delivery'];
  696. $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
  697. $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
  698. if( $is_has_refund_deliveryfree == 1)
  699. {
  700. //后台设置退运费了
  701. //退回运费,导致佣金出错问题修改
  702. $free_tongji += $opdata['item']['shipping_fare'];
  703. }
  704. $hx_used_total = 0;
  705. if($item['delivery'] == 'hexiao'){
  706. $used_quantity = D('Home/Salesroom')->get_hexiao_order_used_quantity($id);
  707. $hx_used_total = D('Home/Salesroom')->get_hexiao_order_used_total($id);
  708. $total_quantity = $total_quantity - $used_quantity;
  709. $free_tongji = $free_tongji - $hx_used_total;
  710. }
  711. //判断是否有预售 begin
  712. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
  713. $presale_info = [];
  714. if( $presale_result['code'] == 0 )
  715. {
  716. $presale_info = $presale_result['data'];
  717. $free_tongji = $free_tongji - $presale_info['presale_for_ordermoney'];
  718. }
  719. //end
  720. $this->presale_info = $presale_info;
  721. $this->is_has_refund_deliveryfree = $is_has_refund_deliveryfree;
  722. $this->shipping_fare = $shipping_fare;
  723. $this->total_quantity = $total_quantity;
  724. $this->delivery = $delivery;
  725. $this->hx_used_total = $hx_used_total;
  726. if( IS_POST )
  727. {
  728. if(!$this->checkLocalTownOrderCanRefund($item)){
  729. show_json(0, array('message' => '同城配送订单配送中不能退款') );
  730. }
  731. $refund_money = isset($_GPC['refund_money']) && $_GPC['refund_money'] >0 ? floatval($_GPC['refund_money']) : 0;
  732. $is_refund_shippingfare = isset($_GPC['is_refund_shippingfare']) ? $_GPC['is_refund_shippingfare'] : 0;//退运费
  733. $is_back_sellcount = isset($_GPC['is_back_sellcount']) ? $_GPC['is_back_sellcount'] : 0;//退库存
  734. $is_back_buyscore = isset($_GPC['is_back_buyscore']) ? $_GPC['is_back_buyscore'] : 0;//退积分
  735. $wx_refund_money = $refund_money;
  736. $free_tongji = $opdata['item']['total']-$opdata['item']['voucher_credit']-$opdata['item']['fullreduction_money'] - $opdata['item']['score_for_money'];
  737. //已经退款运费
  738. $refund_shipping_fare_amount = M('lionfish_comshop_order_goods_refund')->where( array('order_id' =>$id ) )->sum('refund_shipping_fare');
  739. if( empty($refund_shipping_fare_amount) )
  740. {
  741. $refund_shipping_fare_amount = 0;
  742. }
  743. if( $is_refund_shippingfare == 1 && $opdata['item']['type'] != 'integral' )
  744. {
  745. if($refund_shipping_fare_amount < $shipping_fare) {
  746. $shipping_fare = $shipping_fare - $refund_shipping_fare_amount;
  747. $this->shipping_fare = $shipping_fare;
  748. //$free_tongji += $shipping_fare;
  749. $wx_refund_money += $shipping_fare - $opdata['item']['fare_shipping_free'];
  750. $is_back_buyscore = 2;//退运费
  751. }
  752. }
  753. $free_tongji = $free_tongji - $has_refud_money;
  754. if( $refund_money - $free_tongji >= 0.01 ){
  755. show_json(0, array('message' => '填写金额大于总退款金额' ) );
  756. }
  757. else if( $refund_money < 0 )
  758. {
  759. show_json(0, array('message' => '填写正确的退款金额' ) );
  760. }
  761. else{
  762. $weixin_model = D('Home/Weixin');
  763. $id = $_GPC['id'];
  764. $model = M('lionfish_comshop_order');
  765. //$model->startTrans(); // 开启事务
  766. $order_info = $model->where(array('order_id'=>$id))->find();
  767. if( $order_info['order_status_id'] != 7 )
  768. {
  769. if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
  770. {
  771. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => 0) );
  772. }
  773. //$res = $weixin_model->refundOrder($id,$refund_money,0,0,$is_back_sellcount);
  774. $res = $weixin_model->refundOrder($id,$wx_refund_money,0,0,$is_back_sellcount);
  775. if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
  776. {
  777. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('shipping_fare' => $opdata['item']['shipping_fare'] ) );
  778. }
  779. $model->commit(); // 开启事务
  780. if( $res['code'] == 0 )
  781. {
  782. show_json(0, array('message' => $res['msg']) );
  783. }else{
  784. //integral
  785. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $id ) )->find();
  786. $comment = '后台操作立即退款,退款金额:'.$refund_money.'元';
  787. if( $is_refund_shippingfare == 0 && $opdata['item']['type'] == 'integral' )
  788. {
  789. $comment = '后台操作立即退款,退款积分:'.$refund_money.'积分';
  790. }
  791. if( $order_info['type'] == 'integral' )
  792. {
  793. $comment = '后台操作立即退款,退还积分:'.$refund_money.'积分';
  794. //$comment = '后台操作立即退款,退款金额:'.$refund_money.'元';
  795. }
  796. if($is_refund_shippingfare == 1)
  797. {
  798. if( $order_info['type'] == 'integral' ){
  799. $refund_shipping_fare_amount2 = M('lionfish_comshop_order_goods_refund')->where( array('order_id' =>$id ) )->sum('refund_shipping_fare');
  800. if( empty($refund_shipping_fare_amount2) )
  801. {
  802. $refund_shipping_fare_amount2 = 0;
  803. }
  804. $new_shipping_fare = $opdata['item']['shipping_fare'] - $refund_shipping_fare_amount2;
  805. $comment .= '. 退配送费:'.$new_shipping_fare.'元';
  806. }else{
  807. $comment .= '. 退配送费:'.$opdata['item']['shipping_fare'].'元';
  808. }
  809. }
  810. if($is_back_sellcount == 1)
  811. {
  812. $comment .= '. 退库存:'.$total_quantity;
  813. }else{
  814. $comment .= '. 不退库存,不减销量';
  815. }
  816. $history_data = array();
  817. $history_data['order_id'] = $id;
  818. $history_data['order_status_id'] = 7;
  819. $history_data['notify'] = 0;
  820. $history_data['comment'] = $comment;
  821. $history_data['date_added'] = time();
  822. M('lionfish_comshop_order_history')->add($history_data);
  823. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('order_status_id' => 7) );
  824. //将所有在退款中的状态,全部重置成已退款成功
  825. M('lionfish_comshop_order_refund')->where( array('order_id' => $id, 'state' => 0) )->save( array('state' => 3) );
  826. //将退款中的 申请订单,全部改成已退款
  827. $refund_all = M('lionfish_comshop_order_refund')->where( array('order_id' =>$id, 'state' => 0 ) )->select();
  828. if( !empty($refund_all) )
  829. {
  830. foreach( $refund_all as $val )
  831. {
  832. $ins_data = array();
  833. $ins_data['ref_id'] = $val['ref_id'];
  834. $ins_data['order_id'] = $val['order_id'];
  835. $ins_data['order_goods_id'] = $val['order_goods_id'];
  836. $ins_data['message'] = '平台同意退款   ,退款成功';
  837. $ins_data['type'] = 2;
  838. $ins_data['addtime'] = time();
  839. M('lionfish_comshop_order_refund_history')->add( $ins_data );
  840. M('lionfish_comshop_order_refund')->where( array('ref_id' => $val['ref_id']) )->save( array('state' => 3) );
  841. }
  842. }
  843. //$data[''] = isset($data['is_print_admin_cancleorder']) ? $data['is_print_admin_cancleorder'] : 0;
  844. $is_print_admin_cancleorder = D('Home/Front')->get_config_by_name('is_print_admin_cancleorder');
  845. D('Seller/Commonorder')->refund_one_order( $id , $is_back_buyscore);
  846. if( isset($is_print_admin_cancleorder) && $is_print_admin_cancleorder == 1 )
  847. {
  848. D('Seller/Printaction')->check_print_order($id,'后台操作取消订单');
  849. D('Seller/Printaction')->check_print_order2($id,'后台操作取消订单');
  850. }
  851. sellerLog('订单['.$order_info['order_num_alias'].']退款成功操作', 2);
  852. //核销订单操作
  853. if($item['delivery'] == 'hexiao'){
  854. D('Home/Salesroom')->hexiao_order_refund_action($id);
  855. }
  856. //礼品卡退款
  857. D('Seller/VirtualCard')->refundOrder($id);
  858. show_json(1, array('message' => '退款成功!') );
  859. }
  860. }else{
  861. //$model->rollback(); // 回滚
  862. show_json(0, array('message' => '请勿重复提交'));
  863. }
  864. }
  865. }
  866. $this->id = $id;
  867. $this->free_tongji = $free_tongji;
  868. $this->item = $item;
  869. $commiss_state = '未结算';
  870. $commiss_info = M('lionfish_community_head_commiss_order')->where( array('order_id' => $id, 'type' => 'orderbuy' ) )->find();
  871. if( !empty($commiss_info) && $commiss_info['state'] == 1 )
  872. {
  873. $commiss_state = '已结算';
  874. }
  875. $this->commiss_state = $commiss_state;
  876. if( $item['type'] == 'integral' )
  877. {
  878. $this->display('Order/oprefund_do_integral');
  879. }else{
  880. $this->display();
  881. }
  882. }
  883. function test()
  884. {
  885. //D('Seller/Printaction')->check_print_order(63);
  886. // lionfish_comshop_order
  887. $shop_name = D('Home/Front')->get_config_by_name('shoname');
  888. $this->shop_name = $shop_name;
  889. $order_id = 174;
  890. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  891. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->select();
  892. $need_order_goods = array();
  893. foreach($order_goods as $key => $value)
  894. {
  895. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
  896. $need_order_goods[$key] = $value;
  897. }
  898. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  899. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  900. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  901. $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id'] ) )->find();
  902. $this->province_info = $province_info;
  903. $this->city_info = $city_info;
  904. $this->area_info = $area_info;
  905. $this->member = $member;
  906. $this->order_info = $order_info;
  907. $this->need_order_goods = $need_order_goods;
  908. $this->display('forms');
  909. }
  910. /**
  911. 打印配送单
  912. **/
  913. public function order_print_dan()
  914. {
  915. $order_id = I('get.id');
  916. $shop_name = D('Home/Front')->get_config_by_name('shoname');
  917. $this->shop_name = $shop_name;
  918. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  919. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->select();
  920. $need_order_goods = array();
  921. $total = 0;
  922. foreach($order_goods as $key => $value)
  923. {
  924. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
  925. $need_order_goods[$key] = $value;
  926. }
  927. $total = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->sum('total');
  928. $legal_amount = D('Seller/Order')->num_to_rmb($total);
  929. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  930. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  931. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  932. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  933. sellerLog('订单['.$order_info['order_num_alias'].']打印配送单', 2);
  934. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  935. $order_note_name = isset($order_note_name) && !empty($order_note_name) ? $order_note_name :'店名';
  936. $this->order_note_name = $order_note_name;
  937. $this->legal_amount = $legal_amount;
  938. $this->province_info = $province_info;
  939. $this->city_info = $city_info;
  940. $this->area_info = $area_info;
  941. $this->member = $member;
  942. $this->order_info = $order_info;
  943. $this->need_order_goods = $need_order_goods;
  944. $this->display('forms');
  945. }
  946. //配送团长
  947. public function opsend_tuanz()
  948. {
  949. $opdata = $this->check_order_data();
  950. extract($opdata);
  951. D('Seller/Order')->do_send_tuanz($item['order_id']);
  952. $order_num_alias = M('lionfish_comshop_order')->where( array('order_id' => $item['order_id'] ) )->find();
  953. D('Seller/Operatelog')->addOperateLog('detailed_list','配送团长--订单编号'.$order_num_alias['order_num_alias']);
  954. //后台自动送达团长
  955. D('Seller/Order')->order_auto_service($item,'后台自动确认送达团长');
  956. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  957. }
  958. //同城配送,确认开始配送流程
  959. public function opsend_localtown()
  960. {
  961. $opdata = $this->check_order_data();
  962. extract($opdata);
  963. $count = D('Seller/Order')->do_send_localtown($item['order_id']);
  964. show_json(1, array('url' => $_SERVER['HTTP_REFERER'], 'count' => $count));
  965. }
  966. public function opsend()
  967. {
  968. $_GPC = I('request.');
  969. $opdata = $this->check_order_data();
  970. extract($opdata);
  971. if (empty($item['address_id'])) {
  972. show_json(0, array('message' => '无收货地址,无法发货!'));
  973. }
  974. if ($item['order_status_id'] == 3) {
  975. show_json(0, array('message' => '订单未付款,无法发货!'));
  976. }
  977. if (IS_POST) {
  978. //express shipping_no $express_info['name'] dispatchname
  979. if (!(empty($_GPC['shipping_no'])) && empty($_GPC['shipping_no'])) {
  980. show_json(0, array('message' => '请输入快递单号!') );
  981. }
  982. if ( empty($_GPC['express']) ) {
  983. show_json(0, array('message' => '请选择快递公司!'));
  984. }
  985. if (!(empty($item['transid']))) {
  986. }
  987. $express_info = D('Seller/Express')->get_express_info($_GPC['express']);
  988. $time = time();
  989. $data = array(
  990. 'shipping_method' => trim($_GPC['express']),
  991. 'shipping_no' => trim($_GPC['shipping_no']),
  992. 'dispatchname' => $express_info['name'],
  993. 'express_time' => $time
  994. );
  995. $data['order_status_id'] = 4;
  996. M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( $data );
  997. $history_data = array();
  998. $history_data['order_id'] = $item['order_id'];
  999. $history_data['order_status_id'] = 4;
  1000. $history_data['notify'] = 0;
  1001. $history_data['comment'] = '订单发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $_GPC['shipping_no'];
  1002. $history_data['date_added'] = time();
  1003. M('lionfish_comshop_order_history')->add($history_data);
  1004. D('Home/Frontorder')->send_order_operate($item['order_id']);
  1005. sellerLog('订单['.$item['order_num_alias'].']订单发货操作', 2);
  1006. //TODO...发送已经发货的消息通知
  1007. //m('notice')->sendOrderMessage($item['id']);
  1008. //plog('order.op.send', '订单发货 ID: ' . $item['id'] . ' 订单号: ' . $item['ordersn'] . ' <br/>快递公司: ' . $_GPC['expresscom'] . ' 快递单号: ' . $_GPC['expresssn']);
  1009. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1010. }
  1011. $noshipped = array();
  1012. $shipped = array();
  1013. $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
  1014. $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
  1015. $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
  1016. $order_goods = M()->query('select og.order_goods_id as id,og.name as title,og.goods_images as thumb from ' .
  1017. C('DB_PREFIX'). 'lionfish_comshop_order_goods as og where og.order_id= '.$item['order_id']);
  1018. $express_list = D('Seller/Express')->load_all_express();
  1019. $this->province_info = $province_info;
  1020. $this->city_info = $city_info;
  1021. $this->area_info = $area_info;
  1022. $this->order_goods = $order_goods;
  1023. $this->item = $item;
  1024. $this->express_list = $express_list;
  1025. $this->id = $item['order_id'];
  1026. $this->display();
  1027. }
  1028. // 11 已完成
  1029. public function opfinish()
  1030. {
  1031. $opdata = $this->check_order_data();
  1032. extract($opdata);
  1033. M('lionfish_comshop_order')->where(array('order_id' => $item['order_id']) )->save( array('order_status_id' => 11,
  1034. 'finishtime' => time()) );
  1035. $history_data = array();
  1036. $history_data['order_id'] = $item['order_id'];
  1037. $history_data['order_status_id'] = 11;
  1038. $history_data['notify'] = 0;
  1039. $history_data['comment'] = '后台操作,已完成' ;
  1040. $history_data['date_added'] = time();
  1041. sellerLog('订单['.$item['order_num_alias'].']订单完成操作', 2);
  1042. M('lionfish_comshop_order_history')->add($history_data);
  1043. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1044. }
  1045. public function export_form()
  1046. {
  1047. $_GPC = I('request.');
  1048. /**
  1049. order_status_id:
  1050. type: normal
  1051. searchtime:
  1052. time[start]: 2019-12-23 00:00:00
  1053. time[end]: 2019-12-23 23:59:59
  1054. delivery:
  1055. searchfield: ordersn
  1056. keyword:
  1057. export: 0
  1058. **/
  1059. unset($_GPC['controller']);
  1060. unset($_GPC['export']);
  1061. $post_data = array();
  1062. $post_data['order_status_id'] = $_GPC['order_status_id'];
  1063. $post_data['type'] = $_GPC['type'];
  1064. $post_data['searchtime'] = $_GPC['searchtime'];
  1065. $post_data['time[start]'] = $_GPC['time']['start'];
  1066. $post_data['time[end]'] = $_GPC['time']['end'];
  1067. $post_data['headid'] = $_GPC['headid'];
  1068. $post_data['delivery'] = $_GPC['delivery'];
  1069. $post_data['searchfield'] = $_GPC['searchfield'];
  1070. $post_data['keyword'] = $_GPC['keyword'];
  1071. $post_data['export'] = 1;
  1072. $note_content = D('Home/Front')->get_config_by_name('order_note_name');
  1073. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  1074. $columns = array(
  1075. array('title' => '订单流水号', 'field' => 'day_paixu', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1076. array('title' => '订单编号', 'field' => 'order_num_alias', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1077. array('title' => '会员昵称', 'field' => 'name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1078. array('title' => '会员手机号', 'field' => 'telephone', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1079. array('title' => '会员备注', 'field' => 'member_content', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1080. array('title' => '收货姓名(或自提人)', 'field' => 'shipping_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1081. array('title' => '联系电话', 'field' => 'shipping_tel', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1082. array('title' => '收货地址', 'field' => 'address_province_city_area', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1083. array('title' => '供应商名称/类型', 'field' => 'supply_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1084. array('title' => '提货详细地址', 'field' => 'address_address', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1085. array('title' => '商品名称', 'field' => 'goods_title', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1086. array('title' => '商品分类', 'field' => 'goods_category', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1087. array('title' => '商品价格', 'field' => 'goods_rprice2', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1088. array('title' => '商品数量', 'field' => 'quantity', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1089. array('title' => '支付方式', 'field' => 'paytype', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1090. array('title' => '配送方式', 'field' => 'delivery', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1091. array('title' => '预计送达时间', 'field' => 'expected_delivery_time', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1092. array('title' => '团长配送送货详细地址', 'field' => 'tuan_send_address', 'width' => 22, 'sort' => 0, 'is_check' => 1),
  1093. array('title' => '商品规格', 'field' => 'goods_optiontitle', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1094. array('title' => '商品单价', 'field' => 'goods_price1', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1095. array('title' => '收货时间', 'field' => 'receive_time', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1096. array('title' => '快递单号', 'field' => 'expresssn', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1097. array('title' => '下单时间', 'field' => 'createtime', 'width' => 24, 'sort' => 0, 'is_check' => 1),
  1098. array('title' => '小区名称', 'field' => 'community_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1099. array('title' => '团长姓名', 'field' => 'head_name', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1100. array('title' => '团长电话', 'field' => 'head_mobile', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1101. array('title' => '退款商品数量', 'field' => 'has_refund_quantity', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1102. array('title' => '退款金额', 'field' => 'has_refund_money', 'width' => 12, 'sort' => 0, 'is_check' => 1),
  1103. array('title' => '微信支付交易单号', 'field' => 'transaction_id', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1104. array('title' => '商品编码', 'field' => 'goods_goodssn', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1105. array('title' => 'openid', 'field' => 'openid', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1106. array('title' => '运费', 'field' => 'dispatchprice', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1107. array('title' => '积分抵扣', 'field' => 'score_for_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1108. array('title' => '满额立减', 'field' => 'fullreduction_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1109. array('title' => '优惠券优惠', 'field' => 'voucher_credit', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1110. array('title' => '应收款(该笔订单总款)', 'field' => 'price', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1111. array('title' => '状态', 'field' => 'status', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1112. array('title' => '团长佣金', 'field' => 'head_money', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1113. array('title' => '会员佣金', 'field' => 'member_commissmoney', 'width' => 12, 'sort' => 0, 'is_check' => 0),
  1114. array('title' => '付款时间', 'field' => 'paytime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1115. array('title' => '发货时间', 'field' => 'sendtime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1116. array('title' => '完成时间', 'field' => 'finishtime', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1117. array('title' => '快递公司', 'field' => 'expresscom', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1118. array('title' => '完整地址', 'field' => 'fullAddress', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1119. array('title' => '订单备注', 'field' => 'remark', 'width' => 36, 'sort' => 0, 'is_check' => 0),
  1120. array('title' => '卖家订单备注', 'field' => 'remarksaler', 'width' => 36, 'sort' => 0, 'is_check' => 0),
  1121. array('title' => '商品成本价', 'field' => 'costprice', 'width' => 36, 'sort' => 0, 'is_check' => 0),
  1122. array('title' => '省市区', 'field' => 'province', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1123. array('title' => '商品重量', 'field' => 'goods_weight', 'width' => 24, 'sort' => 0, 'is_check' => 0),
  1124. );
  1125. if($order_note_open == 1){
  1126. if(empty($note_content)){
  1127. $note_content= '店名';
  1128. }
  1129. $columns[] = array('title' => $note_content, 'field' => 'note_content', 'width' => 24, 'sort' => 0, 'is_check' => 0);
  1130. }
  1131. //load_model_class('config')->update( array('modify_export_fields' => $modify_explode_arr ) );
  1132. sellerLog('订单excel导出操作', 2);
  1133. $modify_explode_json = D('Home/Front')->get_config_by_name('modify_export_fields');
  1134. if( !empty($modify_explode_json) )
  1135. {
  1136. $modify_explode_arr = json_decode($modify_explode_json, true);
  1137. foreach( $columns as $key => $val )
  1138. {
  1139. if( in_array($val['field'], array_keys($modify_explode_arr) ) )
  1140. {
  1141. $val['is_check'] =1;
  1142. $val['sort'] = $modify_explode_arr[$val['field']];
  1143. }else{
  1144. $val['is_check'] =0;
  1145. $val['sort'] = 0;
  1146. }
  1147. $columns[$key] = $val;
  1148. }
  1149. $last_index_sort = array_column($columns,'sort');
  1150. array_multisort($last_index_sort,SORT_DESC,$columns);
  1151. }
  1152. $this->post_data = $post_data;
  1153. $this->columns = $columns;
  1154. $this->_GPC = $_GPC;
  1155. $this->display();
  1156. }
  1157. public function oppay()
  1158. {
  1159. if (defined('ROLE') && ROLE == 'agenter' )
  1160. {
  1161. show_json(0, array('message' => '您无此权限') );
  1162. }
  1163. $order_id = I('request.id');
  1164. $res_arr = D('Seller/Order')->admin_pay_order($order_id);
  1165. if( $res_arr['code'] == 0)
  1166. {
  1167. show_json(0, array('message' => $res_arr['msg']) );
  1168. }else{
  1169. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1170. }
  1171. }
  1172. public function detail()
  1173. {
  1174. $id = I('get.id');
  1175. $item = M('lionfish_comshop_order')->where( array('order_id' => $id ) )->find();
  1176. if (defined('ROLE') && ROLE == 'agenter' )
  1177. {
  1178. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1179. if($supply_can_look_headinfo != 1){
  1180. $item['ziti_name'] = D('Seller/Order')->desensitize($item['ziti_name'],1,1);
  1181. $item['ziti_mobile'] = D('Seller/Order')->desensitize($item['ziti_mobile'],3,4);
  1182. }
  1183. }
  1184. switch ($item['delivery']){
  1185. case 'pickup':$item['delivery_text'] = '社区自提';break;
  1186. case 'express':$item['delivery_text'] = '快递';break;
  1187. case 'tuanz_send':$item['delivery_text'] = '团长配送';break;
  1188. case 'hexiao':$item['delivery_text'] = '到店核销';break;
  1189. }
  1190. //预收订单信息begin
  1191. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
  1192. if( $presale_result['code'] == 0 )
  1193. {
  1194. $item['presale_info'] = $presale_result['data'];
  1195. }else{
  1196. $item['presale_info'] = [];
  1197. }
  1198. //预收订单信息end
  1199. if($item['type'] == 'pintuan'){
  1200. $pin_order = M('lionfish_comshop_pin_order')->field('pin_id')->where( array('order_id' => $id ) )->find();
  1201. $pin_id = $pin_order['pin_id'];
  1202. $this->pin_id = $pin_id;
  1203. }
  1204. $order_goods = array();
  1205. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id) )->select();
  1206. $need_order_goods = array();
  1207. $shipping_fare = 0;
  1208. $fullreduction_money = 0;
  1209. $voucher_credit = 0;
  1210. $total = 0;
  1211. $order_head_status = 0 ;
  1212. foreach($order_goods as $key => $value)
  1213. {
  1214. // lionfish_community_head_commiss_order
  1215. $value['name'] = htmlspecialchars_decode(stripslashes($value['name']));
  1216. $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();
  1217. if( !empty($head_commission_order_info) )
  1218. {
  1219. foreach( $head_commission_order_info as &$vv)
  1220. {
  1221. if($vv['state'] == 1){
  1222. $order_head_status =1;
  1223. }
  1224. $head_info_tp = M('lionfish_community_head')->field('head_name')->where( array('id' => $vv['head_id'] ) )->find();
  1225. $vv['head_name'] = $head_info_tp['head_name'];
  1226. if (defined('ROLE') && ROLE == 'agenter' )
  1227. {
  1228. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1229. if($supply_can_look_headinfo != 1){
  1230. $vv['head_name'] = D('Seller/Order')->desensitize($vv['head_name'],1,1);
  1231. }
  1232. }
  1233. //退配送费
  1234. $refund_shipping_fare = 0;
  1235. if($vv['type'] == 'orderbuy' && $vv['add_shipping_fare'] > 0){
  1236. $refund_shipping_sql = "SELECT sum(refund_shipping_fare) as refund_shipping_fare "
  1237. . " FROM ".C('DB_PREFIX')."lionfish_comshop_order_goods_refund "
  1238. . " WHERE order_id=".$vv['order_id'].' and order_goods_id='.$vv['order_goods_id'];
  1239. $refund_shippings = M()->query($refund_shipping_sql);
  1240. if(!empty($refund_shippings)){
  1241. $refund_shipping_fare = $refund_shippings[0]['refund_shipping_fare'];
  1242. }
  1243. $vv['add_shipping_fare'] = $vv['add_shipping_fare'] - $refund_shipping_fare;
  1244. $vv['money'] = $vv['money'];
  1245. }else{
  1246. $vv['add_shipping_fare'] = $vv['add_shipping_fare'];
  1247. }
  1248. if($vv['state'] == 2){//分佣订单已取消,分佣金额为0
  1249. $vv['money'] = 0;
  1250. }
  1251. }
  1252. unset($vv);
  1253. }
  1254. if( $value['is_refund_state'] == 1 || $value['has_refund_money'] > 0)
  1255. {
  1256. $refund_info = M('lionfish_comshop_order_refund')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->order('ref_id desc')->find();
  1257. $value['refund_info'] = $refund_info;
  1258. $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');
  1259. $value['goods_refund_shipping_fare'] = $goods_refund_shipping_fare;
  1260. }
  1261. if( $item['is_commission'] == 1 )
  1262. {
  1263. $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();
  1264. if( !empty($member_commission_list) )
  1265. {
  1266. foreach( $member_commission_list as $kk => $vv )
  1267. {
  1268. $tmp_if = M('lionfish_comshop_member')->field('username')->where( array('member_id' => $vv['member_id'] ) )->find();
  1269. $vv['username'] = $tmp_if['username'];
  1270. $member_commission_list[$kk] = $vv;
  1271. }
  1272. }
  1273. $value['member_commission_list'] = $member_commission_list;
  1274. }
  1275. $value['head_commission_order_info'] = $head_commission_order_info;
  1276. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($item['order_id'], $value['order_goods_id']);
  1277. //退款商品价格
  1278. $has_refund_money = M('lionfish_comshop_order_goods')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->find();
  1279. $value['has_refund_money'] = $has_refund_money['has_refund_money'];
  1280. if (defined('ROLE') && ROLE == 'agenter' )
  1281. {
  1282. $supper_info = get_agent_logininfo();
  1283. if($supper_info['id'] != $value['supply_id'])
  1284. {
  1285. continue;
  1286. }
  1287. }
  1288. if( $value['supply_id'] > 0 )
  1289. {
  1290. $supply_info = D('Home/Front')->get_supply_info($value['supply_id']);
  1291. $value['supply_name'] = $supply_info['shopname'];
  1292. $value['supply_type'] = $supply_info['type'] == 1 ? '独立' :'自营';
  1293. }else{
  1294. $value['supply_name'] = '平台自营';
  1295. $value['supply_type'] = '自营';
  1296. }
  1297. $shipping_fare += $value['shipping_fare'];
  1298. $fullreduction_money += $value['fullreduction_money'];
  1299. $voucher_credit += $value['voucher_credit'];
  1300. $total += $value['total'];
  1301. if($item['delivery'] == 'hexiao'){
  1302. $value['hx_info'] = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->find();
  1303. if(!empty($value['hx_info'])){
  1304. if($value['hx_info']['is_hexiao_over'] == 1 || $value['hx_info']['is_hexiao_over'] == 2){
  1305. $value['hx_info']['is_can_refund'] = 0;
  1306. }else if($value['hx_info']['is_hexiao_over'] == 0){
  1307. $can_refund_quantity = floor($value['hx_info']['remain_hexiao_count']/$value['hx_info']['one_hexiao_count']);
  1308. if($can_refund_quantity >= 1){
  1309. $value['hx_info']['is_can_refund'] = 1;
  1310. }else{
  1311. $value['hx_info']['is_can_refund'] = 0;
  1312. }
  1313. }
  1314. $record_count = M('lionfish_comshop_order_goods_saleshexiao_record')->where(array('order_id' => $id,'order_goods_id' => $value['order_goods_id'] ) )->count();
  1315. $value['hx_info']['record_count'] = $record_count;
  1316. }
  1317. }
  1318. $need_order_goods[$key] = $value;
  1319. }
  1320. if (defined('ROLE') && ROLE == 'agenter' )
  1321. {
  1322. $item['shipping_fare'] = $shipping_fare;
  1323. $item['fullreduction_money'] = $fullreduction_money;
  1324. $item['voucher_credit'] = $voucher_credit;
  1325. $item['total'] = $total;
  1326. }
  1327. $order_goods = $need_order_goods;
  1328. if (empty($item)) {
  1329. $this->message('抱歉,订单不存在!', $_SERVER['HTTP_REFERER'], 'error');
  1330. }
  1331. $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id'] ) )->find();
  1332. $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
  1333. $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
  1334. $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
  1335. $express_info = array();
  1336. if( !empty($item['shipping_method']) )
  1337. {
  1338. $express_info = D('Seller/Express')->get_express_info($item['shipping_method']);
  1339. }
  1340. $this->express_info = $express_info;
  1341. $coupon = array();
  1342. //voucher_id voucher_credit
  1343. //ims_
  1344. if( $item['voucher_id'] > 0 )
  1345. {
  1346. $coupon = array();
  1347. //$coupon = pdo_fetch("select * from ".tablename('lionfish_comshop_coupon_list')." where uniacid=:uniacid and id=:id ",
  1348. //array(':uniacid' => $_W['uniacid'], ':id' => $item['voucher_id']));
  1349. }
  1350. if( $item['delivery'] == 'localtown_delivery' && ($item['order_status_id'] != 3 && $item['order_status_id'] != 5 ) )
  1351. {
  1352. $item['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $item['order_id'] ) )->find();
  1353. if( !empty($item['orderdistribution_order']) && $item['orderdistribution_order'] > 0 )
  1354. {
  1355. if($item['orderdistribution_order']['orderdistribution_id'] > 0){
  1356. $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $item['orderdistribution_order']['orderdistribution_id'] ) )->find();
  1357. $item['orderdistribution_order']['username'] = $orderdistribution['username'];
  1358. }else{
  1359. /*if($item['orderdistribution_order']['orderdistribution_id'] == -1){
  1360. $item['orderdistribution_order']['username'] = "系统默认配送员";
  1361. }else{*/
  1362. if($item['orderdistribution_order']['third_distribution_type'] == 'imdada'){
  1363. $item['orderdistribution_order']['username'] = "达达平台配送";
  1364. }else if($item['orderdistribution_order']['third_distribution_type'] == 'sf'){
  1365. $item['orderdistribution_order']['username'] = "顺丰同城配送";
  1366. }else if($item['orderdistribution_order']['third_distribution_type'] == 'uupt'){
  1367. $item['orderdistribution_order']['username'] = "UU跑腿配送";
  1368. }else if($item['orderdistribution_order']['third_distribution_type'] == 'dianwoda'){
  1369. $item['orderdistribution_order']['username'] = "点我达配送";
  1370. }
  1371. //}
  1372. }
  1373. }
  1374. }
  1375. if (defined('ROLE') && ROLE == 'agenter' )
  1376. {
  1377. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1378. if($supply_can_look_headinfo != 1){
  1379. if( $item['delivery'] == 'pickup' ){
  1380. $shipping_stree = D('Home/Front')->get_area_info($item['shipping_stree_id']);
  1381. $tuan_address = $province_info['name'].$city_info['name'].$area_info['name'];
  1382. $tuan_address2= str_replace($tuan_address, '',$item['shipping_address']);
  1383. $str = $tuan_address2;
  1384. strlen($str);
  1385. $i = mb_strlen($str,"UTF-8");
  1386. $tuan_address2 = D('Seller/Order')->desensitize($tuan_address2,1,$i-2);
  1387. $item['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$tuan_address2;
  1388. }
  1389. }
  1390. }
  1391. //售后期
  1392. $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
  1393. //天数
  1394. $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
  1395. $order_settlement =" ";
  1396. //订单状态
  1397. if($item['order_status_id'] ==5 || $item['order_status_id'] ==7 ){
  1398. //已失效
  1399. $order_status = 2;
  1400. }else{
  1401. //待结算
  1402. $order_status = $order_head_status;
  1403. if(($item['order_status_id'] ==6 || $item['order_status_id'] ==11) ){
  1404. if($item['order_status_id'] ==6){
  1405. $order_settlement = $item['receive_time'] + $open_aftersale_time*86400;
  1406. }
  1407. if($item['order_status_id'] ==11){
  1408. $order_settlement = $item['finishtime'] + $open_aftersale_time*86400;
  1409. }
  1410. }
  1411. }
  1412. $this->open_aftersale = $open_aftersale;
  1413. $this->order_status = $order_status;
  1414. $this->open_aftersale_time = $open_aftersale_time;
  1415. $this->order_settlement = $order_settlement;
  1416. $this->id = $id;
  1417. $this->item = $item;
  1418. $this->order_goods = $order_goods;
  1419. $this->member = $member;
  1420. $this->province_info = $province_info;
  1421. $this->city_info = $city_info;
  1422. $this->area_info = $area_info;
  1423. $history_list = M('lionfish_comshop_order_history')->where( array('order_id' => $id ) )->order('order_history_id asc')->select();
  1424. $order_status_arr = D('Seller/Order')->get_order_status_name();
  1425. //$order_history['order_status_id'] = 18;
  1426. $order_status_arr[18] = '已结算';
  1427. $order_status_arr[19] = '商品部分退款';
  1428. $order_status_arr[20] = '拒绝商品部分退款';
  1429. $order_status_arr[15] = '预售支付定金';
  1430. foreach( $history_list as &$val )
  1431. {
  1432. if( $val[''] == '订单改价' )
  1433. {
  1434. $val['order_status_name'] = 'comment';
  1435. }
  1436. else{
  1437. $val['order_status_name'] = $order_status_arr[$val['order_status_id']];
  1438. }
  1439. }
  1440. unset($val);
  1441. $this->history_list = $history_list;
  1442. $this->order_status_arr = $order_status_arr;
  1443. $is_can_look_headinfo = true;
  1444. $is_can_nowrfund_order = true;
  1445. $is_can_confirm_delivery = true;
  1446. $is_can_confirm_receipt = true;
  1447. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1448. $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
  1449. $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
  1450. $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
  1451. if (defined('ROLE') && ROLE == 'agenter' )
  1452. {
  1453. if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
  1454. {
  1455. $is_can_look_headinfo = false;
  1456. }
  1457. if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
  1458. {
  1459. $is_can_nowrfund_order = false;
  1460. }
  1461. if( isset($supply_can_confirm_delivery) && $supply_can_confirm_delivery == 2 )
  1462. {
  1463. $is_can_confirm_delivery = false;
  1464. }
  1465. if( isset($supply_can_confirm_receipt) && $supply_can_confirm_receipt == 2 )
  1466. {
  1467. $is_can_confirm_receipt = false;
  1468. }
  1469. }
  1470. $s_id = 1 ;
  1471. if(SELLERUID != 1)
  1472. {
  1473. $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
  1474. $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  1475. $perms1 = str_replace('.','/',$perms_arr['perms2']);
  1476. $perms2 = explode(",", $perms1);
  1477. if(in_array("user/user/index", $perms2)){
  1478. $s_id = 1 ;
  1479. } else {
  1480. $s_id = 0 ;
  1481. }
  1482. }
  1483. $this->s_id = $s_id;
  1484. //预售判断 begin
  1485. $is_presale = 0;
  1486. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $id );
  1487. $presale_for_ordermoney = 0;
  1488. if( $presale_result['code'] == 0 )
  1489. {
  1490. if( $presale_result['data']['presale_deduction_money'] > 0 )
  1491. {
  1492. $presale_for_ordermoney = $presale_result['data']['presale_for_ordermoney'];
  1493. }
  1494. $is_presale = 1;
  1495. }
  1496. $this->is_presale = $is_presale;
  1497. $this->presale_for_ordermoney = $presale_for_ordermoney;
  1498. //预售end
  1499. //礼品卡begin
  1500. $is_virtualcard = 0;
  1501. $virtualcard_result = D('Seller/VirtualCard')->getVirtualCardOrderInfO( $id );
  1502. if( $virtualcard_result['code'] == 0 )
  1503. {
  1504. $is_virtualcard = 1;
  1505. $this->virtualcard_info = $virtualcard_result['data'];
  1506. }
  1507. $this->is_virtualcard = $is_virtualcard;
  1508. //礼品卡end
  1509. //订单表单信息
  1510. $order_form_data = D('Home/Allform')->getOrderFormInfo($id, $item['member_id']);
  1511. $this->order_form_data = $order_form_data;
  1512. $is_order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  1513. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  1514. $order_note_name = isset($order_note_name) && !empty($order_note_name) ? $order_note_name :'店名';
  1515. $open_admin_payment = D('Home/Front')->get_config_by_name('open_admin_payment');
  1516. $this->open_admin_payment = $open_admin_payment;
  1517. $localtown_modifypickingname = D('Home/Front')->get_config_by_name('localtown_modifypickingname');
  1518. $localtown_modifypickingname = !empty($localtown_modifypickingname) ? $localtown_modifypickingname: '包装费';
  1519. $this->is_order_note_open = $is_order_note_open;
  1520. $this->order_note_name = $order_note_name;
  1521. $this->is_can_look_headinfo = $is_can_look_headinfo;
  1522. $this->is_can_nowrfund_order = $is_can_nowrfund_order;
  1523. $this->is_can_confirm_delivery = $is_can_confirm_delivery;
  1524. $this->is_can_confirm_receipt = $is_can_confirm_receipt;
  1525. $this->localtown_modifypickingname = $localtown_modifypickingname;
  1526. $this->display();
  1527. }
  1528. //查看物流
  1529. public function express(){
  1530. $_GPC = I('request.');
  1531. $order_id = $_GPC['order_id'];
  1532. $express_list = D('Seller/Order')->goods_express($order_id);
  1533. if($express_list['code'] == 2){
  1534. $code = $express_list['code'];
  1535. $reason = $express_list['Reason'];
  1536. $this->code = $code;
  1537. $this->reason = $reason;
  1538. }
  1539. $new_array = json_decode(json_encode($express_list['order_info']['shipping_traces']), true);
  1540. $new_array = array_reverse($new_array);
  1541. $this->list = $new_array;
  1542. $this->display();
  1543. }
  1544. public function refund_mult()
  1545. {
  1546. $_GPC = I('request.');
  1547. $ids_arr = $_GPC['ids_arr'];
  1548. $cache_key = md5(time().count($ids_arr).'_sendmulutrefund');
  1549. $quene_order_list = array();
  1550. //限定配送数组
  1551. S('_multrefund_'.$cache_key, $ids_arr);
  1552. $this->_GPC = $_GPC;
  1553. $this->cache_key = $cache_key;
  1554. $this->display();
  1555. }
  1556. public function refund_mult_do()
  1557. {
  1558. $_GPC = I('request.');
  1559. $cache_key = $_GPC['cache_key'];
  1560. $quene_order_list = S('_multrefund_'.$cache_key);
  1561. $order_id = array_shift($quene_order_list);
  1562. S('_multrefund_'.$cache_key, $quene_order_list);
  1563. //...
  1564. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  1565. $weixin_model = D('Home/Weixin');
  1566. $title = '订单编号:'.$order_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理";
  1567. //order_status_id
  1568. if( in_array($order_info['order_status_id'], array(1,4,6,10,11,12,14)) ){
  1569. $res = $weixin_model->refundOrder($order_id);
  1570. if( $res['code'] == 0 )
  1571. {
  1572. $title = '订单编号:'.$order_info['order_num_alias']." 退款失败,还剩余".count($quene_order_list)."个清单未处理";
  1573. }else{
  1574. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  1575. $comment = '群接龙批量退款,全额退款';
  1576. $order_history = array();
  1577. $order_history['order_id'] = $order_id;
  1578. $order_history['order_status_id'] = 7;
  1579. $order_history['notify'] = 0;
  1580. $order_history['comment'] = $comment;
  1581. $order_history['date_added'] = time();
  1582. M('lionfish_comshop_order_history')->add( $order_history );
  1583. M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('order_status_id' => 7) );
  1584. $refund_all = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id, 'state' => 0 ) )->select();
  1585. if( !empty($refund_all) )
  1586. {
  1587. foreach( $refund_all as $val )
  1588. {
  1589. $ins_data = array();
  1590. $ins_data['ref_id'] = $val['ref_id'];
  1591. $ins_data['order_id'] = $val['order_id'];
  1592. $ins_data['order_goods_id'] = $val['order_goods_id'];
  1593. $ins_data['message'] = '群接龙批量退款 ,退款成功';
  1594. $ins_data['type'] = 2;
  1595. $ins_data['addtime'] = time();
  1596. M('lionfish_comshop_order_refund_history')->add( $ins_data );
  1597. M('lionfish_comshop_order_refund')->where( array('ref_id' => $val['ref_id']) )->save( array('state' => 3) );
  1598. }
  1599. }
  1600. $is_print_admin_cancleorder = D('Home/Front')->get_config_by_name('is_print_admin_cancleorder');
  1601. if( isset($is_print_admin_cancleorder) && $is_print_admin_cancleorder == 1 )
  1602. {
  1603. sellerLog('群接龙后台取消订单', 2);
  1604. D('Seller/Printaction')->check_print_order($id,'群接龙后台取消订单');
  1605. D('Seller/Printaction')->check_print_order2($id,'群接龙后台取消订单');
  1606. }
  1607. }
  1608. }
  1609. if( empty($quene_order_list) )
  1610. {
  1611. echo json_encode( array('code' => 2) );
  1612. die();
  1613. }
  1614. //清单编号
  1615. echo json_encode( array('code' => 0, 'msg' => $title ) );
  1616. die();
  1617. }
  1618. public function opreceive()
  1619. {
  1620. $opdata = $this->check_order_data();
  1621. extract($opdata);
  1622. //检查订单是否能确认收货(存在售后未完成无法确认收货)
  1623. $result = D('Seller/Order')->check_order_receive($item['order_id']);
  1624. if($result['status'] == 0){
  1625. show_json(0, array('msg'=>"该订单处于售后处理中,请处理后再确认收货!"));
  1626. }
  1627. if($item['delivery'] == 'localtown_delivery') {
  1628. $result = D('Seller/Order')->check_localtown_order_receive($item['order_id']);
  1629. if ($result['status'] == 0) {
  1630. show_json(0, array('msg' => "该订单未有配送员接单或还未指定配送员,无法确认收货!"));
  1631. }
  1632. }
  1633. //pdo_update('lionfish_comshop_order', array('order_status_id' => 6, 'receive_time' => time()), array('order_id' => $item['order_id'], 'uniacid' => $_W['uniacid']));
  1634. if( $item['delivery'] == 'localtown_delivery' )
  1635. {
  1636. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $item['order_id']) )->save( array('state' => 4) );
  1637. D('Home/LocaltownDelivery')->write_distribution_log( $item['order_id'], 0 , 4 , "后台操作,确认收货" );
  1638. }
  1639. D('Seller/Order')->receive_order($item['order_id']);
  1640. M('lionfish_comshop_order_history')->where( array('order_id' => $item['order_id'],'order_status_id' => 6) )->save( array( 'comment' => '后台操作,确认收货') );
  1641. if( $item['delivery'] == 'localtown_delivery' )
  1642. {
  1643. //D('Home/LocaltownDelivery')->distribution_deliverying_order( $item['order_id'] );
  1644. D('Home/LocaltownDelivery')->distribution_arrived_order( $item['order_id'] ,0 );
  1645. }
  1646. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1647. }
  1648. public function orderaftersales()
  1649. {
  1650. //$_GPC['order_status_id'] = 12;
  1651. $gpc = I('request.');
  1652. $this->gpc = $gpc;
  1653. $this->_GPC = $gpc;
  1654. $time = I('request.time');
  1655. $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  1656. $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  1657. $this->searchfield = I('request.searchfield','');
  1658. $this->keyword = I('request.keyword','');
  1659. $this->searchtime = I('request.searchtime','');
  1660. $this->delivery = I('request.delivery','');
  1661. $this->starttime = $starttime;
  1662. $this->endtime = $endtime;
  1663. $this->time = $time;
  1664. $order_status_arr = D('Seller/Order')->get_order_status_name();
  1665. $this->order_status_arr = $order_status_arr;
  1666. $need_data = D('Seller/Order')->load_afterorder_list();//改造原来的加载方法
  1667. $this->need_data = $need_data;
  1668. $cur_controller = 'order/order';
  1669. $total = $need_data['total'];
  1670. $total_money = $need_data['total_money'];
  1671. $list = $need_data['list'];
  1672. $pager = $need_data['pager'];
  1673. $all_count = $need_data['all_count'];
  1674. $count_status_1 = $need_data['count_status_1'];
  1675. $count_status_3 = $need_data['count_status_3'];
  1676. $count_status_4 = $need_data['count_status_4'];
  1677. $count_status_5 = $need_data['count_status_5'];
  1678. $count_status_7 = $need_data['count_status_7'];
  1679. $count_status_11 = $need_data['count_status_11'];
  1680. $count_status_14 = $need_data['count_status_14'];
  1681. $this->cur_controller = $cur_controller;
  1682. $this->total = $total;
  1683. $this->total_money = $total_money;
  1684. $this->list = $list;
  1685. $this->pager = $pager;
  1686. $this->all_count = $all_count;
  1687. $this->count_status_1 = $count_status_1;
  1688. $this->count_status_3 = $count_status_3;
  1689. $this->count_status_4 = $count_status_4;
  1690. $this->count_status_5 = $count_status_5;
  1691. $this->count_status_7 = $count_status_7;
  1692. $this->count_status_11 = $count_status_11;
  1693. $this->count_status_14 = $count_status_14;
  1694. $s_id = 1 ;
  1695. if(SELLERUID != 1)
  1696. {
  1697. $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
  1698. $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  1699. $perms1 = str_replace('.','/',$perms_arr['perms2']);
  1700. $perms2 = explode(",", $perms1);
  1701. if(in_array("user/user/index", $perms2)){
  1702. $s_id = 1 ;
  1703. } else {
  1704. $s_id = 0 ;
  1705. }
  1706. }
  1707. $this->s_id = $s_id;
  1708. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  1709. if( empty($open_feier_print) )
  1710. {
  1711. $open_feier_print = 0;
  1712. }
  1713. $this->open_feier_print = $open_feier_print;
  1714. //退款状态:0申请中,1商家拒绝,2平台介入,3退款成功,4退款失败,5:撤销申请
  1715. $order_refund_state = array(0=>'申请中',1=>'商家拒绝', 2=>'平台介入',3=>'退款成功',4=>'退款失败',5=>'撤销申请');
  1716. $this->order_refund_state = $order_refund_state;
  1717. $is_can_look_headinfo = true;
  1718. $is_can_nowrfund_order = true;
  1719. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1720. $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
  1721. if (defined('ROLE') && ROLE == 'agenter' )
  1722. {
  1723. if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
  1724. {
  1725. $is_can_look_headinfo = false;
  1726. }
  1727. if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
  1728. {
  1729. $is_can_nowrfund_order = false;
  1730. }
  1731. }
  1732. $this->is_can_look_headinfo = $is_can_look_headinfo;
  1733. $this->is_can_nowrfund_order = $is_can_nowrfund_order;
  1734. $this->display();
  1735. }
  1736. public function oprefund_doform()
  1737. {
  1738. $_GPC = I('request.');
  1739. $ref_id = $_GPC['ref_id'];
  1740. $refund_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  1741. $this->ref_id = $ref_id;
  1742. $this->refund_info = $refund_info;
  1743. if (IS_POST) {
  1744. $order_history = array();
  1745. $order_history['order_id'] = $refund_info['order_id'];
  1746. $order_history['order_status_id'] = 0;
  1747. $order_history['notify'] = 0;
  1748. $order_history['comment'] = '';
  1749. $order_history['date_added'] = time();
  1750. $remarkrefund = $_GPC['remarkrefund'];
  1751. $is_forbidden = $_GPC['is_forbidden'];
  1752. $cansub = $_GPC['cansub'];
  1753. if( isset($_GPC['is_forbidden']) && $_GPC['is_forbidden'] > 0 )
  1754. {
  1755. //添加
  1756. $refund_disable = M('lionfish_comshop_order_refund_disable')->where( array('ref_id' => $ref_id ) )->find();
  1757. if( empty($refund_disable) )
  1758. {
  1759. //插入
  1760. $ins_data = array();
  1761. $ins_data['ref_id'] = $ref_id;
  1762. $ins_data['order_id'] = $refund_info['order_id'];
  1763. $ins_data['order_goods_id'] = $refund_info['order_goods_id'];
  1764. $ins_data['addtime'] = time();
  1765. M('lionfish_comshop_order_refund_disable')->add($ins_data);
  1766. }
  1767. }else{
  1768. //删除
  1769. M('lionfish_comshop_order_refund_disable')->where( array('ref_id' => $ref_id ) )->delete();
  1770. }
  1771. if($cansub == 1)
  1772. {
  1773. //确认退款 remarkrefund
  1774. $weixin_model = D('Home/Weixin');
  1775. $order_refund = M('lionfish_comshop_order_refund')->field('ref_money,real_refund_quantity,ref_shipping_fare')->where( array('ref_id' => $ref_id ) )->find();
  1776. //$order_info['total']
  1777. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->find();
  1778. if( $order_info['type'] == 'integral' || $order_info['type'] == 'normal' )
  1779. {
  1780. //M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('shipping_fare' => $order_refund['ref_shipping_fare'] ) );
  1781. if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
  1782. {
  1783. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->find();
  1784. M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->save( array('shipping_fare' => $order_refund['ref_shipping_fare'] ) );
  1785. }
  1786. }
  1787. if( $order_refund['real_refund_quantity'] > 0 )
  1788. {
  1789. //部分商品退款
  1790. $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);
  1791. }else{
  1792. $res = $weixin_model->refundOrder($refund_info['order_id'], $order_refund['ref_money'],0,$refund_info['order_goods_id']);
  1793. }
  1794. if( $order_info['type'] == 'integral' || $order_info['type'] == 'normal')
  1795. {
  1796. //M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('shipping_fare' => $order_info['shipping_fare'] ) );
  1797. if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
  1798. {
  1799. M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$refund_info['order_goods_id'] ) )->save( array('shipping_fare' => $order_goods['shipping_fare'] ) );
  1800. }
  1801. }
  1802. if($res['code'] == 1)
  1803. {
  1804. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] , 'order_id' => $refund_info['order_id'] ) )->find();
  1805. if( $order_refund['real_refund_quantity'] <= 0 )
  1806. {
  1807. $order_refund['real_refund_quantity'] = $order_goods['quantity'] - $order_goods['has_refund_quantity'];
  1808. }
  1809. $pay_total_money = $order_goods['total']-$order_goods['voucher_credit']-$order_goods['fullreduction_money'] - $order_goods['score_for_money'];
  1810. $buy_usescore = D('Seller/Commonorder')->get_order_goods_buyscore($refund_info['order_id'], $refund_info['order_goods_id']);
  1811. if( !empty($buy_usescore) && $buy_usescore > 0 )
  1812. {
  1813. $res_score= ceil( $buy_usescore * ( $order_refund['real_refund_quantity']/ $order_goods['quantity']) );
  1814. D('Seller/Commonorder')->refund_order_goods_intrgral( $refund_info['order_id'], $refund_info['order_goods_id'] ,$res_score );
  1815. }
  1816. if($order_refund['ref_money']-$order_refund['ref_shipping_fare'] <= 0){
  1817. $refund_money = 0;
  1818. }else{
  1819. $refund_money = $order_refund['ref_money']-$order_refund['ref_shipping_fare'];
  1820. }
  1821. if( $order_info['type'] == 'integral'){
  1822. $refund_money = $order_refund['ref_money'];
  1823. }
  1824. //退款配送费问题
  1825. 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']);
  1826. //如果这个商品没有数量了。就改变他的状态为已退款的状态
  1827. $new_total_quantity = D('Seller/Commonorder')->get_order_goods_quantity($refund_info['order_id'],$refund_info['order_goods_id'] );
  1828. $ref_count = M('lionfish_comshop_order_refund')->where( array('order_id' => $refund_info['order_id'], 'state' => 0 ) )->count();
  1829. if( $new_total_quantity <=0 && $ref_count <= 1)
  1830. {
  1831. 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,'平台同意退款,');
  1832. }else{
  1833. $order_history = array();
  1834. $order_history['uniacid'] = 0;
  1835. $order_history['order_id'] = $refund_info['order_id'];
  1836. $order_history['order_goods_id'] = $refund_info['order_goods_id'];
  1837. $order_history['notify'] = 0;
  1838. $order_history['order_status_id'] = 19;
  1839. if( $order_info['type'] == 'integral' )
  1840. {
  1841. $order_history['comment'] = '平台同意退款,子订单退款,退款商品:'.$order_refund['real_refund_quantity'] .'个,退库存/销量数量'.$order_refund['real_refund_quantity'].'个,退款积分'.$order_refund['ref_money'].'积分';
  1842. if( !empty($order_refund['ref_shipping_fare']) ){
  1843. $order_history['comment'] .= '. 退配送费:'.$order_refund['ref_shipping_fare'].'元';
  1844. }
  1845. }else{
  1846. $order_history['comment'] = '平台同意退款,子订单退款,退款商品:'.$order_refund['real_refund_quantity'] .'个,退库存/销量数量'.$order_refund['real_refund_quantity'].'个,退款金额'.$order_refund['ref_money'].'元';
  1847. }
  1848. $order_history['date_added'] = time();
  1849. M('lionfish_comshop_order_history')->add( $order_history );
  1850. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] ) )->save( array('is_refund_state' => 0 ) );
  1851. }
  1852. //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);
  1853. $order_refund_history = array();
  1854. $order_refund_history['ref_id'] = $ref_id;
  1855. $order_refund_history['order_id'] = $refund_info['order_id'];
  1856. $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
  1857. $order_refund_history['message'] = '平台同意退款'.' '.$remarkrefund.' ,退款成功';
  1858. $order_refund_history['type'] = 2;
  1859. $order_refund_history['addtime'] = time();
  1860. M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
  1861. //通过 lionfish_comshop_order_refund
  1862. sellerLog('同意'.$remarkrefund.'退款成功操作', 2);
  1863. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 3,'modify_time' => time(),'remarkrefund' => $remarkrefund) );
  1864. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1865. }else{
  1866. if( empty($res['msg']) )
  1867. {
  1868. $res['msg'] = '请检查商户号与cert证书';
  1869. }
  1870. $order_refund_history = array();
  1871. $order_refund_history['ref_id'] = $ref_id;
  1872. $order_refund_history['order_id'] = $refund_info['order_id'];
  1873. $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
  1874. $order_refund_history['message'] = '平台同意退款'.' '.$remarkrefund.' ,但是退款失败:'.$res['msg'];
  1875. $order_refund_history['type'] = 2;
  1876. $order_refund_history['addtime'] = time();
  1877. M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
  1878. show_json(0, array('message' => $res['msg']) );
  1879. }
  1880. }else if($cansub == 2){
  1881. //拒绝退款
  1882. $order_refund_history = array();
  1883. $order_refund_history['ref_id'] = $ref_id;
  1884. $order_refund_history['order_id'] = $refund_info['order_id'];
  1885. $order_refund_history['order_goods_id'] = $refund_info['order_goods_id'];
  1886. $order_refund_history['message'] = '平台拒绝退款'.' '.$remarkrefund;
  1887. $order_refund_history['type'] = 2;
  1888. $order_refund_history['addtime'] = time();
  1889. M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
  1890. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 1,'modify_time' => time(),'remarkrefund' => $remarkrefund ) );
  1891. $item = M('lionfish_comshop_order')->field('order_status_id,last_refund_order_status_id')->where( array('order_id' => $refund_info['order_id'] ) )->find();
  1892. $order_history['order_status_id'] = 20;
  1893. //如果是部分退款,那么就不是12了
  1894. if( $item['order_status_id'] == 12)
  1895. {
  1896. $order_history['order_status_id'] = 12;
  1897. if( $item['last_refund_order_status_id'] > 0 )
  1898. {
  1899. $order_history['order_status_id'] = $item['last_refund_order_status_id'];
  1900. M('lionfish_comshop_order')->where( array('order_id' => $refund_info['order_id'] ) )->save( array('order_status_id' => $item['last_refund_order_status_id']) );
  1901. $order_history['order_status_id'] = $item['last_refund_order_status_id'];
  1902. $order_history['comment'] = '商家拒绝退款,订单回退上一状态';
  1903. }else{
  1904. $order_history['comment'] = '商家拒绝退款';
  1905. }
  1906. }
  1907. if( !empty($refund_info['order_goods_id']) && $refund_info['order_goods_id'] > 0 )
  1908. {
  1909. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $refund_info['order_goods_id'] ) )->save( array('is_refund_state' => 0) );
  1910. }
  1911. //拒绝 order_status_id
  1912. sellerLog($order_history['comment'].'操作', 2);
  1913. M('lionfish_comshop_order_history')->add( $order_history );
  1914. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1915. }
  1916. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1917. }
  1918. $this->display();
  1919. }
  1920. public function oprefund()
  1921. {
  1922. $_GPC = I('request.');
  1923. $opdata = $this->check_order_data();
  1924. extract($opdata);
  1925. $ref_id = $_GPC['ref_id'];
  1926. $ref_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  1927. $step_array = array();
  1928. $step_array[1]['step'] = 1;
  1929. $step_array[1]['title'] = '客户发起退款';
  1930. $step_array[1]['time'] = $ref_info['addtime'];
  1931. $step_array[1]['done'] = 1;
  1932. $step_array[2]['step'] = 2;
  1933. $step_array[2]['title'] = '平台处理维权申请';
  1934. $step_array[2]['done'] = 0;
  1935. $step_array[2]['time'] = '';
  1936. $step_array[3]['step'] = 3;
  1937. $step_array[3]['done'] = 0;
  1938. $step_array[3]['title'] = '商家处理退款完成';
  1939. $step_array[3]['time'] = '';
  1940. $ref_id = I('request.ref_id');
  1941. $this->ref_id = $ref_id;
  1942. $this->ref_info = $ref_info;
  1943. $order_goods_id = $ref_info['order_goods_id'];
  1944. if( !empty($order_goods_id) && $order_goods_id > 0 )
  1945. {
  1946. $goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id, 'order_id' => $id ) )->select();
  1947. }else{
  1948. $goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id ) )->select();
  1949. }
  1950. $total_fare = 0;
  1951. $total_shipping_fare = 0;
  1952. $total_voucher_credit =0;
  1953. $total_fullreduction_money = 0;
  1954. $total_total_fare = 0;
  1955. $total_score_for_money = 0;
  1956. /**
  1957. php echo number_format($item['total']+$item['shipping_fare']-$item['voucher_credit']-$item['fullreduction_money'],2)
  1958. **/
  1959. foreach($goods as &$value)
  1960. {
  1961. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($item['order_id'], $value['order_goods_id']);
  1962. $total_fare += $value['total'];
  1963. $total_shipping_fare += $value['shipping_fare'];
  1964. $total_voucher_credit += $value['voucher_credit'];
  1965. $total_fullreduction_money += $value['fullreduction_money'];
  1966. $total_score_for_money += $value['score_for_money'];
  1967. $total_total_fare += $value['total']+$value['shipping_fare']-$value['voucher_credit']-$value['fullreduction_money']-$value['score_for_money'];
  1968. }
  1969. $this->goods = $goods;
  1970. $this->total_fare = $total_fare;
  1971. $this->total_shipping_fare = $total_shipping_fare;
  1972. $this->total_voucher_credit = $total_voucher_credit;
  1973. $this->total_fullreduction_money = $total_fullreduction_money;
  1974. $this->total_score_for_money = $total_score_for_money;
  1975. $this->total_total_fare = $total_total_fare;
  1976. unset($r);
  1977. $item['goods'] = $goods;
  1978. $member = M('lionfish_comshop_member')->where( array('member_id' => $item['member_id']) )->find();
  1979. $this->member = $member;
  1980. $express_list = array();
  1981. $r_type = array(1=>'仅退款',2 => '退款退货');
  1982. //ims_
  1983. $this->r_type =$r_type;
  1984. $order_refund = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->find();
  1985. $this->order_refund = $order_refund;
  1986. if($order_refund['modify_time'] != 0 && $order_refund['state']== 3)
  1987. {
  1988. $step_array[3]['done'] = 1;
  1989. $step_array[3]['time'] = $order_refund['modify_time'];
  1990. }
  1991. $refund_imgs = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id'] ) )->select();
  1992. $this->refund_imgs = $refund_imgs;
  1993. /**
  1994. if( !empty($order_goods_id) && $order_goods_id > 0 )
  1995. {
  1996. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' =>$id,'order_goods_id' => $order_goods_id ) )->order('addtime asc')->select();
  1997. }
  1998. else{
  1999. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' =>$id ) )->order('addtime asc')->select();
  2000. }
  2001. **/
  2002. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('ref_id' => $ref_id ) )->order('addtime asc')->select();
  2003. $i = 1;
  2004. foreach($order_refund_history as $key => $val)
  2005. {
  2006. if( $i == 1 && $val['type'] == 2 )
  2007. {
  2008. $step_array[2]['done'] = 1;
  2009. $step_array[2]['time'] = time();
  2010. $i++;
  2011. }
  2012. $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
  2013. switch($val['type'])
  2014. {
  2015. case 1:
  2016. $val['type'] = '用户反馈';
  2017. break;
  2018. case 2:
  2019. $val['type'] = '商家反馈';
  2020. break;
  2021. case 3:
  2022. $val['type'] = '平台反馈';
  2023. break;
  2024. }
  2025. $order_refund_history_image = M('lionfish_comshop_order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
  2026. if(!empty($order_refund_history_image))
  2027. {
  2028. foreach($order_refund_history_image as $kk => $vv)
  2029. {
  2030. $vv['thumb_image'] = resize ($vv['image'], 200,200);
  2031. $order_refund_history_image[$kk] = $vv;
  2032. }
  2033. }
  2034. $val['order_refund_history_image'] = $order_refund_history_image;
  2035. $order_refund_history[$key] = $val;
  2036. }
  2037. $this->step_array = $step_array;
  2038. $this->order_refund_history = $order_refund_history;
  2039. $this->item = $item;
  2040. $this->display();
  2041. }
  2042. public function oprefund_submit()
  2043. {
  2044. $gpc = I('request.');
  2045. $opdata = $this->check_order_data();
  2046. extract($opdata);
  2047. if (IS_POST) {
  2048. $id = $gpc['id'];
  2049. //refundstatus message refundcontent
  2050. $refundstatus = $gpc['refundstatus'];
  2051. $message = $gpc['message'];
  2052. $refundcontent = $gpc['refundcontent'];
  2053. $ref_id = $gpc['refundid'];
  2054. /**
  2055. int(37)
  2056. string(1) "1"
  2057. string(0) ""
  2058. string(15) "天天来退货"
  2059. **/
  2060. //1 ,3
  2061. $comment = '';
  2062. switch( $refundstatus )
  2063. {
  2064. case 1:
  2065. $comment = $refundcontent;
  2066. break;
  2067. case 3:
  2068. $comment = $message;
  2069. break;
  2070. }
  2071. $ref_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  2072. $result = array('code' =>1);
  2073. $order_refund_history = array();
  2074. $order_refund_history['order_id'] = $ref_info['order_id'];
  2075. $order_refund_history['order_goods_id'] = $ref_info['order_goods_id'];
  2076. $order_refund_history['message'] = htmlspecialchars($comment);
  2077. $order_refund_history['type'] = 2;
  2078. $order_refund_history['addtime'] = time();
  2079. M('lionfish_comshop_order_refund_history')->add($order_refund_history);
  2080. $order_history = array();
  2081. $order_history['order_id'] = $id;
  2082. $order_history['order_status_id'] = 0;
  2083. $order_history['notify'] = 0;
  2084. $order_history['comment'] = '';
  2085. $order_history['date_added'] = time();
  2086. if($refundstatus ==1)
  2087. {
  2088. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 1) );
  2089. //id item $order_info $item
  2090. $item = M('lionfish_comshop_order')->field('order_status_id,last_refund_order_status_id')->where( array('order_id' => $id ) )->find();
  2091. //如果是部分退款,那么就不是12了
  2092. if( $item['order_status_id'] == 12)
  2093. {
  2094. $order_history['order_status_id'] = 12;
  2095. if( $item['last_refund_order_status_id'] > 0 )
  2096. {
  2097. $order_history['order_status_id'] = $item['last_refund_order_status_id'];
  2098. M('lionfish_comshop_order')->where( array('order_id' => $id) )->save( array('order_status_id' =>$item['last_refund_order_status_id'] ) );
  2099. $order_history['order_status_id'] = $item['last_refund_order_status_id'];
  2100. }
  2101. }
  2102. if( !empty($ref_info['order_goods_id']) && $ref_info['order_goods_id'] > 0 )
  2103. {
  2104. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $ref_info['order_goods_id'] ) )->save( array('is_refund_state' =>0 ) );
  2105. }
  2106. //拒绝 order_status_id
  2107. $order_history['comment'] = '商家拒绝退款,订单回退上一状态';
  2108. M('lionfish_comshop_order_history')->add( $order_history );
  2109. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2110. } else {
  2111. $weixin_model = D('Home/Weixin');
  2112. $order_refund = M('lionfish_comshop_order_refund')->field('ref_money')->where( array('ref_id' => $ref_id) )->find();
  2113. $res = $weixin_model->refundOrder($id, $order_refund['ref_money'],0,$ref_info['order_goods_id']);
  2114. //array('code' => 0, 'msg' => $res['err_code_des']);
  2115. if($res['code'] == 1)
  2116. {
  2117. $order_history['order_status_id'] = 7;
  2118. $order_history['comment'] = '商家同意退款';
  2119. M('lionfish_comshop_order_history')->add( $order_history );
  2120. //通过 lionfish_comshop_order_refund
  2121. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 3) );
  2122. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2123. }else{
  2124. if( empty($res['msg']) )
  2125. {
  2126. $res['msg'] = '请检查商户号与cert证书';
  2127. }
  2128. show_json(0, array('message' => $res['msg']) );
  2129. }
  2130. }
  2131. }
  2132. $r_type = array(1=>'仅退款',2 => '退款退货');
  2133. //ims_
  2134. $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $id) )->find();
  2135. $refund_imgs = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id']) )->find();
  2136. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $id) )->order('addtime asc')->select();
  2137. foreach($order_refund_history as $key => $val)
  2138. {
  2139. $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
  2140. switch($val['type'])
  2141. {
  2142. case 1:
  2143. $val['type'] = '用户反馈';
  2144. break;
  2145. case 2:
  2146. $val['type'] = '商家反馈';
  2147. break;
  2148. case 3:
  2149. $val['type'] = '平台反馈';
  2150. break;
  2151. }
  2152. $order_refund_history_image = M('lionfish_comshop_order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
  2153. if(!empty($order_refund_history_image))
  2154. {
  2155. foreach($order_refund_history_image as $kk => $vv)
  2156. {
  2157. $vv['thumb_image'] = resize ($vv['image'], 200,200);
  2158. $order_refund_history_image[$kk] = $vv;
  2159. }
  2160. }
  2161. $val['order_refund_history_image'] = $order_refund_history_image;
  2162. $order_refund_history[$key] = $val;
  2163. }
  2164. $this->order_refund = $order_refund;
  2165. $this->r_type = $r_type;
  2166. $this->item = $item;
  2167. $this->display();
  2168. }
  2169. public function ordercomment_gift()
  2170. {
  2171. if (IS_POST) {
  2172. $data = array();
  2173. $data = I('request.data');
  2174. $data['open_comment_gift'] = trim($data['open_comment_gift']);
  2175. $data['comment_gift_score'] = trim($data['comment_gift_score']);
  2176. $data['comment_gift_time'] = trim($data['comment_gift_time']);
  2177. $data['comment_gift_max_score'] = trim($data['comment_gift_max_score']);
  2178. $data['comment_gift_publish'] = trim($data['comment_gift_publish']);
  2179. D('Seller/Config')->update($data);
  2180. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2181. }
  2182. $data = D('Seller/Config')->get_all_config();
  2183. if(empty($data['comment_gift_publish'])){
  2184. $data['comment_gift_publish'] = "​参与好评有礼活动,好评成功并且后台审核通过以后可获得获得活动积分";
  2185. }
  2186. $this->data = $data;
  2187. $this->display();
  2188. }
  2189. public function ordercomment_config()
  2190. {
  2191. if (IS_POST) {
  2192. $data = array();
  2193. $data = I('request.data');
  2194. $data['open_comment_shenhe'] = trim($data['open_comment_shenhe']);
  2195. D('Seller/Config')->update($data);
  2196. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2197. }
  2198. $data = D('Seller/Config')->get_all_config();
  2199. $this->data = $data;
  2200. $this->display();
  2201. }
  2202. public function ordercomment()
  2203. {
  2204. $condition = ' 1 ';//0
  2205. $pindex = I('request.page', 1);
  2206. $psize = 20;
  2207. $keyword = I('request.keyword');
  2208. $this->keyword = $keyword;
  2209. if (!empty($keyword)) {
  2210. $condition .= ' and content like '.'"%' . $keyword . '%" ';
  2211. }
  2212. $label = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_order_comment
  2213. WHERE " . $condition . ' order by comment_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  2214. $total = M('lionfish_comshop_order_comment')->where($condition)->count();
  2215. $pager = pagination2($total, $pindex, $psize);
  2216. $this->pager = $pager;
  2217. $this->total = $total;
  2218. $this->label = $label;
  2219. $this->display();
  2220. }
  2221. public function deletecomment()
  2222. {
  2223. $id = I('request.id');
  2224. if (empty($id)) {
  2225. $ids = I('request.ids');
  2226. $id = (is_array($ids) ? implode(',', $ids) : 0);
  2227. }
  2228. $items = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('comment_id' => array('in',$id) ) )->select();
  2229. if (empty($item)) {
  2230. $item = array();
  2231. }
  2232. foreach ($items as $item) {
  2233. M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->delete();
  2234. }
  2235. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2236. }
  2237. public function commentstate()
  2238. {
  2239. $id = I('request.id');
  2240. if (empty($id)) {
  2241. $ids = I('request.ids');
  2242. $id = (is_array($ids) ? implode(',', $ids) : 0);
  2243. }
  2244. $items = pdo_fetchall('SELECT comment_id FROM ' . tablename('lionfish_comshop_order_comment') . '
  2245. WHERE comment_id in( ' . $id . ' ) ' );
  2246. $items = M('lionfish_comshop_order_comment')->where( array() )->select();
  2247. if (empty($item)) {
  2248. $item = array();
  2249. }
  2250. foreach ($items as $item) {
  2251. pdo_update('lionfish_comshop_order_comment', array('state' => intval($_GPC['state'])), array('comment_id' => $item['comment_id']));
  2252. }
  2253. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2254. }
  2255. public function config()
  2256. {
  2257. if (IS_POST) {
  2258. $data = array();
  2259. $data = I('request.data');
  2260. $data['open_admin_payment'] = trim($data['open_admin_payment']);
  2261. $data['open_auto_receive'] = trim($data['open_auto_receive']);
  2262. $data['shop_limit_buy_distance'] = trim($data['shop_limit_buy_distance']);
  2263. $data['is_open_order_message'] = trim($data['is_open_order_message']);
  2264. $data['is_hidden_orderlist_phone'] = trim($data['is_hidden_orderlist_phone']);
  2265. $data['order_pay_after_share_img'] = save_media($data['order_pay_after_share_img']);
  2266. //-----begin
  2267. if( $data['shop_limit_buy_distance'] == 1)
  2268. {
  2269. if( empty($data['shop_buy_distance']) || $data['shop_buy_distance'] <= 0 )
  2270. {
  2271. show_json(0, array('msg' => '开启限制购买距离,购买距离不能为空') );
  2272. }
  2273. }
  2274. if( $data['open_auto_delete'] == 1)
  2275. {
  2276. if( empty($data['auto_cancle_order_time']) || $data['auto_cancle_order_time'] <= 0 )
  2277. {
  2278. show_json(0, array('msg' => '开启自动取消订单,自动取消订单时间不能为空') );
  2279. }
  2280. }
  2281. //open_aftersale
  2282. if( $data['open_auto_recive_order'] == 1)
  2283. {
  2284. if( empty($data['auto_recive_order_time']) || $data['auto_recive_order_time'] <= 0 )
  2285. {
  2286. show_json(0, array('msg' => '开启系统自动签收,自动签收天数不能为空') );
  2287. }
  2288. }
  2289. $open_aftersale = isset($data['open_aftersale']) ? $data['open_aftersale']:0;
  2290. $open_aftersale_time = isset($data['open_aftersale_time']) ? $data['open_aftersale_time']:0;
  2291. if( $open_aftersale == 1 && ($open_aftersale_time ==0 || empty($open_aftersale_time) ) )
  2292. {
  2293. show_json(0, array('msg' => '开启售后期,请填写售后期天数') );
  2294. }
  2295. if( $data['open_redis_server'] == 1)
  2296. {
  2297. if( empty($data['redis_host']))
  2298. {
  2299. show_json(0, array('msg' => '开启redis服务,redis-host不能为空') );
  2300. }
  2301. if( empty($data['redis_port']))
  2302. {
  2303. show_json(0, array('msg' => '开启redis服务,redis-port不能为空') );
  2304. }
  2305. }
  2306. $open_feier_print = isset($data['open_feier_print']) ? $data['open_feier_print']:0;
  2307. if(empty($open_feier_print) || $open_feier_print == 0)
  2308. {
  2309. $data['open_feier_print'] = $open_feier_print;
  2310. }else if($open_feier_print == 1){
  2311. $feier_print_sn = isset($data['feier_print_sn']) ? $data['feier_print_sn']:'';
  2312. $feier_print_key = isset($data['feier_print_key']) ? $data['feier_print_key']:'';
  2313. $data['open_feier_print'] = $open_feier_print;
  2314. $data['feier_print_sn'] = $feier_print_sn;
  2315. $data['feier_print_key'] = $feier_print_key;
  2316. $feier_print_sn_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_sn') )->find();
  2317. $feier_print_sn_old = $feier_print_sn_old_arr['value'];
  2318. $feier_print_key_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_key') )->find();
  2319. $feier_print_key_old = $feier_print_key_old_arr['value'];
  2320. if($feier_print_sn_old != $feier_print_sn || $feier_print_key_old != $feier_print_key)
  2321. {
  2322. //开始添加打印机
  2323. //printaction
  2324. $print_model = D('Seller/Printaction');
  2325. $snlist = "{$feier_print_sn}#{$feier_print_key}";
  2326. $print_model->addprinter($snlist);
  2327. }
  2328. //...todo测试订单自动打印
  2329. }else if($open_feier_print == 2){
  2330. $yilian_machine_code = isset($data['yilian_machine_code']) ? $data['yilian_machine_code']:'';
  2331. $yilian_msign = isset($data['yilian_msign']) ? $data['yilian_msign']:'';
  2332. $yilian_client_id = isset($data['yilian_client_id']) ? $data['yilian_client_id']:'';
  2333. $yilian_client_key = isset($data['yilian_client_key']) ? $data['yilian_client_key']:'';
  2334. $data['open_feier_print'] = $open_feier_print;
  2335. $data['yilian_machine_code'] = $yilian_machine_code;
  2336. $data['yilian_msign'] = $yilian_msign;
  2337. $data['yilian_client_id'] = $yilian_client_id;
  2338. $data['yilian_client_key'] = $yilian_client_key;
  2339. $yilian_client_id_old = D('Home/Front')->get_config_by_name('yilian_client_id');
  2340. $yilian_machine_code_old = D('Home/Front')->get_config_by_name('yilian_machine_code');
  2341. $yilian_msign_old = D('Home/Front')->get_config_by_name('yilian_msign');
  2342. if(true || $yilian_client_id != $yilian_client_id_old || $yilian_machine_code_old != $yilian_machine_code || $yilian_msign_old != $yilian_msign)
  2343. {
  2344. //开始添加打印机
  2345. //printaction
  2346. $print_model = D('Seller/Printaction');
  2347. $res = $print_model->addyilianyunprinter($yilian_client_id,$yilian_client_key,$yilian_machine_code, $yilian_msign );
  2348. if($res != 0)
  2349. {
  2350. show_json(0, array('msg' => '添加易联云打印机失败!'));
  2351. }
  2352. }
  2353. //...todo测试订单自动打印
  2354. }
  2355. //----end
  2356. $data['is_print_auto'] = $data['is_print_auto'] == 1 ? 0 : 1;
  2357. $data['is_print_cancleorder'] = isset($data['is_print_cancleorder']) ? $data['is_print_cancleorder'] : 0;
  2358. $data['is_print_admin_cancleorder'] = isset($data['is_print_admin_cancleorder']) ? $data['is_print_admin_cancleorder'] : 0;
  2359. $data['is_print_dansupply_order'] = isset($data['is_print_dansupply_order']) ? $data['is_print_dansupply_order'] : 0;
  2360. //----------redis begin
  2361. $data['open_redis_server'] = intval($data['open_redis_server']);
  2362. if($data['open_redis_server'] == 1 && !class_exists('Redis')){
  2363. $data['open_redis_server'] = 0;
  2364. }
  2365. //----------redis end
  2366. $data['is_has_refund_deliveryfree'] = isset($data['is_has_refund_deliveryfree']) ? $data['is_has_refund_deliveryfree'] : 0;
  2367. //订单自动发货
  2368. $data['is_localtown_auto_delivery'] = isset($data['is_localtown_auto_delivery']) ? $data['is_localtown_auto_delivery'] : 0;
  2369. $data['is_communityhead_auto_delivery'] = isset($data['is_communityhead_auto_delivery']) ? $data['is_communityhead_auto_delivery'] : 0;
  2370. $data['is_communityhead_auto_service'] = isset($data['is_communityhead_auto_service']) ? $data['is_communityhead_auto_service'] : 0;
  2371. $data['is_ziti_auto_delivery'] = isset($data['is_ziti_auto_delivery']) ? $data['is_ziti_auto_delivery'] : 0;
  2372. $data['is_ziti_auto_service'] = isset($data['is_ziti_auto_service']) ? $data['is_ziti_auto_service'] : 0;
  2373. D('Seller/Config')->update($data);
  2374. //将商品库存写入redis
  2375. if($data['open_redis_server'] == 1 )
  2376. D('Seller/Redisorder')->sysnc_allgoods_total();
  2377. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2378. }
  2379. $data = D('Seller/Config')->get_all_config();
  2380. $this->data = $data;
  2381. $this->display();
  2382. }
  2383. public function opclose()
  2384. {
  2385. $opdata = $this->check_order_data();
  2386. extract($opdata);
  2387. if ($item['order_status_id'] == 5) {
  2388. show_json(0, '订单已关闭,无需重复关闭!');
  2389. }
  2390. else if (3 != $item['order_status_id']) {
  2391. show_json(0, '订单已付款,不能关闭!');
  2392. }
  2393. if (IS_POST) {
  2394. //load_model_class('frontorder')->cancel_order($item['order_id']);
  2395. D('Home/Frontorder')->cancel_order($item['order_id'], false, '后台操作,取消订单');
  2396. /**
  2397. $time = time();
  2398. pdo_update('lionfish_comshop_order', array('order_status_id' => 5, 'canceltime' => $time), array('order_id' => $item['order_id'], 'uniacid' => $_W['uniacid'])) ;
  2399. //'remarkclose' => $_GPC['remark']),
  2400. $history_data = array();
  2401. $history_data['uniacid'] = $_W['uniacid'];
  2402. $history_data['order_id'] = $item['order_id'];
  2403. $history_data['order_status_id'] = 5;
  2404. $history_data['notify'] = 0;
  2405. $history_data['comment'] = '后台操作,取消订单' ;
  2406. $history_data['date_added'] = time();
  2407. pdo_insert('lionfish_comshop_order_history', $history_data);
  2408. **/
  2409. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2410. }
  2411. $this->item = $item;
  2412. $this->display();
  2413. }
  2414. //--begin
  2415. public function ordersendall()
  2416. {
  2417. $_GPC = I('request.');
  2418. $express_list = D('Seller/Express')->load_all_express();
  2419. $this->_GPC = $_GPC;
  2420. if( IS_POST )
  2421. {
  2422. $type = isset($_GPC['type']) && !empty($_GPC['type']) ? $_GPC['type']:'normal';
  2423. $fext = substr($_FILES['excelfile']['name'], strrpos($_FILES['excelfile']['name'], '.') + 1);
  2424. $express = trim($_GPC['express']);
  2425. $expresscom = trim($_GPC['expresscom']);
  2426. if( $fext == 'csv' )
  2427. {
  2428. $file_name = $_FILES['excelfile']['tmp_name'];
  2429. $file = fopen($file_name,'r');
  2430. $rows = array();
  2431. $i =0;
  2432. while ($data = fgetcsv($file)) {
  2433. $rows[] = eval('return '.iconv('gbk','utf-8',var_export($data,true)).';');
  2434. }
  2435. //var_dump( $rows );
  2436. //die();
  2437. }else{
  2438. $rows = D('Seller/Excel')->import('excelfile');
  2439. }
  2440. $num = count($rows);
  2441. $time = time();
  2442. $express_arr = array();
  2443. foreach($express_list as $val)
  2444. {
  2445. $express_arr[ $val['id'] ] = $val['name'];
  2446. }
  2447. $i = 0;
  2448. $err_array = array();
  2449. $quene_order_list = array();
  2450. $cache_key = md5(time().count($rows));
  2451. $j =0;
  2452. foreach ($rows as $rownum => $col)
  2453. {
  2454. $order_id = trim($col[0]);
  2455. if (empty($order_id)) {
  2456. $err_array[] = $order_id;
  2457. continue;
  2458. }
  2459. if($j == 0)
  2460. {
  2461. $j++;
  2462. continue;
  2463. }
  2464. $quene_order_list[] = array('order_num_alias' => $order_id , 'shipping_no' => $col[1], 'express' => $express,'expresscom' => $expresscom );
  2465. }
  2466. S('_orderquene_'.$cache_key, $quene_order_list);
  2467. $this->cache_key = $cache_key;
  2468. $this->type = $type;
  2469. $this->display('Order/oploadexcelorder');
  2470. die();
  2471. }
  2472. $this->express_list = $express_list;
  2473. $this->type = I('request.type');
  2474. $this->display();
  2475. }
  2476. public function do_order_quene()
  2477. {
  2478. $_GPC = I('request.');
  2479. $type = $_GPC['type'];
  2480. $cache_key = $_GPC['cache_key'];
  2481. $quene_order_list = S('_orderquene_'.$cache_key);
  2482. $tmp_info = array_shift($quene_order_list);
  2483. S('_orderquene_'.$cache_key, $quene_order_list);
  2484. $express = $tmp_info['express'];
  2485. $expresscom = $tmp_info['expresscom'];
  2486. $shipping_no = $tmp_info['shipping_no'];
  2487. $tmp_info['order_num_alias'] = trim($tmp_info['order_num_alias']);
  2488. $tmp_info['order_num_alias'] = preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/","",$tmp_info['order_num_alias']);
  2489. //$rows = D('Seller/Excel')->import('excelfile');
  2490. $order_info = M('lionfish_comshop_order')->where( array('order_num_alias' => $tmp_info['order_num_alias'] ) )->find();
  2491. if(!empty($order_info) && $order_info['order_status_id'] == 1)
  2492. {
  2493. if( $type == 'mult' && $order_info['delivery'] == 'express' )
  2494. {
  2495. $ex_info = D('Seller/Express')-> get_express_info($express);
  2496. $data = array();
  2497. $data['express_time'] = time();
  2498. $data['order_status_id'] = 4;
  2499. $data['shipping_no'] = $shipping_no;
  2500. $data['shipping_method'] = $express;
  2501. $data['dispatchname'] = $ex_info['name'];
  2502. M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save( $data );
  2503. $history_data = array();
  2504. $history_data['order_id'] = $order_info['order_id'];
  2505. $history_data['order_status_id'] = 4;
  2506. $history_data['notify'] = 0;
  2507. $history_data['comment'] = '订单快递已发货,后台导入批量发货';
  2508. $history_data['date_added'] = time();
  2509. M('lionfish_comshop_order_history')->add($history_data);
  2510. //TODO..发送已发货的模板消息
  2511. D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  2512. }
  2513. else {
  2514. if($order_info['delivery'] != 'express')
  2515. {
  2516. /*if($order_info['delivery'] == 'localtown_delivery'){
  2517. 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()) );
  2518. //todo ... send member msg goods is ing
  2519. $history_data = array();
  2520. $history_data['order_id'] = $order_info['order_id'];
  2521. $history_data['order_status_id'] = 4;
  2522. $history_data['notify'] = 0;
  2523. $history_data['comment'] = '订单配送中,使用表格发货';
  2524. $history_data['date_added'] = time();
  2525. M('lionfish_comshop_order_history')->add( $history_data );
  2526. D('Home/LocaltownDelivery')->change_distribution_order_state( $order_info['order_id'], 0, 1);
  2527. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id']) )->save( array('delivery_type' => 1) );
  2528. D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  2529. //给配送员发送公众号消息
  2530. $count = D('Seller/Redisorder')->set_distribution_delivery_message($order_info['order_id']);
  2531. }else{*/
  2532. if($order_info['delivery'] != 'localtown_delivery' && $order_info['delivery'] != 'hexiao') {
  2533. $data = array();
  2534. $data['express_time'] = time();
  2535. $data['order_status_id'] = 14;
  2536. M('lionfish_comshop_order')->where(array('order_id' => $order_info['order_id']))->save($data);
  2537. $history_data = array();
  2538. $history_data['order_id'] = $order_info['order_id'];
  2539. $history_data['order_status_id'] = 14;
  2540. $history_data['notify'] = 0;
  2541. $history_data['comment'] = '订单配送中,使用表格发货';
  2542. $history_data['date_added'] = time();
  2543. M('lionfish_comshop_order_history')->add($history_data);
  2544. }
  2545. //}
  2546. }
  2547. }
  2548. //TODO...发送已经发货给团长的消息通知
  2549. }
  2550. if($type =='mult_send_tuanz' && $order_info['delivery'] != 'express' && $order_info['order_status_id'] == 14 )
  2551. {
  2552. //订单批量团长签收 2019012749451499751
  2553. $history_data = array();
  2554. $history_data['order_id'] = $order_info['order_id'];
  2555. $history_data['order_status_id'] = 4;
  2556. $history_data['notify'] = 0;
  2557. $history_data['comment'] = '后台批量导入发货到团长';
  2558. $history_data['date_added'] = time();
  2559. M('lionfish_comshop_order_history')->add( $history_data );
  2560. D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  2561. }
  2562. if($type =='mult_member_receive_order' && $order_info['order_status_id'] == 4 )
  2563. {
  2564. /*if($order_info['delivery'] == 'localtown_delivery'){
  2565. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id']) )->save( array('state' => 4,'orderdistribution_id'=> -1) );
  2566. D('Seller/Order')->receive_order($order_info['order_id']);
  2567. M('lionfish_comshop_order_history')->where( array('order_id' => $order_info['order_id'],'order_status_id' => 6) )->save( array( 'comment' => '系统自动收货,等待结算佣金') );
  2568. }else{*/
  2569. if($order_info['delivery'] != 'localtown_delivery' && $order_info['delivery'] != 'hexiao') {
  2570. //批量用户确认收货
  2571. D('Home/Frontorder')->receive_order($order_info['order_id'], true);
  2572. }
  2573. //}
  2574. }
  2575. if( empty($quene_order_list) )
  2576. {
  2577. echo json_encode( array('code' => 2) );
  2578. die();
  2579. }
  2580. echo json_encode( array('code' => 0, 'msg' => '订单号:'.$tmp_info['order_num_alias']." 处理成功,还剩余".count($quene_order_list)."个订单未处理") );
  2581. die();
  2582. }
  2583. //--end
  2584. public function ordersendall2()
  2585. {
  2586. if( IS_POST )
  2587. {
  2588. $type = I('request.type', 'normal');
  2589. $express = I('request.express', '');
  2590. $expresscom = I('request.expresscom', '');
  2591. $rows = D('Seller/Excel')->import('excelfile');
  2592. $num = count($rows);
  2593. $time = time();
  2594. $express_arr = array();
  2595. foreach($express_list as $val)
  2596. {
  2597. $express_arr[ $val['id'] ] = $val['name'];
  2598. }
  2599. $i = 0;
  2600. $err_array = array();
  2601. $j =0;
  2602. foreach ($rows as $rownum => $col) {
  2603. $order_id = trim($col[0]);
  2604. if (empty($order_id)) {
  2605. $err_array[] = $order_id;
  2606. continue;
  2607. }
  2608. if($j == 0)
  2609. {
  2610. $j++;
  2611. continue;
  2612. }
  2613. $order_info = M('lionfish_comshop_order')->where( array('order_num_alias' => $order_id ) )->find();
  2614. if(!empty($order_info) && $order_info['order_status_id'] == 1)
  2615. {
  2616. //判断是否快递类型 type //normal mult
  2617. if( $type == 'mult' && $order_info['delivery'] == 'express' )
  2618. {
  2619. $data = array();
  2620. $data['express_time'] = time();
  2621. $data['order_status_id'] = 4;
  2622. $data['shipping_no'] = $col[1];
  2623. $data['shipping_method'] = $express;
  2624. $data['dispatchname'] = $expresscom;
  2625. M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save( $data );
  2626. $history_data = array();
  2627. $history_data['order_id'] = $order_info['order_id'];
  2628. $history_data['order_status_id'] = 4;
  2629. $history_data['notify'] = 0;
  2630. $history_data['comment'] = '订单快递已发货';
  2631. $history_data['date_added'] = time();
  2632. M('lionfish_comshop_order_history')->add($history_data);
  2633. //TODO..发送已发货的模板消息
  2634. D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  2635. }else {
  2636. if($order_info['delivery'] != 'express')
  2637. {
  2638. $data = array();
  2639. $data['express_time'] = time();
  2640. $data['order_status_id'] = 14;
  2641. M('lionfish_comshop_order')->where( array('order_id' => $order_info['order_id'] ) )->save($data);
  2642. $history_data = array();
  2643. $history_data['order_id'] = $order_info['order_id'];
  2644. $history_data['order_status_id'] = 14;
  2645. $history_data['notify'] = 0;
  2646. $history_data['comment'] = '订单配送中';
  2647. $history_data['date_added'] = time();
  2648. M('lionfish_comshop_order_history')->add($history_data);
  2649. }
  2650. }
  2651. //TODO...发送已经发货给团长的消息通知
  2652. ++$i;
  2653. }
  2654. if($type =='mult_send_tuanz' && $order_info['delivery'] != 'express' && $order_info['order_status_id'] == 14 )
  2655. {
  2656. //订单批量团长签收 2019012749451499751
  2657. D('Home/Frontorder')->send_order_operate($order_info['order_id']);
  2658. ++$i;
  2659. }
  2660. if($type =='mult_member_receive_order' && $order_info['order_status_id'] == 4 )
  2661. {
  2662. //批量用户确认收货
  2663. D('Home/Frontorder')->receive_order($order_info['order_id'], true);
  2664. ++$i;
  2665. }
  2666. }
  2667. $tip = '';
  2668. if($type =='mult_send_tuanz')
  2669. {
  2670. $msg = $i . '个订单批量送达团长成功!';
  2671. }
  2672. else if($type == 'mult_member_receive_order')
  2673. {
  2674. $msg = $i . '个订单批量用户确认收货!';
  2675. }
  2676. else{
  2677. $msg = $i . '个订单发货成功!';
  2678. }
  2679. if ($i < $num) {
  2680. $url = '';
  2681. if (!empty($err_array)) {
  2682. $j = 1;
  2683. if($type =='mult_send_tuanz')
  2684. {
  2685. $tip .= '<br>' . count($err_array) . '个订单批量送达团长失败,失败的订单编号: <br>';
  2686. }else if($type == 'mult_member_receive_order'){
  2687. $tip .= '<br>' . count($err_array) . '个订单批量用户确认收货,失败的订单编号: <br>';
  2688. }
  2689. else{
  2690. $tip .= '<br>' . count($err_array) . '个订单发货失败,失败的订单编号: <br>';
  2691. }
  2692. foreach ($err_array as $k => $v) {
  2693. $tip .= $v . ' ';
  2694. if (($j % 2) == 0) {
  2695. $tip .= '<br>';
  2696. }
  2697. ++$j;
  2698. }
  2699. }
  2700. }
  2701. else {
  2702. $url = U('order/ordersendall', array('type' => $type) );
  2703. }
  2704. $redirect = $url;
  2705. $this->message = $msg.$tip;
  2706. $this->redirect = $redirect;
  2707. $this->display('Public/_message');
  2708. die();
  2709. }
  2710. $express_list = D('Seller/Express')->load_all_express();
  2711. $this->express_list = $express_list;
  2712. $this->type = I('request.type');
  2713. $this->display();
  2714. }
  2715. public function opchangeexpress()
  2716. {
  2717. $_GPC = I('request.');
  2718. $opdata = $this->check_order_data();
  2719. extract($opdata);
  2720. $changeexpress = 1;
  2721. $sendtype = intval($_GPC['sendtype']);
  2722. $edit_flag = 1;
  2723. if (IS_POST) {
  2724. if (!(empty($_GPC['shipping_no'])) && empty($_GPC['shipping_no'])) {
  2725. show_json(0, array('msg' => '请输入快递单号!') );
  2726. }
  2727. if (!(empty($item['transid']))) {
  2728. }
  2729. $express_info = D('Seller/Express')->get_express_info($_GPC['express']);
  2730. $time = time();
  2731. $data = array(
  2732. 'shipping_method' => trim($_GPC['express']),
  2733. 'dispatchname' => $express_info['name'],
  2734. 'shipping_no' => trim($_GPC['shipping_no']),
  2735. 'express_time' => $time
  2736. );
  2737. M('lionfish_comshop_order')->where( array('order_id' => $item['order_id']) )->save( $data );
  2738. $history_data = array();
  2739. $history_data['order_id'] = $item['order_id'];
  2740. $history_data['order_status_id'] = 4;
  2741. $history_data['notify'] = 0;
  2742. $history_data['comment'] = '修改发货物流,订单发货 ID: ' . $item['order_id'] . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $_GPC['shipping_no'];
  2743. $history_data['date_added'] = time();
  2744. M('lionfish_comshop_order_history')->add( $history_data );
  2745. //TODO...发送已经发货的消息通知
  2746. //m('notice')->sendOrderMessage($item['id']);
  2747. //plog('order.op.send', '订单发货 ID: ' . $item['id'] . ' 订单号: ' . $item['ordersn'] . ' <br/>快递公司: ' . $_GPC['expresscom'] . ' 快递单号: ' . $_GPC['expresssn']);
  2748. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2749. }
  2750. $noshipped = array();
  2751. $shipped = array();
  2752. $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
  2753. $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
  2754. $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
  2755. $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();
  2756. $express_list = D('Seller/Express')->load_all_express();
  2757. $this->id = $item['order_id'];
  2758. $this->item = $item;
  2759. $this->province_info = $province_info;
  2760. $this->city_info = $city_info;
  2761. $this->area_info = $area_info;
  2762. $this->order_goods = $order_goods;
  2763. $this->express_list = $express_list;
  2764. $this->display('Order/opsend');
  2765. }
  2766. public function batchsend_import()
  2767. {
  2768. global $_W;
  2769. global $_GPC;
  2770. $type = I('request.type','normal');
  2771. $this->type = $type;
  2772. $columns = array();
  2773. $columns[] = array('title' => '订单编号', 'field' => '', 'width' => 32);
  2774. //$columns[] = array('title' => '快递单号', 'field' => '', 'width' => 32);
  2775. if($type == 'normal')
  2776. {
  2777. D('Seller/Excel')->temp('批量发货数据模板', $columns);
  2778. }else{
  2779. $columns[] = array('title' => '快递单号', 'field' => '', 'width' => 32);
  2780. D('Seller/Excel')->temp('批量发货数据模板', $columns);
  2781. }
  2782. }
  2783. /**
  2784. * 上传订单Excel批量发货
  2785. */
  2786. function sendexpress_excel_done()
  2787. {
  2788. set_time_limit(0);
  2789. if(isset($_FILES["file"]) && ($_FILES["file"]["error"] == 0)){
  2790. $excel_dir = ROOT_PATH.'Uploads/image/'.date('Y-m-d');
  2791. $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
  2792. RecursiveMkdir( $excel_dir );
  2793. $path = $excel_dir.'/'.md5($_FILES['file']['name'].mt_rand(1, 999)).'.'.$extension;
  2794. $rs = move_uploaded_file($_FILES["file"]["tmp_name"],$path);
  2795. $notify_model = D('Home/Weixinnotify');
  2796. //
  2797. $result = importExecl($path);
  2798. if(!empty($result)) {
  2799. $order_ids = array();
  2800. //开始导入数据库,并发货
  2801. foreach($result as $val){
  2802. if(empty($val[0]))
  2803. {
  2804. continue;
  2805. }
  2806. $order_info = M('order')->field('order_id,order_status_id,delivery')->where( array('order_num_alias' => trim($val[0])) )->find();
  2807. //order_status_id 1
  2808. if($order_info['order_status_id'] != 1)
  2809. {
  2810. continue;
  2811. }
  2812. //['delivery'] == 'pickup'
  2813. $order_ids[] = $order_info['order_id'];
  2814. if($order_info['delivery'] == 'pickup')
  2815. {
  2816. M('order')->where( array('order_id' => $order_info['order_id'] ) )->save( array('order_status_id' => 4) );
  2817. } else {
  2818. M('order')->where( array('order_id' => $order_info['order_id'] ) )->save( array('shipping_method' =>$val[5],'shipping_no' =>$val[6],'order_status_id' => 4) );
  2819. }
  2820. $oh = array();
  2821. $oh['order_id']=$order_info['order_id'];
  2822. $oh['order_status_id']=4;
  2823. $oh['notify'] = 0;
  2824. $oh['comment']='导入excel批量发货';
  2825. $oh['date_added']=time();
  2826. $oh_id=M('OrderHistory')->add($oh);
  2827. }
  2828. foreach($order_ids as $order_id) {
  2829. $order_info = M('order')->field('delivery')->where( array('order_id' => $order_id) )->find();
  2830. if($order_info['delivery'] == 'pickup')
  2831. {
  2832. $notify_model->sendPickupMsg($order_id);
  2833. } else {
  2834. $notify_model->sendExpressMsg($order_id);
  2835. }
  2836. }
  2837. }
  2838. }
  2839. echo json_encode( array('code' => 1) );
  2840. die();
  2841. }
  2842. function sendexpress()
  2843. {
  2844. $this->breadcrumb2='批量发货';
  2845. $this->display();
  2846. }
  2847. function print_order(){
  2848. $model=new OrderModel();
  2849. $this->order=$model->order_info(I('id'));
  2850. $this->print=true;
  2851. $this->display('./Themes/Home/default/Mail/order.html');
  2852. }
  2853. public function refunddone()
  2854. {
  2855. $id = I('get.id',0,'intval');
  2856. $comment = I('post.comment');
  2857. $order_refund_type = I('post.order_refund_type',0,'intval');
  2858. $result = array('code' =>1);
  2859. $order_refund_history = array();
  2860. $order_refund_history['order_id'] = $id;
  2861. $order_refund_history['message'] = htmlspecialchars($comment);
  2862. $order_refund_history['type'] = 2;
  2863. $order_refund_history['addtime'] = time();
  2864. M('order_refund_history')->add($order_refund_history);
  2865. $order_history = array();
  2866. $order_history['order_id'] = $id;
  2867. $order_history['order_status_id'] = 0;
  2868. $order_history['notify'] = 0;
  2869. $order_history['comment'] = '';
  2870. $order_history['date_added'] = time();
  2871. if($order_refund_type ==1)
  2872. {
  2873. //拒绝
  2874. M('order_refund')->where( array('order_id' => $id) )->save( array('state' => 1) );
  2875. $order_history['order_status_id'] = 12;
  2876. $order_history['comment'] = '商家拒绝退款';
  2877. M('order_history')->add($order_history);
  2878. } else {
  2879. $order_history['order_status_id'] = 12;
  2880. $order_history['comment'] = '商家统一退款';
  2881. M('order_history')->add($order_history);
  2882. $weixin_model = D('Home/Weixin');
  2883. //通过
  2884. M('order_refund')->where( array('order_id' => $id) )->save( array('state' => 3) );
  2885. $order_refund = M('order_refund')->where( array('order_id' => $id) )->find();
  2886. $weixin_model->refundOrder($id, $order_refund['ref_money']);
  2887. }
  2888. echo json_encode($result);
  2889. die();
  2890. }
  2891. public function show_refund()
  2892. {
  2893. $this->crumbs='订单退款详情';
  2894. $model=new OrderModel();
  2895. $data = $model->order_info(I('id'));
  2896. $order_statuses = $data['order_statuses'];
  2897. $need_status = array();
  2898. foreach($order_statuses as $key => $val)
  2899. {
  2900. if( in_array($val['order_status_id'], array(4)) )
  2901. {
  2902. $need_status[$key] = $val;
  2903. }
  2904. }
  2905. $data['order_statuses'] = $need_status;
  2906. $refund_reason = array(
  2907. '97' =>'商品有质量问题',
  2908. '98' =>'没有收到货',
  2909. '99' =>'商品少发漏发发错',
  2910. '100' =>'商品与描述不一致',
  2911. '101' =>'收到商品时有划痕或破损',
  2912. '102' =>'质疑假货',
  2913. '111' =>'其他',
  2914. );
  2915. $order_refund = M('order_refund')->where( array('order_id' =>I('id')) )->find();
  2916. //ref_type
  2917. $order_refund['ref_type'] = $order_refund['ref_type'] ==1 ? '仅退款': '退款退货';
  2918. $order_refund['ref_name'] = empty($refund_reason[$order_refund['ref_name']]) ? $order_refund['ref_name']: $refund_reason[$order_refund['ref_name']] ;
  2919. $refund_state = array(
  2920. 0 => '申请中',
  2921. 1 => '商家拒绝',
  2922. 2 => '平台介入',
  2923. 3 => '退款成功',
  2924. 4 => '退款失败',
  2925. 5 => '撤销申请',
  2926. );
  2927. $order_refund['state'] = $refund_state[$order_refund['state']];
  2928. $this->order_refund = $order_refund;
  2929. $order_refund_image = M('order_refund_image')->where( array('ref_id' => $order_refund['ref_id']) )->select();
  2930. $refund_images = array();
  2931. if(!empty($order_refund_image))
  2932. {
  2933. foreach($order_refund_image as $refund_image)
  2934. {
  2935. $refund_image['thumb_image'] = resize($refund_image['image'], 100, 100);
  2936. $refund_images[] = $refund_image;
  2937. }
  2938. }
  2939. $order_refund_history = M('order_refund_history')->where( array('order_id' => I('id')) )->order('addtime asc')->select();
  2940. foreach($order_refund_history as $key => $val)
  2941. {
  2942. $val['type'] = $val['type'] == 1 ?'用户反馈':'商家反馈';
  2943. switch($val['type'])
  2944. {
  2945. case 1:
  2946. $val['type'] = '用户反馈';
  2947. break;
  2948. case 2:
  2949. $val['type'] = '商家反馈';
  2950. break;
  2951. case 3:
  2952. $val['type'] = '平台反馈';
  2953. break;
  2954. }
  2955. $order_refund_history_image = M('order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
  2956. if(!empty($order_refund_history_image))
  2957. {
  2958. foreach($order_refund_history_image as $kk => $vv)
  2959. {
  2960. $vv['thumb_image'] = resize($vv['image'], 100, 100);
  2961. $order_refund_history_image[$kk] = $vv;
  2962. }
  2963. }
  2964. $val['order_refund_history_image'] = $order_refund_history_image;
  2965. $order_refund_history[$key] = $val;
  2966. }
  2967. $this->order_refund_history = $order_refund_history;
  2968. $this->refund_images = $refund_images;
  2969. $this->data = $data;
  2970. $this->display('refund');
  2971. }
  2972. public function show_order(){
  2973. $this->crumbs='订单详情';
  2974. //is_ziti/1 commiss_list
  2975. $is_ziti = I('get.is_ziti', 0);
  2976. if($is_ziti == 1)
  2977. {
  2978. $this->breadcrumb1='自提管理';
  2979. $this->breadcrumb2='自提管理';
  2980. }
  2981. $model=new OrderModel();
  2982. $data = $model->order_info(I('id'));
  2983. $order_statuses = $data['order_statuses'];
  2984. $need_status = array();
  2985. foreach($order_statuses as $key => $val)
  2986. {
  2987. if( in_array($val['order_status_id'], array(1,2,3,4,5,6,7,8,11,12,13)) )
  2988. {
  2989. $need_status[$key] = $val;
  2990. }
  2991. }
  2992. $data['order_statuses'] = $need_status;
  2993. //$data['order']
  2994. if($data['order']['type'] == 'integral')
  2995. {
  2996. $integral_order = M('integral_order')->where( array('order_id' => I('id') ) )->find();
  2997. $this->integral_order = $integral_order;
  2998. }
  2999. $this->data = $data;
  3000. $pick_order_info = array();
  3001. $pick_up = array();
  3002. if($data['order']['delivery'] == 'pickup')
  3003. {
  3004. $pick_order_info = M('pick_order')->where( array('order_id' => $data['order']['order_id']) )->find();
  3005. $pick_up = M('pick_up')->where( array('id' => $pick_order_info['pick_id']) )->find();
  3006. }
  3007. $this->pick_order_info = $pick_order_info;
  3008. $this->pick_up = $pick_up;
  3009. $sql="select s.* from ".C('DB_PREFIX')."seller_express as s, ".C('DB_PREFIX')."seller_express_relat as ser
  3010. where s.id = ser.express_id and ser.store_id = ".SELLERUID;
  3011. $express_list= M()->query($sql);
  3012. $this->express_list = $express_list;
  3013. //$data['order']['order_id']
  3014. $order_goods_haitao = M('order_goods_haitao')->where( array('order_id' => $data['order']['order_id']) )->find();
  3015. $this->order_goods_haitao = $order_goods_haitao;
  3016. $this->display('show');
  3017. }
  3018. function history(){
  3019. $model=new OrderModel();
  3020. if(IS_POST){
  3021. if(I('order_status_id')==C('cancel_order_status_id')){
  3022. $Order = new \Home\Model\OrderModel();
  3023. $Order->cancel_order($_GET['id']);
  3024. storage_user_action(session('user_auth.uid'),session('user_auth.username'),C('BACKEND_USER'),'取消了订单 '.$_GET['id']);
  3025. $result=true;
  3026. }else{
  3027. //order_status_id 4
  3028. if($_POST['order_status_id'] != 4)
  3029. {
  3030. unset($_POST['shipping_no']);
  3031. unset($_POST['shipping_method']);
  3032. die();
  3033. }else {
  3034. }
  3035. $result=$model->addOrderHistory($_GET['id'],$_POST);
  3036. }
  3037. if($result){
  3038. $this->success='新增成功!!';
  3039. }else{
  3040. $this->error='新增失败!!';
  3041. }
  3042. }
  3043. $results = $model->getOrderHistories($_GET['id']);
  3044. foreach ($results as $result) {
  3045. $histories[] = array(
  3046. 'notify' => $result['notify'] ? '是' : '否',
  3047. 'status' => $result['status'],
  3048. 'comment' => nl2br($result['comment']),
  3049. 'date_added' => date('Y/m/d H:i:s', $result['date_added'])
  3050. );
  3051. }
  3052. $this->histories=$histories;
  3053. $this->display();
  3054. }
  3055. function del(){
  3056. $model=new OrderModel();
  3057. $return=$model->del_order(I('get.id'));
  3058. $this->osc_alert($return);
  3059. }
  3060. //begin
  3061. public function printconfig()
  3062. {
  3063. if (defined('ROLE') && ROLE == 'agenter' )
  3064. {
  3065. $supper_info = get_agent_logininfo();
  3066. if (IS_POST) {
  3067. $_GPC = I('request.');
  3068. $data = array();
  3069. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  3070. //$supper_info['id']
  3071. $open_feier_print = isset($data['open_feier_print'.$supper_info['id']]) ? $data['open_feier_print'.$supper_info['id']]:0;
  3072. if(empty($open_feier_print) || $open_feier_print == 0)
  3073. {
  3074. $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
  3075. }else if($open_feier_print == 1){
  3076. $feier_print_sn = isset($data['feier_print_sn'.$supper_info['id']]) ? $data['feier_print_sn'.$supper_info['id']]:'';
  3077. $feier_print_key = isset($data['feier_print_key'.$supper_info['id']]) ? $data['feier_print_key'.$supper_info['id']]:'';
  3078. $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
  3079. $data['feier_print_sn'.$supper_info['id']] = $feier_print_sn;
  3080. $data['feier_print_key'.$supper_info['id']] = $feier_print_key;
  3081. $feier_print_sn_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_sn'.$supper_info['id'] ) )->find();
  3082. $feier_print_sn_old = $feier_print_sn_old_arr['value'];
  3083. $feier_print_key_old_arr = M('lionfish_comshop_config')->where( array('name' => 'feier_print_key'.$supper_info['id'] ) )->find();
  3084. $feier_print_key_old = $feier_print_key_old_arr['value'];
  3085. if($feier_print_sn_old != $feier_print_sn || $feier_print_key_old != $feier_print_key)
  3086. {
  3087. //开始添加打印机
  3088. //printaction
  3089. $print_model = D('Seller/Printaction');
  3090. $snlist = "{$feier_print_sn}#{$feier_print_key}";
  3091. $print_model->addprinter($snlist);
  3092. }
  3093. //...todo测试订单自动打印
  3094. }else if($open_feier_print == 2){
  3095. $yilian_machine_code = isset($data['yilian_machine_code'.$supper_info['id']]) ? $data['yilian_machine_code'.$supper_info['id']]:'';
  3096. $yilian_msign = isset($data['yilian_msign'.$supper_info['id']]) ? $data['yilian_msign'.$supper_info['id']]:'';
  3097. $yilian_client_id = isset($data['yilian_client_id'.$supper_info['id']]) ? $data['yilian_client_id'.$supper_info['id']]:'';
  3098. $yilian_client_key = isset($data['yilian_client_key'.$supper_info['id']]) ? $data['yilian_client_key'.$supper_info['id']]:'';
  3099. $data['open_feier_print'.$supper_info['id']] = $open_feier_print;
  3100. $data['yilian_machine_code'.$supper_info['id']] = $yilian_machine_code;
  3101. $data['yilian_msign'.$supper_info['id']] = $yilian_msign;
  3102. $data['yilian_client_id'.$supper_info['id']] = $yilian_client_id;
  3103. $data['yilian_client_key'.$supper_info['id']] = $yilian_client_key;
  3104. $yilian_client_id_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_client_id'.$supper_info['id'] ) )->find();
  3105. $yilian_client_id_old = $yilian_client_id_old_arr['value'];
  3106. $yilian_machine_code_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_machine_code'.$supper_info['id'] ) )->find();
  3107. $yilian_machine_code_old = $yilian_machine_code_old_arr['value'];
  3108. $yilian_msign_old_arr = M('lionfish_comshop_config')->where( array('name' => 'yilian_msign'.$supper_info['id'] ) )->find();
  3109. $yilian_msign_old = $yilian_msign_old_arr['value'];
  3110. if(true || $yilian_client_id != $yilian_client_id_old || $yilian_machine_code_old != $yilian_machine_code || $yilian_msign_old != $yilian_msign)
  3111. {
  3112. //开始添加打印机
  3113. //printaction
  3114. $print_model = D('Seller/Printaction');
  3115. $res = $print_model->addyilianyunprinter($yilian_client_id,$yilian_client_key,$yilian_machine_code, $yilian_msign );
  3116. if($res != 0)
  3117. {
  3118. show_json(0, array('msg' => '添加易联云打印机失败!' ) );
  3119. }
  3120. }
  3121. //...todo测试订单自动打印
  3122. }
  3123. D('Seller/Config')->update($data);
  3124. show_json(1);
  3125. }
  3126. $data = D('Seller/Config')->get_all_config();
  3127. $this->supper_info = $supper_info;
  3128. $this->data = $data;
  3129. include $this->display();
  3130. }
  3131. }
  3132. public function express_list(){
  3133. $this->type = I('request.type','');
  3134. $this->order_id = I('request.order_id','');
  3135. $express_list = D('Seller/Express')->load_kdn_express();
  3136. $this->express_list = $express_list;
  3137. $this->display();
  3138. }
  3139. public function kdn_print_log_list(){
  3140. $log_list = M('lionfish_comshop_order_kdniao_print_log')->order('id desc')->limit(5)->select();
  3141. $this->log_list = $log_list;
  3142. $this->display();
  3143. }
  3144. /**
  3145. * 判断快递鸟寄件人信息
  3146. * @param $express_code
  3147. */
  3148. public function check_kdn_sender($express_code){
  3149. $result = array();
  3150. $result['status'] = 1;
  3151. $data = D('Seller/Config')->get_all_config();
  3152. if(empty($data['kdn_sender_name'])){
  3153. $result['status'] = 0;
  3154. $result['msg'] = '寄件人未配置';
  3155. return $result;
  3156. }
  3157. if(empty($data['kdn_sender_mobile'])){
  3158. $result['status'] = 0;
  3159. $result['msg'] = '寄件人联系电话未配置';
  3160. return $result;
  3161. }
  3162. if(empty($data['kdn_province_id'])){
  3163. $result['status'] = 0;
  3164. $result['msg'] = '寄件人省份未配置';
  3165. return $result;
  3166. }
  3167. if(empty($data['kdn_city_id'])){
  3168. $result['status'] = 0;
  3169. $result['msg'] = '寄件人城市未配置';
  3170. return $result;
  3171. }
  3172. if(empty($data['kdn_area_id'])){
  3173. $result['status'] = 0;
  3174. $result['msg'] = '寄件人区域未配置';
  3175. return $result;
  3176. }
  3177. if(empty($data['kdn_sender_address'])){
  3178. $result['status'] = 0;
  3179. $result['msg'] = '寄件人详细地址未配置';
  3180. return $result;
  3181. }
  3182. $code_list = array('EMS','YZPY','YZBK');
  3183. if(in_array($express_code,$code_list)){
  3184. if(empty($data['kdn_sender_postcode'])){
  3185. $result['status'] = 0;
  3186. $result['msg'] = '寄件人邮编未配置';
  3187. return $result;
  3188. }
  3189. }
  3190. return $result;
  3191. }
  3192. //打印面单
  3193. public function kdniao_order(){
  3194. $result = array();
  3195. $order_id = I('request.order_id','');
  3196. $express_code = I('request.express_code','');
  3197. if(empty($order_id)){
  3198. $result['status'] = 1;
  3199. $result['message'] = "订单号不存在";
  3200. }else if(empty($express_code)){
  3201. $result['status'] = 1;
  3202. $result['message'] = "快递公司不存在";
  3203. }else{
  3204. $sender_result = $this->check_kdn_sender($express_code);
  3205. if($sender_result['status'] == 1){
  3206. $kdNiao = new \Lib\KdApiEOrder();
  3207. $config_data = D('Seller/Config')->get_all_config();
  3208. $result = $kdNiao->printOrder($order_id,$express_code,$config_data);
  3209. }else{
  3210. $result['status'] = 3;
  3211. $result['message'] = $sender_result['msg'];
  3212. }
  3213. }
  3214. echo json_encode($result);
  3215. }
  3216. //打印多条订单面单
  3217. public function kdniao_print_orders(){
  3218. $print_type = I('request.print_type','');
  3219. $order_id = I('request.order_id','');
  3220. $express_code = I('request.express_code','');
  3221. $order_id_list = array();
  3222. $order_list = array();
  3223. $order_kdn_status = array();
  3224. if($print_type == "select"){
  3225. $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();
  3226. }else if($print_type == "all"){
  3227. $order_list = M('lionfish_comshop_order')->field('order_id,is_kdn_print')->where("order_status_id = 1 and delivery = 'express' ")->select();
  3228. }
  3229. foreach($order_list as $k=>$v){
  3230. $order_id_list[] = $v['order_id'];
  3231. $order_kdn_status[$v['order_id']] = $v['is_kdn_print'];
  3232. }
  3233. $time = time();
  3234. $print_count = count($order_id_list);
  3235. //保存快递鸟打印日志
  3236. $kd_data = array();
  3237. $kd_data['addtime'] = $time;
  3238. $kd_data['print_count'] = $print_count;
  3239. $kdn_id = M('lionfish_comshop_order_kdniao_print_log')->add( $kd_data );
  3240. $succ_count = 0;
  3241. $fail_count = 0;
  3242. $fail_result = array();
  3243. $kdNiao = new \Lib\KdApiEOrder();
  3244. $config_data = D('Seller/Config')->get_all_config();
  3245. $sender_result = $this->check_kdn_sender($express_code);
  3246. if($sender_result['status'] == 1){
  3247. foreach($order_id_list as $v){
  3248. if($order_kdn_status[$v] == 1){
  3249. $succ_count++;
  3250. }else{
  3251. $result = $kdNiao->printOrder($v,$express_code,$config_data);
  3252. if($result['status'] == 0){//打印成功
  3253. $succ_count++;
  3254. }else{//打印失败
  3255. $fail_count++;
  3256. $fail_result[] = $result['message'];
  3257. }
  3258. }
  3259. }
  3260. }else{
  3261. $result['status'] = 3;
  3262. $result['message'] = $sender_result['msg'];
  3263. }
  3264. $fail_reason = json_encode(array_unique($fail_result));
  3265. //打印完成更新快递鸟打印日志
  3266. $kdn_data = array();
  3267. $kdn_data['succ_count'] = $succ_count;
  3268. $kdn_data['fail_count'] = $fail_count;
  3269. $kdn_data['fail_reason'] = $fail_reason;
  3270. $kdn_data['status'] = 1;
  3271. M('lionfish_comshop_order_kdniao_print_log')->where(array('id' => $kdn_id))->save($kdn_data);
  3272. $kdn_order_ids = implode(",",$order_id_list);
  3273. echo json_encode(array('status'=>0,'order_ids'=>$kdn_order_ids));
  3274. }
  3275. //检查是否配置快递鸟接口参数
  3276. public function check_kdniao(){
  3277. $config_data = D('Seller/Config')->get_all_config();
  3278. if(isset($config_data['kdniao_id']) && !empty($config_data['kdniao_id']) && isset($config_data['kdniao_api_key']) && !empty($config_data['kdniao_api_key'])){
  3279. show_json(1);
  3280. }else{
  3281. show_json(0, array('msg' => '快递鸟未配置!' ) );
  3282. }
  3283. }
  3284. public function kdn_info(){
  3285. $this->order_id = I('request.order_id','');
  3286. $kdn_info = M('lionfish_comshop_order_kdniao_info')->where( array('order_id' => $this->order_id,'status'=>1) )->find();
  3287. $this->kdn_info = $kdn_info;
  3288. $this->display();
  3289. }
  3290. public function kdn_orders_info(){
  3291. $this->order_ids = I('request.order_ids','');
  3292. $kdn_list_info = M('lionfish_comshop_order_kdniao_info')->where("order_id in (".$this->order_ids.") and status = 1")->select();
  3293. $this->kdn_list_info = $kdn_list_info;
  3294. $this->display();
  3295. }
  3296. /**
  3297. * 快递鸟打印成功订单发货
  3298. */
  3299. public function kdn_send(){
  3300. $order_id = I('request.id','');
  3301. $order_ids = I('request.ids','');
  3302. if(!empty($order_id)){
  3303. $item = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  3304. if (empty($item)) {
  3305. show_json(0, '未找到订单!');
  3306. }
  3307. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  3308. if(!empty($order_info)) {
  3309. if ($order_info['order_status_id'] == 1 && $order_info['delivery'] == 'express' && $order_info['is_kdn_print'] == 1) {
  3310. $express_info = D('Seller/Express')->get_express_info($order_info['shipping_method']);
  3311. $data = array();
  3312. $data['order_status_id'] = 4;
  3313. M('lionfish_comshop_order')->where(array('order_id' => $order_id))->save($data);
  3314. $history_data = array();
  3315. $history_data['order_id'] = $order_id;
  3316. $history_data['order_status_id'] = 4;
  3317. $history_data['notify'] = 0;
  3318. $history_data['comment'] = '订单发货 ID: ' . $order_id . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $item['shipping_no'];
  3319. $history_data['date_added'] = time();
  3320. M('lionfish_comshop_order_history')->add($history_data);
  3321. D('Home/Frontorder')->send_order_operate($item['order_id']);
  3322. } else {
  3323. show_json(0, '待发货快递订单才能发货成功!');
  3324. }
  3325. }else{
  3326. show_json(0, '未找到订单!');
  3327. }
  3328. }else if(!empty($order_ids)){
  3329. $ids = explode(",",$order_ids);
  3330. foreach($ids as $k=>$v){
  3331. $order_id = $v;
  3332. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  3333. if (empty($order_info)) {
  3334. show_json(0, '未找到订单!');
  3335. }
  3336. if(!empty($order_info)) {
  3337. if ($order_info['order_status_id'] == 1 && $order_info['delivery'] == 'express' && $order_info['is_kdn_print'] == 1) {
  3338. $express_info = D('Seller/Express')->get_express_info($order_info['shipping_method']);
  3339. $data = array();
  3340. $data['order_status_id'] = 4;
  3341. M('lionfish_comshop_order')->where(array('order_id' => $order_id))->save($data);
  3342. $history_data = array();
  3343. $history_data['order_id'] = $order_id;
  3344. $history_data['order_status_id'] = 4;
  3345. $history_data['notify'] = 0;
  3346. $history_data['comment'] = '订单发货 ID: ' . $order_id . ' 订单号: ' . $item['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $item['shipping_no'];
  3347. $history_data['date_added'] = time();
  3348. M('lionfish_comshop_order_history')->add($history_data);
  3349. D('Home/Frontorder')->send_order_operate($item['order_id']);
  3350. } else {
  3351. show_json(0, '待发货快递订单才能发货成功!');
  3352. }
  3353. }else{
  3354. show_json(0, '未找到订单!');
  3355. }
  3356. }
  3357. }else{
  3358. show_json(0, '未找到订单!');
  3359. }
  3360. show_json(1);
  3361. }
  3362. /**
  3363. * 修改订单价格
  3364. */
  3365. public function change_order(){
  3366. $_GPC = I('request.');
  3367. $opdata = $this->check_order_data();
  3368. extract($opdata);
  3369. $id = I('request.id',0);
  3370. if( IS_POST )
  3371. {
  3372. $_GPC = I('request.');
  3373. $order_id = $_GPC['id'];
  3374. $order_goods_ids = $_GPC['order_goods_id'];
  3375. $change_prices = $_GPC['change_price'];
  3376. $count = 0;
  3377. foreach($change_prices as $v){
  3378. if(empty(trim($v))){
  3379. $count++;
  3380. }
  3381. }
  3382. if($count == count($change_prices)){
  3383. show_json(0, array('message' => '未填写涨价或减价金额!'));
  3384. }
  3385. //改价后的商品实付价格不能低于0.1元
  3386. foreach($order_goods_ids as $k=>$order_goods_id){
  3387. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' =>$order_goods_id ) )->find();
  3388. $total = $order_goods_info['total'];
  3389. $fullreduction_money = $order_goods_info['fullreduction_money'];
  3390. $voucher_credit = $order_goods_info['voucher_credit'];
  3391. $score_for_money = $order_goods_info['score_for_money'];
  3392. $total = round($total - $fullreduction_money - $voucher_credit - $score_for_money,2);
  3393. if(!empty($change_prices[$k])){
  3394. $change_price = $change_prices[$k];
  3395. $total = floatval($total) + floatval($change_price);
  3396. if(bccomp($total, '0.1', 2) == -1){
  3397. show_json(0, array('message' => '改价后的商品实付价格不能低于0.1元'));
  3398. }
  3399. }
  3400. }
  3401. $change_amount = 0;
  3402. foreach($order_goods_ids as $k=>$order_goods_id){
  3403. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' =>$order_goods_id ) )->find();
  3404. $total = $order_goods_info['total'];
  3405. $update_data = array();
  3406. if(!empty($change_prices[$k])){
  3407. $change_amount = $change_amount + $change_prices[$k];
  3408. $change_price = $change_prices[$k];
  3409. $update_data['total'] = round(floatval($total) + floatval($change_price),2);
  3410. $update_data['is_change_price'] = 1;
  3411. M('lionfish_comshop_order_goods')->where( array('order_id' =>$id,'order_goods_id' => $order_goods_id ) )->save( $update_data);
  3412. }
  3413. }
  3414. $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$id) )->find();
  3415. $order_total = $order_info['total'];
  3416. $order_data = array();
  3417. $order_data['total'] = round(floatval($order_total) + floatval($change_amount),2);
  3418. $order_data['is_change_price'] = 1;
  3419. M('lionfish_comshop_order')->where( array('order_id' =>$id) )->save($order_data);
  3420. $oh = array();
  3421. $oh['order_id'] = $id;
  3422. $oh['order_status_id']=15;
  3423. $oh['comment']='订单改价';
  3424. $oh['date_added']=time();
  3425. M('lionfish_comshop_order_history')->add($oh);
  3426. show_json(1);
  3427. }
  3428. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $id) )->select();
  3429. foreach($order_goods as $k=>$v){
  3430. $order_goods[$k]['goods_img_url'] = tomedia($v['goods_images']);
  3431. }
  3432. $this->item = $opdata['item'];
  3433. $this->order_goods = $order_goods;
  3434. $this->display();
  3435. }
  3436. //检查是否配置第三方配送接口参数
  3437. public function check_delivery_config(){
  3438. $_GPC = I('request.');
  3439. $config_data = D('Seller/Config')->get_all_config();
  3440. $data_type = $_GPC['data_type'];
  3441. if($data_type == 'imdada'){
  3442. 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'])){
  3443. show_json(1);
  3444. }else{
  3445. show_json(0, array('msg' => '达达配送平台参数未配置!' ) );
  3446. }
  3447. }else if($data_type == 'sf'){
  3448. if(isset($config_data['localtown_sf_dev_id']) && !empty($config_data['localtown_sf_dev_key']) && isset($config_data['localtown_sf_store_id'])){
  3449. show_json(1);
  3450. }else{
  3451. show_json(0, array('msg' => '顺丰同城参数未配置!' ) );
  3452. }
  3453. }else if($data_type == 'make'){
  3454. if(isset($config_data['localtown_mk_token']) && !empty($config_data['localtown_mk_token']) ){
  3455. show_json(1);
  3456. }else{
  3457. show_json(0, array('msg' => '码科配送参数未配置!' ) );
  3458. }
  3459. }else if($data_type == 'ele'){
  3460. 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'])
  3461. && !empty($config_data['localtown_ele_transport_address']) && !empty($config_data['localtown_ele_transport_longitude']) && !empty($config_data['localtown_ele_transport_latitude'])
  3462. && !empty($config_data['localtown_ele_transport_tel']) && !empty($config_data['localtown_ele_position_source'])
  3463. ){
  3464. show_json(1);
  3465. }else{
  3466. show_json(0, array('msg' => '蜂鸟即配平台参数未配置!' ) );
  3467. }
  3468. }
  3469. }
  3470. /**
  3471. * 将订单推送给第三方配送
  3472. */
  3473. public function thirth_delivery_order(){
  3474. $_GPC = I('request.');
  3475. $data_type = $_GPC['data_type'];
  3476. $order_id = $_GPC['order_id'];
  3477. if(empty($data_type)){
  3478. show_json(0, array('msg' => '未选择第三方配送' ) );
  3479. }
  3480. if(empty($order_id)){
  3481. show_json(0, array('msg' => '订单号不存在' ) );
  3482. }
  3483. $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
  3484. if(empty($order_info)){
  3485. show_json(0, array('msg' => '订单不存在' ) );
  3486. }
  3487. //店铺地址
  3488. if($order_info['store_id'] > 0) {
  3489. $store_data = D('Home/Order')->getOrderStoreAddress($order_info);
  3490. $order_info['store_data'] = $store_data;
  3491. }
  3492. //商品信息
  3493. $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 "
  3494. . 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 "
  3495. ." where og.order_id = ".$order_id;
  3496. $goods_list = M()->query($sql);
  3497. $goods_count = 0;
  3498. $goods_weight = 0;
  3499. $goods_type_count = 0;
  3500. foreach($goods_list as $k=>$v){
  3501. $goods_count = $goods_count + $v['quantity'];
  3502. if(!empty($v['rela_goodsoption_valueid'])){
  3503. $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();
  3504. if(!empty($goods_option_mult_value)){
  3505. $v['goods_weight'] = $goods_option_mult_value['weight'];
  3506. }
  3507. }
  3508. $goods_weight = $goods_weight + $v['quantity'] * $v['goods_weight'];
  3509. $goods_type_count = $goods_type_count + 1;
  3510. }
  3511. if(empty($goods_weight)){
  3512. $goods_weight = 100;//默认100克
  3513. }
  3514. $order_info['goods_list'] = $goods_list;
  3515. //商品种类
  3516. $order_info['goods_type_count'] = $goods_type_count;
  3517. //商品数量
  3518. $order_info['goods_count'] = $goods_count;
  3519. //商品重量
  3520. $order_info['goods_weight'] = $goods_weight;
  3521. //订单总金额
  3522. $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'];
  3523. //收货人地址
  3524. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  3525. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  3526. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  3527. $order_info['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$order_info['shipping_address'];
  3528. //收货人经纬度
  3529. $order_distribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3530. //收货人地址纬度
  3531. $order_info['shipping_lat'] = $order_distribution_info['member_lat'];
  3532. //收货人地址经度
  3533. $order_info['shipping_lng'] = $order_distribution_info['member_lon'];
  3534. //商城名称
  3535. $shoname = D('Home/Front')->get_config_by_name('shoname');
  3536. $order_info['shoname'] = $shoname;
  3537. if($data_type == 'imdada'){
  3538. $imdada = new \Lib\Localtown\Imdada();
  3539. $result = $imdada->addOrder($order_info);
  3540. if($result['status'] == 1){//成功
  3541. //配送费用
  3542. $delivery_fee = $result['result']['fee'];
  3543. $express_info = array();
  3544. $express_info['delivery_fee'] = $delivery_fee;
  3545. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3546. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3547. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3548. show_json(1);
  3549. }else{//失败
  3550. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3551. }
  3552. }else if($data_type == 'sf'){
  3553. $sfexpress = new \Lib\Localtown\Sfexpress();
  3554. $result = $sfexpress->addOrder($order_info);
  3555. if($result['status'] == 1){//成功
  3556. //配送费用
  3557. $delivery_fee = round($result['result']['total_price']/100,2);
  3558. //顺丰订单号
  3559. $delivery_order_id = $result['result']['sf_order_id'];
  3560. //顺丰运单号
  3561. $delivery_bill_id = $result['result']['sf_bill_id'];
  3562. $express_info = array();
  3563. $express_info['delivery_fee'] = $delivery_fee;
  3564. $express_info['delivery_order_id'] = $delivery_order_id;
  3565. $express_info['delivery_bill_id'] = $delivery_bill_id;
  3566. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3567. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3568. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3569. show_json(1);
  3570. }else{//失败
  3571. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3572. }
  3573. }else if( $data_type == 'make' )
  3574. {
  3575. //$store_data = D('Home/Make')->getOrderStoreAddress($order_info);
  3576. $result = D('Home/Make')->addOrder($order_info);
  3577. if( $result['code'] == 0 )
  3578. {
  3579. //码科订单号
  3580. $delivery_order_id = $result['order_number'];
  3581. $express_info = array();
  3582. $express_info['delivery_fee'] = $order_distribution_info['shipping_money'];
  3583. $express_info['delivery_order_id'] = $delivery_order_id;
  3584. $express_info['delivery_bill_id'] = '';
  3585. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3586. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3587. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3588. show_json(1);
  3589. }else{
  3590. show_json(0, array('msg' => $result['message'] ) );
  3591. }
  3592. }else if($data_type == 'ele'){//蜂鸟即配
  3593. $eleDistribution = new \Lib\Localtown\EleDistribution();
  3594. $order_code = build_order_no(session('user_auth.uid'));
  3595. //保存蜂鸟即配商户订单号
  3596. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->save(['order_code'=>$order_code]);
  3597. $order_info['order_num_alias'] = $order_code;
  3598. $result = $eleDistribution->addOrder($order_info);
  3599. if($result['status'] == 1){//成功
  3600. //配送费用
  3601. $delivery_fee = round($result['result']['total_price']/100,2);
  3602. //蜂鸟即配订单号
  3603. $delivery_order_id = $result['result']['sf_order_id'];
  3604. //蜂鸟即配运单号
  3605. $delivery_bill_id = $result['result']['sf_bill_id'];
  3606. $express_info = array();
  3607. $express_info['delivery_fee'] = $delivery_fee;
  3608. $express_info['delivery_order_id'] = $delivery_order_id;
  3609. $express_info['delivery_bill_id'] = $delivery_bill_id;
  3610. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3611. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3612. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3613. show_json(1);
  3614. }else{//失败
  3615. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3616. }
  3617. }else{
  3618. show_json(0, array('msg' => '不存在第三方配送' ) );
  3619. }
  3620. }
  3621. /**
  3622. * 将订单重新推送给第三方配送
  3623. */
  3624. public function thirth_renew_delivery_order(){
  3625. $_GPC = I('request.');
  3626. $data_type = $_GPC['data_type'];
  3627. $order_id = $_GPC['order_id'];
  3628. if(empty($data_type)){
  3629. show_json(0, array('msg' => '未选择第三方配送' ) );
  3630. }
  3631. if(empty($order_id)){
  3632. show_json(0, array('msg' => '订单号不存在' ) );
  3633. }
  3634. $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
  3635. if(empty($order_info)){
  3636. show_json(0, array('msg' => '订单不存在' ) );
  3637. }
  3638. //店铺地址
  3639. if($order_info['store_id'] > 0) {
  3640. $store_data = D('Home/Order')->getOrderStoreAddress($order_info);
  3641. $order_info['store_data'] = $store_data;
  3642. }
  3643. //商品信息
  3644. $sql = "select og.goods_id,og.name as goods_name,og.quantity,og.rela_goodsoption_valueid,g.weight as goods_weight from "
  3645. . 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 "
  3646. ." where og.order_id = ".$order_id;
  3647. $goods_list = M()->query($sql);
  3648. $goods_count = 0;
  3649. $goods_weight = 0;
  3650. $goods_type_count = 0;
  3651. foreach($goods_list as $k=>$v){
  3652. $goods_count = $goods_count + $v['quantity'];
  3653. if(!empty($v['rela_goodsoption_valueid'])){
  3654. $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();
  3655. if(!empty($goods_option_mult_value)){
  3656. $v['goods_weight'] = $goods_option_mult_value['weight'];
  3657. }
  3658. }
  3659. $goods_weight = $goods_weight + $v['quantity'] * $v['goods_weight'];
  3660. $goods_type_count = $goods_type_count + 1;
  3661. }
  3662. if(empty($goods_weight)){
  3663. $goods_weight = 100;//默认100克
  3664. }
  3665. $order_info['goods_list'] = $goods_list;
  3666. //商品种类
  3667. $order_info['goods_type_count'] = $goods_type_count;
  3668. //商品数量
  3669. $order_info['goods_count'] = $goods_count;
  3670. //商品重量
  3671. $order_info['goods_weight'] = $goods_weight;
  3672. //订单总金额
  3673. $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'];
  3674. //收货人地址
  3675. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  3676. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  3677. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  3678. $order_info['shipping_address'] = $province_info['name'].$city_info['name'].$area_info['name'].$order_info['shipping_address'];
  3679. //收货人经纬度
  3680. $order_distribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3681. //收货人地址纬度
  3682. $order_info['shipping_lat'] = $order_distribution_info['member_lat'];
  3683. //收货人地址经度
  3684. $order_info['shipping_lng'] = $order_distribution_info['member_lon'];
  3685. //商城名称
  3686. $shoname = D('Home/Front')->get_config_by_name('shoname');
  3687. $order_info['shoname'] = $shoname;
  3688. if($data_type == 'imdada'){
  3689. $imdada = new \Lib\Localtown\Imdada();
  3690. $result = $imdada->reAddOrder($order_info);
  3691. if($result['status'] == 1){//成功
  3692. //配送费用
  3693. $delivery_fee = array();
  3694. $delivery_fee['delivery_fee'] = $result['result']['fee'];
  3695. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$delivery_fee);
  3696. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3697. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3698. show_json(1);
  3699. }else{//失败
  3700. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3701. }
  3702. }else if($data_type == 'sf'){
  3703. $sfexpress = new \Lib\Localtown\Sfexpress();
  3704. $result = $sfexpress->addOrder($order_info);
  3705. if($result['status'] == 1){//成功
  3706. //配送费用
  3707. $delivery_fee = round($result['result']['total_price']/100,2);
  3708. //顺丰订单号
  3709. $delivery_order_id = $result['result']['sf_order_id'];
  3710. //顺丰运单号
  3711. $delivery_bill_id = $result['result']['sf_bill_id'];
  3712. $express_info = array();
  3713. $express_info['delivery_fee'] = $delivery_fee;
  3714. $express_info['delivery_order_id'] = $delivery_order_id;
  3715. $express_info['delivery_bill_id'] = $delivery_bill_id;
  3716. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3717. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3718. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3719. show_json(1);
  3720. }else{//失败
  3721. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3722. }
  3723. }else if($data_type == 'make')
  3724. {
  3725. $result = D('Home/Make')->addOrder($order_info);
  3726. if( $result['code'] == 0 )
  3727. {
  3728. //码科订单号
  3729. $delivery_order_id = $result['order_number'];
  3730. $express_info = array();
  3731. $express_info['delivery_fee'] = $order_distribution_info['shipping_money'];
  3732. $express_info['delivery_order_id'] = $delivery_order_id;
  3733. $express_info['delivery_bill_id'] = '';
  3734. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3735. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3736. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3737. show_json(1);
  3738. }else{
  3739. show_json(0, array('msg' => $result['message'] ) );
  3740. }
  3741. }else if($data_type == 'ele'){//蜂鸟即配
  3742. $eleDistribution = new \Lib\Localtown\EleDistribution();
  3743. $order_code = build_order_no(session('user_auth.uid'));
  3744. //保存蜂鸟即配商户订单号
  3745. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->save(['order_code'=>$order_code]);
  3746. $order_info['order_num_alias'] = $order_code;
  3747. $result = $eleDistribution->addOrder($order_info);
  3748. if($result['status'] == 1){//成功
  3749. //配送费用
  3750. $delivery_fee = round($result['result']['total_price']/100,2);
  3751. //蜂鸟即配订单号
  3752. $delivery_order_id = $result['result']['sf_order_id'];
  3753. //蜂鸟即配运单号
  3754. $delivery_bill_id = $result['result']['sf_bill_id'];
  3755. $express_info = array();
  3756. $express_info['delivery_fee'] = $delivery_fee;
  3757. $express_info['delivery_order_id'] = $delivery_order_id;
  3758. $express_info['delivery_bill_id'] = $delivery_bill_id;
  3759. D('Seller/Order')->do_send_localtown_thirth_delivery($order_id,$data_type,$express_info);
  3760. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3761. D('Seller/Supply')->update_supply_commission($order_id,$shipping_money["shipping_money"]);
  3762. show_json(1);
  3763. }else{//失败
  3764. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3765. }
  3766. }
  3767. else{
  3768. show_json(0, array('msg' => '不存在第三方配送' ) );
  3769. }
  3770. }
  3771. public function third_cancel_reason(){
  3772. $order_id = I('request.order_id','');
  3773. $third_distribution_type = I('request.third_distribution_type','');
  3774. $this->order_id = $order_id;
  3775. $this->third_distribution_type = $third_distribution_type;
  3776. $this->display();
  3777. }
  3778. /**
  3779. * 取消第三方配送订单
  3780. */
  3781. public function thirth_cancel_delivery_order(){
  3782. $_GPC = I('request.');
  3783. $order_id = $_GPC['order_id'];
  3784. if(empty($order_id)){
  3785. show_json(0, array('msg' => '订单号不存在' ) );
  3786. }
  3787. $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
  3788. if(empty($order_info)){
  3789. show_json(0, array('msg' => '订单不存在' ) );
  3790. }
  3791. $orderdistribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' =>$order_id) )->find();
  3792. if(empty($orderdistribution_info)){
  3793. show_json(0, array('msg' => '配送订单不存在' ) );
  3794. }
  3795. $cancel_reason_id = $_GPC['cancel_reason_id'];
  3796. $cancel_reason = $_GPC['cancel_reason'];
  3797. $data_type = $orderdistribution_info['third_distribution_type'];
  3798. if($orderdistribution_info['state'] == 0 || $orderdistribution_info['state'] == 1 || $orderdistribution_info['state'] == 2){
  3799. if($data_type == 'imdada'){
  3800. $imdada = new \Lib\Localtown\Imdada();
  3801. $result = $imdada->cancelOrder($order_info,$cancel_reason_id,$cancel_reason);
  3802. if($result['status'] == 1){//成功
  3803. $deduct_fee = $result['result']['deduct_fee'];
  3804. $other_data = array();
  3805. $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
  3806. $other_data['cancel_reason'] = $cancel_reason;
  3807. $other_data['now_deduct_fee'] = $deduct_fee;
  3808. D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
  3809. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3810. D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
  3811. show_json(1);
  3812. }else{//失败
  3813. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3814. }
  3815. }else if($data_type == 'sf'){
  3816. $sfexpress = new \Lib\Localtown\Sfexpress();
  3817. $result = $sfexpress->cancelOrder($orderdistribution_info,$cancel_reason);
  3818. if($result['status'] == 1){//成功
  3819. $other_data = array();
  3820. if(empty($cancel_reason)){
  3821. $cancel_reason = "商家取消";
  3822. }
  3823. $other_data['cancel_reason'] = $cancel_reason;
  3824. $deduct_fee = round($result['result']['deduction_detail']['deduction_fee']/100,2);
  3825. $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
  3826. $other_data['now_deduct_fee'] = $deduct_fee;
  3827. D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
  3828. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3829. D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
  3830. show_json(1);
  3831. }else{//失败
  3832. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3833. }
  3834. }else if( $data_type == 'make' )
  3835. {
  3836. //$orderdistribution_info
  3837. $third_order_id = $orderdistribution_info['third_order_id'];
  3838. $result = D('Home/Make')->cancelOrder( $third_order_id );
  3839. if( $result['code'] == 0 )
  3840. {
  3841. $other_data = array();
  3842. if(empty($cancel_reason)){
  3843. $cancel_reason = "商家取消";
  3844. }
  3845. $other_data['cancel_reason'] = $cancel_reason;
  3846. $deduct_fee = 0;
  3847. $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
  3848. $other_data['now_deduct_fee'] = $deduct_fee;
  3849. D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
  3850. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3851. //D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
  3852. //load_model_class('supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
  3853. show_json(1);
  3854. }else{
  3855. show_json(0, array('msg' => $result['message'] ) );
  3856. }
  3857. }else if($data_type == 'ele'){
  3858. $eleDistribution = new \Lib\Localtown\EleDistribution();
  3859. $result = $eleDistribution->cancelOrder($orderdistribution_info,$cancel_reason_id,$cancel_reason);
  3860. if($result['status'] == 1){//成功
  3861. $other_data = array();
  3862. if(empty($cancel_reason)){
  3863. $cancel_reason = "商家取消";
  3864. }
  3865. $other_data['cancel_reason'] = $cancel_reason;
  3866. $deduct_fee = round($result['result']['deduction_detail']['deduction_fee']/100,2);
  3867. $other_data['deduct_fee'] = $deduct_fee+$orderdistribution_info['deduct_fee'];
  3868. $other_data['now_deduct_fee'] = $deduct_fee;
  3869. D('Seller/Order')->do_cancel_thirth_delivery_order($order_id,$data_type,$other_data);
  3870. $shipping_money = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id ) )->find();
  3871. D('Seller/Supply')->thirth_cancel_supply_commission($order_id,$shipping_money["shipping_money"]);
  3872. show_json(1);
  3873. }else{//失败
  3874. show_json(0, array('msg' => $result['code'].':'.$result['message'] ) );
  3875. }
  3876. }
  3877. }else{
  3878. show_json(0, array('msg' => '配送订单无法取消' ) );
  3879. }
  3880. }
  3881. /**
  3882. * 达达平台模拟取货
  3883. */
  3884. public function orderFetch(){
  3885. $_GPC = I('request.');
  3886. $order_sn = $_GPC['order_sn'];
  3887. $type = $_GPC['type'];
  3888. $imdada = new \Lib\Localtown\Imdada();
  3889. if($type == 1){
  3890. $imdada->orderFetch($order_sn);//模拟取货
  3891. }else if($type == 2){
  3892. $imdada->orderFinish($order_sn);//完成订单
  3893. }else if($type == 3){
  3894. $imdada->orderCancel($order_sn);//取消订单
  3895. }else if($type == 4){
  3896. $imdada->orderAbnormal($order_sn);//异常妥投物品返还中
  3897. }
  3898. }
  3899. public function third_delivery_log_list(){
  3900. $order_id = I('request.order_id','');
  3901. $orderdistribution_info = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' =>$order_id) )->find();
  3902. $distribution_type = $orderdistribution_info['third_distribution_type'];
  3903. $log_list = M('lionfish_comshop_orderdistribution_thirth_log')->where( array('order_id' =>$order_id,'third_distribution_type'=>$distribution_type) )->order('addtime desc')->select();
  3904. $third_name = "";
  3905. if($distribution_type == 'imdada'){
  3906. $third_name = '达达平台';
  3907. }else if($distribution_type == 'sf'){
  3908. $third_name = '顺丰同城';
  3909. }else if($distribution_type == 'make'){
  3910. $third_name = '码科配送';
  3911. }else if($distribution_type == 'uupt'){
  3912. $third_name = 'UU跑腿';
  3913. }else if($distribution_type == 'dianwoda'){
  3914. $third_name = '点我达';
  3915. }
  3916. $this->third_name = $third_name;
  3917. $this->log_list = $log_list;
  3918. $this->orderdistribution_info = $orderdistribution_info;
  3919. $this->display();
  3920. }
  3921. //end
  3922. /**
  3923. * 订单核销
  3924. */
  3925. public function order_hexiao()
  3926. {
  3927. $opdata = $this->check_order_data();
  3928. extract($opdata);
  3929. if( $item['delivery'] == 'hexiao' )
  3930. {
  3931. D('Seller/Order')->hexiao_all_orders($item['order_id']);
  3932. }
  3933. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  3934. }
  3935. /**
  3936. * 商品按订单核销
  3937. */
  3938. public function order_goods_hexiao(){
  3939. $opdata = $this->check_order_data();
  3940. extract($opdata);
  3941. $order_goods_id = I('request.order_goods_id','');
  3942. $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id, 'order_goods_id' => $order_goods_id) )->find();
  3943. if (empty($order_hexiao_info)) {
  3944. show_json(0, '未找到核销订单!');
  3945. }
  3946. D('Seller/Order')->hexiao_order_goods($order_hexiao_info,0);
  3947. D('Seller/Order')->hexiao_finished($id,'后台确认使用,订单完成');
  3948. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  3949. }
  3950. /**
  3951. * 查看核销记录
  3952. */
  3953. public function view_hexiao_history(){
  3954. $opdata = $this->get_goods_saleshexiao();
  3955. extract($opdata);
  3956. $data = D('Seller/Order')->get_goods_hexiao_record();
  3957. $this->order_hexiao_info = $order_hexiao_info;
  3958. $this->hx_list = $data['hx_list'];
  3959. $this->display("hexiao_history");
  3960. }
  3961. /**
  3962. * 按次数核销商品
  3963. */
  3964. public function hexiao_times(){
  3965. $opdata = $this->get_goods_saleshexiao();
  3966. extract($opdata);
  3967. $data = D('Seller/Order')->get_goods_hexiao_record();
  3968. $this->order_hexiao_info = $order_hexiao_info;
  3969. $this->hx_list = $data['hx_list'];
  3970. $this->hx_count = $data['hx_count'];
  3971. $this->display();
  3972. }
  3973. /**
  3974. * 获取商品核销信息
  3975. * @return
  3976. */
  3977. public function get_goods_saleshexiao(){
  3978. $opdata = $this->check_order_data();
  3979. extract($opdata);
  3980. $order_goods_id = I('request.order_goods_id','');
  3981. $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' => $id, 'order_goods_id' => $order_goods_id) )->find();
  3982. if (empty($order_hexiao_info)) {
  3983. show_json(0, '未找到核销订单!');
  3984. }
  3985. $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();
  3986. $order_hexiao_info['goods_id'] = $order_goods_info['goods_id'];
  3987. $order_hexiao_info['goods_name'] = $order_goods_info['goods_name'];
  3988. $order_hexiao_info['goods_images'] = tomedia($order_goods_info['goods_images']);
  3989. $order_hexiao_info['quantity'] = $order_goods_info['quantity'];
  3990. return array('order_hexiao_info' => $order_hexiao_info);
  3991. }
  3992. /**
  3993. * 核销商品使用
  3994. */
  3995. public function hexiao_goods(){
  3996. $hx_id = I('request.hx_id','');
  3997. $hx_count = I('request.hx_count','');
  3998. if(empty($hx_id)){
  3999. show_json(0, '核销商品数据错误!');
  4000. }
  4001. if(empty($hx_count)){
  4002. show_json(0, '核销商品数量错误!');
  4003. }
  4004. $order_hexiao_info = M('lionfish_comshop_order_goods_saleshexiao')->where( array('id' => $hx_id) )->find();
  4005. if (empty($order_hexiao_info)) {
  4006. show_json(0, '未找到核销订单!');
  4007. }
  4008. D('Seller/Order')->hexiao_order_goods($order_hexiao_info,$hx_count);
  4009. D('Seller/Order')->hexiao_finished($order_hexiao_info['order_id'],'后台确认使用,订单完成');
  4010. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  4011. }
  4012. /**
  4013. * 查看商品指定核销信息
  4014. */
  4015. public function hexiao_goods_assign_salesroom(){
  4016. $goods_id = I('request.goods_id','');
  4017. $order_goods_id = I('request.order_goods_id','');
  4018. if(empty($goods_id)){
  4019. show_json(0, '商品信息错误!');
  4020. }
  4021. if(empty($order_goods_id)){
  4022. show_json(0, '核销商品信息错误!');
  4023. }
  4024. $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();
  4025. $goods_salesroom_info = D('Seller/Order')->get_goods_assign_salesroom($goods_id);
  4026. $this->salesroom_list = $goods_salesroom_info['salesroom_list'];
  4027. $this->smember_list = $goods_salesroom_info['smember_list'];
  4028. $this->goods_info = $order_goods_info;
  4029. $this->display();
  4030. }
  4031. public function checkLocalTownOrderCanRefund($item){
  4032. if($item['delivery'] == 'localtown_delivery'){//同城配送订单
  4033. if($item['order_status_id'] == 4){//已发货不能退款
  4034. return false;
  4035. }else{
  4036. return true;
  4037. }
  4038. }else{
  4039. return true;
  4040. }
  4041. }
  4042. }
  4043. ?>