GoodsController.class.php 154 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class GoodsController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->breadcrumb1='商品管理';
  19. $this->breadcrumb2='普通商品信息';
  20. $this->sellerid = SELLERUID;
  21. }
  22. public function index(){
  23. $pindex = I('get.page', 1);
  24. $psize = 20;
  25. $starttime_arr = I('get.time');
  26. $starttime = isset($starttime_arr['start']) ? strtotime($starttime_arr['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  27. $endtime = isset($starttime_arr['end']) ? strtotime($starttime_arr['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  28. $sort_starttime = I('get.sort_starttime');
  29. $sort_endtime = I('get.sort_endtime');
  30. if( isset($sort_starttime) && $sort_starttime > 0 )
  31. {
  32. $starttime = $sort_starttime;
  33. }
  34. if( isset($sort_endtime) && $sort_endtime > 0 )
  35. {
  36. $endtime = $sort_endtime;
  37. }
  38. $this->starttime = $starttime;
  39. $this->endtime = $endtime;
  40. $searchtime = I('get.searchtime','');
  41. $this->searchtime = $searchtime;
  42. $shop_data = array();
  43. $type = I('get.type','all');
  44. $goods_type = I('get.goods_type', 'normal');
  45. //---begin
  46. $count_common_where ="";
  47. if (defined('ROLE') && ROLE == 'agenter' ) {
  48. $supper_info = get_agent_logininfo();
  49. $supper_goods_list = M('lionfish_comshop_good_common')->field('goods_id')->where( array('supply_id' =>$supper_info['id'] ) )->select();
  50. $gids_list = array();
  51. foreach($supper_goods_list as $vv)
  52. {
  53. $gids_list[] = $vv['goods_id'];
  54. }
  55. if( !empty($gids_list) )
  56. {
  57. $count_common_where = " and id in ( ".implode(',', $gids_list )." )";
  58. }else{
  59. $count_common_where = " and id in (0)";
  60. }
  61. }
  62. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  63. $goods_stock_notice = intval($goods_stock_notice);
  64. if( empty($goods_stock_notice) )
  65. {
  66. $goods_stock_notice = 0;
  67. }
  68. if($goods_type != 'normal' && $goods_type == 'presale')
  69. {
  70. $all_count = D('Seller/Goods')->get_goods_count(" and type = 'presale' {$count_common_where}");//全部商品数量
  71. $onsale_count = D('Seller/Goods')->get_goods_count(" and grounding = 1 and type = 'presale' {$count_common_where}");//出售中商品数量
  72. $getdown_count = D('Seller/Goods')->get_goods_count(" and grounding = 0 and type = 'presale' {$count_common_where}");//已下架商品数量
  73. $warehouse_count = D('Seller/Goods')->get_goods_count(" and grounding = 2 and type = 'presale' {$count_common_where}");//仓库商品数量
  74. $recycle_count = D('Seller/Goods')->get_goods_count(" and grounding = 3 and type = 'presale' {$count_common_where}");//回收站商品数量
  75. $waishen_count = D('Seller/Goods')->get_goods_count(" and grounding = 4 and type = 'presale' {$count_common_where}");//审核商品数量
  76. $unsuccshen_count = D('Seller/Goods')->get_goods_count(" and grounding = 5 and type = 'presale' {$count_common_where}");//拒绝审核商品数量
  77. $stock_notice_count = D('Admin/Goods')->get_goods_count(" and grounding = 1 and total<= {$goods_stock_notice} and type = 'presale' {$count_common_where} ");//回收站商品数量
  78. }
  79. else if($goods_type != 'normal' && $goods_type == 'virtualcard')
  80. {
  81. //礼品卡
  82. $all_count = D('Seller/Goods')->get_goods_count(" and type = 'virtualcard' {$count_common_where}");//全部商品数量
  83. $onsale_count = D('Seller/Goods')->get_goods_count(" and grounding = 1 and type = 'virtualcard' {$count_common_where}");//出售中商品数量
  84. $getdown_count = D('Seller/Goods')->get_goods_count(" and grounding = 0 and type = 'virtualcard' {$count_common_where}");//已下架商品数量
  85. $warehouse_count = D('Seller/Goods')->get_goods_count(" and grounding = 2 and type = 'virtualcard' {$count_common_where}");//仓库商品数量
  86. $recycle_count = D('Seller/Goods')->get_goods_count(" and grounding = 3 and type = 'virtualcard' {$count_common_where}");//回收站商品数量
  87. $waishen_count = D('Seller/Goods')->get_goods_count(" and grounding = 4 and type = 'virtualcard' {$count_common_where}");//审核商品数量
  88. $unsuccshen_count = D('Seller/Goods')->get_goods_count(" and grounding = 5 and type = 'virtualcard' {$count_common_where}");//拒绝审核商品数量
  89. $stock_notice_count = D('Admin/Goods')->get_goods_count(" and grounding = 1 and total<= {$goods_stock_notice} and type = 'virtualcard' {$count_common_where} ");//回收站商品数量
  90. }
  91. else{
  92. $all_count = D('Seller/Goods')->get_goods_count(" and type = 'normal' {$count_common_where}");//全部商品数量
  93. $onsale_count = D('Seller/Goods')->get_goods_count(" and grounding = 1 and type = 'normal' {$count_common_where}");//出售中商品数量
  94. $getdown_count = D('Seller/Goods')->get_goods_count(" and grounding = 0 and type = 'normal' {$count_common_where}");//已下架商品数量
  95. $warehouse_count = D('Seller/Goods')->get_goods_count(" and grounding = 2 and type = 'normal' {$count_common_where}");//仓库商品数量
  96. $recycle_count = D('Seller/Goods')->get_goods_count(" and grounding = 3 and type = 'normal' {$count_common_where}");//回收站商品数量
  97. $waishen_count = D('Seller/Goods')->get_goods_count(" and grounding = 4 and type = 'normal' {$count_common_where}");//审核商品数量
  98. $unsuccshen_count = D('Seller/Goods')->get_goods_count(" and grounding = 5 and type = 'normal' {$count_common_where}");//拒绝审核商品数量
  99. $stock_notice_count = D('Admin/Goods')->get_goods_count(" and grounding = 1 and total<= {$goods_stock_notice} and type = 'normal' {$count_common_where} ");//回收站商品数量
  100. }
  101. $this->assign('waishen_count',$waishen_count);
  102. $this->assign('unsuccshen_count',$unsuccshen_count);
  103. //goods_stock_notice
  104. //grounding 1
  105. //type all 全部
  106. //saleon 1 出售中
  107. //getdown 0 已下架
  108. //warehouse 2 仓库中
  109. //recycle 3 回收站
  110. $psize = 20;
  111. $condition = ' WHERE g.type = "normal" ';
  112. //预售
  113. if($goods_type != 'normal' && $goods_type == 'presale')
  114. {
  115. $condition = ' WHERE g.type = "presale" ';
  116. }else if( $goods_type != 'normal' && $goods_type == 'virtualcard' )
  117. {
  118. $condition = ' WHERE g.type = "virtualcard" ';
  119. }
  120. $sqlcondition = "";
  121. if( !empty($type) && $type != 'all')
  122. {
  123. switch($type)
  124. {
  125. case 'saleon':
  126. $condition .= " and g.grounding = 1";
  127. break;
  128. case 'getdown':
  129. $condition .= " and g.grounding = 0";
  130. break;
  131. case 'warehouse':
  132. $condition .= " and g.grounding = 2";
  133. break;
  134. case 'wait_shen':
  135. $condition .= " and g.grounding = 4";
  136. break;
  137. case 'refuse':
  138. $condition .= " and g.grounding = 5";
  139. break;
  140. case 'recycle':
  141. $condition .= " and g.grounding = 3";
  142. break;
  143. case 'stock_notice':
  144. $condition .= " and g.grounding = 1 and g.total<= {$goods_stock_notice} ";
  145. break;
  146. }
  147. }else{
  148. $condition .= " and g.grounding != 3 ";
  149. }
  150. $keyword = I('get.keyword','','addslashes');
  151. $keyword2 = stripslashes($keyword);
  152. $this->keyword = $keyword2;
  153. if (!(empty($keyword))) {
  154. $condition .= " AND (g.`id` = '{$keyword}' or g.`goodsname` LIKE '%{$keyword}%' or g.`codes` LIKE '%{$keyword}%' ) ";
  155. }
  156. if (defined('ROLE') && ROLE == 'agenter' )
  157. {
  158. $supper_info = get_agent_logininfo();
  159. $sqlcondition .= ' , ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm ';
  160. $condition .= ' and gm.goods_id =g.id AND gm.supply_id ='.$supper_info['id'].' ';
  161. }
  162. if( !empty($searchtime) )
  163. {
  164. switch( $searchtime )
  165. {
  166. case 'create':
  167. $condition .= ' AND (gm.begin_time >='.$starttime.' and gm.end_time <= '.$endtime.' )';
  168. if (!defined('ROLE') && ROLE != 'agenter' )
  169. {
  170. $sqlcondition .= ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm on gm.goods_id = g.id ';
  171. }
  172. break;
  173. }
  174. }
  175. $cate = I('get.cate', '');
  176. $this->cate = $cate;
  177. if( !empty($cate) )
  178. {
  179. $cat_ids = D('Seller/GoodsCategory')->getChildCategorys($cate,'id');
  180. $cate_list = M('lionfish_comshop_goods_to_category')->field('goods_id')->where(array('cate_id' => array('in', $cat_ids)))->select();
  181. $catids_arr = array();
  182. foreach($cate_list as $val)
  183. {
  184. $catids_arr[] = $val['goods_id'];
  185. }
  186. if( !empty($catids_arr) )
  187. {
  188. $catids_str = implode(',', $catids_arr);
  189. $condition .= ' and g.id in ('.$catids_str.')';
  190. }else{
  191. $condition .= " and 1=0 ";
  192. }
  193. }
  194. $sql = 'SELECT COUNT(g.id) as count FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition. $condition ;
  195. $total_arr = M()->query($sql);
  196. $total = $total_arr[0]['count'];
  197. //'sortby' =>$sortby,'sortfield' => 'day_salescount',
  198. $sortby = I('get.sortby');
  199. $sortfield = I('get.sortfield');
  200. $this->sortfield = $sortfield;
  201. $sortby = (!empty($sortby) ? ($sortby== 'asc' ?'desc':'asc') : ( !empty($sortfield) ? 'desc':'' ) );
  202. $this->sortby = $sortby;
  203. $pager = pagination2($total, $pindex, $psize);
  204. if (!(empty($total))) {
  205. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  206. if( empty($index_sort_method) || $index_sort_method == 0 )
  207. {
  208. $sort_way = 'g.istop DESC, g.settoptime DESC, g.`id` DESC';
  209. if( !empty($sortfield) )
  210. {
  211. $sort_way = ' g.'.$sortfield.' '.$sortby.' , '.$sort_way;
  212. }
  213. $sql = 'SELECT g.* FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition . $condition . '
  214. ORDER BY '.$sort_way.' ';
  215. }else{
  216. $sort_way = 'g.index_sort DESC, g.`id` DESC';
  217. if( !empty($sortfield) )
  218. {
  219. $sort_way = ' g.'.$sortfield.' '.$sortby.' ,'.$sort_way;
  220. }
  221. $sql = 'SELECT g.* FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition . $condition . '
  222. ORDER BY '.$sort_way.' ';
  223. }
  224. if(I('export') != 1) { // 如果导出excel 就显示全部
  225. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  226. }
  227. //$sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  228. $list = M()->query($sql);
  229. $open_redis_server = D('Home/Front')->get_config_by_name('open_redis_server');
  230. if( isset($open_redis_server) && $open_redis_server >0 )
  231. {
  232. $open_redis_server = 1;
  233. }else{
  234. $open_redis_server = 0;
  235. }
  236. $this->open_redis_server = $open_redis_server;
  237. foreach ($list as $key => &$value ) {
  238. $price_arr = D('Home/pingoods')->get_goods_price($value['id'], -888 );
  239. $value['codes'] = "\t".$value['codes']."\t";
  240. $value['price_arr'] = $price_arr;
  241. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $value['id']) )->order('id asc')->find();
  242. if( empty($thumb['thumb']) )
  243. {
  244. $value['thumb'] = $thumb['image'];
  245. }else{
  246. $value['thumb'] = $thumb['thumb'];
  247. }
  248. //is_take_fullreduction print_sub_title
  249. $gd_common = M('lionfish_comshop_good_common')->field('is_take_fullreduction,supply_id,is_only_distribution,is_spike_buy,is_only_express,is_only_hexiao,print_sub_title')->where( array('goods_id' => $value['id']) )->find();
  250. //print_sub_title
  251. $value['print_sub_title'] = $gd_common['print_sub_title'];
  252. //判断是否开启redis
  253. if( $open_redis_server == 1 )
  254. {
  255. $value['redis_total'] = D('Seller/Redisorder')->get_goods_total_quantity( $value['id'] );
  256. }
  257. $value['is_take_fullreduction'] = $gd_common['is_take_fullreduction'];
  258. $value['is_only_hexiao'] = $gd_common['is_only_hexiao'];
  259. $value['is_only_distribution'] = $gd_common['is_only_distribution'];
  260. $value['is_spike_buy'] = $gd_common['is_spike_buy'];
  261. $value['is_only_express'] = $gd_common['is_only_express'];
  262. $value['supply_name'] = '';
  263. $value['supply_type'] = '0';
  264. if( empty($gd_common['supply_id']) || $gd_common['supply_id'] ==0 )
  265. {
  266. $value['supply_id'] = 0;
  267. }else{
  268. $value['supply_id'] = $gd_common['supply_id'];
  269. $sub_info = M('lionfish_comshop_supply')->field('name,type')->where( array('id' => $gd_common['supply_id'] ) )->find();
  270. $value['supply_name'] = $sub_info['name'];
  271. $value['supply_type'] = $sub_info['type'];
  272. }
  273. $categorys = M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $value['id']) )->order('id asc')->select();
  274. $value['cate'] = $categorys;
  275. $time_info = D('home/front')->get_goods_common_field($value['id'] , 'begin_time,end_time');
  276. $value['begin_time'] = $time_info['begin_time'];
  277. $value['end_time'] = $time_info['end_time'];
  278. //团长数量
  279. $head_count = 0;
  280. if( $value['is_all_sale'] == 1 )
  281. {
  282. $head_count = M('lionfish_community_head')->count();
  283. }else{
  284. $head_count = M('lionfish_community_head_goods')->where( array('goods_id' => $value['id'] ) )->count();
  285. }
  286. $value['head_count'] = $head_count;
  287. $value['option'] = [];
  288. if(I('get.export') > 0) {// 商品列表到处excel时要导出规格
  289. $value['option'] = M('lionfish_comshop_goods_option_item_value')->where('goods_id = "'.$value['id'].'"')->field('id,title,productprice,marketprice,card_price,stock,title,goodssn,costprice,weight')->select();
  290. if($value['option'] === null){
  291. $value['option'] = [];
  292. }
  293. foreach($categorys as $categorysKey => $categorysVal){
  294. $categorysInfo = M('lionfish_comshop_goods_category')->where( array('id' => $categorysVal['cate_id']) )->find();
  295. $value['cate'.($categorysKey+1).'_id'] = $categorysVal['cate_id'];
  296. $value['cate'.($categorysKey+1).'_name'] = $categorysInfo['name'];
  297. }
  298. $goodsCommon = M('lionfish_comshop_good_common')->where('goods_id = "'.$value['id'].'"')->field('is_spike_buy,is_new_buy,one_limit_count,oneday_limit_count,total_limit_count,begin_time,end_time')->find();
  299. $value['oneday_limit_count'] = $goodsCommon['oneday_limit_count'];
  300. $value['one_limit_count'] = $goodsCommon['one_limit_count'];
  301. $value['total_limit_count'] = $goodsCommon['total_limit_count'];
  302. $value['is_spike_buy'] = $goodsCommon['is_spike_buy'];
  303. $value['is_new_buy'] = $goodsCommon['is_new_buy'];
  304. $value['pin_begin_time'] = date('Y-m-d H:i:s',$goodsCommon['begin_time']);
  305. $value['pin_end_time'] = date('Y-m-d H:i:s',$goodsCommon['end_time']);
  306. $goodsPin = M('lionfish_comshop_good_pin')->where('goods_id = "'.$value['id'].'"')->field('begin_time,end_time')->find();
  307. if($goodsPin){
  308. $value['pin_begin_time'] = date('Y-m-d H:i:s',$goodsPin['begin_time']);
  309. $value['pin_end_time'] = date('Y-m-d H:i:s',$goodsPin['end_time']);
  310. }
  311. if($value['is_all_sale'] == 1){
  312. $value['is_all_sale_str'] = '[所有团长'.$head_count.']';
  313. }else if($head_count == 0){
  314. $value['is_all_sale_str'] = '[无团长0]';
  315. }else if($head_count > 0){
  316. $value['is_all_sale_str'] = '[部分团长'.$head_count.']';
  317. }
  318. }
  319. }
  320. }
  321. unset($value);
  322. $categorys = D('Seller/GoodsCategory')->getFullCategory(true);
  323. $category = array();
  324. foreach ($categorys as $cate ) {
  325. $category[$cate['id']] = $cate;
  326. }
  327. $this->category =$category;
  328. $this->type = $type;
  329. $this->all_count = $all_count;
  330. $this->onsale_count = $onsale_count;
  331. $this->getdown_count = $getdown_count;
  332. $this->warehouse_count = $warehouse_count;
  333. $this->recycle_count = $recycle_count;
  334. $this->stock_notice_count = $stock_notice_count;
  335. $this->assign('list',$list);// 赋值数据集
  336. $this->assign('pager',$pager);// 赋值分页输出
  337. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  338. $this->assign('is_open_fullreduction',$is_open_fullreduction);
  339. //供应商同城配送 0关 1开
  340. $supply_is_open_localtown_distribution = D('Home/Front')->get_config_by_name('supply_is_open_localtown_distribution');
  341. $this->assign('supply_is_open_localtown_distribution',$supply_is_open_localtown_distribution);
  342. //总后台同城配送 0关 1开
  343. $isopen_localtown_delivery = D('Home/Front')->get_config_by_name('isopen_localtown_delivery');
  344. $this->assign('isopen_localtown_delivery',$isopen_localtown_delivery);
  345. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  346. if( empty($index_sort_method) || $index_sort_method == 0 )
  347. {
  348. $index_sort_method = 0;
  349. }
  350. $this->index_sort_method = $index_sort_method;
  351. //---
  352. $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
  353. $supply_edit_goods_shenhe = D('Home/Front')->get_config_by_name('supply_edit_goods_shenhe');
  354. if(empty($supply_add_goods_shenhe))
  355. {
  356. $supply_add_goods_shenhe = 0;
  357. }
  358. if(empty($supply_edit_goods_shenhe))
  359. {
  360. $supply_edit_goods_shenhe = 0;
  361. }
  362. $is_open_shenhe = 0;
  363. if($supply_add_goods_shenhe ==1 || $supply_edit_goods_shenhe == 1)
  364. {
  365. $is_open_shenhe = 1;
  366. }
  367. $this->supply_add_goods_shenhe = $supply_add_goods_shenhe;
  368. $this->supply_edit_goods_shenhe = $supply_edit_goods_shenhe;
  369. $this->is_open_shenhe = $is_open_shenhe;
  370. //--
  371. //团长分组
  372. $group_default_list = array(
  373. array('id' => 'default', 'groupname' => '默认分组')
  374. );
  375. $group_list = M('lionfish_community_head_group')->field('id,groupname')->order('id asc')->select();
  376. $group_list = array_merge($group_default_list, $group_list);
  377. $this->group_list = $group_list;
  378. $config_data = D('Seller/Config')->get_all_config();
  379. $is_index = true;
  380. $is_top = true;
  381. $is_updown = true;
  382. $is_fullreduce = true;
  383. $is_vir_count = true;
  384. $is_newbuy = true;
  385. $is_goodsspike = true;
  386. $is_distributionsale = true;
  387. $is_supply_add_goods_shenhe = true;
  388. if (defined('ROLE') && ROLE == 'agenter' )
  389. {
  390. $is_fullreduce = false;
  391. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  392. {
  393. $is_index = false;
  394. }
  395. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  396. {
  397. $is_top = false;
  398. }
  399. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  400. {
  401. $is_updown = false;
  402. }
  403. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  404. {
  405. $is_vir_count = false;
  406. }
  407. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  408. {
  409. $is_newbuy = false;
  410. }
  411. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  412. {
  413. $is_goodsspike = false;
  414. }
  415. if( isset($config_data['supply_can_distribution_sale']) && $config_data['supply_can_distribution_sale'] == 2 )
  416. {
  417. $is_distributionsale = false;
  418. }
  419. if( isset($config_data['supply_add_goods_shenhe']) && $config_data['supply_add_goods_shenhe'] == 0 )
  420. {
  421. $is_supply_add_goods_shenhe = false;
  422. }
  423. }
  424. $seckill_is_open = D('Home/Front')->get_config_by_name('seckill_is_open');
  425. $this->seckill_is_open = $seckill_is_open;
  426. if(I('get.export') > 0) {// 商品列表到处excel
  427. $this->goods_listexcel($list);
  428. }
  429. $this->config_data = $config_data;
  430. $this->is_index = $is_index;
  431. $this->is_top = $is_top;
  432. $this->is_updown = $is_updown;
  433. $this->is_fullreduce = $is_fullreduce;
  434. $this->is_vir_count = $is_vir_count;
  435. $this->is_newbuy = $is_newbuy;
  436. $this->is_goodsspike = $is_goodsspike;
  437. $this->is_distributionsale = $is_distributionsale;
  438. $this->is_supply_add_goods_shenhe = $is_supply_add_goods_shenhe;
  439. $this->display();
  440. }
  441. /**
  442. * 商品列表到处excel
  443. * @author 刘鑫芮 2020-03-02
  444. * @param $list 商品列表集合数据 全部-根据where 条件搜索的
  445. * */
  446. public function goods_listexcel($list) {
  447. // dump($list);die;
  448. $printList = $list;
  449. foreach($list as $key => $value) {
  450. $printList[$key] = array(
  451. 'id' => $value['id']
  452. );
  453. }
  454. $columns = array(
  455. array(
  456. 'title' => '商品ID(禁止修改)',
  457. 'field' => 'id',
  458. 'width' => 24
  459. ) ,
  460. array(
  461. 'title' => '商品名称',
  462. 'field' => 'goodsname',
  463. 'width' => 24
  464. ) ,
  465. array(
  466. 'title' => '商品简称',
  467. 'field' => 'print_sub_title',
  468. 'width' => 24
  469. ) ,
  470. array(
  471. 'title' => '商品编码',
  472. 'field' => 'codes',
  473. 'width' => 24
  474. ) ,
  475. array(
  476. 'title' => '一级分类ID',
  477. 'field' => 'cate1_id',
  478. 'width' => 24
  479. ) ,
  480. array(
  481. 'title' => '一级分类名称',
  482. 'field' => 'cate1_name',
  483. 'width' => 24
  484. ) ,
  485. array(
  486. 'title' => '二级分类ID',
  487. 'field' => 'cate2_id',
  488. 'width' => 24
  489. ) ,
  490. array(
  491. 'title' => '二级分类名称',
  492. 'field' => 'cate2_name',
  493. 'width' => 24
  494. ) ,
  495. array(
  496. 'title' => '商品价格',
  497. 'field' => 'price',
  498. 'width' => 24
  499. ) ,
  500. array(
  501. 'title' => '商品成本价',
  502. 'field' => 'costprice',
  503. 'width' => 24
  504. ) ,
  505. array(
  506. 'title' => '会员卡价格',
  507. 'field' => 'card_price',
  508. 'width' => 24
  509. ) ,
  510. array(
  511. 'title' => '商品原价',
  512. 'field' => 'productprice',
  513. 'width' => 24
  514. ) ,
  515. array(
  516. 'title' => '商品库存',
  517. 'field' => 'total',
  518. 'width' => 24
  519. ) ,
  520. array(
  521. 'title' => '每日销量',
  522. 'field' => 'day_salescount',
  523. 'width' => 24
  524. ) ,
  525. array(
  526. 'title' => '总销量',
  527. 'field' => 'seller_count',
  528. 'width' => 24
  529. ) ,
  530. array(
  531. 'title' => '1上架/0下架',
  532. 'field' => 'grounding',
  533. 'width' => 24
  534. ) ,
  535. array(
  536. 'title' => '首页推荐(0:取消/1:是)',
  537. 'field' => 'is_index_show',
  538. 'width' => 24
  539. ) ,
  540. array(
  541. 'title' => '限时秒杀(0:取消/1:是)',
  542. 'field' => 'is_spike_buy',
  543. 'width' => 24
  544. ) ,
  545. array(
  546. 'title' => '所有团长',
  547. 'field' => 'is_all_sale_str',
  548. 'width' => 24
  549. ) ,
  550. array(
  551. 'title' => '新人专享',
  552. 'field' => 'is_new_buy',
  553. 'width' => 24
  554. ) ,
  555. array(
  556. 'title' => '商品排序(数字)',
  557. 'field' => 'index_sort',
  558. 'width' => 24
  559. ) ,
  560. array(
  561. 'title' => '每天限购',
  562. 'field' => 'oneday_limit_count',
  563. 'width' => 24
  564. ) ,
  565. array(
  566. 'title' => '单次限购',
  567. 'field' => 'one_limit_count',
  568. 'width' => 24
  569. ) ,
  570. array(
  571. 'title' => '历史限购',
  572. 'field' => 'total_limit_count',
  573. 'width' => 24
  574. ) ,
  575. array(
  576. 'title' => '开始时间',
  577. 'field' => 'pin_begin_time',
  578. 'width' => 24
  579. ) ,
  580. array(
  581. 'title' => '结束时间',
  582. 'field' => 'pin_end_time',
  583. 'width' => 24
  584. ) ,
  585. array(
  586. 'title' => '商品重量(单位:g)',
  587. 'field' => 'weight',
  588. 'width' => 24
  589. ) ,
  590. array(
  591. 'title' => '规格(1:开启/0:关闭)',
  592. 'field' => 'hasoption',
  593. 'width' => 24
  594. ) ,
  595. array(
  596. 'title' => '规格id(禁止修改)',
  597. 'field' => 'option_id',
  598. 'width' => 24
  599. ) ,
  600. array(
  601. 'title' => '规格名称(禁止修改)',
  602. 'field' => 'option_title',
  603. 'width' => 24
  604. ) ,
  605. array(
  606. 'title' => '规格库存',
  607. 'field' => 'option_stock',
  608. 'width' => 24
  609. ) ,
  610. array(
  611. 'title' => '规格现价',
  612. 'field' => 'option_marketprice',
  613. 'width' => 24
  614. ) ,
  615. array(
  616. 'title' => '规格原价',
  617. 'field' => 'option_productprice',
  618. 'width' => 24
  619. ) ,
  620. array(
  621. 'title' => '规格会员价',
  622. 'field' => 'option_card_price',
  623. 'width' => 24
  624. ) ,
  625. array(
  626. 'title' => '规格成本价',
  627. 'field' => 'option_costprice',
  628. 'width' => 24
  629. ) ,
  630. array(
  631. 'title' => '规格编码',
  632. 'field' => 'option_goodssn',
  633. 'width' => 24
  634. ) ,
  635. array(
  636. 'title' => '规格重量(单位:g)',
  637. 'field' => 'option_weight',
  638. 'width' => 24
  639. )
  640. );
  641. sellerLog('导出商品excel', 3);
  642. D('Seller/Excel')->export_goods_list_pi(array(
  643. 'title' => '商品列表',
  644. 'columns' => $columns
  645. ), $list);
  646. }
  647. public function edittags()
  648. {
  649. $_GPC = I('request.');
  650. $id = intval($_GPC['id']);
  651. if (!empty($id)) {
  652. $item = M('lionfish_comshop_goods_tags')->field('id,type,tagname,tagcontent,state,sort_order')->where( array('id' =>$id ) )->find();
  653. if (json_decode($item['tagcontent'], true)) {
  654. $labelname = json_decode($item['tagcontent'], true);
  655. }
  656. else {
  657. $labelname = unserialize($item['tagcontent']);
  658. }
  659. $this->item = $item;
  660. $this->labelname = $labelname;
  661. }
  662. if (IS_POST) {
  663. $data = $_GPC['data'];
  664. D('Seller/Tags')->update($data);
  665. show_json(1, array('url' => U('goods/goodstag') ));
  666. }
  667. $this->display('Goods/addtags');
  668. }
  669. public function addtags()
  670. {
  671. $_GPC = I('request.');
  672. if (IS_POST) {
  673. $data = $_GPC['data'];
  674. D('Seller/Tags')->update($data);
  675. show_json(1, array('url' => U('goods/goodstag')));
  676. }
  677. $this->display();
  678. }
  679. public function show_logs()
  680. {
  681. $goods_id = I('get.goods_id');
  682. D('Seller/Redisorder')->show_logs($goods_id);
  683. }
  684. public function tagsstate()
  685. {
  686. $_GPC = I('request.');
  687. $id = intval($_GPC['id']);
  688. if (empty($id)) {
  689. $id = $_GPC['ids'];
  690. }
  691. if( is_array($id) )
  692. {
  693. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  694. }else{
  695. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  696. }
  697. if (empty($item)) {
  698. $item = array();
  699. }
  700. foreach ($items as $item) {
  701. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->save( array('state' => intval($_GPC['state'])) );
  702. D('Seller/Operatelog')->addOperateLog('goods','修改商品标签状态--'.$item['tagname']);
  703. }
  704. show_json(1, array('url' => U('goods/goodstag')));
  705. }
  706. public function deletetags()
  707. {
  708. $_GPC = I('request.');
  709. $id = intval($_GPC['id']);
  710. if (empty($id)) {
  711. $id = $_GPC['ids'];
  712. }
  713. if( is_array($id) )
  714. {
  715. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  716. }else{
  717. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  718. }
  719. //$items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id )) )->select();
  720. if (empty($item)) {
  721. $item = array();
  722. }
  723. foreach ($items as $item) {
  724. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->delete();
  725. D('Seller/Operatelog')->addOperateLog('goods','删除商品标签--'.$item['tagname']);
  726. }
  727. show_json(1, array('url' => U('goods/goodstag')));
  728. }
  729. public function labelquery()
  730. {
  731. $_GPC = I('request.');
  732. $kwd = trim($_GPC['keyword']);
  733. $type = isset($_GPC['type']) ? $_GPC['type'] : 'normal';
  734. $condition = ' and state = 1 and tag_type="'.$type.'" ';
  735. if (!empty($kwd)) {
  736. $condition .= ' AND tagname LIKE "%'.$kwd.'%" ';
  737. }
  738. $labels = M('lionfish_comshop_goods_tags')->field('id,tagname,tagcontent')->where( '1 '. $condition )->order('id desc')->select();
  739. if (empty($labels)) {
  740. $labels = array();
  741. }
  742. $html = '';
  743. foreach ($labels as $key => $value) {
  744. if (json_decode($value['tagcontent'], true)) {
  745. $labels[$key]['tagcontent'] = json_decode($value['tagcontent'], true);
  746. }
  747. else {
  748. $labels[$key]['tagcontent'] = unserialize($value['tagcontent']);
  749. }
  750. $html .= '<nav class="btn btn-default btn-sm choose_dan_link" data-id="'.$value['id'].'" data-json=\''.json_encode(array("id"=>$value["id"],"tagname"=>$value["tagname"])).'\'>';
  751. $html .= $value['tagname'];
  752. $html .= '</nav>';
  753. }
  754. if( isset($_GPC['is_ajax']) )
  755. {
  756. echo json_encode( array('code' => 0, 'html' => $html) );
  757. die();
  758. }
  759. $this->labels = $labels;
  760. $this->display();
  761. }
  762. public function deletecomment()
  763. {
  764. $_GPC = I('request.');
  765. $id = intval($_GPC['id']);
  766. if (empty($id)) {
  767. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  768. }
  769. $items = M()->query('SELECT comment_id FROM ' . C('DB_PREFIX') .
  770. 'lionfish_comshop_order_comment WHERE comment_id in( ' . $id . ' ) ');
  771. if (empty($item)) {
  772. $item = array();
  773. }
  774. foreach ($items as $item) {
  775. M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->delete();
  776. }
  777. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  778. }
  779. public function addvircomment()
  780. {
  781. $_GPC = I('request.');
  782. if (IS_POST) {
  783. $data = $_GPC['data'];
  784. $jia_id = $_GPC['jiaid'];
  785. $goods_id = $_GPC['goods_id'];
  786. if( empty($goods_id) )
  787. {
  788. show_json(0, array('message' => '请选择评价商品!'));
  789. }
  790. if( empty($jia_id) )
  791. {
  792. show_json(0, array('message' => '请选择机器人!'));
  793. }
  794. $goods_info = M('lionfish_comshop_goods')->field('goodsname')->where( array('id' => $goods_id) )->find();
  795. $goods_image = isset($_GPC['goods_image']) && !empty($_GPC['goods_image']) ? $_GPC['goods_image'] : array();
  796. $time = empty($_GPC['time']) ? time() : $_GPC['time'];
  797. $jia_info = M('lionfish_comshop_jiauser')->where( array('id' => $jia_id ) )->find();
  798. $commen_data = array();
  799. $commen_data['order_id'] = 0;
  800. $commen_data['state'] = 1;
  801. $commen_data['type'] = 1;
  802. $commen_data['member_id'] = $jia_id;
  803. $commen_data['avatar'] = $jia_info['avatar'];
  804. $commen_data['user_name'] = $jia_info['username'];
  805. $commen_data['order_num_alias'] = 1;
  806. $commen_data['star'] = $data['star'];
  807. $commen_data['star3'] = $data['star3'];
  808. $commen_data['star2'] = $data['star2'];
  809. $commen_data['is_picture'] = !empty($goods_image) ? 1: 0;
  810. $commen_data['content'] = $data['content'];
  811. $commen_data['images'] = serialize(implode(',', $goods_image));
  812. $image = D('Home/Pingoods')->get_goods_images($goods_id);
  813. $seller_id = 1;
  814. if(!empty($image))
  815. {
  816. $commen_data['goods_image'] = $image['image'];
  817. }else{
  818. $commen_data['goods_image'] = '';
  819. }
  820. $commen_data['goods_id'] = $goods_id;
  821. $commen_data['goods_name'] = $goods_info['goodsname'];
  822. $commen_data['add_time'] = strtotime($time);
  823. M('lionfish_comshop_order_comment')->add($commen_data);
  824. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  825. }
  826. $this->display();
  827. }
  828. public function change_cm()
  829. {
  830. $_GPC = I('request.');
  831. $id = intval($_GPC['id']);
  832. //ids
  833. if (empty($id)) {
  834. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  835. }
  836. if (empty($id)) {
  837. show_json(0, array('message' => '参数错误'));
  838. }
  839. $type = trim($_GPC['type']);
  840. $value = trim($_GPC['value']);
  841. if (!(in_array($type, array('is_take_fullreduction')))) {
  842. show_json(0, array('message' => '参数错误'));
  843. }
  844. $items = M('lionfish_comshop_goods')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  845. foreach ($items as $item ) {
  846. //--
  847. if($type == 'is_take_fullreduction' && $value == 1)
  848. {
  849. $gd_common = M('lionfish_comshop_good_common')->field('supply_id')->where( array('goods_id' => $item['id'] ) )->find();
  850. if( !empty($gd_common['supply_id']) && $gd_common['supply_id'] > 0)
  851. {
  852. $supply_info = M('lionfish_comshop_supply')->field('type')->where( array('id' => $gd_common['supply_id'] ) )->find();
  853. if( !empty($supply_info) && $supply_info['type'] == 1 )
  854. {
  855. continue;
  856. }
  857. }
  858. }
  859. //---
  860. M('lionfish_comshop_good_common')->where( array('goods_id' => $item['id']) )->save( array($type => $value) );
  861. }
  862. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  863. }
  864. public function commentstate()
  865. {
  866. $_GPC = I('request.');
  867. $id = intval($_GPC['id']);
  868. if (empty($id)) {
  869. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  870. }
  871. $items = M('lionfish_comshop_order_comment')->field('comment_id,member_id,is_send_point')->where( "comment_id in ({$id})")->select();
  872. if (empty($item)) {
  873. $item = array();
  874. }
  875. foreach ($items as $item) {
  876. M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->save( array('state' => intval($_GPC['state'])) );
  877. if(intval($_GPC['state']) == 1 && $item['is_send_point'] == 0){
  878. //好评有礼送积分
  879. D('Seller/Order')->sendCommentGift($item['comment_id']);
  880. M('lionfish_comshop_order_comment')->where(array('comment_id'=>$item['comment_id'],'member_id'=>$item['member_id']))->save(array('is_send_point'=>1));
  881. }
  882. }
  883. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  884. }
  885. /**
  886. * 一键设置商品时间
  887. */
  888. public function settime()
  889. {
  890. if (IS_POST) {
  891. $data = I('request.time', array());
  892. $param = array();
  893. $param['goods_same_starttime'] = strtotime(trim($data['start'])) ? strtotime(trim($data['start'])) : time();
  894. $param['goods_same_endtime'] = strtotime(trim($data['end'])) ? strtotime(trim($data['end'])) : time();
  895. $is_samedefault_now = I('request.is_samedefault_now');
  896. $is_sametihuo_time = I('request.is_sametihuo_time');
  897. $pick_up_type = I('request.pick_up_type');
  898. $pick_up_modify = I('request.pick_up_modify');
  899. if( $pick_up_type == 4 )
  900. {
  901. $pick_up_type = 0;
  902. }
  903. $param['is_samedefault_now'] = $is_samedefault_now;
  904. $param['is_sametihuo_time'] = $is_sametihuo_time;
  905. $param['pick_up_type'] = $pick_up_type;
  906. $param['pick_up_modify'] = $pick_up_modify;
  907. // lionfish_comshop_good_common begin_time end_time
  908. D('Seller/Config')->update($param);
  909. $param1 = array();
  910. $param1['begin_time'] = $param['goods_same_starttime'];
  911. $param1['end_time'] = $param['goods_same_endtime'];
  912. //--begin
  913. if (defined('ROLE') && ROLE == 'agenter' )
  914. {
  915. $supper_info = get_agent_logininfo();
  916. if( $is_samedefault_now == 2 )
  917. {
  918. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set end_time = ".$param['goods_same_endtime'].", begin_time=".$param['goods_same_starttime']."
  919. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin") and supply_id='.$supper_info['id'];
  920. M()->execute($sql);
  921. }
  922. if( $is_sametihuo_time == 2 )
  923. {
  924. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set pick_up_type = '".$pick_up_type."', pick_up_modify='".$pick_up_modify."'"
  925. . " where goods_id in (select id from ".C('DB_PREFIX')."lionfish_comshop_goods where `grounding` =1 and type != 'pin' ) and supply_id=".$supper_info['id'];
  926. M()->execute($sql);
  927. }
  928. }else{
  929. //取出所有独立供应商
  930. $all_du_supply = M('lionfish_comshop_supply')->where( array('type' => 1) )->select();
  931. $all_du_sids = array();
  932. if( !empty($all_du_supply) )
  933. {
  934. foreach( $all_du_supply as $val )
  935. {
  936. $all_du_sids[] = $val['id'];
  937. }
  938. }
  939. if( $is_samedefault_now == 1 )
  940. {
  941. //仅平台
  942. $where = "";
  943. if( !empty($all_du_sids) )
  944. {
  945. $where = " and supply_id not in(".implode(',', $all_du_sids ).") ";
  946. }
  947. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set end_time = ".$param['goods_same_endtime'].", begin_time=".$param['goods_same_starttime']."
  948. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin" '.$where.' ) ';
  949. M()->execute($sql);
  950. }else if( $is_samedefault_now == 2 )
  951. {
  952. //所有商品除了拼团
  953. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set end_time = ".$param['goods_same_endtime'].", begin_time=".$param['goods_same_starttime']."
  954. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin") ';
  955. M()->execute($sql);
  956. }
  957. if( $is_sametihuo_time == 1 )
  958. {
  959. //仅平台
  960. $where = "";
  961. if( !empty($all_du_sids) )
  962. {
  963. $where = " and supply_id not in(".implode(',', $all_du_sids ).") ";
  964. }
  965. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set pick_up_type = ".$pick_up_type.", pick_up_modify='".$pick_up_modify."'
  966. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin" '.$where.' ) ';
  967. M()->execute($sql);
  968. }else if( $is_sametihuo_time == 2 )
  969. {
  970. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set pick_up_type = ".$pick_up_type.", pick_up_modify='".$pick_up_modify."'
  971. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin" ) ';
  972. M()->execute($sql);
  973. }
  974. /**
  975. $sql = 'UPDATE '.C('DB_PREFIX'). 'lionfish_comshop_good_pin SET begin_time = '.$param['goods_same_starttime'].
  976. ',end_time='.$param['goods_same_endtime'].' where goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1) ';
  977. M()->execute($sql);
  978. **/
  979. }
  980. D('Seller/Operatelog')->addOperateLog('goods','修改商品设置--统一时间');
  981. //--end
  982. //M('lionfish_comshop_good_common')->where("1")->save($param1);
  983. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  984. }
  985. $data = D('Seller/Config')->get_all_config();
  986. if(empty($data['goods_same_starttime']))
  987. {
  988. $data['goods_same_starttime'] = time();
  989. }
  990. if(empty($data['goods_same_endtime']))
  991. {
  992. $data['goods_same_endtime'] = time()+86400;
  993. }
  994. $this->data = $data;
  995. $this->display();
  996. }
  997. public function addgoods()
  998. {
  999. if (IS_POST) {
  1000. $_GPC = I('request.');
  1001. $type = isset($_GPC['type']) ? $_GPC['type'] : 'normal';
  1002. if (!isset($_GPC['thumbs']) || empty($_GPC['thumbs'])) {
  1003. show_json(0, array('message' => '商品图片必须上传', 'url' => $_SERVER['HTTP_REFERER']));
  1004. die();
  1005. }
  1006. if (!empty($_GPC['has_mb_level_buy'])) {
  1007. foreach ($_GPC['discount'] as $val) {
  1008. if (preg_match("/^(([1-9]\d?)|100)$/", $val)) {
  1009. } else {
  1010. show_json(0, array('message' => '请按照提示设置独立会员等级折扣', 'url' => $_SERVER['HTTP_REFERER']));
  1011. die();
  1012. }
  1013. }
  1014. }
  1015. if ($_GPC['is_only_distribution'] == 1 && !empty($_GPC['supply_id'])) {
  1016. //供应商开启同城
  1017. $sup_isopen_localtown_delivery = D('Home/Front')->get_supply_config_by_name('isopen_localtown_delivery', $_GPC['supply_id']);
  1018. if (empty($sup_isopen_localtown_delivery)) {
  1019. $supply_name = M('lionfish_comshop_supply')->field('shopname,type')->where(array('id' => $_GPC['supply_id']))->find();
  1020. if ($supply_name["type"] == 1) {
  1021. show_json(0, array('message' => '独立供应商(' . $supply_name["shopname"] . ')没有开启同城配送,此商品无法开启同城配送', 'url' => $_SERVER['HTTP_REFERER']));
  1022. die();
  1023. }
  1024. }
  1025. }
  1026. $supply_id = $_GPC['supply_id'];
  1027. if (defined('ROLE') && ROLE == 'agenter') {
  1028. $supper_info = get_agent_logininfo();
  1029. $supply_id = $supper_info['id'];
  1030. }
  1031. if ($_GPC['is_only_hexiao'] == 1) {
  1032. if (!empty($supply_id)) {
  1033. $salesroom_count = M('lionfish_comshop_salesroom')->where(array('supply_id' => $supply_id, 'state' => 1))->count();
  1034. if ($salesroom_count == 0) {
  1035. $supply_name = M('lionfish_comshop_supply')->field('shopname,type')->where(array('id' => $supply_id))->find();
  1036. if ($supply_name["type"] == 1) {
  1037. show_json(0, array('message' => '独立供应商(' . $supply_name["shopname"] . ')没有创建门店信息,此商品无法开启到店核销', 'url' => $_SERVER['HTTP_REFERER']));
  1038. die();
  1039. }
  1040. }
  1041. }
  1042. if ($_GPC['grounding'] == 1) {//上架商品
  1043. if ($_GPC['hx_expire_type'] == 1) {//指定过期时间
  1044. $hx_expire_end_time = $_GPC['hx_expire_end_time'];
  1045. if (strtotime($hx_expire_end_time) < time()) {
  1046. show_json(0, array('message' => '核销过期时间小于当前时间,商品不能上架', 'url' => $_SERVER['HTTP_REFERER']));
  1047. die();
  1048. }
  1049. }
  1050. }
  1051. if ($_GPC['hx_expire_type'] == 1) {//指定过期时间
  1052. if ($_GPC['hx_auto_off'] == 1) {//设置自动下架时间
  1053. if (empty($_GPC['hx_auto_off_time']) || !is_numeric($_GPC['hx_auto_off_time']) || floatval($_GPC['hx_auto_off_time']) <= 0) {
  1054. show_json(0, array('message' => '提前自动下架商品时间不能为空且必须为大于0数字', 'url' => $_SERVER['HTTP_REFERER']));
  1055. die();
  1056. }
  1057. }
  1058. }
  1059. }
  1060. //礼品卡
  1061. if (isset($_GET['goods_type']) && $_GET['goods_type'] == 'virtualcard')
  1062. {
  1063. $type = 'virtualcard';
  1064. $virtual_code_id = I('post.virtual_code_id');
  1065. if( !isset($virtual_code_id) || $virtual_code_id <= 0 )
  1066. {
  1067. show_json(0, array('message' => '礼品卡商品必须关联兑换码' ,'url' => $_SERVER['HTTP_REFERER']) );
  1068. die();
  1069. }
  1070. }
  1071. //预售时间判断
  1072. if( isset($_GET['goods_type']) && $_GET['goods_type'] == 'presale' )
  1073. {
  1074. $type = 'presale';
  1075. //预售时间限制判断
  1076. $time = I('post.time');
  1077. $post_begin_time = strtotime( $time['start'] );
  1078. $post_end_time = strtotime( $time['end'] );
  1079. $presale_ding_time = I('post.presale_ding_time');//定金支付时间
  1080. $presale_ding_time_start = strtotime( $presale_ding_time['start'] ); //开始
  1081. $presale_ding_time_end = strtotime( $presale_ding_time['end'] );//结束
  1082. if($presale_ding_time_start < $post_begin_time )
  1083. {
  1084. show_json(0, array('message' => '预售定金支付开始时间不能小于团购开始时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  1085. die();
  1086. }
  1087. if($presale_ding_time_end > $post_end_time )
  1088. {
  1089. show_json(0, array('message' => '预售定金支付结束时间不能大于团购结束时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  1090. die();
  1091. }
  1092. $presale_sendorder_type = I('post.presale_sendorder_type');
  1093. if($presale_sendorder_type == 1)
  1094. {
  1095. $presale_sendorder_afterday = I('post.presale_sendorder_afterday');
  1096. if( $presale_sendorder_afterday < 1 )
  1097. {
  1098. show_json(0, array('message' => '预售购买后几日发货必须是大于0的整数' ,'url' => $_SERVER['HTTP_REFERER']) );
  1099. die();
  1100. }
  1101. }else if( $presale_sendorder_type == 0 )
  1102. {
  1103. //预计发货时间 必须大于 定金尾款付款时间
  1104. $presale_sendorder_datetime = I('post.presale_sendorder_datetime');
  1105. $presale_sendorder_datetime = strtotime($presale_sendorder_datetime.' 00:00:00');
  1106. if( $presale_sendorder_datetime < $presale_ding_time_start )
  1107. {
  1108. show_json(0, array('message' => '固定发货日期必须大于定金支付开始时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  1109. die();
  1110. }
  1111. }
  1112. }
  1113. //判断预售价格是否合理设置,不是bug价格
  1114. $this->checkPresaleAddGoods();
  1115. D('Seller/Goods')->addgoods($type);
  1116. $http_refer = S('HTTP_REFERER');
  1117. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  1118. sellerLog('添加新增商品', 3);
  1119. show_json(1, array('message' => '添加商品成功!','url' => $http_refer ));
  1120. }
  1121. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  1122. $category = D('Seller/GoodsCategory')->getFullCategory(true, true);
  1123. $this->category = $category;
  1124. $spec_list = D('Seller/Spec')->get_all_spec();
  1125. $this->spec_list = $spec_list;
  1126. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1,'isdefault' =>1) )->order('sort_order desc')->select();
  1127. $this->dispatch_data = $dispatch_data;
  1128. $set = D('Seller/Config')->get_all_config();
  1129. $this->set = $set;
  1130. $commission_level = array();
  1131. $config_data = $set;
  1132. $this->config_data = $config_data;
  1133. $default = array('id' => 'default', 'levelname' => empty($config_data['commission_levelname']) ? '默认等级' : $config_data['commission_levelname'], 'commission1' => $config_data['commission1'], 'commission2' => $config_data['commission2'], 'commission3' => $config_data['commission3']);
  1134. $others = M('lionfish_comshop_commission_level')->order('commission1 asc')->select();
  1135. $commission_level = array_merge(array($default), $others);
  1136. $communityhead_commission = $config_data['default_comunity_money'];
  1137. $this->communityhead_commission = $communityhead_commission;
  1138. //$level['key']
  1139. foreach($commission_level as $key => $val)
  1140. {
  1141. $val['key'] = $val['id'];
  1142. $commission_level[$key] = $val;
  1143. }
  1144. $this->commission_level = $commission_level;
  1145. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  1146. $this->shopset_level = $shopset_level;
  1147. //赠送积分开关
  1148. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  1149. $this->open_buy_send_score = $open_buy_send_score;
  1150. $index_sort_method = empty($set['index_sort_method']) ? 0: $set['index_sort_method'];
  1151. $this->index_sort_method = $index_sort_method;
  1152. $item = array();
  1153. $item['begin_time'] = time();
  1154. $item['community_head_commission'] = $communityhead_commission;
  1155. $item['end_time'] = time() + 86400;
  1156. $item['hexiao_effect_begin_time'] = time();
  1157. $item['hexiao_effect_end_time'] = time() + 86400;
  1158. //预售begin
  1159. if( isset($_GET['goods_type']) && $_GET['goods_type'] == 'presale' )
  1160. {
  1161. $item['presale_ding_time_start'] = time();
  1162. $item['presale_ding_time_end'] = time() + 86400;
  1163. }
  1164. //预售end
  1165. $delivery_type_express = $config_data['delivery_type_express'];
  1166. if( empty($delivery_type_express) )
  1167. {
  1168. $delivery_type_express = 2;
  1169. }
  1170. $this->delivery_type_express = $delivery_type_express;
  1171. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  1172. $this->is_open_fullreduction = $is_open_fullreduction;
  1173. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  1174. $head_commission_levelname = $config_data['head_commission_levelname'];
  1175. $default_comunity_money = $config_data['default_comunity_money'];
  1176. $list_default = array(
  1177. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  1178. );
  1179. $community_head_level = array_merge($list_default, $community_head_level);
  1180. if( !empty($community_head_level) )
  1181. {
  1182. foreach( $community_head_level as $head_level)
  1183. {
  1184. $item['head_level'.$head_level['id']] = $head_level['commission'];
  1185. }
  1186. }
  1187. $this->item = $item;
  1188. $this->community_head_level = $community_head_level;
  1189. $community_money_type = $config_data['community_money_type'];
  1190. $this->community_money_type = $community_money_type;
  1191. $mb_level = M('lionfish_comshop_member_level')->count();
  1192. $this->mb_level = $mb_level;
  1193. $is_open_only_express = $config_data['is_open_only_express'];
  1194. $this->is_open_only_express = $is_open_only_express;
  1195. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  1196. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  1197. //供应商权限begin
  1198. $is_index = true;
  1199. $is_top = true;
  1200. $is_updown = true;
  1201. $is_fullreduce = true;
  1202. $is_vir_count = true;
  1203. $is_newbuy = true;
  1204. $is_goodsspike = true;
  1205. $supply_can_goods_sendscore = true;
  1206. $supply_can_distribution_sale = true ;
  1207. //核销
  1208. $sales_supply_id = 0;
  1209. if (defined('ROLE') && ROLE == 'agenter' )
  1210. {
  1211. $supply_can_goods_sendscore = empty($config_data['supply_can_goods_sendscore']) ? 0: $config_data['supply_can_goods_sendscore'];
  1212. $supply_can_distribution_sale = empty($config_data['supply_can_distribution_sale']) ? 0: $config_data['supply_can_distribution_sale'];
  1213. $is_fullreduce = false;
  1214. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  1215. {
  1216. $is_index = false;
  1217. }
  1218. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  1219. {
  1220. $is_top = false;
  1221. }
  1222. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  1223. {
  1224. $is_updown = false;
  1225. }
  1226. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  1227. {
  1228. $is_vir_count = false;
  1229. }
  1230. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  1231. {
  1232. $is_newbuy = false;
  1233. }
  1234. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  1235. {
  1236. $is_goodsspike = false;
  1237. }
  1238. $sales_supply_id = $supper_info = get_agent_logininfo();
  1239. $sales_supply_id = $supper_info['id'];
  1240. }
  1241. $salesroom_count = M('lionfish_comshop_salesroom')->where(array('supply_id' => $sales_supply_id,'state'=>1))->count();
  1242. if($salesroom_count > 0){
  1243. $this->is_exist_salesroom = 1;
  1244. }
  1245. $is_open_vipcard_buy = $config_data['is_open_vipcard_buy'];
  1246. //供应商权限end
  1247. $this->is_index = $is_index;
  1248. $this->supply_can_goods_sendscore = $supply_can_goods_sendscore;
  1249. $this->supply_can_distribution_sale = $supply_can_distribution_sale;
  1250. $this->is_top = $is_top;
  1251. $this->is_updown = $is_updown;
  1252. $this->is_fullreduce = $is_fullreduce;
  1253. $this->is_vir_count = $is_vir_count;
  1254. $this->is_newbuy = $is_newbuy;
  1255. $this->is_goodsspike = $is_goodsspike;
  1256. $this->is_open_vipcard_buy = $is_open_vipcard_buy;
  1257. $seckill_is_open = $config_data['seckill_is_open'];
  1258. $this->seckill_is_open = $seckill_is_open;
  1259. // $is_head_takegoods
  1260. $is_head_takegoods = isset($config_data['is_head_takegoods']) && $config_data['is_head_takegoods'] == 1 ? 1 : 0;
  1261. $this->is_head_takegoods = $is_head_takegoods;
  1262. //判断是否兑换卡 begin
  1263. if( isset($_GET['goods_type']) && $_GET['goods_type'] == 'virtualcard' )
  1264. {
  1265. //商品选中的兑换编组
  1266. $goods_virtualcode_id = 0;
  1267. $this->goods_virtualcode_id = $goods_virtualcode_id;
  1268. //可用的兑换编组列表
  1269. $virtualcard_code_list = D('Seller/VirtualCard')->getCanUseVirtualcardCodes( );
  1270. $this->virtualcard_code_list = $virtualcard_code_list;
  1271. }
  1272. //end
  1273. $isopen_localtown_delivery = isset($config_data['isopen_localtown_delivery']) && $config_data['isopen_localtown_delivery'] == 1 ? 1 : 0;
  1274. $this->isopen_localtown_delivery = $isopen_localtown_delivery;
  1275. $supply_is_open_localtown_distribution = isset($config_data['supply_is_open_localtown_distribution']) && $config_data['supply_is_open_localtown_distribution'] == 1 ? 1 : 0;
  1276. $this->supply_is_open_localtown_distribution = $supply_is_open_localtown_distribution;
  1277. $this->delivery_type_express = isset($config_data['delivery_type_express']) ? $config_data['delivery_type_express'] : 0;
  1278. //$is_default_levellimit_buy = isset($config_data['is_default_levellimit_buy']) && $config_data['is_default_levellimit_buy'] == 1 ? 1 : 0;
  1279. //$this->is_default_levellimit_buy = $is_default_levellimit_buy;
  1280. //$is_default_vipmember_buy = isset($config_data['is_default_vipmember_buy']) && $config_data['is_default_vipmember_buy'] == 1 ? 1 : 0;
  1281. //$this->is_default_vipmember_buy = $is_default_vipmember_buy;
  1282. //获取会员等级列表
  1283. $member_level_ist = M('lionfish_comshop_member_level')->order('id asc')->select();
  1284. $this->member_level_ist = $member_level_ist;
  1285. $this->display();
  1286. }
  1287. public function checkPresaleAddGoods()
  1288. {
  1289. if( isset($_POST['presale_type']) )
  1290. {
  1291. $presale_type = I('post.presale_type', 0);//预售方式 0 定金
  1292. $presale_ding_money = I('post.presale_ding_money', 0);//定金金额,判断定金金额不能大于商品价格
  1293. $presale_deduction_money = I('post.presale_deduction_money');//定金可抵扣金额
  1294. if( $presale_type == 0)
  1295. {
  1296. $goods_price = I('post.price', 0);
  1297. $hasoption = I('post.hasoption');
  1298. if( intval($hasoption) == 1 )
  1299. {
  1300. //取规格最低价格
  1301. $option_ids_arr = I('post.option_ids');
  1302. foreach($option_ids_arr as $val)
  1303. {
  1304. $productprice = I('post.option_productprice_' . $val);
  1305. if( $goods_price > $productprice )
  1306. {
  1307. $goods_price = $productprice;
  1308. }
  1309. }
  1310. }
  1311. if( $presale_ding_money > $goods_price )
  1312. {
  1313. show_json(0 , ['message' => '预售方式为定金,定金金额不能大于商品单价' ] );
  1314. }
  1315. if( $presale_deduction_money > $goods_price )
  1316. {
  1317. show_json(0 , ['message' => '预售方式为定金,定金膨胀金不能大于商品单价' ] );
  1318. }
  1319. if($presale_deduction_money != 0){
  1320. if( $presale_deduction_money < $presale_ding_money )
  1321. {
  1322. show_json(0 , ['message' => '定金膨胀金不能小于定金金额' ] );
  1323. }
  1324. }
  1325. //付费价格
  1326. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1327. $is_take_vipcard = I('post.is_take_vipcard', 0);
  1328. $card_price =I ('post.card_price'); //付费会员价
  1329. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 && $is_take_vipcard == 1){
  1330. if( $presale_ding_money > $card_price )
  1331. {
  1332. show_json(0 , ['message' => '预售方式为定金,定金金额不能大于付费会员价' ] );
  1333. }
  1334. if( $presale_deduction_money > $card_price )
  1335. {
  1336. show_json(0 , ['message' => '预售方式为定金,定金膨胀金不能大于付费会员价' ] );
  1337. }
  1338. }
  1339. }
  1340. }
  1341. }
  1342. public function category_enabled()
  1343. {
  1344. $id = I('request.id');
  1345. if (empty($id)) {
  1346. $ids = I('request.ids');
  1347. $id = (is_array($ids) ? implode(',', $ids) : 0);
  1348. }
  1349. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  1350. $enabled = I('request.enabled');
  1351. foreach ($items as $item) {
  1352. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_show' => intval($enabled)) );
  1353. D('Seller/Operatelog')->addOperateLog('goods','修改分类首页显示--'.$item['name']);
  1354. }
  1355. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1356. }
  1357. public function category_typeenabled()
  1358. {
  1359. $_GPC = I('request.');
  1360. $id = intval($_GPC['id']);
  1361. if (empty($id)) {
  1362. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  1363. }
  1364. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  1365. foreach ($items as $item) {
  1366. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_type_show' => intval($_GPC['enabled'])) );
  1367. D('Seller/Operatelog')->addOperateLog('goods','修改分类独立分类页显示--'.$item['name']);
  1368. }
  1369. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1370. }
  1371. public function category_expressenabled()
  1372. {
  1373. $_GPC = I('request.');
  1374. $id = intval($_GPC['id']);
  1375. if (empty($id)) {
  1376. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  1377. }
  1378. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  1379. foreach ($items as $item) {
  1380. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_express_show' => intval($_GPC['enabled'])) );
  1381. D('Seller/Operatelog')->addOperateLog('goods','修改分类仅快递商品页显示--'.$item['name']);
  1382. }
  1383. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1384. }
  1385. public function mult_tpl()
  1386. {
  1387. $tpl = I('get.tpl','','trim');
  1388. $spec_str = I('post.spec_str', '', 'trim');
  1389. $options_name = I('post.options_name','','trim');
  1390. $cur_cate_id = I('post.cur_cate_id',0);
  1391. if ($tpl == 'spec') {
  1392. $spec = array('id' => random(32), 'title' => $options_name);
  1393. $need_items = array();
  1394. $spec_list = explode('@', $spec_str);
  1395. foreach($spec_list as $itemname)
  1396. {
  1397. $tmp_item = array('id' =>random(32),'title' => $itemname, 'show' => 1);
  1398. $need_items[] = $tmp_item;
  1399. }
  1400. $spec['items'] = $need_items;
  1401. $this->spec = $spec;
  1402. $this->tmp_item = $tmp_item;
  1403. $this->tpl = $tpl;
  1404. $this->spec_str = $spec_str;
  1405. $this->options_name = $options_name;
  1406. $this->cur_cate_id = $cur_cate_id;
  1407. $this->display('Goods/tpl/spec');
  1408. }
  1409. }
  1410. public function ajax_batchtime_pintuan()
  1411. {
  1412. $begin_time = I('request.begin_time');
  1413. $goodsids = I('request.goodsids');
  1414. $end_time = I('request.end_time');
  1415. foreach ($goodsids as $goods_id ) {
  1416. if($begin_time && $end_time){
  1417. $param = array();
  1418. $param['begin_time'] = strtotime($begin_time);
  1419. $param['end_time'] = strtotime($end_time);
  1420. M('lionfish_comshop_good_common')->where( array('goods_id' => $goods_id) )->save( $param );
  1421. M('lionfish_comshop_good_pin')->where( array('goods_id' => $goods_id) )->save( $param );
  1422. }
  1423. }
  1424. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1425. }
  1426. public function ajax_batchtime()
  1427. {
  1428. $begin_time = I('request.begin_time');
  1429. $goodsids = I('request.goodsids');
  1430. $end_time = I('request.end_time');
  1431. foreach ($goodsids as $goods_id ) {
  1432. if($begin_time && $end_time){
  1433. $param = array();
  1434. $param['begin_time'] = strtotime($begin_time);
  1435. $param['end_time'] = strtotime($end_time);
  1436. M('lionfish_comshop_good_common')->where( array('goods_id' => $goods_id) )->save( $param );
  1437. }
  1438. }
  1439. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1440. }
  1441. public function tpl()
  1442. {
  1443. $tpl = I('get.tpl');
  1444. $title = I('get.title','');
  1445. if ($tpl == 'spec') {
  1446. $spec = array('id' => random(32), 'title' => $title);
  1447. $this->title = $title;
  1448. $this->spec = $spec;
  1449. $this->display('Goods/tpl/spec');
  1450. }else if($tpl == 'specitem')
  1451. {
  1452. $specid = I('get.specid');
  1453. $spec = array('id' => $specid);
  1454. $specitem = array('id' => random(32), 'title' => $title, 'show' => 1);
  1455. $this->specid = $specid;
  1456. $this->spec = $spec;
  1457. $this->specitem = $specitem;
  1458. $this->display('Goods/tpl/spec_item');
  1459. }
  1460. }
  1461. public function config()
  1462. {
  1463. if (IS_POST) {
  1464. $data = I('post.parameter', array());
  1465. $data['goods_stock_notice'] = trim($data['goods_stock_notice']);
  1466. $data['instructions'] = trim($data['instructions']);
  1467. $data['is_show_buy_record'] = trim($data['is_show_buy_record']);
  1468. $data['is_show_list_timer'] = intval($data['is_show_list_timer']);
  1469. $data['is_show_list_count'] = intval($data['is_show_list_count']);
  1470. $data['is_show_comment_list'] = intval($data['is_show_comment_list']);
  1471. $data['is_show_new_buy'] = intval($data['is_show_new_buy']);
  1472. $data['is_new_buy_limit'] = intval($data['is_new_buy_limit']);
  1473. $new_buy_limit_num = !empty(intval($data['new_buy_limit_num'])) ? $data['new_buy_limit_num'] : 1;
  1474. $data['new_buy_limit_num'] = intval($new_buy_limit_num);
  1475. $data['is_show_ziti_time'] = intval($data['is_show_ziti_time']);
  1476. $data['is_show_spike_buy'] = intval($data['is_show_spike_buy']);
  1477. $data['goodsdetails_addcart_bg_color'] = $data['goodsdetails_addcart_bg_color'];
  1478. $data['goodsdetails_buy_bg_color'] = $data['goodsdetails_buy_bg_color'];
  1479. $data['is_show_guess_like'] = $data['is_show_guess_like'];
  1480. $data['show_goods_guess_like'] = $data['show_goods_guess_like'];
  1481. if(!empty($data['num_guess_like'])){
  1482. $data['num_guess_like'] = $data['num_guess_like'];
  1483. }else{
  1484. $data['num_guess_like'] = 8;
  1485. }
  1486. $data['isopen_community_group_share'] = intval($data['isopen_community_group_share']);
  1487. $data['group_share_avatar'] = save_media($data['group_share_avatar']);
  1488. $data['group_share_title'] = trim($data['group_share_title']);
  1489. $data['group_share_desc'] = trim($data['group_share_desc']);
  1490. $data['is_close_details_time'] = intval($data['is_close_details_time']);
  1491. $data['videolist_nav_title'] = trim($data['videolist_nav_title']);
  1492. $data['videolist_share_title'] = trim($data['videolist_share_title']);
  1493. $data['videolist_share_poster'] = save_media($data['videolist_share_poster']);
  1494. $data['goods_details_title_bg'] = save_media($data['goods_details_title_bg']);
  1495. D('Seller/Config')->update($data);
  1496. D('Seller/Operatelog')->addOperateLog('goods','修改商品设置--基本设置');
  1497. //旧的的域名
  1498. $present_realm_name = I('post.present_realm_name');
  1499. //修改商品详情域名
  1500. $new_realm_name = I('post.new_realm_name');
  1501. if(!empty($new_realm_name)){
  1502. $str="/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/";
  1503. if (!preg_match($str,$present_realm_name)){
  1504. show_json(0, array('message' => '旧的域名格式不正确'));
  1505. }
  1506. if (!preg_match($str,$new_realm_name)){
  1507. show_json(0, array('message' => '新的域名格式不正确'));
  1508. }
  1509. $sql = " update ". C('DB_PREFIX') ."lionfish_comshop_good_common set content = replace( content , '".$present_realm_name."' , '".$new_realm_name."' ) ";
  1510. $list = M()->execute($sql);
  1511. if(empty($list)){
  1512. show_json(0, array('message' => '商品详情中不存在该域名,或者不能填写相同的域名,请检查后重新填写'));
  1513. }else{
  1514. D('Seller/Operatelog')->addOperateLog('goods','替换商品详情域名--原域名:'.$present_realm_name.'新域名:'.$new_realm_name );
  1515. }
  1516. }
  1517. show_json(1, array('url'=> U('goods/config')));
  1518. }
  1519. $data = D('Seller/Config')->get_all_config();
  1520. $this->data = $data;
  1521. $this->display();
  1522. }
  1523. function addspec()
  1524. {
  1525. global $_W;
  1526. global $_GPC;
  1527. if (IS_POST) {
  1528. $data = I('post.data');
  1529. D('Seller/Spec')->update($data);
  1530. show_json(1, array('url' => U('goods/goodsspec')));
  1531. }
  1532. $this->display();
  1533. }
  1534. public function editspec()
  1535. {
  1536. $id = I('request.id');
  1537. if (!empty($id)) {
  1538. $item = M('lionfish_comshop_spec')->where( array('id' => $id) )->find();
  1539. if (json_decode($item['value'], true)) {
  1540. $labelname = json_decode($item['value'], true);
  1541. }
  1542. else {
  1543. $labelname = unserialize($item['value']);
  1544. }
  1545. }
  1546. if (IS_POST) {
  1547. $data = I('post.data');
  1548. D('Seller/Spec')->update($data);
  1549. show_json(1, array('url' => U('goods/goodsspec')));
  1550. }
  1551. $this->item = $item;
  1552. $this->labelname = $labelname;
  1553. $this->display('Goods/addspec');
  1554. }
  1555. public function deletespec()
  1556. {
  1557. $id = I('get.id');
  1558. if (empty($id)) {
  1559. $ids = I('post.ids');
  1560. $id = (is_array($ids) ? implode(',', $ids) : 0);
  1561. }
  1562. $items = M('lionfish_comshop_spec')->field('id,name')->where( array('id' => array('in', $id)) )->select();
  1563. if (empty($item)) {
  1564. $item = array();
  1565. }
  1566. foreach ($items as $item) {
  1567. M('lionfish_comshop_spec')->where( array('id' => $item['id']) )->delete();
  1568. D('Seller/Operatelog')->addOperateLog('goods','删除商品规格--'.$item['name']);
  1569. }
  1570. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1571. }
  1572. public function addcategory()
  1573. {
  1574. $data = array();
  1575. $pid = I('get.pid', 0);
  1576. $id = I('get.id', 0);
  1577. if (IS_POST) {
  1578. $data = I('post.data');
  1579. if(!isset($data['sort_order'])){
  1580. show_json(0, array('message' => '分类排序必须填写'));
  1581. }
  1582. if(!is_numeric($data['sort_order'])){
  1583. show_json(0, array('message' => '分类排序必须在1-999之间的整数'));
  1584. }
  1585. if(floor($data['sort_order']) != $data['sort_order']){
  1586. show_json(0, array('message' => '分类排序必须在1-999之间的整数'));
  1587. }
  1588. if($data['sort_order'] < 1 || $data['sort_order'] > 999){
  1589. show_json(0, array('message' => '分类排序必须在1-999之间的整数'));
  1590. }
  1591. $where = array();
  1592. $where['sort_order'] = $data['sort_order'];
  1593. $where['cate_type'] = 'normal';
  1594. $cate_info = M('lionfish_comshop_goods_category')->where($where)->find();
  1595. if(!empty($cate_info) && (($id == 0) || ($id > 0 && $id != $cate_info['id']))){
  1596. show_json(0, array('message' => '分类排序已存在,请重新填写'));
  1597. }
  1598. D('Seller/GoodsCategory')->update($data);
  1599. show_json(1, array('url' => U('goods/goodscategory')));
  1600. }
  1601. if($id >0 )
  1602. {
  1603. $data = M('lionfish_comshop_goods_category')->where( array('id' => $id) )->find();
  1604. $this->data = $data;
  1605. }
  1606. $this->pid = $pid;
  1607. $this->id = $id;
  1608. $this->display();
  1609. }
  1610. /**
  1611. * 更新商品分类排序
  1612. */
  1613. public function update_catesort(){
  1614. $cate_id = I('post.cate_id', 0);
  1615. $sort_order = I('post.sort_order', 0);
  1616. if(!is_numeric($sort_order)){
  1617. show_json(0, array('message' => '分类排序必须为数字'));
  1618. }
  1619. if($sort_order < 1 || $sort_order > 999){
  1620. show_json(0, array('message' => '分类排序必须在1-999之间'));
  1621. }
  1622. if($cate_id > 0){
  1623. $where = array();
  1624. $where['sort_order'] = $sort_order;
  1625. $where['cate_type'] = 'normal';
  1626. $where['id'] = array('neq',$cate_id);
  1627. $cate_info = M('lionfish_comshop_goods_category')->where($where)->find();
  1628. if(!empty($cate_info)){
  1629. show_json(0, array('message' => '分类排序已存在,请重新填写'));
  1630. }
  1631. M('lionfish_comshop_goods_category')->where( array('id' => $cate_id) )->save(array('sort_order'=>$sort_order));
  1632. D('Seller/Operatelog')->addOperateLog('goods','修改商品分类排序--'.$item['name']);
  1633. show_json(1, array('url' => U('goods/goodscategory')));
  1634. }else{
  1635. show_json(0, array('message' => '分类信息错误'));
  1636. }
  1637. }
  1638. public function category_delete()
  1639. {
  1640. $id = I('get.id');
  1641. $item = M('lionfish_comshop_goods_category')->field('id, name, pid')->where( array('id' => $id) )->find();
  1642. M('lionfish_comshop_goods_category')->where( "id={$id} or pid={$id}" )->delete();
  1643. D('Seller/Operatelog')->addOperateLog('goods','删除商品分类--'.$item['name']);
  1644. //m('shop')->getCategory(true);
  1645. show_json(1, array('url' => U('goods/goodscategory')));
  1646. }
  1647. public function goodscategory()
  1648. {
  1649. if (IS_POST) {
  1650. $datas = I('post.datas');
  1651. if (!empty($datas)) {
  1652. D('Seller/GoodsCategory')->goodscategory_modify($datas);
  1653. show_json(1 , array('url' => U('goods/goodscategory') ));
  1654. }
  1655. $parameter = I('post.parameter');
  1656. if (!empty($parameter)) {
  1657. $data = ((is_array($parameter) ? $parameter : array()));
  1658. D('Seller/Config')->update($data);
  1659. show_json(1);
  1660. }
  1661. }
  1662. $children = array();
  1663. $category = M('lionfish_comshop_goods_category')->where(' cate_type="normal" ')->order('pid ASC, sort_order DESC')->select();
  1664. foreach ($category as $index => $row) {
  1665. if (!empty($row['pid'])) {
  1666. $children[$row['pid']][] = $row;
  1667. unset($category[$index]);
  1668. }
  1669. }
  1670. $data = D('Seller/Config')->get_all_config();
  1671. $this->data = $data;
  1672. $this->children = $children;
  1673. $this->category = $category;
  1674. $this->display();
  1675. }
  1676. public function goodsspec()
  1677. {
  1678. $condition = ' 1=1 and spec_type="normal" ';
  1679. $pindex = I('get.page',1);
  1680. $psize = 20;
  1681. $enabled = I('get.enabled');
  1682. if ($enabled != '') {
  1683. $condition .= ' and state=' . intval($enabled);
  1684. }
  1685. $keyword = I('get.keyword','','trim');
  1686. if (!empty($keyword)) {
  1687. $condition .= ' and name like "%'.$keyword.'%" ';
  1688. }
  1689. $offset = ($pindex - 1) * $psize;
  1690. $label = M('lionfish_comshop_spec')->field('id,name,value')->where($condition)->order(' id desc ')->limit($offset, $psize)->select();
  1691. $total = M('lionfish_comshop_spec')->where( $condition )->count();
  1692. $cur_url = U('goods/goodsspec', array('enabled' => $enabled,'keyword' => $keyword));
  1693. $pager = pagination2($total, $pindex, $psize);
  1694. foreach( $label as &$val )
  1695. {
  1696. $val['value'] = unserialize($val['value']);
  1697. $val['value_str'] = !empty($val['value']) ? implode(',', $val['value']) : '';
  1698. }
  1699. $this->keyword = $keyword;
  1700. $this->label = $label;
  1701. $this->total = $total;
  1702. $this->pager = $pager;
  1703. $this->display();
  1704. }
  1705. /**
  1706. 搜索全部商品,可添加虚拟评价
  1707. **/
  1708. public function goods_search_all()
  1709. {
  1710. $goods_name = I('post.goods_name','');
  1711. $where = " status=1 and quantity>0 and store_id = " . $this->sellerid;
  1712. if(!empty($goods_name))
  1713. {
  1714. $where .= " and name like '%".$goods_name."%' ";
  1715. }
  1716. $goods_list = M('goods')->where($where)->limit(20)->select();
  1717. $this->goods_list = $goods_list;
  1718. $result = array();
  1719. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1720. echo json_encode($result);
  1721. die();
  1722. }
  1723. function toggle_statues_show() {
  1724. $goods_id = I('post.gid',0);
  1725. $goods_info =M('Goods')->where( array('goods_id' => $goods_id) )->find();
  1726. $status = $goods_info['status'] == 1 ? 0: 1;
  1727. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('status' => $status) );
  1728. echo json_encode( array('code' => 1) );
  1729. die();
  1730. }
  1731. /**
  1732. 搜索可报名的商品
  1733. **/
  1734. public function goods_search_voucher()
  1735. {
  1736. $goods_name = I('post.goods_name','');
  1737. $where = " (type='normal' or type ='pintuan') and status=1 and quantity>0 and store_id = " . $this->sellerid;
  1738. if(!empty($goods_name))
  1739. {
  1740. $where .= " and ( name like '%".$goods_name."%' or goods_id like '%".$goods_name."%') ";
  1741. }
  1742. $goods_list = M('goods')->where($where)->limit(10)->select();
  1743. $this->goods_list = $goods_list;
  1744. $result = array();
  1745. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1746. echo json_encode($result);
  1747. die();
  1748. }
  1749. /**
  1750. 搜索可报名的商品
  1751. **/
  1752. public function goods_search()
  1753. {
  1754. $goods_name = I('post.goods_name','');
  1755. $where = " type='normal' and status=1 and quantity>0 and store_id = " . $this->sellerid;
  1756. if(!empty($goods_name))
  1757. {
  1758. $where .= " and name like '%".$goods_name."%' ";
  1759. }
  1760. $goods_list = M('goods')->where($where)->limit(20)->select();
  1761. $this->goods_list = $goods_list;
  1762. $result = array();
  1763. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1764. echo json_encode($result);
  1765. die();
  1766. }
  1767. public function query_normal()
  1768. {
  1769. $_GPC = I('request.');
  1770. $kwd = trim($_GPC['keyword']);
  1771. $is_recipe = isset($_GPC['is_recipe']) ? intval($_GPC['is_recipe']) : 0 ;
  1772. $is_soli = isset($_GPC['is_soli']) ? intval($_GPC['is_soli']) : 0 ;
  1773. $params = array();
  1774. $type = isset($_GPC['type']) ? $_GPC['type']:'normal';
  1775. $condition = ' type = "'.$type.'" and grounding = 1 and is_seckill =0 ';
  1776. if (!empty($kwd)) {
  1777. $condition .= ' AND `goodsname` LIKE "%' . $kwd . '%" ';
  1778. }
  1779. if( isset($_GPC['unselect_goodsid']) && $_GPC['unselect_goodsid'] > 0 )
  1780. {
  1781. $condition .= ' AND `id` != '.$_GPC['unselect_goodsid'];
  1782. }
  1783. if( $is_soli == 1 )
  1784. {
  1785. $head_id = $_GPC['head_id'];
  1786. $goods_ids_arr = M('lionfish_community_head_goods')->field('goods_id')->where( "head_id in ({$head_id})" )->order('id desc')->select();
  1787. $ids_arr = array();
  1788. foreach($goods_ids_arr as $val){
  1789. $ids_arr[] = $val['goods_id'];
  1790. }
  1791. if( !empty($ids_arr) )
  1792. {
  1793. $ids_str = implode(',',$ids_arr);
  1794. $condition .= " and ( is_all_sale = 1 or id in ({$ids_str}) ) ";
  1795. }else{
  1796. $condition .= " and ( is_all_sale = 1 ) ";
  1797. }
  1798. //is_all_sale
  1799. }
  1800. //todo....
  1801. $time = time();
  1802. $ds = M('lionfish_comshop_goods')->field('id as gid,goodsname,price,productprice,total')->where( $condition )->select();
  1803. $s_html = "";
  1804. foreach ($ds as &$d) {
  1805. //thumb
  1806. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' =>$d['gid'] ) )->order('id asc')->find();
  1807. $d['thumb'] = tomedia($thumb['image']);
  1808. $goods_common_info = M('lionfish_comshop_good_common')->field("begin_time,end_time")->where( array('goods_id' =>$d['gid'] ) )->order('id asc')->find();
  1809. if($time >= $goods_common_info['begin_time'] && $time <= $goods_common_info['end_time']){
  1810. $d['is_finished'] = 0;
  1811. }else{
  1812. $d['is_finished'] = 1;//已结束
  1813. }
  1814. if($d['total'] <= 0){
  1815. $d['is_grab'] = 1;//已抢光
  1816. }else{
  1817. $d['is_grab'] = 0;
  1818. }
  1819. $s_html.= '<tr>';
  1820. $s_html.=" <td><img src='".tomedia($d['thumb'])."' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> ".$d['goodsname']."</td>";
  1821. if ( isset($_GPC['template']) && $_GPC['template'] == 'mult' ) {
  1822. if( $is_recipe == 1 )
  1823. {
  1824. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_recipe" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1825. }else{
  1826. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_goods" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1827. }
  1828. }else{
  1829. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1830. }
  1831. $s_html.="</tr>";
  1832. }
  1833. unset($d);
  1834. if( isset($_GPC['is_ajax']) )
  1835. {
  1836. echo json_encode( array('code' => 0, 'html' =>$s_html ) );
  1837. die();
  1838. }
  1839. $this->ds = $ds;
  1840. $this->_GPC = $_GPC;
  1841. if ( isset($_GPC['template']) && $_GPC['template'] == 'mult' ) {
  1842. if( $is_recipe == 1 )
  1843. {
  1844. $this->display('Goods/query_normal_mult_recipe');
  1845. }else{
  1846. $this->display('Goods/query_normal_mult');
  1847. }
  1848. }else{
  1849. $this->display();
  1850. }
  1851. }
  1852. /**
  1853. * 获取商品规格情况
  1854. */
  1855. function get_ajax_search_goods_info()
  1856. {
  1857. $goods_id = I('get.goods_id');
  1858. $is_hide = I('get.is_hide',0);
  1859. $type = I('get.type','pin');
  1860. //'type' => 'bargain'
  1861. $this->is_hide = $is_hide;
  1862. $goods_info = M('goods')->field('name,goods_id,price,danprice')->where( array('goods_id' => $goods_id) )->find();
  1863. $model=new GoodsModel();
  1864. $this->goods_options=$model->get_goods_options($goods_id, UID);
  1865. $goods_option_mult_value = M('goods_option_mult_value')->where( array('goods_id' => $goods_id ) )->select();
  1866. $goods_option_mult_str = '';
  1867. if( !empty($goods_option_mult_value) )
  1868. {
  1869. $goods_option_mult_arr = array();
  1870. foreach($goods_option_mult_value as $key => $val)
  1871. {
  1872. $goods_option_mult_arr[] = 'mult_id:'.$val['rela_goodsoption_valueid'].'@@mult_qu:'.$val['quantity'].'@@mult_image:'.$val['image'];
  1873. //option_value option_value_id value_name
  1874. $option_name_arr = explode('_', $val['rela_goodsoption_valueid']);
  1875. $option_name_list = array();
  1876. foreach($option_name_arr as $option_value_id_tp)
  1877. {
  1878. $tp_op_val_info =M('option_value')->where( array('option_value_id' => $option_value_id_tp) )->find();
  1879. $option_name_list[] = $tp_op_val_info['value_name'];
  1880. }
  1881. $val['option_name_list'] = $option_name_list;
  1882. $goods_option_mult_value[$key] = $val;
  1883. }
  1884. $goods_option_mult_str = implode(',', $goods_option_mult_arr);
  1885. }
  1886. $this->goods_option_mult_value = $goods_option_mult_value;
  1887. $this->goods_option_mult_str = $goods_option_mult_str;
  1888. $this->goods_info = $goods_info;
  1889. $result = array();
  1890. if($type == 'bargain')
  1891. {
  1892. $result['html'] = $this->fetch('Goods:goods_option_fetch_bargain');
  1893. }
  1894. else if($type == 'integral'){
  1895. $result['html'] = $this->fetch('Goods:goods_option_fetch_integral');
  1896. }else{
  1897. $result['html'] = $this->fetch('Goods:goods_option_fetch');
  1898. }
  1899. echo json_encode($result);
  1900. die();
  1901. }
  1902. function toggle_index_sort()
  1903. {
  1904. $goods_id = I('post.gid',0);
  1905. $index_sort = I('post.index_sort',0,'intval');
  1906. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('index_sort' => $index_sort) );
  1907. echo json_encode( array('code' => 1) );
  1908. die();
  1909. }
  1910. function toggle_index_show()
  1911. {
  1912. $goods_id = I('post.gid',0);
  1913. $goods_info =M('Goods')->where( array('goods_id' => $goods_id) )->find();
  1914. $is_index_show = $goods_info['is_index_show'] == 1 ? 0: 1;
  1915. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('is_index_show' => $is_index_show) );
  1916. echo json_encode( array('code' => 1) );
  1917. die();
  1918. }
  1919. /**
  1920. * 活动商品
  1921. */
  1922. public function activity()
  1923. {
  1924. $this->breadcrumb2='活动商品信息';
  1925. $model=new GoodsModel();
  1926. $filter=I('get.');
  1927. $search=array('store_id' => SELLERUID);
  1928. if(isset($filter['name'])){
  1929. $search['name']=$filter['name'];
  1930. }
  1931. if(isset($filter['category'])){
  1932. $search['category']=$filter['category'];
  1933. $this->get_category=$search['category'];
  1934. }
  1935. if(isset($filter['status'])){
  1936. $search['status']=$filter['status'];
  1937. $this->get_status=$search['status'];
  1938. }
  1939. if(isset($filter['type'])){
  1940. $search['type']=$filter['type'];
  1941. $this->type=$search['type'];
  1942. }else {
  1943. $search['type']='activity';
  1944. $this->type=$search['type'];
  1945. }
  1946. //type
  1947. $data=$model->show_goods_page($search);
  1948. $store_bind_class = M('store_bind_class')->where( array('seller_id' => SELLERUID) )->select();
  1949. $cate_ids = array();
  1950. foreach($store_bind_class as $val)
  1951. {
  1952. if( !empty($val['class_1'])) {
  1953. $cate_ids[] = $val['class_1'];
  1954. }
  1955. if( !empty($val['class_2'])) {
  1956. $cate_ids[] = $val['class_2'];
  1957. }
  1958. if( !empty($val['class_3'])) {
  1959. $cate_ids[] = $val['class_3'];
  1960. }
  1961. }
  1962. if(empty($cate_ids)) {
  1963. $this->category = array();
  1964. } else {
  1965. $cate_ids_str = implode(',', $cate_ids);
  1966. $category=M('goods_category')->where( array('id' => array('in',$cate_ids_str)) )->select();
  1967. $category_tree =list_to_tree($category);
  1968. $this->category = $category_tree;
  1969. }
  1970. foreach($data['list'] as $key => $goods)
  1971. {
  1972. $all_comment = M('order_comment')->where( array('goods_id' => $goods['goods_id']) )->count();
  1973. $wait_comment = M('order_comment')->where( array('state' => 0 ,'goods_id' => $goods['goods_id']) )->count();
  1974. $goods['all_comment'] = $all_comment;
  1975. $goods['wait_comment'] = $wait_comment;
  1976. $data['list'][$key] = $goods;
  1977. }
  1978. $this->assign('empty',$data['empty']);// 赋值数据集
  1979. $this->assign('list',$data['list']);// 赋值数据集
  1980. $this->assign('page',$data['page']);// 赋值分页输出
  1981. $this->display();
  1982. }
  1983. /**
  1984. 回收站商品重新上架
  1985. **/
  1986. public function goback()
  1987. {
  1988. $goods_id = I('get.id',0,'intval');
  1989. $result = array('code' => 0);
  1990. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  1991. if(empty($goods_info))
  1992. {
  1993. $result['msg'] = '非法操作';
  1994. echo json_encode($result);
  1995. die();
  1996. }
  1997. $up_data = array();
  1998. $up_data['lock_type'] = 'normal';
  1999. $up_data['status'] = 2;//下架
  2000. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  2001. $result['code'] = 1;
  2002. echo json_encode($result);
  2003. die();
  2004. }
  2005. public function get_weshare_image()
  2006. {
  2007. $goods_id = I('get.id',0,'intval');
  2008. //400*400 fan_image
  2009. //get_goods_price($goods_id)
  2010. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2011. $goods_img = ROOT_PATH.'Uploads/image/'.$goods_info['image'];
  2012. if( !empty($goods_info['fan_image']) )
  2013. {
  2014. $goods_img = ROOT_PATH.'Uploads/image/'.$goods_info['fan_image'];
  2015. }
  2016. $goods_model = D('Home/Goods');
  2017. $goods_price = $goods_model->get_goods_price($goods_id);
  2018. $goods_price['market_price'] = $goods_info['price'];
  2019. //price
  2020. $goods_title = $goods_info['name'];
  2021. $need_img = $goods_model->_get_compare_zan_img($goods_img,$goods_title,$goods_price);
  2022. //贴上二维码图
  2023. //$rocede_path = $goods_model->_get_goods_user_wxqrcode($goods_id,$member_id);
  2024. //$res = $goods_model->_get_compare_qrcode_bgimg($need_img['need_path'], $rocede_path);
  2025. M('goods_description')->where( array('goods_id' =>$goods_id) )->save( array('wepro_qrcode_image' =>$need_img['need_path']) );
  2026. echo json_encode(array('code' =>1));
  2027. die();
  2028. }
  2029. /**
  2030. 加入回车站
  2031. **/
  2032. public function backhuiche()
  2033. {
  2034. $goods_id = I('get.id',0,'intval');
  2035. $result = array('code' => 0);
  2036. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  2037. if(empty($goods_info))
  2038. {
  2039. $result['msg'] = '非法操作';
  2040. echo json_encode($result);
  2041. die();
  2042. }
  2043. $lock_type = $goods_info['lock_type'];
  2044. switch($lock_type)
  2045. {
  2046. case 'lottery':
  2047. M('lottery_goods')->where( array('goods_id' => $goods_id) )->delete();
  2048. break;
  2049. case 'super_spike':
  2050. M('super_spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  2051. break;
  2052. case 'spike':
  2053. M('spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  2054. break;
  2055. case 'subject':
  2056. case 'free_trial':
  2057. case 'niyuan':
  2058. case 'oneyuan':
  2059. case 'haitao':
  2060. M('subject_goods')->where( array('goods_id' => $goods_id) )->delete();
  2061. break;
  2062. }
  2063. $up_data = array();
  2064. $up_data['type'] = 'normal';
  2065. $up_data['lock_type'] = 'normal';
  2066. $up_data['status'] = 4;//下架
  2067. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  2068. $result['code'] = 1;
  2069. echo json_encode($result);
  2070. die();
  2071. }
  2072. /**
  2073. 撤回活动申请
  2074. **/
  2075. public function backshenqing()
  2076. {
  2077. $goods_id = I('get.id',0,'intval');
  2078. $result = array('code' => 0);
  2079. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  2080. if(empty($goods_info))
  2081. {
  2082. $result['msg'] = '非法操作';
  2083. echo json_encode($result);
  2084. die();
  2085. }
  2086. $lock_type = $goods_info['lock_type'];
  2087. switch($lock_type)
  2088. {
  2089. case 'lottery':
  2090. M('lottery_goods')->where( array('goods_id' => $goods_id) )->delete();
  2091. break;
  2092. case 'super_spike':
  2093. M('super_spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  2094. break;
  2095. case 'spike':
  2096. M('spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  2097. break;
  2098. case 'subject':
  2099. case 'free_trial':
  2100. case 'niyuan':
  2101. case 'oneyuan':
  2102. case 'haitao':
  2103. M('subject_goods')->where( array('goods_id' => $goods_id) )->delete();
  2104. break;
  2105. }
  2106. $up_data = array();
  2107. $up_data['lock_type'] = 'normal';
  2108. $up_data['status'] = 0;//下架
  2109. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  2110. $result['code'] = 1;
  2111. echo json_encode($result);
  2112. die();
  2113. }
  2114. ///Goods/delcomment/id/1
  2115. /**
  2116. * 删除评论
  2117. */
  2118. public function delcomment()
  2119. {
  2120. $id = I('get.id');
  2121. $goods_id = I('get.goods_id');
  2122. M('order_comment')->where( array('comment_id' => $id) )->delete();
  2123. //echo
  2124. $result = array(
  2125. 'status'=>'success',
  2126. 'message'=>'删除成功',
  2127. 'jump'=>U('Goods/comment_info', array('id' => $goods_id))
  2128. );
  2129. $this->osc_alert($result);
  2130. }
  2131. /**
  2132. * 审核评论
  2133. */
  2134. public function toggle_comment_state()
  2135. {
  2136. $comment_id = I('post.comment_id');
  2137. $order_comment = M('order_comment')->where( array('comment_id' => $comment_id) )->find();
  2138. //state
  2139. $state = $order_comment['state'] == 1 ? 0: 1;
  2140. M('order_comment')->where( array('comment_id' => $comment_id) )->save( array('state' => $state) );
  2141. echo json_encode( array('code' => 1) );
  2142. die();
  2143. }
  2144. /**
  2145. * 商品评论信息
  2146. */
  2147. public function comment_info()
  2148. {
  2149. $goods_id = I('get.id');
  2150. $model=new GoodsModel();
  2151. $search = array();
  2152. $search['goods_id'] = $goods_id;
  2153. $data=$model->show_comment_page($search);
  2154. $this->assign('empty',$data['empty']);// 赋值数据集
  2155. $this->assign('list',$data['list']);// 赋值数据集
  2156. $this->assign('page',$data['page']);// 赋值分页输出
  2157. $this->display();
  2158. }
  2159. public function ajax_batchheads()
  2160. {
  2161. $goodsids = I('request.goodsids');
  2162. $head_id_arr = I('request.head_id_arr');
  2163. $is_clear_old = I('request.is_clear_old');
  2164. $is_cancle_allhead = I('request.is_cancle_allhead');
  2165. if( $is_clear_old == 1 )
  2166. {
  2167. foreach($goodsids as $goods_id)
  2168. {
  2169. M('lionfish_community_head_goods')->where( array('goods_id' => $goods_id) )->delete();
  2170. }
  2171. }
  2172. if( isset($is_cancle_allhead) && $is_cancle_allhead == 1 )
  2173. {
  2174. foreach($goodsids as $goods_id)
  2175. {
  2176. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( array('is_all_sale' => 0) );
  2177. }
  2178. }
  2179. foreach($head_id_arr as $head_id)
  2180. {
  2181. foreach($goodsids as $goods_id)
  2182. {
  2183. D('Seller/Communityhead')->insert_head_goods($goods_id, $head_id);
  2184. }
  2185. }
  2186. show_json(1);
  2187. }
  2188. public function ajax_batchcates_headgroup()
  2189. {
  2190. $_GPC = I('request.');
  2191. $goodsids = $_GPC['goodsids'];
  2192. $groupid = $_GPC['groupid'];
  2193. if( $groupid == 'default')
  2194. {
  2195. $groupid = 0;
  2196. }
  2197. $head_list = M('lionfish_community_head')->field('id')->where( array("groupid" => $groupid, 'state' => 1 ) )->select();
  2198. $is_clear_old = $_GPC['is_clear_old'];
  2199. $is_cancle_allhead = isset($_GPC['is_cancle_allhead']) ? $_GPC['is_cancle_allhead'] : 0;
  2200. if($is_cancle_allhead == 1)
  2201. {
  2202. foreach($goodsids as $goods_id)
  2203. {
  2204. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( array('is_all_sale' => 0) );
  2205. }
  2206. }
  2207. if( $is_clear_old == 1 )
  2208. {
  2209. foreach($goodsids as $goods_id)
  2210. {
  2211. M('lionfish_community_head_goods')->where( array('goods_id' => $goods_id ) )->delete();
  2212. }
  2213. }
  2214. if( !empty($head_list) )
  2215. {
  2216. foreach($head_list as $val)
  2217. {
  2218. foreach($goodsids as $goods_id)
  2219. {
  2220. D('Seller/Communityhead')->insert_head_goods($goods_id, $val['id']);
  2221. }
  2222. }
  2223. }
  2224. show_json(1);
  2225. }
  2226. public function ajax_batchcates()
  2227. {
  2228. $iscover = I('request.iscover');
  2229. $goodsids = I('request.goodsids');
  2230. $cates = I('request.cates');
  2231. if( !is_array($cates) )
  2232. {
  2233. $cates = array($cates);
  2234. }
  2235. foreach ($goodsids as $goods_id ) {
  2236. if( $iscover == 1)
  2237. {
  2238. //覆盖,即删除原有的分类
  2239. M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $goods_id) )->delete();
  2240. foreach($cates as $cate_id)
  2241. {
  2242. $post_data_cate = array();
  2243. $post_data_cate['cate_id'] = $cate_id;
  2244. $post_data_cate['goods_id'] = $goods_id;
  2245. M('lionfish_comshop_goods_to_category')->add($post_data_cate);
  2246. }
  2247. }else{
  2248. foreach($cates as $cate_id)
  2249. {
  2250. //仅更新
  2251. $item = M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $goods_id,'cate_id' => $cate_id) )->find();
  2252. if(empty($item))
  2253. {
  2254. $post_data_cate = array();
  2255. $post_data_cate['cate_id'] = $cate_id;
  2256. $post_data_cate['goods_id'] = $goods_id;
  2257. M('lionfish_comshop_goods_to_category')->add($post_data_cate);
  2258. }
  2259. }
  2260. }
  2261. }
  2262. show_json(1);
  2263. }
  2264. public function lotteryinfo()
  2265. {
  2266. $goods_id = I('get.id',0);
  2267. $lottery_goods = M('lottery_goods')->where( array('goods_id' =>$goods_id) )->find();
  2268. if(empty($lottery_goods)){
  2269. die('非法操作');
  2270. }//store_id
  2271. $page = I('get.page',1);
  2272. $per_page = 4;
  2273. $offset = ($page - 1) * $per_page;
  2274. $sql = "select m.uname,m.avatar,p.pin_id,p.lottery_state,o.lottery_win,o.order_id,o.pay_time from ".C('DB_PREFIX')."pin as p,".C('DB_PREFIX')."pin_order as po,
  2275. ".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og,".C('DB_PREFIX')."member as m
  2276. where p.state = 1 and p.pin_id = po.pin_id and po.order_id = o.order_id
  2277. and o.order_id = og.order_id and og.goods_id and o.member_id = m.member_id and og.store_id =".SELLERUID." and og.goods_id = {$goods_id}
  2278. and o.date_added >= ".$lottery_goods['begin_time']." order by p.pin_id asc limit {$offset},{$per_page}";
  2279. //begin_time date_added
  2280. $list=M()->query($sql);
  2281. $this->list = $list;
  2282. $this->goods_id = $goods_id;
  2283. $this->lottery_goods = $lottery_goods;
  2284. if($page>1){
  2285. $result = array();
  2286. $result['code'] = 0;
  2287. if(!empty($list)) {
  2288. $content = $this->fetch('Goods:lottery_info_fetch');
  2289. $result['code'] = 1;
  2290. $result['html'] = $content;
  2291. }
  2292. echo json_encode($result);
  2293. die();
  2294. }
  2295. $this->display();
  2296. }
  2297. public function openlottery()
  2298. {
  2299. $goods_id = I('get.id',0);
  2300. $oids = I('post.oids');
  2301. $order_model = D('Home/Order');
  2302. $order_model->open_goods_lottery_order($goods_id,$oids,false);
  2303. //$order_model->open_goods_lottery_order($goods_id,'',true);
  2304. //$map['id'] = array('in','1,3,8')
  2305. echo json_encode( array('code' => 1) );
  2306. die();
  2307. }
  2308. public function lottery_shenqing()
  2309. {
  2310. $result = array('code' => 0);
  2311. $goods_id = I('post.goods_id',0);
  2312. if($goods_id == 0){
  2313. $result['msg'] = '商品不存在';
  2314. echo json_encode($result);
  2315. die();
  2316. }
  2317. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2318. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2319. $spike_data = array();
  2320. $spike_data['goods_id'] = $goods_id;
  2321. $spike_data['state'] = 0;
  2322. $spike_data['quantity'] = $goods_info['quantity'];
  2323. $spike_data['begin_time'] = 0;
  2324. $spike_data['end_time'] = 0;
  2325. $spike_data['addtime'] = time();
  2326. $rs = M('lottery_goods')->add($spike_data);
  2327. if($rs) {
  2328. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'lottery') );
  2329. }
  2330. $result['code'] = 1;
  2331. echo json_encode($result);
  2332. die();
  2333. } else{
  2334. $result['msg'] = '已存在其他活动中';
  2335. echo json_encode($result);
  2336. die();
  2337. }
  2338. }
  2339. public function xianshimiaosha_shenqing()
  2340. {
  2341. $result = array('code' => 0);
  2342. $goods_id = I('post.goods_id',0);
  2343. if($goods_id == 0){
  2344. $result['msg'] = '商品不存在';
  2345. echo json_encode($result);
  2346. die();
  2347. }
  2348. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2349. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2350. $spike_data = array();
  2351. $spike_data['goods_id'] = $goods_id;
  2352. $spike_data['state'] = 0;
  2353. $spike_data['quantity'] = $goods_info['quantity'];
  2354. $spike_data['begin_time'] = 0;
  2355. $spike_data['end_time'] = 0;
  2356. $spike_data['addtime'] = time();
  2357. $rs = M('spike_goods')->add($spike_data);
  2358. if($rs) {
  2359. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'spike') );
  2360. }
  2361. $result['code'] = 1;
  2362. echo json_encode($result);
  2363. die();
  2364. } else{
  2365. $result['msg'] = '已存在其他活动中';
  2366. echo json_encode($result);
  2367. die();
  2368. }
  2369. }
  2370. public function spike_sub()
  2371. {
  2372. $spike_id = I('post.spike',0);
  2373. $goods_id = I('post.goods_id',0);
  2374. if($goods_id == 0){
  2375. $result['msg'] = '商品不存在';
  2376. echo json_encode($result);
  2377. die();
  2378. }
  2379. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2380. $spike_info = M('spike')->where( array('id' => $spike_id) )->find();
  2381. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2382. $super_data = array();
  2383. $super_data['spike_id'] = $spike_id;
  2384. $super_data['goods_id'] = $goods_id;
  2385. $super_data['state'] = 0;
  2386. $super_data['begin_time'] = $spike_info['begin_time'];
  2387. $super_data['end_time'] = $spike_info['end_time'];
  2388. $super_data['addtime'] = time();
  2389. $rs = M('spike_goods')->add($super_data);
  2390. if($rs) {
  2391. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'spike') );
  2392. }
  2393. $result['code'] = 1;
  2394. echo json_encode($result);
  2395. die();
  2396. } else {
  2397. $result['msg'] = '已存在其他活动中';
  2398. echo json_encode($result);
  2399. die();
  2400. }
  2401. }
  2402. public function chaozhidapai_sub()
  2403. {
  2404. $super_spike_id = I('post.super_spike',0);
  2405. $goods_id = I('post.goods_id',0);
  2406. if($goods_id == 0){
  2407. $result['msg'] = '商品不存在';
  2408. echo json_encode($result);
  2409. die();
  2410. }
  2411. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2412. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2413. $super_data = array();
  2414. $super_data['super_spike_id'] = $super_spike_id;
  2415. $super_data['goods_id'] = $goods_id;
  2416. $super_data['state'] = 0;
  2417. $super_data['begin_time'] = 0;
  2418. $super_data['end_time'] = 0;
  2419. $super_data['addtime'] = time();
  2420. $rs = M('super_spike_goods')->add($super_data);
  2421. if($rs) {
  2422. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'super_spike') );
  2423. }
  2424. $result['code'] = 1;
  2425. echo json_encode($result);
  2426. die();
  2427. } else {
  2428. $result['msg'] = '已存在其他活动中';
  2429. echo json_encode($result);
  2430. die();
  2431. }
  2432. }
  2433. public function oneyuansubject_sub()
  2434. {
  2435. $subject_id = I('post.subject',0);
  2436. $goods_id = I('post.goods_id',0);
  2437. if($goods_id == 0){
  2438. $result['msg'] = '商品不存在';
  2439. echo json_encode($result);
  2440. die();
  2441. }
  2442. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2443. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2444. $super_data = array();
  2445. $super_data['subject_id'] = $subject_id;
  2446. $super_data['goods_id'] = $goods_id;
  2447. $super_data['state'] = 0;
  2448. $super_data['addtime'] = time();
  2449. $rs = M('subject_goods')->add($super_data);
  2450. if($rs) {
  2451. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'oneyuan') );
  2452. }
  2453. $result['code'] = 1;
  2454. echo json_encode($result);
  2455. die();
  2456. } else {
  2457. $result['msg'] = '已存在其他活动中';
  2458. echo json_encode($result);
  2459. die();
  2460. }
  2461. }
  2462. public function niyuansubject_sub()
  2463. {
  2464. $subject_id = I('post.subject',0);
  2465. $goods_id = I('post.goods_id',0);
  2466. if($goods_id == 0){
  2467. $result['msg'] = '商品不存在';
  2468. echo json_encode($result);
  2469. die();
  2470. }
  2471. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2472. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2473. $super_data = array();
  2474. $super_data['subject_id'] = $subject_id;
  2475. $super_data['goods_id'] = $goods_id;
  2476. $super_data['state'] = 0;
  2477. $super_data['addtime'] = time();
  2478. $rs = M('subject_goods')->add($super_data);
  2479. if($rs) {
  2480. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'niyuan') );
  2481. }
  2482. $result['code'] = 1;
  2483. echo json_encode($result);
  2484. die();
  2485. } else {
  2486. $result['msg'] = '已存在其他活动中';
  2487. echo json_encode($result);
  2488. die();
  2489. }
  2490. }
  2491. public function mianfei_sub()
  2492. {
  2493. $subject_id = I('post.subject',0);
  2494. $goods_id = I('post.goods_id',0);
  2495. if($goods_id == 0){
  2496. $result['msg'] = '商品不存在';
  2497. echo json_encode($result);
  2498. die();
  2499. }
  2500. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2501. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2502. $super_data = array();
  2503. $super_data['subject_id'] = $subject_id;
  2504. $super_data['goods_id'] = $goods_id;
  2505. $super_data['state'] = 0;
  2506. $super_data['addtime'] = time();
  2507. $rs = M('subject_goods')->add($super_data);
  2508. if($rs) {
  2509. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'zeyuan') );
  2510. }
  2511. $result['code'] = 1;
  2512. echo json_encode($result);
  2513. die();
  2514. } else {
  2515. $result['msg'] = '已存在其他活动中';
  2516. echo json_encode($result);
  2517. die();
  2518. }
  2519. }
  2520. public function putongsubject_sub()
  2521. {
  2522. $subject_id = I('post.subject',0);
  2523. $goods_id = I('post.goods_id',0);
  2524. if($goods_id == 0){
  2525. $result['msg'] = '商品不存在';
  2526. echo json_encode($result);
  2527. die();
  2528. }
  2529. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2530. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2531. $super_data = array();
  2532. $super_data['subject_id'] = $subject_id;
  2533. $super_data['goods_id'] = $goods_id;
  2534. $super_data['state'] = 0;
  2535. $super_data['addtime'] = time();
  2536. $rs = M('subject_goods')->add($super_data);
  2537. if($rs) {
  2538. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'subject') );
  2539. }
  2540. $result['code'] = 1;
  2541. echo json_encode($result);
  2542. die();
  2543. } else {
  2544. $result['msg'] = '已存在其他活动中';
  2545. echo json_encode($result);
  2546. die();
  2547. }
  2548. }
  2549. public function haitaosubject_sub()
  2550. {
  2551. $subject_id = I('post.subject',0);
  2552. $goods_id = I('post.goods_id',0);
  2553. if($goods_id == 0){
  2554. $result['msg'] = '商品不存在';
  2555. echo json_encode($result);
  2556. die();
  2557. }
  2558. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2559. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2560. $super_data = array();
  2561. $super_data['subject_id'] = $subject_id;
  2562. $super_data['goods_id'] = $goods_id;
  2563. $super_data['state'] = 0;
  2564. $super_data['addtime'] = time();
  2565. $rs = M('subject_goods')->add($super_data);
  2566. if($rs) {
  2567. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'haitao') );
  2568. }
  2569. $result['code'] = 1;
  2570. echo json_encode($result);
  2571. die();
  2572. } else {
  2573. $result['msg'] = '已存在其他活动中';
  2574. echo json_encode($result);
  2575. die();
  2576. }
  2577. }
  2578. public function yiyuan_form()
  2579. {
  2580. $result = array('code' => 0);
  2581. $goods_id = I('post.goods_id',0);
  2582. if($goods_id == 0){
  2583. $result['msg'] = '商品不存在';
  2584. echo json_encode($result);
  2585. die();
  2586. }
  2587. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2588. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2589. $subject = M('subject')->where('can_shenqing=1 and type="oneyuan"')->select();
  2590. $this->subject = $subject;
  2591. $this->goods_id = $goods_id;
  2592. $content = $this->fetch('Goods:goods_oneyuansubject_fetch');
  2593. $result['code'] = 1;
  2594. $result['html'] = $content;
  2595. echo json_encode($result);
  2596. die();
  2597. } else {
  2598. $result['msg'] = '已存在其他活动中';
  2599. echo json_encode($result);
  2600. die();
  2601. }
  2602. }
  2603. public function jiukuaijiu_form()
  2604. {
  2605. $result = array('code' => 0);
  2606. $goods_id = I('post.goods_id',0);
  2607. if($goods_id == 0){
  2608. $result['msg'] = '商品不存在';
  2609. echo json_encode($result);
  2610. die();
  2611. }
  2612. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2613. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2614. $subject = M('subject')->where('can_shenqing=1 and type="niyuan"')->select();
  2615. $this->subject = $subject;
  2616. $this->goods_id = $goods_id;
  2617. $content = $this->fetch('Goods:goods_niyuansubject_fetch');
  2618. $result['code'] = 1;
  2619. $result['html'] = $content;
  2620. echo json_encode($result);
  2621. die();
  2622. } else {
  2623. $result['msg'] = '已存在其他活动中';
  2624. echo json_encode($result);
  2625. die();
  2626. }
  2627. }
  2628. public function lottery_form()
  2629. {
  2630. $result = array('code' => 0);
  2631. $goods_id = I('post.goods_id',0);
  2632. if($goods_id == 0){
  2633. $result['msg'] = '商品不存在';
  2634. echo json_encode($result);
  2635. die();
  2636. }
  2637. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2638. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2639. $voucher_list = M('voucher')->where( "store_id=".SELLERUID." and begin_time>".time() )->select();
  2640. $this->voucher_list = $voucher_list;
  2641. $this->goods_id = $goods_id;
  2642. $content = $this->fetch('Goods:goods_lottery_fetch');
  2643. $result['code'] = 1;
  2644. $result['html'] = $content;
  2645. echo json_encode($result);
  2646. die();
  2647. } else {
  2648. $result['msg'] = '已存在其他活动中';
  2649. echo json_encode($result);
  2650. die();
  2651. }
  2652. }
  2653. public function lottery_sub()
  2654. {
  2655. $voucher_id = I('post.voucher_id',0);
  2656. $goods_id = I('post.goods_id',0);
  2657. $win_quantity = I('post.win_quantity',0);
  2658. $is_auto_open = I('post.is_auto_open',0);
  2659. $real_win_quantity = I('post.real_win_quantity',0);
  2660. if($goods_id == 0){
  2661. $result['msg'] = '商品不存在';
  2662. echo json_encode($result);
  2663. die();
  2664. }
  2665. if($voucher_id == 0){
  2666. $result['msg'] = '请选择退款时赠送的优惠券';
  2667. echo json_encode($result);
  2668. die();
  2669. }
  2670. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2671. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2672. $spike_data = array();
  2673. $spike_data['goods_id'] = $goods_id;
  2674. $spike_data['state'] = 0;
  2675. $spike_data['is_open_lottery'] = 0;
  2676. $spike_data['voucher_id'] = $voucher_id;
  2677. $spike_data['win_quantity'] = $win_quantity;
  2678. $spike_data['is_auto_open'] = $is_auto_open;
  2679. $spike_data['real_win_quantity'] = $real_win_quantity;
  2680. $spike_data['quantity'] = $goods_info['quantity'];
  2681. $spike_data['begin_time'] = 0;
  2682. $spike_data['end_time'] = 0;
  2683. $spike_data['addtime'] = time();
  2684. $rs = M('lottery_goods')->add($spike_data);
  2685. if($rs) {
  2686. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'lottery') );
  2687. }
  2688. $result['code'] = 1;
  2689. echo json_encode($result);
  2690. die();
  2691. die();
  2692. } else {
  2693. $result['msg'] = '已存在其他活动中';
  2694. echo json_encode($result);
  2695. die();
  2696. }
  2697. }
  2698. public function putongsubject_form()
  2699. {
  2700. $result = array('code' => 0);
  2701. $goods_id = I('post.goods_id',0);
  2702. if($goods_id == 0){
  2703. $result['msg'] = '商品不存在';
  2704. echo json_encode($result);
  2705. die();
  2706. }
  2707. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2708. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2709. $subject = M('subject')->where('can_shenqing=1 and type="normal"')->select();
  2710. $this->subject = $subject;
  2711. $this->goods_id = $goods_id;
  2712. $content = $this->fetch('Goods:goods_putongsubject_fetch');
  2713. $result['code'] = 1;
  2714. $result['html'] = $content;
  2715. echo json_encode($result);
  2716. die();
  2717. } else {
  2718. $result['msg'] = '已存在其他活动中';
  2719. echo json_encode($result);
  2720. die();
  2721. }
  2722. }
  2723. public function haitaosubject_form()
  2724. {
  2725. $result = array('code' => 0);
  2726. $goods_id = I('post.goods_id',0);
  2727. if($goods_id == 0){
  2728. $result['msg'] = '商品不存在';
  2729. echo json_encode($result);
  2730. die();
  2731. }
  2732. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2733. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2734. $subject = M('subject')->where('can_shenqing=1 and type="haitao"')->select();
  2735. $this->subject = $subject;
  2736. $this->goods_id = $goods_id;
  2737. $content = $this->fetch('Goods:goods_haitaosubject_fetch');
  2738. $result['code'] = 1;
  2739. $result['html'] = $content;
  2740. echo json_encode($result);
  2741. die();
  2742. } else {
  2743. $result['msg'] = '已存在其他活动中';
  2744. echo json_encode($result);
  2745. die();
  2746. }
  2747. }
  2748. public function mianfeishiyong_form()
  2749. {
  2750. $result = array('code' => 0);
  2751. $goods_id = I('post.goods_id',0);
  2752. if($goods_id == 0){
  2753. $result['msg'] = '商品不存在';
  2754. echo json_encode($result);
  2755. die();
  2756. }
  2757. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2758. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2759. $subject = M('subject')->where('can_shenqing=1 and type="zeyuan"')->select();
  2760. $this->subject = $subject;
  2761. $this->goods_id = $goods_id;
  2762. $content = $this->fetch('Goods:goods_mianfeishiyong_fetch');
  2763. $result['code'] = 1;
  2764. $result['html'] = $content;
  2765. echo json_encode($result);
  2766. die();
  2767. } else {
  2768. $result['msg'] = '已存在其他活动中';
  2769. echo json_encode($result);
  2770. die();
  2771. }
  2772. }
  2773. public function chaozhidapai_form()
  2774. {
  2775. $result = array('code' => 0);
  2776. $goods_id = I('post.goods_id',0);
  2777. if($goods_id == 0){
  2778. $result['msg'] = '商品不存在';
  2779. echo json_encode($result);
  2780. die();
  2781. }
  2782. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2783. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2784. $super_spike_list = M('super_spike')->where('begin_time>'.time())->select();
  2785. $this->super_spike_list = $super_spike_list;
  2786. $this->goods_id = $goods_id;
  2787. $content = $this->fetch('Goods:goods_chaozhidapai_fetch');
  2788. $result['code'] = 1;
  2789. $result['html'] = $content;
  2790. echo json_encode($result);
  2791. die();
  2792. } else {
  2793. $result['msg'] = '已存在其他活动中';
  2794. echo json_encode($result);
  2795. die();
  2796. }
  2797. }
  2798. public function spike_form()
  2799. {
  2800. $result = array('code' => 0);
  2801. $goods_id = I('post.goods_id',0);
  2802. if($goods_id == 0){
  2803. $result['msg'] = '商品不存在';
  2804. echo json_encode($result);
  2805. die();
  2806. }
  2807. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2808. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2809. $spike_list = M('spike')->where()->select();
  2810. //$spike_list = M('spike')->where('begin_time>'.time())->select();
  2811. $this->spike_list = $spike_list;
  2812. $this->goods_id = $goods_id;
  2813. $content = $this->fetch('Goods:goods_spike_fetch');
  2814. $result['code'] = 1;
  2815. $result['html'] = $content;
  2816. echo json_encode($result);
  2817. die();
  2818. } else {
  2819. $result['msg'] = '已存在其他活动中';
  2820. echo json_encode($result);
  2821. die();
  2822. }
  2823. }
  2824. public function get_json_category_tree($pid,$is_ajax=0)
  2825. {
  2826. // {pid:pid,is_ajax:1}
  2827. $pid = empty($_GET['pid']) ? 0: intval($_GET['pid']);
  2828. $is_ajax = empty($_GET['is_ajax']) ? 0:intval($_GET['is_ajax']);
  2829. $goods_cate_model = D('Seller/GoodsCategory');
  2830. //$list = $goods_cate_model->get_parent_cateory($pid,SELLERUID);
  2831. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid) )->order('sort_order asc')->select();
  2832. if($pid > 0)
  2833. {
  2834. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid) )->order('sort_order asc')->select();
  2835. }
  2836. $result = array();
  2837. if($is_ajax ==0)
  2838. {
  2839. return $list;
  2840. } else {
  2841. if(empty($list)){
  2842. $result['code'] = 0;
  2843. } else {
  2844. $result['code'] = 1;
  2845. $result['list'] = $list;
  2846. }
  2847. echo json_encode($result);
  2848. die();
  2849. }
  2850. }
  2851. function add(){
  2852. $model=new GoodsModel();
  2853. if(IS_POST){
  2854. $data=I('post.');
  2855. $data['goods_description']['tag'] = str_replace(',', ',', $data['goods_description']['tag']);
  2856. $data['store_id']=SELLERUID;
  2857. if($this->goods_is_shenhe()) {
  2858. $data['status'] = 2;
  2859. }
  2860. $return=$model->add_goods($data);
  2861. $this->osc_alert($return);
  2862. }
  2863. $m=new \Admin\Model\OptionModel();
  2864. //getOptions
  2865. $options_list = $m->getOptions('',SELLERUID);
  2866. $this->options_list = $options_list;
  2867. $pick_list = M('pick_up')->where( array('store_id' => SELLERUID) )->select();
  2868. $this->pick_list = $pick_list;
  2869. $member_model= D('Admin/Member');
  2870. $level_list = $member_model->show_member_level();
  2871. $member_default_levelname_info = D('Home/Front')->get_config_by_name('member_default_levelname');
  2872. $member_defualt_discount_info = D('Home/Front')->get_config_by_name('member_defualt_discount');
  2873. $default = array('id'=>'default', 'level' => 0,'levelname' => $member_default_levelname_info,'discount' => $member_defualt_discount_info);
  2874. array_unshift($level_list['list'], $default );
  2875. $need_level_list = $level_list['list'];
  2876. $set = D('Seller/Config')->get_all_config();
  2877. $this->set = $set;
  2878. /***
  2879. 是否开启 分享等级佣金 begin
  2880. **/
  2881. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  2882. if( empty($index_sort_method) || $index_sort_method == 0 )
  2883. {
  2884. $index_sort_method = 0;
  2885. }
  2886. $this->index_sort_method = $index_sort_method;
  2887. $show_fissionsharing_level = 1;
  2888. $is_open_sharing = D('Home/Front')->get_config_by_name('is_open_fissionsharing');
  2889. $show_fissionsharing_level = D('Home/Front')->get_config_by_name('show_fissionsharing_level');
  2890. $this->show_fissionsharing_level = $show_fissionsharing_level;
  2891. $this->is_open_sharing = $is_open_sharing;
  2892. /***
  2893. 是否开启 分享等级佣金 end
  2894. **/
  2895. $this->member_level_is_open_info = D('Home/Front')->get_config_by_name('member_level_is_open');
  2896. $this->need_level_list = $need_level_list;
  2897. $this->cate_data = $this->get_json_category_tree(0);
  2898. $this->action=U('Goods/add');
  2899. $this->crumbs='新增';
  2900. $this->display('edit');
  2901. }
  2902. /**
  2903. 商品是否需要审核
  2904. **/
  2905. function goods_is_shenhe()
  2906. {
  2907. $shenhegoods = M('config')->where( array('name' => 'shenhegoods') )->find();
  2908. $is_need_shen = 0;
  2909. if(!empty($shenhegoods)) {
  2910. $is_need_shen = $shenhegoods['value'];
  2911. }
  2912. return $is_need_shen;
  2913. }
  2914. public function change()
  2915. {
  2916. $id = I('request.id',0);
  2917. //ids
  2918. if (empty($id)) {
  2919. $ids = I('request.ids');
  2920. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  2921. }
  2922. if (empty($id)) {
  2923. show_json(0, array('message' => '参数错误'));
  2924. }
  2925. $type = I('request.type');
  2926. $value = I('request.value');
  2927. //type/grounding/
  2928. $is_can_do = D('Seller/Supply')->checksupply_pri( $type );
  2929. if( !$is_can_do )
  2930. {
  2931. show_json(0, array('message' => '无此操作权限','url' => $_SERVER['HTTP_REFERER'] ));
  2932. }
  2933. if (!(in_array($type, array('goodsname', 'price','index_sort','is_index_show', 'total','grounding', 'goodssn', 'productsn', 'displayorder')))) {
  2934. show_json(0, array('message' => '参数错误','url' => $_SERVER['HTTP_REFERER'] ));
  2935. }
  2936. if($type =='total'){
  2937. $value=str_replace('.00','',$value);
  2938. if(preg_match("/^[1-9][0-9]*$/" ,$value) || $value == 0 ) {
  2939. }else{
  2940. show_json(3);
  2941. }
  2942. }
  2943. $items = M('lionfish_comshop_goods')->field('id,goodsname')->where( array('id' => array('in', $id)) )->select();
  2944. foreach ($items as $item ) {
  2945. if($type == 'grounding' && $value == 1){//上架判断核销商品过期时间
  2946. $goods_hexiao = M('lionfish_comshop_goods_salesroombase')->field('is_only_hexiao,hexiao_type,hx_expire_type,hx_expire_end_time')->where( array('goods_id' => $item['id']) )->find();
  2947. if(!empty($goods_hexiao) && $goods_hexiao['is_only_hexiao'] == 1 && $goods_hexiao['hx_expire_type'] == 1){
  2948. if($goods_hexiao['hx_expire_end_time'] < time()){
  2949. show_json(0, array('message' => '核销过期时间小于当前时间,商品不能上架','url' => $_SERVER['HTTP_REFERER'] ));
  2950. }
  2951. }
  2952. }
  2953. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->save( array($type => $value) );
  2954. if($type == 'goodsname'){
  2955. D('Seller/Operatelog')->addOperateLog('goods','商品修改名称--'.$item['goodsname']);
  2956. }elseif($type == 'price'){
  2957. D('Seller/Operatelog')->addOperateLog('goods','商品修改价格--'.$item['goodsname']);
  2958. }elseif($type == 'index_sort'){
  2959. D('Seller/Operatelog')->addOperateLog('goods','商品修改排序序号--'.$item['goodsname']);
  2960. }elseif($type == 'is_index_show'){
  2961. D('Seller/Operatelog')->addOperateLog('goods','商品修改首页推荐--'.$item['goodsname']);
  2962. }elseif($type == 'total'){
  2963. D('Seller/Operatelog')->addOperateLog('goods','商品修改库存--'.$item['goodsname']);
  2964. }elseif($type == 'grounding'){
  2965. if($value == 1){
  2966. if (defined('ROLE') && ROLE == 'agenter' )
  2967. {
  2968. $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
  2969. if($supply_add_goods_shenhe == 1 )
  2970. {
  2971. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->save( array('grounding' => 4) );
  2972. }
  2973. }
  2974. //D('Seller/Operatelog')->addOperateLog('goods','商品上架--'.$item['goodsname']);
  2975. }
  2976. if($value == 0){
  2977. D('Seller/Operatelog')->addOperateLog('goods','商品下架--'.$item['goodsname']);
  2978. }
  2979. if($value == 2){
  2980. D('Seller/Operatelog')->addOperateLog('goods','商品放入仓库中--'.$item['goodsname']);
  2981. }
  2982. if($value == 3){
  2983. D('Seller/Operatelog')->addOperateLog('goods','商品放入回收站--'.$item['goodsname']);
  2984. }
  2985. }elseif($type == 'goodssn'){
  2986. }elseif($type == 'productsn'){
  2987. }elseif($type == 'displayorder'){
  2988. }
  2989. if($type == 'total')
  2990. {
  2991. D('Seller/Redisorder')->sysnc_goods_total($item['id']);
  2992. }
  2993. }
  2994. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2995. }
  2996. public function delete()
  2997. {
  2998. $id = I('get.id');
  2999. //ids
  3000. if (empty($id)) {
  3001. $ids = I('post.ids');
  3002. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  3003. }
  3004. if (empty($id)) {
  3005. show_json(0, array('message' => '参数错误'));
  3006. }
  3007. $items = M('lionfish_comshop_goods')->field('id,goodsname')->where( array('id' => array('in', $id)) )->select();
  3008. foreach ($items as $item ) {
  3009. //pdo_update('lionfish_comshop_goods', array($type => $value), array('id' => $item['id'])); //ims_lionfish_comshop_goods
  3010. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->delete();
  3011. M('lionfish_comshop_goods_images')->where( array('goods_id' => $item['id']) )->delete();
  3012. M('lionfish_comshop_goods_option')->where( array('goods_id' => $item['id']) )->delete();
  3013. M('lionfish_comshop_goods_option_item')->where( array('goods_id' => $item['id']) )->delete();
  3014. M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $item['id']) )->delete();
  3015. M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $item['id']) )->delete();
  3016. M('lionfish_comshop_good_common')->where( array('goods_id' => $item['id']) )->delete();
  3017. D('Seller/Operatelog')->addOperateLog('goods','永久删除商品--'.$item['goodsname']);
  3018. }
  3019. sellerLog('删除了['.$items['goodsname'].']商品', 3);
  3020. show_json(1);
  3021. }
  3022. function edit(){
  3023. $id = I('get.id');
  3024. if (IS_POST) {
  3025. $_GPC = I('post.');
  3026. if( !isset($_GPC['thumbs']) || empty($_GPC['thumbs']) )
  3027. {
  3028. show_json(0, array('message' => '商品图片必须上传' ,'url' => $_SERVER['HTTP_REFERER']) );
  3029. die();
  3030. }
  3031. if(!empty($_GPC['has_mb_level_buy'])){
  3032. foreach($_GPC['discount'] as $val)
  3033. {
  3034. if(preg_match("/^(([1-9]\d?)|100)$/", $val)){
  3035. }else{
  3036. show_json(0, array('message' => '请按照提示设置独立会员等级折扣' ,'url' => $_SERVER['HTTP_REFERER']) );
  3037. die();
  3038. }
  3039. }
  3040. }
  3041. if($_GPC['is_only_distribution'] == 1 && !empty($_GPC['supply_id']) ){
  3042. //供应商开启同城
  3043. $sup_isopen_localtown_delivery = D('Home/Front')->get_supply_config_by_name('isopen_localtown_delivery',$_GPC['supply_id']);
  3044. if( empty($sup_isopen_localtown_delivery) )
  3045. {
  3046. $supply_name = M('lionfish_comshop_supply')->field('shopname,type')->where( array('id' => $_GPC['supply_id'] ) )->find();
  3047. if($supply_name["type"] == 1 ){
  3048. show_json(0, array('message' => '独立供应商('.$supply_name["shopname"].')没有开启同城配送,此商品无法开启同城配送' ,'url' => $_SERVER['HTTP_REFERER']) );
  3049. die();
  3050. }
  3051. }
  3052. }
  3053. $supply_id = $_GPC['supply_id'];
  3054. if (defined('ROLE') && ROLE == 'agenter' )
  3055. {
  3056. $supper_info = get_agent_logininfo();
  3057. $supply_id = $supper_info['id'];
  3058. }
  3059. if($_GPC['is_only_hexiao'] == 1){
  3060. if(!empty($supply_id)){
  3061. $salesroom_count = M('lionfish_comshop_salesroom')->where( array('supply_id' => $supply_id,'state'=>1 ) )->count();
  3062. if($salesroom_count == 0){
  3063. $supply_name = M('lionfish_comshop_supply')->field('shopname,type')->where( array('id' => $supply_id ) )->find();
  3064. if($supply_name["type"] == 1 ){
  3065. show_json(0, array('message' => '独立供应商('.$supply_name["shopname"].')没有创建门店信息,此商品无法开启到店核销' ,'url' => $_SERVER['HTTP_REFERER']) );
  3066. die();
  3067. }
  3068. }
  3069. }
  3070. if($_GPC['grounding'] == 1){//上架商品
  3071. if($_GPC['hx_expire_type'] == 1){//指定过期时间
  3072. $hx_expire_end_time = $_GPC['hx_expire_end_time'];
  3073. if(strtotime($hx_expire_end_time) < time()){
  3074. show_json(0, array('message' => '核销过期时间小于当前时间,商品不能上架' ,'url' => $_SERVER['HTTP_REFERER']) );
  3075. die();
  3076. }
  3077. }
  3078. }
  3079. if($_GPC['hx_expire_type'] == 1){//指定过期时间
  3080. if($_GPC['hx_auto_off'] == 1){//设置自动下架时间
  3081. if(empty($_GPC['hx_auto_off_time']) || !is_numeric($_GPC['hx_auto_off_time']) || floatval($_GPC['hx_auto_off_time']) <= 0){
  3082. show_json(0, array('message' => '提前自动下架商品时间不能为空且必须为大于0数字' ,'url' => $_SERVER['HTTP_REFERER']) );
  3083. die();
  3084. }
  3085. }
  3086. }
  3087. }
  3088. //礼品卡
  3089. if (isset($_GET['goods_type']) && $_GET['goods_type'] == 'virtualcard')
  3090. {
  3091. $type = 'virtualcard';
  3092. $virtual_code_id = I('post.virtual_code_id');
  3093. if( !isset($virtual_code_id) || $virtual_code_id <= 0 )
  3094. {
  3095. show_json(0, array('message' => '礼品卡商品必须关联兑换码' ,'url' => $_SERVER['HTTP_REFERER']) );
  3096. die();
  3097. }
  3098. }
  3099. //预售时间判断
  3100. if( isset($_GET['goods_type']) && $_GET['goods_type'] == 'presale' )
  3101. {
  3102. //预售时间限制判断
  3103. $time = I('post.time');
  3104. $post_begin_time = strtotime( $time['start'] );
  3105. $post_end_time = strtotime( $time['end'] );
  3106. $presale_ding_time = I('post.presale_ding_time');//定金支付时间
  3107. $presale_ding_time_start = strtotime( $presale_ding_time['start'] ); //开始
  3108. $presale_ding_time_end = strtotime( $presale_ding_time['end'] );//结束
  3109. if($presale_ding_time_start < $post_begin_time )
  3110. {
  3111. show_json(0, array('message' => '预售定金支付开始时间不能小于团购开始时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  3112. die();
  3113. }
  3114. if($presale_ding_time_end > $post_end_time )
  3115. {
  3116. show_json(0, array('message' => '预售定金支付结束时间不能大于团购结束时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  3117. die();
  3118. }
  3119. $presale_sendorder_type = I('post.presale_sendorder_type');
  3120. if($presale_sendorder_type == 1)
  3121. {
  3122. $presale_sendorder_afterday = I('post.presale_sendorder_afterday');
  3123. if( $presale_sendorder_afterday < 1 )
  3124. {
  3125. show_json(0, array('message' => '预售购买后几日发货必须是大于0的整数' ,'url' => $_SERVER['HTTP_REFERER']) );
  3126. die();
  3127. }
  3128. }else if( $presale_sendorder_type == 0 )
  3129. {
  3130. //预计发货时间 必须大于 定金尾款付款时间
  3131. $presale_sendorder_datetime = I('post.presale_sendorder_datetime');
  3132. $presale_sendorder_datetime = strtotime($presale_sendorder_datetime.' 00:00:00');
  3133. if( $presale_sendorder_datetime < $presale_ding_time_start )
  3134. {
  3135. show_json(0, array('message' => '固定发货日期必须大于定金支付开始时间' ,'url' => $_SERVER['HTTP_REFERER']) );
  3136. die();
  3137. }
  3138. }
  3139. }
  3140. //判断预售价格是否合理设置,不是bug价格
  3141. $this->checkPresaleAddGoods();
  3142. D('Seller/Goods')->modify_goods();
  3143. $http_refer = S('HTTP_REFERER');
  3144. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  3145. $goods = M('lionfish_comshop_goods')->where('id = "'.I('get.id').'"')->field('goodsname')->find();
  3146. sellerLog('编辑了['.$goods['goodsname'].']商品', 3);
  3147. D('Seller/Operatelog')->addOperateLog('goods','编辑商品--'.$goods['goodsname']);
  3148. show_json(1, array('message'=>'修改商品成功!','url' => $http_refer ));
  3149. }
  3150. //sss
  3151. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  3152. $this->id = $id;
  3153. $item = D('Seller/Goods')->get_edit_goods_info($id);
  3154. //-------------------------以上是获取资料
  3155. $limit_goods = array();
  3156. //limit_goods_list
  3157. if( !empty($item['relative_goods_list']) )
  3158. {
  3159. $item['relative_goods_list'] = unserialize($item['relative_goods_list']);
  3160. if( !empty($item['relative_goods_list']) )
  3161. {
  3162. $relative_goods_list_str = implode(',', $item['relative_goods_list']);
  3163. $limit_goods = M()->query("SELECT id as gid,goodsname,subtitle FROM " . C('DB_PREFIX') .
  3164. 'lionfish_comshop_goods WHERE id in('.$relative_goods_list_str.') order by id desc' );
  3165. foreach($limit_goods as $kk => $vv)
  3166. {
  3167. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $vv['gid'] ) )->order('id asc')->find();
  3168. $vv['image'] = tomedia($thumb['image']);
  3169. $limit_goods[$kk] = $vv;
  3170. }
  3171. }
  3172. }
  3173. $this->limit_goods = $limit_goods;
  3174. $mb_level_discount_list = array();
  3175. if(!empty($item['mb_level_buy_list'])){
  3176. $item['mb_level_buy_list'] = unserialize($item['mb_level_buy_list']);
  3177. foreach($item['mb_level_buy_list'] as $k=>$v){
  3178. $mb_level_discount_list[$v['level_id']] = $v['discount'];
  3179. }
  3180. }
  3181. $this->mb_level_discount_list = $mb_level_discount_list;
  3182. $category = D('Seller/GoodsCategory')->getFullCategory(true, true);
  3183. $this->category = $category;
  3184. $spec_list = D('Seller/Spec')->get_all_spec();
  3185. $this->spec_list = $spec_list;
  3186. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1, 'isdefault' => 1) )->order('sort_order desc')->select();
  3187. $this->dispatch_data = $dispatch_data;
  3188. $set = D('Seller/Config')->get_all_config();
  3189. $this->set = $set;
  3190. $commission_level = array();
  3191. $config_data = $set;
  3192. $this->config_data = $config_data;
  3193. $default = array('id' => 'default', 'levelname' => empty($config_data['commission_levelname']) ? '默认等级' : $config_data['commission_levelname'], 'commission1' => $config_data['commission1'], 'commission2' => $config_data['commission2'], 'commission3' => $config_data['commission3']);
  3194. //$others = pdo_fetchall('SELECT * FROM ' . tablename('lionfish_comshop_commission_level') . ' WHERE uniacid = \'' . $_W['uniacid'] . '\' ORDER BY commission1 asc');
  3195. //$commission_level = array_merge(array($default), $others);
  3196. $commission_level = array();
  3197. //$level['key']
  3198. foreach($commission_level as $key => $val)
  3199. {
  3200. $val['key'] = $val['id'];
  3201. $commission_level[$key] = $val;
  3202. }
  3203. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  3204. $this->shopset_level = $shopset_level;
  3205. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  3206. $this->open_buy_send_score = $open_buy_send_score;
  3207. $delivery_type_express = $config_data['delivery_type_express'];
  3208. if( empty($delivery_type_express) )
  3209. {
  3210. $delivery_type_express = 2;
  3211. }
  3212. $this->delivery_type_express = $delivery_type_express;
  3213. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  3214. $this->is_open_fullreduction = $is_open_fullreduction;
  3215. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  3216. $head_commission_levelname = $config_data['head_commission_levelname'];
  3217. $default_comunity_money = $config_data['default_comunity_money'];
  3218. $list_default = array(
  3219. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  3220. );
  3221. $community_head_level = array_merge($list_default, $community_head_level);
  3222. $community_head_commission_info = D('Seller/Communityhead')->get_goods_head_level_bili( $id );
  3223. $mb_level = M('lionfish_comshop_member_level')->count();
  3224. $this->mb_level = $mb_level;
  3225. if( !empty($community_head_commission_info) )
  3226. {
  3227. foreach( $community_head_commission_info as $kk => $vv)
  3228. {
  3229. $item[$kk] = $vv;
  3230. }
  3231. }
  3232. //判断是否预售 begin
  3233. if( $item['type'] == 'presale' )
  3234. {
  3235. $goods_presale = M('lionfish_comshop_goods_presale')->where(['goods_id' => $id ])->find();
  3236. if( !empty($goods_presale) )
  3237. {
  3238. unset( $goods_presale['id'] );
  3239. unset( $goods_presale['goods_id'] );
  3240. unset( $goods_presale['addtime'] );
  3241. foreach( $goods_presale as $k => $val )
  3242. {
  3243. $item[ $k ] = $val;
  3244. }
  3245. }
  3246. }
  3247. //end
  3248. //判断是否兑换卡 begin
  3249. if( $item['type'] == 'virtualcard' )
  3250. {
  3251. //商品选中的兑换编组
  3252. $goods_virtualcode_info = D('Seller/VirtualCard')->getGoodsVirtualCardInfoByGoodsId( $id );
  3253. $goods_virtualcode_id = $goods_virtualcode_info['code_id'];
  3254. $this->goods_virtualcode_id = $goods_virtualcode_id;
  3255. //可用的兑换编组列表
  3256. $virtualcard_code_list = D('Seller/VirtualCard')->getCanUseVirtualcardCodes( );
  3257. $this->virtualcard_code_list = $virtualcard_code_list;
  3258. }
  3259. //end
  3260. $this->community_head_commission_info = $community_head_commission_info;
  3261. $this->item = $item;
  3262. $this->community_head_level = $community_head_level;
  3263. //end
  3264. $community_money_type = $config_data['community_money_type'];
  3265. $this->community_money_type = $community_money_type;
  3266. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  3267. if( empty($index_sort_method) || $index_sort_method == 0 )
  3268. {
  3269. $index_sort_method = 0;
  3270. }
  3271. $this->index_sort_method = $index_sort_method;
  3272. $is_open_only_express = $config_data['is_open_only_express'];
  3273. $this->is_open_only_express = $is_open_only_express;
  3274. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  3275. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  3276. //获取会员等级列表
  3277. $member_level_ist = M('lionfish_comshop_member_level')->order('id asc')->select();
  3278. //供应商权限begin
  3279. $is_index = true;
  3280. $is_top = true;
  3281. $is_updown = true;
  3282. $is_fullreduce = true;
  3283. $is_vir_count = true;
  3284. $is_newbuy = true;
  3285. $is_goodsspike = true;
  3286. $supply_can_goods_sendscore = true;
  3287. $supply_can_distribution_sale = 1;
  3288. $sales_supply_id = 0;
  3289. if (defined('ROLE') && ROLE == 'agenter' )
  3290. {
  3291. $supply_can_goods_sendscore = empty($config_data['supply_can_goods_sendscore']) ? 0: $config_data['supply_can_goods_sendscore'];
  3292. $supply_can_distribution_sale = empty($config_data['supply_can_distribution_sale']) ? 0: $config_data['supply_can_distribution_sale'];
  3293. $is_fullreduce = false;
  3294. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  3295. {
  3296. $is_index = false;
  3297. }
  3298. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  3299. {
  3300. $is_top = false;
  3301. }
  3302. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  3303. {
  3304. $is_updown = false;
  3305. }
  3306. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  3307. {
  3308. $is_vir_count = false;
  3309. }
  3310. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  3311. {
  3312. $is_newbuy = false;
  3313. }
  3314. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  3315. {
  3316. $is_goodsspike = false;
  3317. }
  3318. $sales_supply_id = $supper_info = get_agent_logininfo();
  3319. $sales_supply_id = $supper_info['id'];
  3320. }
  3321. $salesroom_count = M('lionfish_comshop_salesroom')->where(array('supply_id' => $sales_supply_id,'state'=>1))->count();
  3322. if($salesroom_count > 0){
  3323. $this->is_exist_salesroom = 1;
  3324. }
  3325. $is_open_vipcard_buy = $config_data['is_open_vipcard_buy'];
  3326. $seckill_is_open = $config_data['seckill_is_open'];
  3327. $is_head_takegoods = isset($config_data['is_head_takegoods']) && $config_data['is_head_takegoods'] == 1 ? 1 : 0;
  3328. $isopen_localtown_delivery = isset($config_data['isopen_localtown_delivery']) && $config_data['isopen_localtown_delivery'] == 1 ? 1 : 0;
  3329. $this->isopen_localtown_delivery = $isopen_localtown_delivery;
  3330. $salesroom_count = 0;
  3331. $this->salesroom_count = $salesroom_count;
  3332. //供应商权限end
  3333. $this->supply_can_goods_sendscore = $supply_can_goods_sendscore;
  3334. $this->supply_can_distribution_sale = $supply_can_distribution_sale;
  3335. $this->is_index = $is_index;
  3336. $this->is_top = $is_top;
  3337. $this->is_updown = $is_updown;
  3338. $this->is_fullreduce = $is_fullreduce;
  3339. $this->is_vir_count = $is_vir_count;
  3340. $this->is_newbuy = $is_newbuy;
  3341. $this->is_goodsspike = $is_goodsspike;
  3342. $this->is_open_vipcard_buy = $is_open_vipcard_buy;
  3343. $this->seckill_is_open = $seckill_is_open;
  3344. $this->is_head_takegoods = $is_head_takegoods;
  3345. $this->member_level_is_open_info = D('Home/Front')->get_config_by_name('member_level_is_open');
  3346. $this->member_level_ist = $member_level_ist;
  3347. //$is_default_levellimit_buy = isset($config_data['is_default_levellimit_buy']) && $config_data['is_default_levellimit_buy'] == 1 ? 1 : 0;
  3348. //$this->is_default_levellimit_buy = $is_default_levellimit_buy;
  3349. //$is_default_vipmember_buy = isset($config_data['is_default_vipmember_buy']) && $config_data['is_default_vipmember_buy'] == 1 ? 1 : 0;
  3350. //$this->is_default_vipmember_buy = $is_default_vipmember_buy;
  3351. $isopen_localtown_delivery = isset($config_data['isopen_localtown_delivery']) && $config_data['isopen_localtown_delivery'] == 1 ? 1 : 0;
  3352. $this->isopen_localtown_delivery = $isopen_localtown_delivery;
  3353. $supply_is_open_localtown_distribution = isset($config_data['supply_is_open_localtown_distribution']) && $config_data['supply_is_open_localtown_distribution'] == 1 ? 1 : 0;
  3354. $this->supply_is_open_localtown_distribution = $supply_is_open_localtown_distribution;
  3355. if( $item['type'] == 'presale' )
  3356. {
  3357. $this->display('Presale/addgoods');
  3358. }
  3359. else if( $item['type'] == 'virtualcard' )
  3360. {
  3361. $this->display('Virtualcard/addgoods');
  3362. }
  3363. else{
  3364. $this->display('Goods/addgoods');
  3365. }
  3366. }
  3367. public function labelfile()
  3368. {
  3369. $_GPC = I('request.');
  3370. $id = intval($_GPC['id']);
  3371. if (empty($id)) {
  3372. show_json(0, array() );
  3373. die();
  3374. }
  3375. $condition = ' id = '.$id.' and state = 1 ';
  3376. $labels = M('lionfish_comshop_goods_tags')->field('id,tagname,type,tagcontent')->where($condition)->find();
  3377. if (empty($labels)) {
  3378. $labels = array();
  3379. show_json(0, array('msg' => '您查找的标签不存在或已删除!') );
  3380. die();
  3381. }
  3382. show_json(1, array('label' => $labels['tagname'], 'id' => $labels['id']));
  3383. }
  3384. public function goodstag()
  3385. {
  3386. $_GPC = I('request.');
  3387. $this->gpc = $_GPC;
  3388. $condition = ' 1 and tag_type="normal" ';
  3389. $pindex = max(1, intval($_GPC['page']));
  3390. $psize = 20;
  3391. if ($_GPC['enabled'] != '') {
  3392. $condition .= ' and state=' . intval($_GPC['enabled']);
  3393. }
  3394. if (!empty($_GPC['keyword'])) {
  3395. $_GPC['keyword'] = trim($_GPC['keyword']);
  3396. $condition .= ' and tagname like "%'.$_GPC['keyword'].'%" ';
  3397. }
  3398. $label = M('lionfish_comshop_goods_tags')->where( $condition )->order(' id asc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  3399. $total = M('lionfish_comshop_goods_tags')->where( $condition )->count();
  3400. $pager = pagination2($total, $pindex, $psize);
  3401. $this->label = $label;
  3402. $this->pager = $pager;
  3403. $this->display();
  3404. }
  3405. function copy_goods(){
  3406. $id =I('id');
  3407. $model=new GoodsModel();
  3408. if($id){
  3409. foreach ($id as $k => $v) {
  3410. $model->copy_goods($v);
  3411. }
  3412. $data['redirect']=U('Goods/index');
  3413. $this->ajaxReturn($data);
  3414. die;
  3415. }
  3416. }
  3417. function del(){
  3418. $model=new GoodsModel();
  3419. $return=$model->del_goods(I('get.id'));
  3420. $this->osc_alert($return);
  3421. }
  3422. /**
  3423. * 置顶
  3424. * @return [json] 0 失败 1 成功
  3425. */
  3426. public function settop()
  3427. {
  3428. $id = I('request.id');
  3429. //ids
  3430. if (empty($id)) {
  3431. $ids = I('request.ids');
  3432. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  3433. }
  3434. if (empty($id)) {
  3435. show_json(0, array('message' => '参数错误'));
  3436. }
  3437. $type = I('request.type');
  3438. $value = I('request.value');
  3439. if ($type != 'istop') {
  3440. show_json(0, array('message' => '参数错误'));
  3441. }
  3442. $items = M('lionfish_comshop_goods')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  3443. foreach ($items as $item ) {
  3444. $settoptime = $value ? time() : '';
  3445. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->save( array($type => $value, 'settoptime' => $settoptime) );
  3446. }
  3447. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  3448. }
  3449. public function industrial()
  3450. {
  3451. $_GPC = I('request.');
  3452. if ( IS_POST ) {
  3453. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  3454. $data['goods_industrial'] = serialize($data['goods_industrial']);
  3455. D('Seller/Config')->update($data);
  3456. D('Seller/Operatelog')->addOperateLog('goods','修改商品设置--工商资质');
  3457. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  3458. }
  3459. $data = D('Seller/Config')->get_all_config();
  3460. $data['goods_industrial'] = unserialize($data['goods_industrial']);
  3461. $piclist = array();
  3462. if( !empty($data['goods_industrial']) )
  3463. {
  3464. foreach($data['goods_industrial'] as $val)
  3465. {
  3466. $piclist[] = array('image' =>$val, 'thumb' => tomedia($val) ); //$val['image'];
  3467. }
  3468. }
  3469. $this->piclist = $piclist;
  3470. $this->data = $data;
  3471. $this->display();
  3472. }
  3473. /**
  3474. * excel商品导入编辑
  3475. * @author liu 2020-03-03
  3476. * */
  3477. public function excel_goodslist_edit()
  3478. {
  3479. $columns = array(
  3480. array(
  3481. 'title' => '商品ID(禁止修改)',
  3482. 'field' => 'id',
  3483. 'width' => 24
  3484. ) ,
  3485. array(
  3486. 'title' => '商品名称',
  3487. 'field' => 'goodsname',
  3488. 'width' => 24
  3489. ) ,
  3490. array(
  3491. 'title' => '一级分类ID',
  3492. 'field' => 'cate1_id',
  3493. 'width' => 24
  3494. ) ,
  3495. array(
  3496. 'title' => '一级分类名称',
  3497. 'field' => 'cate1_name',
  3498. 'width' => 24
  3499. ) ,
  3500. array(
  3501. 'title' => '二级分类ID',
  3502. 'field' => 'cate2_id',
  3503. 'width' => 24
  3504. ) ,
  3505. array(
  3506. 'title' => '二级分类名称',
  3507. 'field' => 'cate2_name',
  3508. 'width' => 24
  3509. ) ,
  3510. array(
  3511. 'title' => '商品价格',
  3512. 'field' => 'price',
  3513. 'width' => 24
  3514. ) ,
  3515. array(
  3516. 'title' => '商品成本价',
  3517. 'field' => 'costprice',
  3518. 'width' => 24
  3519. ) ,
  3520. array(
  3521. 'title' => '会员卡价格',
  3522. 'field' => 'card_price',
  3523. 'width' => 24
  3524. ) ,
  3525. array(
  3526. 'title' => '商品原价',
  3527. 'field' => 'productprice',
  3528. 'width' => 24
  3529. ) ,
  3530. array(
  3531. 'title' => '商品库存',
  3532. 'field' => 'total',
  3533. 'width' => 24
  3534. ) ,
  3535. array(
  3536. 'title' => '1上架/0下架',
  3537. 'field' => 'grounding',
  3538. 'width' => 24
  3539. ) ,
  3540. array(
  3541. 'title' => '首页推荐(0:取消/1:是)',
  3542. 'field' => 'is_index_show',
  3543. 'width' => 24
  3544. ) ,
  3545. array(
  3546. 'title' => '限时秒杀(0:取消/1:是)',
  3547. 'field' => 'is_spike_buy',
  3548. 'width' => 24
  3549. ) ,
  3550. array(
  3551. 'title' => '所有团长',
  3552. 'field' => 'is_all_sale_str',
  3553. 'width' => 24
  3554. ) ,
  3555. array(
  3556. 'title' => '新人专享',
  3557. 'field' => 'is_new_buy',
  3558. 'width' => 24
  3559. ) ,
  3560. array(
  3561. 'title' => '商品排序(数字)',
  3562. 'field' => 'index_sort',
  3563. 'width' => 24
  3564. ) ,
  3565. array(
  3566. 'title' => '每天限购',
  3567. 'field' => 'oneday_limit_count',
  3568. 'width' => 24
  3569. ) ,
  3570. array(
  3571. 'title' => '单次限购',
  3572. 'field' => 'one_limit_count',
  3573. 'width' => 24
  3574. ) ,
  3575. array(
  3576. 'title' => '历史限购',
  3577. 'field' => 'total_limit_count',
  3578. 'width' => 24
  3579. ) ,
  3580. array(
  3581. 'title' => '开始时间',
  3582. 'field' => 'pin_begin_time',
  3583. 'width' => 24
  3584. ) ,
  3585. array(
  3586. 'title' => '结束时间',
  3587. 'field' => 'pin_end_time',
  3588. 'width' => 24
  3589. ) ,
  3590. array(
  3591. 'title' => '商品重量(单位:g)',
  3592. 'field' => 'weight',
  3593. 'width' => 24
  3594. ) ,
  3595. array(
  3596. 'title' => '规格(1:开启/0:关闭)',
  3597. 'field' => 'hasoption',
  3598. 'width' => 24
  3599. ) ,
  3600. array(
  3601. 'title' => '规格id(禁止修改)',
  3602. 'field' => 'option_id',
  3603. 'width' => 24
  3604. ) ,
  3605. array(
  3606. 'title' => '规格名称(禁止修改)',
  3607. 'field' => 'option_title',
  3608. 'width' => 24
  3609. ) ,
  3610. array(
  3611. 'title' => '规格库存',
  3612. 'field' => 'option_stock',
  3613. 'width' => 24
  3614. ) ,
  3615. array(
  3616. 'title' => '规格现价',
  3617. 'field' => 'option_marketprice',
  3618. 'width' => 24
  3619. ) ,
  3620. array(
  3621. 'title' => '规格原价',
  3622. 'field' => 'option_productprice',
  3623. 'width' => 24
  3624. ) ,
  3625. array(
  3626. 'title' => '规格会员价',
  3627. 'field' => 'option_card_price',
  3628. 'width' => 24
  3629. ) ,
  3630. array(
  3631. 'title' => '规格成本价',
  3632. 'field' => 'option_costprice',
  3633. 'width' => 24
  3634. ) ,
  3635. array(
  3636. 'title' => '规格编码',
  3637. 'field' => 'option_goodssn',
  3638. 'width' => 24
  3639. ) ,
  3640. array(
  3641. 'title' => '规格重量(单位:g)',
  3642. 'field' => 'option_weight',
  3643. 'width' => 24
  3644. )
  3645. );
  3646. sellerLog('导入商品excel编辑', 3);
  3647. $rows = D('Seller/Excel')->import('excel');
  3648. $row_count = count($rows);
  3649. $field_arr = [];
  3650. if($row_count <= 1){
  3651. $this->error('失败','goods/index');
  3652. die;
  3653. }
  3654. foreach($rows[0] as $key => $value) {
  3655. foreach($columns as $k => $val) {
  3656. if($val['title'] == $value){
  3657. $field_arr[$key]= $val['field'];
  3658. }
  3659. }
  3660. }
  3661. unset($rows[0]);
  3662. foreach($rows as $key => $value){
  3663. $this->excelGoodsUpdate($value, $field_arr);
  3664. }
  3665. $this->success('成功','goods/index');
  3666. }
  3667. public function excelGoodsUpdate($data, $field_arr)
  3668. {
  3669. $optionId = 0;
  3670. $goodsId = 0;
  3671. $goodsData = [];
  3672. $optionData = [];
  3673. foreach($data as $key => $value){
  3674. $field = $field_arr[$key];
  3675. if(strstr($field, 'option_') > -1 && $value){// 规格
  3676. if($field == 'option_id'){// 规格id
  3677. $optionId = $value;
  3678. $goodsData = [];
  3679. }
  3680. $optionData[str_replace('option_','',$field)] = $value;
  3681. $goodsId = 0;
  3682. }else{ // 普通商品数据
  3683. if(strstr($field, 'option_') > -1 ) {// 规格
  3684. continue;
  3685. }
  3686. if($field == 'id'){// 规格id
  3687. $goodsId = $value;
  3688. $optionData = [];
  3689. }
  3690. $optionId = 0;
  3691. $goodsData[$field] = $value;
  3692. }
  3693. }
  3694. if($optionId > 0 && count($optionData) > 0){
  3695. unset($optionData['title']);
  3696. unset($optionData['id']);
  3697. M('lionfish_comshop_goods_option_item_value')->where('id = "'.$optionId.'"')->save($optionData);
  3698. unset($optionData);
  3699. }else if($goodsId > 0 && count($goodsData) > 0){
  3700. unset($goodsData['is_all_sale_str']);
  3701. unset($goodsData['cate1_id']);
  3702. unset($goodsData['cate1_name']);
  3703. unset($goodsData['cate2_id']);
  3704. unset($goodsData['cate2_name']);
  3705. unset($goodsData['id']);
  3706. $goodsCommon = M('lionfish_comshop_good_common')->where('goods_id = "'.$goodsId.'"')->field('id')->find();
  3707. if($goodsCommon['id']){
  3708. M('lionfish_comshop_good_common')
  3709. ->where('id = "'.$goodsCommon['id'].'"')
  3710. ->save([
  3711. 'one_limit_count' => $goodsData['one_limit_count'],
  3712. 'total_limit_count' => $goodsData['total_limit_count'],
  3713. 'is_spike_buy' => $goodsData['is_spike_buy'],
  3714. 'is_new_buy' => $goodsData['is_new_buy'],
  3715. ]);
  3716. unset($goodsData['one_limit_count']);
  3717. unset($goodsData['total_limit_count']);
  3718. unset($goodsData['is_spike_buy']);
  3719. unset($goodsData['is_new_buy']);
  3720. }
  3721. $goodsPin = M('lionfish_comshop_good_pin')->where('goods_id = "'.$goodsId.'"')->field('id')->find();
  3722. if($goodsPin['id']){
  3723. M('lionfish_comshop_good_pin')
  3724. ->where('id = "'.$goodsPin['id'].'"')
  3725. ->save([
  3726. 'begin_time' => $goodsData['begin_time'],
  3727. 'end_time' => $goodsData['end_time'],
  3728. ]);
  3729. unset($goodsData['begin_time']);
  3730. unset($goodsData['end_time']);
  3731. }
  3732. M('lionfish_comshop_goods')
  3733. ->where('id = "'.$goodsId.'"')
  3734. ->save($goodsData);
  3735. unset($goodsData);
  3736. }
  3737. }
  3738. public function check_express(){
  3739. $result = array();
  3740. $pintuan_model_buy = D('Home/Front')->get_config_by_name('pintuan_model_buy');
  3741. $count = 0;
  3742. $sql = " select count(1) as count from ".C('DB_PREFIX')."lionfish_comshop_goods as g left join ".C('DB_PREFIX')."lionfish_comshop_good_common as gc "
  3743. . " on g.id = gc.goods_id where g.type = 'normal' AND g.grounding =1 AND gc.is_only_express =1";
  3744. $goods_list = M()->query( $sql );
  3745. if(!empty($goods_list)){
  3746. $count = $goods_list[0]['count'];
  3747. }
  3748. if($count > 0 || $pintuan_model_buy == 0){
  3749. $result['status'] = 1;
  3750. }else{
  3751. $result['status'] = 0;
  3752. }
  3753. echo json_encode($result);
  3754. }
  3755. //部分团长列表
  3756. public function goods_head(){
  3757. $condition = ' ';
  3758. $pindex = I('get.page',1);
  3759. $psize = 20;
  3760. $goods_id = I('get.id');
  3761. $goods_info = M('lionfish_comshop_goods')->where(array('id'=>$goods_id))->field('id,goodsname,is_all_sale')->find();
  3762. $keyword = I('get.keyword','');
  3763. $this->keyword = $keyword;
  3764. if (!empty($keyword)) {
  3765. $condition .= ' and ( m.username like '.'"%' . $keyword . '%"'.' or ch.community_name like '.'"%' . $keyword . '%"'.' or ch.head_name like '.'"%' . $keyword . '%"'.' or ch.head_mobile like '.'"%' . $keyword . '%"'.' or ch.address like '.'"%' . $keyword . '%"'.') ';
  3766. }
  3767. $condition .= ' and hg.goods_id='.$goods_id;
  3768. $sql = "SELECT ch.*,m.we_openid,m.username,m.avatar,hg.id as hg_id FROM " . C('DB_PREFIX') . "lionfish_community_head as ch "
  3769. . " left join ".C('DB_PREFIX')."lionfish_comshop_member as m on ch.member_id = m.member_id "
  3770. . ' left join '.C('DB_PREFIX')."lionfish_community_head_goods as hg on hg.head_id = ch.id "
  3771. . " WHERE 1 " . $condition . " order by ch.id desc ";
  3772. if (empty($export)) {
  3773. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  3774. }
  3775. $list = M()->query($sql);
  3776. $sql_count = 'SELECT count(1) as total FROM ' . C('DB_PREFIX') . 'lionfish_community_head as ch '
  3777. . ' left join '.C('DB_PREFIX').'lionfish_comshop_member as m on ch.member_id = m.member_id '
  3778. . ' left join '. C('DB_PREFIX').'lionfish_community_head_goods as hg on hg.head_id = ch.id '
  3779. . ' WHERE 1 ' . $condition;
  3780. $total_arr = M()->query($sql_count);
  3781. $total = $total_arr[0]['total'];
  3782. $pager = pagination2($total, $pindex, $psize);
  3783. $this->goods_info = $goods_info;
  3784. $this->pager = $pager;
  3785. $this->list = $list;
  3786. $this->display('goods_communityhead');
  3787. }
  3788. public function cancel_goods_head(){
  3789. $_GPC = I('request.');
  3790. $id = intval($_GPC['id']);
  3791. $goods_id = intval($_GPC['goods_id']);
  3792. M('lionfish_community_head_goods')->where( array('id' => $id) )->delete();
  3793. show_json(1, array('url' => U('goods/goods_head/id/'.$goods_id)));
  3794. }
  3795. public function all_goods_head(){
  3796. $_GPC = I('request.');
  3797. $goods_id = intval($_GPC['goods_id']);
  3798. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save(array('is_all_sale'=>1));
  3799. show_json(1, array('url' => U('goods/index/ok/1')));
  3800. }
  3801. public function copy(){
  3802. // echo 7777;die;
  3803. $data = I('request.');
  3804. $id = $data['id'];
  3805. $res = M('lionfish_comshop_goods')->where(['id'=>$id])->find();
  3806. isset($res['copy_times'])?$res['copy_times']:0;
  3807. $copy_times = $res['copy_times'];
  3808. M('lionfish_comshop_goods')->where(['id'=>$id])->setInc('copy_times');
  3809. //dump($copy_times);
  3810. if ($copy_times>0){
  3811. $copy_times = $copy_times+1;
  3812. $str = '00'.$copy_times;
  3813. }else{
  3814. $str = '001';
  3815. }
  3816. unset($res['id']);
  3817. unset($res['copy_times']);
  3818. $res['goodsname'] = $res['goodsname'].$str;
  3819. //销量设置0
  3820. $res['sales'] = 0;
  3821. $res['seller_count'] = 0;
  3822. $res['day_salescount'] = 0;
  3823. $goods_id = M('lionfish_comshop_goods')->add($res);
  3824. // $goods_id = 385; //to delete
  3825. $cate = M('lionfish_comshop_goods_to_category')->where(['goods_id'=>$id])->select();
  3826. //dump($cate);
  3827. foreach ($cate as $k=>$v){
  3828. $tmp['cate_id'] = $v['cate_id'];
  3829. $tmp['goods_id'] = $goods_id;
  3830. M('lionfish_comshop_goods_to_category')->add($tmp);
  3831. }
  3832. $goods_common = M('lionfish_comshop_good_common')->where(['goods_id'=>$id])->find();
  3833. unset($goods_common['id']);
  3834. $goods_common['goods_id'] = $goods_id;
  3835. // $goods_common['goods_id'] = 385;
  3836. M('lionfish_comshop_good_common')->add($goods_common);
  3837. $option = M('lionfish_comshop_goods_option')->where(['goods_id'=>$id])->select();
  3838. if ( count($option)) {
  3839. foreach ($option as $k => $v) {//循环规格: 颜色 尺寸
  3840. $front_goods_option_id = $v['id'];
  3841. unset($v['id']);
  3842. $v['goods_id'] = $goods_id;
  3843. //dump($v);
  3844. $goods_option_id = M('lionfish_comshop_goods_option')->add($v);
  3845. $option_item = M('lionfish_comshop_goods_option_item')->where(['goods_option_id' => $front_goods_option_id])->select();
  3846. // dump($option_item);die;
  3847. static $i = 0;
  3848. foreach ($option_item as $kk => $vv) { //循环单个规格的选项,颜色有蓝色,绿色。。。
  3849. unset($vv['id']);
  3850. $vv['goods_id'] = $goods_id;
  3851. $vv['goods_option_id'] = $goods_option_id;
  3852. $ids[$i][] = M('lionfish_comshop_goods_option_item')->add($vv);
  3853. }
  3854. $i++;
  3855. }
  3856. $ids = $this->resver_arr($ids);
  3857. $ids = $this->zuhe($ids);
  3858. //dump($ids);die;
  3859. $j = 0;
  3860. $option_item_value = M('lionfish_comshop_goods_option_item_value')->where(['goods_id' => $id])->select();
  3861. foreach ($option_item_value as $key => $value) {
  3862. unset($value['id']);
  3863. $value['option_item_ids'] = $ids[0][$j++];
  3864. $value['goods_id'] = $goods_id;
  3865. M('lionfish_comshop_goods_option_item_value')->add($value);
  3866. }
  3867. }
  3868. $imgs = M('lionfish_comshop_goods_images')->where(['goods_id'=>$id])->select();
  3869. foreach ($imgs as $v){
  3870. unset($v['id']);
  3871. $v['goods_id'] = $goods_id;
  3872. M('lionfish_comshop_goods_images')->add($v);
  3873. }
  3874. D('Seller/Redisorder')->sysnc_goods_total($goods_id);
  3875. $url = U("goods/edit/id/$goods_id");
  3876. echo json_encode(['code'=>1,'url'=>$url]);
  3877. }
  3878. function zuhe($arr){
  3879. if(count($arr) >= 2){
  3880. $tmparr = array();
  3881. $arr1 = array_shift($arr);
  3882. $arr2 = array_shift($arr);
  3883. foreach($arr1 as $k1 => $v1){
  3884. foreach($arr2 as $k2 => $v2){
  3885. $tmparr[] = $v2.'_'.$v1;
  3886. }
  3887. }
  3888. array_unshift($arr, $tmparr);
  3889. $arr = $this->zuhe($arr);
  3890. }else{
  3891. return $arr;
  3892. }
  3893. return $arr;
  3894. }
  3895. function resver_arr($arr){
  3896. $len = count($arr);
  3897. $i = $len - 1;
  3898. foreach($arr as $k=>$v){
  3899. $tmp[$i--] = $v;
  3900. }
  3901. ksort($tmp);
  3902. return $tmp;
  3903. }
  3904. }
  3905. ?>