GoodsController.class.php 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900
  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. $this->starttime = $starttime;
  29. $this->endtime = $endtime;
  30. $searchtime = I('get.searchtime','');
  31. $this->searchtime = $searchtime;
  32. $shop_data = array();
  33. $type = I('get.type','all');
  34. //---begin
  35. $count_common_where ="";
  36. if (defined('ROLE') && ROLE == 'agenter' ) {
  37. $supper_info = get_agent_logininfo();
  38. $supper_goods_list = M('lionfish_comshop_good_common')->field('goods_id')->where( array('supply_id' =>$supper_info['id'] ) )->select();
  39. $gids_list = array();
  40. foreach($supper_goods_list as $vv)
  41. {
  42. $gids_list[] = $vv['goods_id'];
  43. }
  44. if( !empty($gids_list) )
  45. {
  46. $count_common_where = " and id in ( ".implode(',', $gids_list )." )";
  47. }else{
  48. $count_common_where = " and id in (0)";
  49. }
  50. }
  51. $all_count = D('Seller/Goods')->get_goods_count(" and type = 'normal' {$count_common_where}");//全部商品数量
  52. $onsale_count = D('Seller/Goods')->get_goods_count(" and grounding = 1 and type = 'normal' {$count_common_where}");//出售中商品数量
  53. $getdown_count = D('Seller/Goods')->get_goods_count(" and grounding = 0 and type = 'normal' {$count_common_where}");//已下架商品数量
  54. $warehouse_count = D('Seller/Goods')->get_goods_count(" and grounding = 2 and type = 'normal' {$count_common_where}");//仓库商品数量
  55. $recycle_count = D('Seller/Goods')->get_goods_count(" and grounding = 3 and type = 'normal' {$count_common_where}");//回收站商品数量
  56. $waishen_count = D('Seller/Goods')->get_goods_count(" and grounding = 4 and type = 'normal' {$count_common_where}");//审核商品数量
  57. $unsuccshen_count = D('Seller/Goods')->get_goods_count(" and grounding = 5 and type = 'normal' {$count_common_where}");//拒绝审核商品数量
  58. $this->assign('waishen_count',$waishen_count);
  59. $this->assign('unsuccshen_count',$unsuccshen_count);
  60. //recycle 仓库
  61. //--end
  62. //recycle 仓库 get_config_by_name($name)
  63. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  64. $goods_stock_notice = intval($goods_stock_notice);
  65. if( empty($goods_stock_notice) )
  66. {
  67. $goods_stock_notice = 0;
  68. }
  69. $stock_notice_count = D('Admin/Goods')->get_goods_count(" and grounding = 1 and total<= {$goods_stock_notice} and type = 'normal' {$count_common_where} ");//回收站商品数量
  70. //goods_stock_notice
  71. //grounding 1
  72. //type all 全部
  73. //saleon 1 出售中
  74. //getdown 0 已下架
  75. //warehouse 2 仓库中
  76. //recycle 3 回收站
  77. $psize = 20;
  78. $condition = ' WHERE g.type = "normal" ';
  79. $sqlcondition = "";
  80. if( !empty($type) && $type != 'all')
  81. {
  82. switch($type)
  83. {
  84. case 'saleon':
  85. $condition .= " and g.grounding = 1";
  86. break;
  87. case 'getdown':
  88. $condition .= " and g.grounding = 0";
  89. break;
  90. case 'warehouse':
  91. $condition .= " and g.grounding = 2";
  92. break;
  93. case 'wait_shen':
  94. $condition .= " and g.grounding = 4";
  95. break;
  96. case 'refuse':
  97. $condition .= " and g.grounding = 5";
  98. break;
  99. case 'recycle':
  100. $condition .= " and g.grounding = 3";
  101. break;
  102. case 'stock_notice':
  103. $condition .= " and g.grounding = 1 and g.total<= {$goods_stock_notice} ";
  104. break;
  105. }
  106. }else{
  107. $condition .= " and g.grounding != 3 ";
  108. }
  109. $keyword = I('get.keyword','');
  110. $this->keyword = $keyword;
  111. if (!(empty($keyword))) {
  112. $condition .= " AND (g.`id` = '{$keyword}' or g.`goodsname` LIKE '%{$keyword}%' or g.`codes` LIKE '%{$keyword}%' ) ";
  113. }
  114. if (defined('ROLE') && ROLE == 'agenter' )
  115. {
  116. $supper_info = get_agent_logininfo();
  117. $sqlcondition .= ' , ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm ';
  118. $condition .= ' and gm.goods_id =g.id AND gm.supply_id ='.$supper_info['id'].' ';
  119. }
  120. if( !empty($searchtime) )
  121. {
  122. switch( $searchtime )
  123. {
  124. case 'create':
  125. $condition .= ' AND (gm.begin_time >='.$starttime.' and gm.end_time <= '.$endtime.' )';
  126. if (!defined('ROLE') && ROLE != 'agenter' )
  127. {
  128. $sqlcondition .= ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm on gm.goods_id = g.id ';
  129. }
  130. break;
  131. }
  132. }
  133. $cate = I('get.cate', '');
  134. $this->cate = $cate;
  135. if( !empty($cate) )
  136. {
  137. $cate_list = M('lionfish_comshop_goods_to_category')->field('goods_id')->where(array('cate_id' => $cate))->select();
  138. $catids_arr = array();
  139. foreach($cate_list as $val)
  140. {
  141. $catids_arr[] = $val['goods_id'];
  142. }
  143. if( !empty($catids_arr) )
  144. {
  145. $catids_str = implode(',', $catids_arr);
  146. $condition .= ' and g.id in ('.$catids_str.')';
  147. }else{
  148. $condition .= " and 1=0 ";
  149. }
  150. }
  151. $sql = 'SELECT COUNT(g.id) as count FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition. $condition ;
  152. $total_arr = M()->query($sql);
  153. $total = $total_arr[0]['count'];
  154. $pager = pagination2($total, $pindex, $psize);
  155. if (!(empty($total))) {
  156. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  157. if( empty($index_sort_method) || $index_sort_method == 0 )
  158. {
  159. $sql = 'SELECT g.* FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition . $condition . '
  160. ORDER BY g.istop DESC, g.settoptime DESC, g.`id` DESC ';
  161. }else{
  162. $sql = 'SELECT g.* FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition . $condition . '
  163. ORDER BY g.index_sort DESC, g.`id` DESC ';
  164. }
  165. if(I('export') != 1) { // 如果导出excel 就显示全部
  166. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  167. }
  168. //$sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  169. $list = M()->query($sql);
  170. foreach ($list as $key => &$value ) {
  171. $price_arr = D('Home/pingoods')->get_goods_price($value['id']);
  172. $value['price_arr'] = $price_arr;
  173. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $value['id']) )->order('id asc')->find();
  174. if( empty($thumb['thumb']) )
  175. {
  176. $value['thumb'] = $thumb['image'];
  177. }else{
  178. $value['thumb'] = $thumb['thumb'];
  179. }
  180. //is_take_fullreduction print_sub_title
  181. $gd_common = M('lionfish_comshop_good_common')->field('is_take_fullreduction,supply_id,is_only_hexiao,print_sub_title')->where( array('goods_id' => $value['id']) )->find();
  182. //print_sub_title
  183. $value['print_sub_title'] = $gd_common['print_sub_title'];
  184. $value['is_take_fullreduction'] = $gd_common['is_take_fullreduction'];
  185. $value['is_only_hexiao'] = $gd_common['is_only_hexiao'];
  186. $value['supply_name'] = '';
  187. $value['supply_type'] = '0';
  188. if( empty($gd_common['supply_id']) || $gd_common['supply_id'] ==0 )
  189. {
  190. $value['supply_id'] = 0;
  191. }else{
  192. $value['supply_id'] = $gd_common['supply_id'];
  193. $sub_info = M('lionfish_comshop_supply')->field('name,type')->where( array('id' => $gd_common['supply_id'] ) )->find();
  194. $value['supply_name'] = $sub_info['name'];
  195. $value['supply_type'] = $sub_info['type'];
  196. }
  197. $categorys = M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $value['id']) )->order('id asc')->select();
  198. $value['cate'] = $categorys;
  199. $time_info = D('home/front')->get_goods_common_field($value['id'] , 'begin_time,end_time');
  200. $value['begin_time'] = $time_info['begin_time'];
  201. $value['end_time'] = $time_info['end_time'];
  202. //团长数量
  203. $head_count = 0;
  204. if( $value['is_all_sale'] == 1 )
  205. {
  206. $head_count = M('lionfish_community_head')->count();
  207. }else{
  208. $head_count = M('lionfish_community_head_goods')->where( array('goods_id' => $value['id'] ) )->count();
  209. }
  210. $value['head_count'] = $head_count;
  211. $value['option'] = [];
  212. if(I('get.export') > 0) {// 商品列表到处excel时要导出规格
  213. $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();
  214. if($value['option'] === null){
  215. $value['option'] = [];
  216. }
  217. foreach($categorys as $categorysKey => $categorysVal){
  218. $categorysInfo = M('lionfish_comshop_goods_category')->where( array('id' => $categorysVal['cate_id']) )->find();
  219. $value['cate'.($categorysKey+1).'_id'] = $categorysVal['cate_id'];
  220. $value['cate'.($categorysKey+1).'_name'] = $categorysInfo['name'];
  221. }
  222. $goodsCommon = M('lionfish_comshop_good_common')->where('goods_id = "'.$value['id'].'"')->field('is_spike_buy,is_new_buy,one_limit_count,total_limit_count,begin_time,end_time')->find();
  223. $value['one_limit_count'] = $goodsCommon['one_limit_count'];
  224. $value['total_limit_count'] = $goodsCommon['total_limit_count'];
  225. $value['is_spike_buy'] = $goodsCommon['is_spike_buy'];
  226. $value['is_new_buy'] = $goodsCommon['is_new_buy'];
  227. $goodsPin = M('lionfish_comshop_good_pin')->where('goods_id = "'.$value['id'].'"')->field('begin_time,end_time')->find();
  228. if($goodsPin){
  229. $value['pin_begin_time'] = $goodsPin['begin_time'];
  230. $value['pin_end_time'] = $goodsPin['end_time'];
  231. }
  232. if($value['is_all_sale'] == 1){
  233. $value['is_all_sale_str'] = '[所有团长'.$head_count.']';
  234. }else if($head_count == 0){
  235. $value['is_all_sale_str'] = '[无团长0]';
  236. }else if($head_count > 0){
  237. $value['is_all_sale_str'] = '[部分团长'.$head_count.']';
  238. }
  239. }
  240. }
  241. }
  242. unset($value);
  243. $categorys = D('Seller/GoodsCategory')->getFullCategory(true);
  244. $category = array();
  245. foreach ($categorys as $cate ) {
  246. $category[$cate['id']] = $cate;
  247. }
  248. $this->category =$category;
  249. $this->type = $type;
  250. $this->all_count = $all_count;
  251. $this->onsale_count = $onsale_count;
  252. $this->getdown_count = $getdown_count;
  253. $this->warehouse_count = $warehouse_count;
  254. $this->recycle_count = $recycle_count;
  255. $this->stock_notice_count = $stock_notice_count;
  256. $this->assign('list',$list);// 赋值数据集
  257. $this->assign('pager',$pager);// 赋值分页输出
  258. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  259. $this->assign('is_open_fullreduction',$is_open_fullreduction);
  260. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  261. if( empty($index_sort_method) || $index_sort_method == 0 )
  262. {
  263. $index_sort_method = 0;
  264. }
  265. $this->index_sort_method = $index_sort_method;
  266. //---
  267. $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
  268. $supply_edit_goods_shenhe = D('Home/Front')->get_config_by_name('supply_edit_goods_shenhe');
  269. if(empty($supply_add_goods_shenhe))
  270. {
  271. $supply_add_goods_shenhe = 0;
  272. }
  273. if(empty($supply_edit_goods_shenhe))
  274. {
  275. $supply_edit_goods_shenhe = 0;
  276. }
  277. $is_open_shenhe = 0;
  278. if($supply_add_goods_shenhe ==1 || $supply_edit_goods_shenhe == 1)
  279. {
  280. $is_open_shenhe = 1;
  281. }
  282. $this->supply_add_goods_shenhe = $supply_add_goods_shenhe;
  283. $this->supply_edit_goods_shenhe = $supply_edit_goods_shenhe;
  284. $this->assign('is_open_shenhe',$is_open_shenhe);
  285. //--
  286. //团长分组
  287. $group_default_list = array(
  288. array('id' => 'default', 'groupname' => '默认分组')
  289. );
  290. $group_list = M('lionfish_community_head_group')->field('id,groupname')->order('id asc')->select();
  291. $group_list = array_merge($group_default_list, $group_list);
  292. $this->group_list = $group_list;
  293. $config_data = D('Seller/Config')->get_all_config();
  294. $is_index = true;
  295. $is_top = true;
  296. $is_updown = true;
  297. $is_fullreduce = true;
  298. $is_vir_count = true;
  299. $is_newbuy = true;
  300. $is_goodsspike = true;
  301. if (defined('ROLE') && ROLE == 'agenter' )
  302. {
  303. $is_fullreduce = false;
  304. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  305. {
  306. $is_index = false;
  307. }
  308. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  309. {
  310. $is_top = false;
  311. }
  312. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  313. {
  314. $is_updown = false;
  315. }
  316. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  317. {
  318. $is_vir_count = false;
  319. }
  320. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  321. {
  322. $is_newbuy = false;
  323. }
  324. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  325. {
  326. $is_goodsspike = false;
  327. }
  328. }
  329. if(I('get.export') > 0) {// 商品列表到处excel
  330. $this->goods_listexcel($list);
  331. }
  332. $this->config_data = $config_data;
  333. $this->is_index = $is_index;
  334. $this->is_top = $is_top;
  335. $this->is_updown = $is_updown;
  336. $this->is_fullreduce = $is_fullreduce;
  337. $this->is_vir_count = $is_vir_count;
  338. $this->is_newbuy = $is_newbuy;
  339. $this->is_goodsspike = $is_goodsspike;
  340. $this->display();
  341. }
  342. /**
  343. * 商品列表到处excel
  344. * @author 刘鑫芮 2020-03-02
  345. * @param $list 商品列表集合数据 全部-根据where 条件搜索的
  346. * */
  347. public function goods_listexcel($list) {
  348. // dump($list);die;
  349. $printList = $list;
  350. foreach($list as $key => $value) {
  351. $printList[$key] = array(
  352. 'id' => $value['id']
  353. );
  354. }
  355. $columns = array(
  356. array(
  357. 'title' => '商品ID(禁止修改)',
  358. 'field' => 'id',
  359. 'width' => 24
  360. ) ,
  361. array(
  362. 'title' => '商品名称',
  363. 'field' => 'goodsname',
  364. 'width' => 24
  365. ) ,
  366. array(
  367. 'title' => '商品简称',
  368. 'field' => 'print_sub_title',
  369. 'width' => 24
  370. ) ,
  371. array(
  372. 'title' => '一级分类ID',
  373. 'field' => 'cate1_id',
  374. 'width' => 24
  375. ) ,
  376. array(
  377. 'title' => '一级分类名称',
  378. 'field' => 'cate1_name',
  379. 'width' => 24
  380. ) ,
  381. array(
  382. 'title' => '二级分类ID',
  383. 'field' => 'cate2_id',
  384. 'width' => 24
  385. ) ,
  386. array(
  387. 'title' => '二级分类名称',
  388. 'field' => 'cate2_name',
  389. 'width' => 24
  390. ) ,
  391. array(
  392. 'title' => '商品价格',
  393. 'field' => 'price',
  394. 'width' => 24
  395. ) ,
  396. array(
  397. 'title' => '商品成本价',
  398. 'field' => 'costprice',
  399. 'width' => 24
  400. ) ,
  401. array(
  402. 'title' => '会员卡价格',
  403. 'field' => 'card_price',
  404. 'width' => 24
  405. ) ,
  406. array(
  407. 'title' => '商品原价',
  408. 'field' => 'productprice',
  409. 'width' => 24
  410. ) ,
  411. array(
  412. 'title' => '商品库存',
  413. 'field' => 'total',
  414. 'width' => 24
  415. ) ,
  416. array(
  417. 'title' => '1上架/0下架',
  418. 'field' => 'grounding',
  419. 'width' => 24
  420. ) ,
  421. array(
  422. 'title' => '首页推荐(0:取消/1:是)',
  423. 'field' => 'is_index_show',
  424. 'width' => 24
  425. ) ,
  426. array(
  427. 'title' => '限时秒杀(0:取消/1:是)',
  428. 'field' => 'is_spike_buy',
  429. 'width' => 24
  430. ) ,
  431. array(
  432. 'title' => '所有团长',
  433. 'field' => 'is_all_sale_str',
  434. 'width' => 24
  435. ) ,
  436. array(
  437. 'title' => '新人专享',
  438. 'field' => 'is_new_buy',
  439. 'width' => 24
  440. ) ,
  441. array(
  442. 'title' => '商品排序(数字)',
  443. 'field' => 'index_sort',
  444. 'width' => 24
  445. ) ,
  446. array(
  447. 'title' => '单次限购',
  448. 'field' => 'one_limit_count',
  449. 'width' => 24
  450. ) ,
  451. array(
  452. 'title' => '历史限购',
  453. 'field' => 'total_limit_count',
  454. 'width' => 24
  455. ) ,
  456. array(
  457. 'title' => '开始时间',
  458. 'field' => 'pin_begin_time',
  459. 'width' => 24
  460. ) ,
  461. array(
  462. 'title' => '结束时间',
  463. 'field' => 'pin_end_time',
  464. 'width' => 24
  465. ) ,
  466. array(
  467. 'title' => '商品重量(单位:g)',
  468. 'field' => 'weight',
  469. 'width' => 24
  470. ) ,
  471. array(
  472. 'title' => '规格(1:开启/0:关闭)',
  473. 'field' => 'hasoption',
  474. 'width' => 24
  475. ) ,
  476. array(
  477. 'title' => '规格id(禁止修改)',
  478. 'field' => 'option_id',
  479. 'width' => 24
  480. ) ,
  481. array(
  482. 'title' => '规格名称(禁止修改)',
  483. 'field' => 'option_title',
  484. 'width' => 24
  485. ) ,
  486. array(
  487. 'title' => '规格库存',
  488. 'field' => 'option_stock',
  489. 'width' => 24
  490. ) ,
  491. array(
  492. 'title' => '规格现价',
  493. 'field' => 'option_marketprice',
  494. 'width' => 24
  495. ) ,
  496. array(
  497. 'title' => '规格原价',
  498. 'field' => 'option_productprice',
  499. 'width' => 24
  500. ) ,
  501. array(
  502. 'title' => '规格会员价',
  503. 'field' => 'option_card_price',
  504. 'width' => 24
  505. ) ,
  506. array(
  507. 'title' => '规格成本价',
  508. 'field' => 'option_costprice',
  509. 'width' => 24
  510. ) ,
  511. array(
  512. 'title' => '规格编码',
  513. 'field' => 'option_goodssn',
  514. 'width' => 24
  515. ) ,
  516. array(
  517. 'title' => '规格重量(单位:g)',
  518. 'field' => 'option_weight',
  519. 'width' => 24
  520. )
  521. );
  522. sellerLog('导出商品excel', 3);
  523. D('Seller/Excel')->export_goods_list_pi(array(
  524. 'title' => '商品列表',
  525. 'columns' => $columns
  526. ), $list);
  527. }
  528. public function edittags()
  529. {
  530. $_GPC = I('request.');
  531. $id = intval($_GPC['id']);
  532. if (!empty($id)) {
  533. $item = M('lionfish_comshop_goods_tags')->field('id,tagname,tagcontent,state,sort_order')->where( array('id' =>$id ) )->find();
  534. if (json_decode($item['tagcontent'], true)) {
  535. $labelname = json_decode($item['tagcontent'], true);
  536. }
  537. else {
  538. $labelname = unserialize($item['tagcontent']);
  539. }
  540. $this->item = $item;
  541. $this->labelname = $labelname;
  542. }
  543. if (IS_POST) {
  544. $data = $_GPC['data'];
  545. D('Seller/Tags')->update($data);
  546. show_json(1, array('url' => U('goods/goodstag') ));
  547. }
  548. $this->display('Goods/addtags');
  549. }
  550. public function addtags()
  551. {
  552. $_GPC = I('request.');
  553. if (IS_POST) {
  554. $data = $_GPC['data'];
  555. D('Seller/Tags')->update($data);
  556. show_json(1, array('url' => U('goods/goodstag')));
  557. }
  558. $this->display();
  559. }
  560. public function tagsstate()
  561. {
  562. $_GPC = I('request.');
  563. $id = intval($_GPC['id']);
  564. if (empty($id)) {
  565. $id = $_GPC['ids'];
  566. }
  567. if( is_array($id) )
  568. {
  569. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  570. }else{
  571. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  572. }
  573. if (empty($item)) {
  574. $item = array();
  575. }
  576. foreach ($items as $item) {
  577. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->save( array('state' => intval($_GPC['state'])) );
  578. }
  579. show_json(1, array('url' => U('goods/goodstag')));
  580. }
  581. public function deletetags()
  582. {
  583. $_GPC = I('request.');
  584. $id = intval($_GPC['id']);
  585. if (empty($id)) {
  586. $id = $_GPC['ids'];
  587. }
  588. if( is_array($id) )
  589. {
  590. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  591. }else{
  592. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  593. }
  594. //$items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id )) )->select();
  595. if (empty($item)) {
  596. $item = array();
  597. }
  598. foreach ($items as $item) {
  599. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->delete();
  600. }
  601. show_json(1, array('url' => U('goods/goodstag')));
  602. }
  603. public function labelquery()
  604. {
  605. $_GPC = I('request.');
  606. $kwd = trim($_GPC['keyword']);
  607. $type = isset($_GPC['type']) ? $_GPC['type'] : 'normal';
  608. $condition = ' and state = 1 and tag_type="'.$type.'" ';
  609. if (!empty($kwd)) {
  610. $condition .= ' AND tagname LIKE "%'.$kwd.'%" ';
  611. }
  612. $labels = M('lionfish_comshop_goods_tags')->field('id,tagname,tagcontent')->where( '1 '. $condition )->order('id desc')->select();
  613. if (empty($labels)) {
  614. $labels = array();
  615. }
  616. $html = '';
  617. foreach ($labels as $key => $value) {
  618. if (json_decode($value['tagcontent'], true)) {
  619. $labels[$key]['tagcontent'] = json_decode($value['tagcontent'], true);
  620. }
  621. else {
  622. $labels[$key]['tagcontent'] = unserialize($value['tagcontent']);
  623. }
  624. $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"])).'\'>';
  625. $html .= $value['tagname'];
  626. $html .= '</nav>';
  627. }
  628. if( isset($_GPC['is_ajax']) )
  629. {
  630. echo json_encode( array('code' => 0, 'html' => $html) );
  631. die();
  632. }
  633. $this->labels = $labels;
  634. $this->display();
  635. }
  636. public function deletecomment()
  637. {
  638. $_GPC = I('request.');
  639. $id = intval($_GPC['id']);
  640. if (empty($id)) {
  641. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  642. }
  643. $items = M()->query('SELECT comment_id FROM ' . C('DB_PREFIX') .
  644. 'lionfish_comshop_order_comment WHERE comment_id in( ' . $id . ' ) ');
  645. if (empty($item)) {
  646. $item = array();
  647. }
  648. foreach ($items as $item) {
  649. M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->delete();
  650. }
  651. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  652. }
  653. public function addvircomment()
  654. {
  655. $_GPC = I('request.');
  656. if (IS_POST) {
  657. $data = $_GPC['data'];
  658. $jia_id = $_GPC['jiaid'];
  659. $goods_id = $_GPC['goods_id'];
  660. if( empty($goods_id) )
  661. {
  662. show_json(0, array('message' => '请选择评价商品!'));
  663. }
  664. if( empty($jia_id) )
  665. {
  666. show_json(0, array('message' => '请选择机器人!'));
  667. }
  668. $goods_info = M('lionfish_comshop_goods')->field('goodsname')->where( array('id' => $goods_id) )->find();
  669. $goods_image = isset($_GPC['goods_image']) && !empty($_GPC['goods_image']) ? $_GPC['goods_image'] : array();
  670. $time = empty($_GPC['time']) ? time() : $_GPC['time'];
  671. $jia_info = M('lionfish_comshop_jiauser')->where( array('id' => $jia_id ) )->find();
  672. $commen_data = array();
  673. $commen_data['order_id'] = 0;
  674. $commen_data['state'] = 1;
  675. $commen_data['type'] = 1;
  676. $commen_data['member_id'] = $jia_id;
  677. $commen_data['avatar'] = $jia_info['avatar'];
  678. $commen_data['user_name'] = $jia_info['username'];
  679. $commen_data['order_num_alias'] = 1;
  680. $commen_data['star'] = $data['star'];
  681. $commen_data['star3'] = $data['star3'];
  682. $commen_data['star2'] = $data['star2'];
  683. $commen_data['is_picture'] = !empty($goods_image) ? 1: 0;
  684. $commen_data['content'] = $data['content'];
  685. $commen_data['images'] = serialize(implode(',', $goods_image));
  686. $image = D('Home/Pingoods')->get_goods_images($goods_id);
  687. $seller_id = 1;
  688. if(!empty($image))
  689. {
  690. $commen_data['goods_image'] = $image['image'];
  691. }else{
  692. $commen_data['goods_image'] = '';
  693. }
  694. $commen_data['goods_id'] = $goods_id;
  695. $commen_data['goods_name'] = $goods_info['goodsname'];
  696. $commen_data['add_time'] = strtotime($time);
  697. M('lionfish_comshop_order_comment')->add($commen_data);
  698. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  699. }
  700. $this->display();
  701. }
  702. public function change_cm()
  703. {
  704. $_GPC = I('request.');
  705. $id = intval($_GPC['id']);
  706. //ids
  707. if (empty($id)) {
  708. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  709. }
  710. if (empty($id)) {
  711. show_json(0, array('message' => '参数错误'));
  712. }
  713. $type = trim($_GPC['type']);
  714. $value = trim($_GPC['value']);
  715. if (!(in_array($type, array('is_take_fullreduction')))) {
  716. show_json(0, array('message' => '参数错误'));
  717. }
  718. $items = M('lionfish_comshop_goods')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  719. foreach ($items as $item ) {
  720. //--
  721. if($type == 'is_take_fullreduction' && $value == 1)
  722. {
  723. $gd_common = M('lionfish_comshop_good_common')->field('supply_id')->where( array('goods_id' => $item['id'] ) )->find();
  724. if( !empty($gd_common['supply_id']) && $gd_common['supply_id'] > 0)
  725. {
  726. $supply_info = M('lionfish_comshop_supply')->field('type')->where( array('id' => $gd_common['supply_id'] ) )->find();
  727. if( !empty($supply_info) && $supply_info['type'] == 1 )
  728. {
  729. continue;
  730. }
  731. }
  732. }
  733. //---
  734. M('lionfish_comshop_good_common')->where( array('goods_id' => $item['id']) )->save( array($type => $value) );
  735. }
  736. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  737. }
  738. public function commentstate()
  739. {
  740. $_GPC = I('request.');
  741. $id = intval($_GPC['id']);
  742. if (empty($id)) {
  743. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  744. }
  745. $items = M('lionfish_comshop_order_comment')->field('comment_id')->where( "comment_id in ({$id})")->select();
  746. if (empty($item)) {
  747. $item = array();
  748. }
  749. foreach ($items as $item) {
  750. M('lionfish_comshop_order_comment')->where( array('comment_id' => $item['comment_id']) )->save( array('state' => intval($_GPC['state'])) );
  751. }
  752. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  753. }
  754. /**
  755. * 一键设置商品时间
  756. */
  757. public function settime()
  758. {
  759. if (IS_POST) {
  760. $data = I('request.time', array());
  761. $param = array();
  762. $param['goods_same_starttime'] = strtotime(trim($data['start'])) ? strtotime(trim($data['start'])) : time();
  763. $param['goods_same_endtime'] = strtotime(trim($data['end'])) ? strtotime(trim($data['end'])) : time();
  764. // lionfish_comshop_good_common begin_time end_time
  765. D('Seller/Config')->update($param);
  766. $param1 = array();
  767. $param1['begin_time'] = $param['goods_same_starttime'];
  768. $param1['end_time'] = $param['goods_same_endtime'];
  769. //--begin
  770. if (defined('ROLE') && ROLE == 'agenter' )
  771. {
  772. $supper_info = get_agent_logininfo();
  773. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set end_time = ".$param['goods_same_endtime'].", begin_time=".$param['goods_same_starttime']."
  774. 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'];
  775. M()->execute($sql);
  776. //array('end_time' => $param['goods_same_endtime'],'begin_time' =>$param['goods_same_starttime'] )
  777. //M('lionfish_comshop_good_common')->where( 'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1) and supply_id='.$supper_info['id'] )->save( );
  778. }else{
  779. $sql = " update ".C('DB_PREFIX')."lionfish_comshop_good_common set end_time = ".$param['goods_same_endtime'].", begin_time=".$param['goods_same_starttime']."
  780. where ".'goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1 and type != "pin") ';
  781. M()->execute($sql);
  782. $sql = 'UPDATE '.C('DB_PREFIX'). 'lionfish_comshop_good_pin SET begin_time = '.$param['goods_same_starttime'].
  783. ',end_time='.$param['goods_same_endtime'].' where goods_id in (select id from '.C('DB_PREFIX').'lionfish_comshop_goods where `grounding` =1) ';
  784. M()->execute($sql);
  785. }
  786. //--end
  787. //M('lionfish_comshop_good_common')->where("1")->save($param1);
  788. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  789. }
  790. $data = D('Seller/Config')->get_all_config();
  791. if(empty($data['goods_same_starttime']))
  792. {
  793. $data['goods_same_starttime'] = time();
  794. }
  795. if(empty($data['goods_same_endtime']))
  796. {
  797. $data['goods_same_endtime'] = time()+86400;
  798. }
  799. $this->data = $data;
  800. $this->display();
  801. }
  802. public function addgoods()
  803. {
  804. if (IS_POST) {
  805. $_GPC = I('request.');
  806. if( !isset($_GPC['thumbs']) || empty($_GPC['thumbs']) )
  807. {
  808. show_json(0, array('message' => '商品图片必须上传' ,'url' => $_SERVER['HTTP_REFERER']) );
  809. die();
  810. }
  811. D('Seller/Goods')->addgoods();
  812. $http_refer = S('HTTP_REFERER');
  813. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  814. sellerLog('添加新增商品', 3);
  815. show_json(1, array('message' => '添加商品成功!','url' => $http_refer ));
  816. }
  817. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  818. $category = D('Seller/GoodsCategory')->getFullCategory(true, true);
  819. $this->category = $category;
  820. $spec_list = D('Seller/Spec')->get_all_spec();
  821. $this->spec_list = $spec_list;
  822. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1,'isdefault' =>1) )->order('sort_order desc')->select();
  823. $this->dispatch_data = $dispatch_data;
  824. $set = D('Seller/Config')->get_all_config();
  825. $this->set = $set;
  826. $commission_level = array();
  827. $config_data = $set;
  828. $this->config_data = $config_data;
  829. $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']);
  830. $others = M('lionfish_comshop_commission_level')->order('commission1 asc')->select();
  831. $commission_level = array_merge(array($default), $others);
  832. $communityhead_commission = $config_data['default_comunity_money'];
  833. $this->communityhead_commission = $communityhead_commission;
  834. //$level['key']
  835. foreach($commission_level as $key => $val)
  836. {
  837. $val['key'] = $val['id'];
  838. $commission_level[$key] = $val;
  839. }
  840. $this->commission_level = $commission_level;
  841. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  842. $this->shopset_level = $shopset_level;
  843. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  844. $this->open_buy_send_score = $open_buy_send_score;
  845. $item = array();
  846. $item['begin_time'] = time();
  847. $item['community_head_commission'] = $communityhead_commission;
  848. $item['end_time'] = time() + 86400;
  849. $item['hexiao_effect_begin_time'] = time();
  850. $item['hexiao_effect_end_time'] = time() + 86400;
  851. $delivery_type_express = $config_data['delivery_type_express'];
  852. if( empty($delivery_type_express) )
  853. {
  854. $delivery_type_express = 2;
  855. }
  856. $this->delivery_type_express = $delivery_type_express;
  857. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  858. $this->is_open_fullreduction = $is_open_fullreduction;
  859. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  860. $head_commission_levelname = $config_data['head_commission_levelname'];
  861. $default_comunity_money = $config_data['default_comunity_money'];
  862. $list_default = array(
  863. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  864. );
  865. $community_head_level = array_merge($list_default, $community_head_level);
  866. if( !empty($community_head_level) )
  867. {
  868. foreach( $community_head_level as $head_level)
  869. {
  870. $item['head_level'.$head_level['id']] = $head_level['commission'];
  871. }
  872. }
  873. $this->item = $item;
  874. $this->community_head_level = $community_head_level;
  875. $community_money_type = $config_data['community_money_type'];
  876. $this->community_money_type = $community_money_type;
  877. $mb_level = M('lionfish_comshop_member_level')->count();
  878. $this->mb_level = $mb_level;
  879. $is_open_only_express = $config_data['is_open_only_express'];
  880. $this->is_open_only_express = $is_open_only_express;
  881. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  882. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  883. //供应商权限begin
  884. $is_index = true;
  885. $is_top = true;
  886. $is_updown = true;
  887. $is_fullreduce = true;
  888. $is_vir_count = true;
  889. $is_newbuy = true;
  890. $is_goodsspike = true;
  891. $supply_can_goods_sendscore = true;
  892. //核销
  893. $sales_supply_id = 0;
  894. if (defined('ROLE') && ROLE == 'agenter' )
  895. {
  896. $supply_can_goods_sendscore = empty($set['supply_can_goods_sendscore']) ? 0: $set['supply_can_goods_sendscore'];
  897. $is_fullreduce = false;
  898. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  899. {
  900. $is_index = false;
  901. }
  902. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  903. {
  904. $is_top = false;
  905. }
  906. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  907. {
  908. $is_updown = false;
  909. }
  910. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  911. {
  912. $is_vir_count = false;
  913. }
  914. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  915. {
  916. $is_newbuy = false;
  917. }
  918. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  919. {
  920. $is_goodsspike = false;
  921. }
  922. }
  923. //查看是否有 ims_
  924. $salesroom_count = 0;
  925. $this->salesroom_count = $salesroom_count;
  926. $is_open_vipcard_buy = $config_data['is_open_vipcard_buy'];
  927. //供应商权限end
  928. $this->is_index = $is_index;
  929. $this->supply_can_goods_sendscore = $supply_can_goods_sendscore;
  930. $this->is_top = $is_top;
  931. $this->is_updown = $is_updown;
  932. $this->is_fullreduce = $is_fullreduce;
  933. $this->is_vir_count = $is_vir_count;
  934. $this->is_newbuy = $is_newbuy;
  935. $this->is_goodsspike = $is_goodsspike;
  936. $this->is_open_vipcard_buy = $is_open_vipcard_buy;
  937. $seckill_is_open = $config_data['seckill_is_open'];
  938. $this->seckill_is_open = $seckill_is_open;
  939. // $is_head_takegoods
  940. $is_head_takegoods = isset($config_data['is_head_takegoods']) && $config_data['is_head_takegoods'] == 1 ? 1 : 0;
  941. $this->is_head_takegoods = $is_head_takegoods;
  942. //$is_default_levellimit_buy = isset($config_data['is_default_levellimit_buy']) && $config_data['is_default_levellimit_buy'] == 1 ? 1 : 0;
  943. //$this->is_default_levellimit_buy = $is_default_levellimit_buy;
  944. //$is_default_vipmember_buy = isset($config_data['is_default_vipmember_buy']) && $config_data['is_default_vipmember_buy'] == 1 ? 1 : 0;
  945. //$this->is_default_vipmember_buy = $is_default_vipmember_buy;
  946. $this->display();
  947. }
  948. public function category_enabled()
  949. {
  950. $id = I('request.id');
  951. if (empty($id)) {
  952. $ids = I('request.ids');
  953. $id = (is_array($ids) ? implode(',', $ids) : 0);
  954. }
  955. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  956. $enabled = I('request.enabled');
  957. foreach ($items as $item) {
  958. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_show' => intval($enabled)) );
  959. }
  960. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  961. }
  962. public function category_typeenabled()
  963. {
  964. $_GPC = I('request.');
  965. $id = intval($_GPC['id']);
  966. if (empty($id)) {
  967. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  968. }
  969. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  970. foreach ($items as $item) {
  971. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_type_show' => intval($_GPC['enabled'])) );
  972. }
  973. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  974. }
  975. public function mult_tpl()
  976. {
  977. $tpl = I('get.tpl','','trim');
  978. $spec_str = I('post.spec_str', '', 'trim');
  979. $options_name = I('post.options_name','','trim');
  980. $cur_cate_id = I('post.cur_cate_id',0);
  981. if ($tpl == 'spec') {
  982. $spec = array('id' => random(32), 'title' => $options_name);
  983. $need_items = array();
  984. $spec_list = explode('@', $spec_str);
  985. foreach($spec_list as $itemname)
  986. {
  987. $tmp_item = array('id' =>random(32),'title' => $itemname, 'show' => 1);
  988. $need_items[] = $tmp_item;
  989. }
  990. $spec['items'] = $need_items;
  991. $this->spec = $spec;
  992. $this->tmp_item = $tmp_item;
  993. $this->tpl = $tpl;
  994. $this->spec_str = $spec_str;
  995. $this->options_name = $options_name;
  996. $this->cur_cate_id = $cur_cate_id;
  997. $this->display('Goods/tpl/spec');
  998. }
  999. }
  1000. public function ajax_batchtime()
  1001. {
  1002. $begin_time = I('request.begin_time');
  1003. $goodsids = I('request.goodsids');
  1004. $end_time = I('request.end_time');
  1005. foreach ($goodsids as $goods_id ) {
  1006. if($begin_time && $end_time){
  1007. $param = array();
  1008. $param['begin_time'] = strtotime($begin_time);
  1009. $param['end_time'] = strtotime($end_time);
  1010. M('lionfish_comshop_good_common')->where( array('goods_id' => $goods_id) )->save( $param );
  1011. }
  1012. }
  1013. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1014. }
  1015. public function tpl()
  1016. {
  1017. $tpl = I('get.tpl');
  1018. $title = I('get.title','');
  1019. if ($tpl == 'spec') {
  1020. $spec = array('id' => random(32), 'title' => $title);
  1021. $this->title = $title;
  1022. $this->spec = $spec;
  1023. $this->display('Goods/tpl/spec');
  1024. }else if($tpl == 'specitem')
  1025. {
  1026. $specid = I('get.specid');
  1027. $spec = array('id' => $specid);
  1028. $specitem = array('id' => random(32), 'title' => $title, 'show' => 1);
  1029. $this->specid = $specid;
  1030. $this->spec = $spec;
  1031. $this->specitem = $specitem;
  1032. $this->display('Goods/tpl/spec_item');
  1033. }
  1034. }
  1035. public function config()
  1036. {
  1037. if (IS_POST) {
  1038. $data = I('post.parameter', array());
  1039. $data['goods_stock_notice'] = trim($data['goods_stock_notice']);
  1040. $data['instructions'] = trim($data['instructions']);
  1041. $data['is_show_buy_record'] = trim($data['is_show_buy_record']);
  1042. $data['is_show_list_timer'] = intval($data['is_show_list_timer']);
  1043. $data['is_show_list_count'] = intval($data['is_show_list_count']);
  1044. $data['is_show_comment_list'] = intval($data['is_show_comment_list']);
  1045. $data['is_show_new_buy'] = intval($data['is_show_new_buy']);
  1046. $data['is_show_ziti_time'] = intval($data['is_show_ziti_time']);
  1047. $data['is_show_spike_buy'] = intval($data['is_show_spike_buy']);
  1048. $data['goodsdetails_addcart_bg_color'] = $data['goodsdetails_addcart_bg_color'];
  1049. $data['goodsdetails_buy_bg_color'] = $data['goodsdetails_buy_bg_color'];
  1050. $data['is_show_guess_like'] = $data['is_show_guess_like'];
  1051. $data['show_goods_guess_like'] = $data['show_goods_guess_like'];
  1052. if(!empty($data['num_guess_like'])){
  1053. $data['num_guess_like'] = $data['num_guess_like'];
  1054. }else{
  1055. $data['num_guess_like'] = 8;
  1056. }
  1057. $data['isopen_community_group_share'] = intval($data['isopen_community_group_share']);
  1058. $data['group_share_avatar'] = save_media($data['group_share_avatar']);
  1059. $data['group_share_title'] = trim($data['group_share_title']);
  1060. $data['group_share_desc'] = trim($data['group_share_desc']);
  1061. $data['is_close_details_time'] = intval($data['is_close_details_time']);
  1062. D('Seller/Config')->update($data);
  1063. //旧的的域名
  1064. $present_realm_name = I('post.present_realm_name');
  1065. //修改商品详情域名
  1066. $new_realm_name = I('post.new_realm_name');
  1067. if(!empty($new_realm_name)){
  1068. $str="/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/";
  1069. if (!preg_match($str,$present_realm_name)){
  1070. show_json(0, array('message' => '旧的域名格式不正确'));
  1071. }
  1072. if (!preg_match($str,$new_realm_name)){
  1073. show_json(0, array('message' => '新的域名格式不正确'));
  1074. }
  1075. $sql = " update ". C('DB_PREFIX') ."lionfish_comshop_good_common set content = replace( content , '".$present_realm_name."' , '".$new_realm_name."' ) ";
  1076. $list = M()->execute($sql);
  1077. if(empty($list)){
  1078. show_json(0, array('message' => '商品详情中不存在该域名,或者不能填写相同的域名,请检查后重新填写'));
  1079. }
  1080. }
  1081. show_json(1, array('url'=> U('goods/config')));
  1082. }
  1083. $data = D('Seller/Config')->get_all_config();
  1084. $this->data = $data;
  1085. $this->display();
  1086. }
  1087. function addspec()
  1088. {
  1089. global $_W;
  1090. global $_GPC;
  1091. if (IS_POST) {
  1092. $data = I('post.data');
  1093. D('Seller/Spec')->update($data);
  1094. show_json(1, array('url' => U('goods/goodsspec')));
  1095. }
  1096. $this->display();
  1097. }
  1098. public function editspec()
  1099. {
  1100. $id = I('request.id');
  1101. if (!empty($id)) {
  1102. $item = M('lionfish_comshop_spec')->where( array('id' => $id) )->find();
  1103. if (json_decode($item['value'], true)) {
  1104. $labelname = json_decode($item['value'], true);
  1105. }
  1106. else {
  1107. $labelname = unserialize($item['value']);
  1108. }
  1109. }
  1110. if (IS_POST) {
  1111. $data = I('post.data');
  1112. D('Seller/Spec')->update($data);
  1113. show_json(1, array('url' => U('goods/goodsspec')));
  1114. }
  1115. $this->item = $item;
  1116. $this->labelname = $labelname;
  1117. $this->display('Goods/addspec');
  1118. }
  1119. public function deletespec()
  1120. {
  1121. $id = I('get.id');
  1122. if (empty($id)) {
  1123. $ids = I('post.ids');
  1124. $id = (is_array($ids) ? implode(',', $ids) : 0);
  1125. }
  1126. $items = M('lionfish_comshop_spec')->field('id,name')->where( array('id' => array('in', $id)) )->select();
  1127. if (empty($item)) {
  1128. $item = array();
  1129. }
  1130. foreach ($items as $item) {
  1131. M('lionfish_comshop_spec')->where( array('id' => $item['id']) )->delete();
  1132. }
  1133. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1134. }
  1135. public function addcategory()
  1136. {
  1137. $data = array();
  1138. $pid = I('get.pid', 0);
  1139. $id = I('get.id', 0);
  1140. if (IS_POST) {
  1141. $data = I('post.data');
  1142. D('Seller/GoodsCategory')->update($data);
  1143. show_json(1, array('url' => U('goods/goodscategory')));
  1144. }
  1145. if($id >0 )
  1146. {
  1147. $data = M('lionfish_comshop_goods_category')->where( array('id' => $id) )->find();
  1148. $this->data = $data;
  1149. }
  1150. $this->pid = $pid;
  1151. $this->id = $id;
  1152. $this->display();
  1153. }
  1154. public function category_delete()
  1155. {
  1156. $id = I('get.id');
  1157. $item = M('lionfish_comshop_goods_category')->field('id, name, pid')->where( array('id' => $id) )->find();
  1158. M('lionfish_comshop_goods_category')->where( "id={$id} or pid={$id}" )->delete();
  1159. //m('shop')->getCategory(true);
  1160. show_json(1, array('url' => U('goods/goodscategory')));
  1161. }
  1162. public function goodscategory()
  1163. {
  1164. if (IS_POST) {
  1165. $datas = I('post.datas');
  1166. if (!empty($datas)) {
  1167. D('Seller/GoodsCategory')->goodscategory_modify($datas);
  1168. show_json(1 , array('url' => U('goods/goodscategory') ));
  1169. }
  1170. $parameter = I('post.parameter');
  1171. if (!empty($parameter)) {
  1172. $data = ((is_array($parameter) ? $parameter : array()));
  1173. D('Seller/Config')->update($data);
  1174. show_json(1);
  1175. }
  1176. }
  1177. $children = array();
  1178. $category = M('lionfish_comshop_goods_category')->where(' cate_type="normal" ')->order('pid ASC, sort_order DESC')->select();
  1179. foreach ($category as $index => $row) {
  1180. if (!empty($row['pid'])) {
  1181. $children[$row['pid']][] = $row;
  1182. unset($category[$index]);
  1183. }
  1184. }
  1185. $data = D('Seller/Config')->get_all_config();
  1186. $this->data = $data;
  1187. $this->children = $children;
  1188. $this->category = $category;
  1189. $this->display();
  1190. }
  1191. public function goodsspec()
  1192. {
  1193. $condition = ' 1=1 and spec_type="normal" ';
  1194. $pindex = I('get.page',1);
  1195. $psize = 20;
  1196. $enabled = I('get.enabled');
  1197. if ($enabled != '') {
  1198. $condition .= ' and state=' . intval($enabled);
  1199. }
  1200. $keyword = I('get.keyword','','trim');
  1201. if (!empty($keyword)) {
  1202. $condition .= ' and name like "%'.$keyword.'%" ';
  1203. }
  1204. $offset = ($pindex - 1) * $psize;
  1205. $label = M('lionfish_comshop_spec')->field('id,name,value')->where($condition)->order(' id desc ')->limit($offset, $psize)->select();
  1206. $total = M('lionfish_comshop_spec')->where( $condition )->count();
  1207. $cur_url = U('goods/goodsspec', array('enabled' => $enabled,'keyword' => $keyword));
  1208. $pager = pagination2($total, $pindex, $psize);
  1209. foreach( $label as &$val )
  1210. {
  1211. $val['value'] = unserialize($val['value']);
  1212. $val['value_str'] = !empty($val['value']) ? implode(',', $val['value']) : '';
  1213. }
  1214. $this->keyword = $keyword;
  1215. $this->label = $label;
  1216. $this->total = $total;
  1217. $this->pager = $pager;
  1218. $this->display();
  1219. }
  1220. /**
  1221. 搜索全部商品,可添加虚拟评价
  1222. **/
  1223. public function goods_search_all()
  1224. {
  1225. $goods_name = I('post.goods_name','');
  1226. $where = " status=1 and quantity>0 and store_id = " . $this->sellerid;
  1227. if(!empty($goods_name))
  1228. {
  1229. $where .= " and name like '%".$goods_name."%' ";
  1230. }
  1231. $goods_list = M('goods')->where($where)->limit(20)->select();
  1232. $this->goods_list = $goods_list;
  1233. $result = array();
  1234. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1235. echo json_encode($result);
  1236. die();
  1237. }
  1238. function toggle_statues_show() {
  1239. $goods_id = I('post.gid',0);
  1240. $goods_info =M('Goods')->where( array('goods_id' => $goods_id) )->find();
  1241. $status = $goods_info['status'] == 1 ? 0: 1;
  1242. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('status' => $status) );
  1243. echo json_encode( array('code' => 1) );
  1244. die();
  1245. }
  1246. /**
  1247. 搜索可报名的商品
  1248. **/
  1249. public function goods_search_voucher()
  1250. {
  1251. $goods_name = I('post.goods_name','');
  1252. $where = " (type='normal' or type ='pintuan') and status=1 and quantity>0 and store_id = " . $this->sellerid;
  1253. if(!empty($goods_name))
  1254. {
  1255. $where .= " and ( name like '%".$goods_name."%' or goods_id like '%".$goods_name."%') ";
  1256. }
  1257. $goods_list = M('goods')->where($where)->limit(10)->select();
  1258. $this->goods_list = $goods_list;
  1259. $result = array();
  1260. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1261. echo json_encode($result);
  1262. die();
  1263. }
  1264. /**
  1265. 搜索可报名的商品
  1266. **/
  1267. public function goods_search()
  1268. {
  1269. $goods_name = I('post.goods_name','');
  1270. $where = " type='normal' and status=1 and quantity>0 and store_id = " . $this->sellerid;
  1271. if(!empty($goods_name))
  1272. {
  1273. $where .= " and name like '%".$goods_name."%' ";
  1274. }
  1275. $goods_list = M('goods')->where($where)->limit(20)->select();
  1276. $this->goods_list = $goods_list;
  1277. $result = array();
  1278. $result['html'] = $this->fetch('Goods:goods_list_fetch');
  1279. echo json_encode($result);
  1280. die();
  1281. }
  1282. public function query_normal()
  1283. {
  1284. $_GPC = I('request.');
  1285. $kwd = trim($_GPC['keyword']);
  1286. $is_recipe = isset($_GPC['is_recipe']) ? intval($_GPC['is_recipe']) : 0 ;
  1287. $is_soli = isset($_GPC['is_soli']) ? intval($_GPC['is_soli']) : 0 ;
  1288. $params = array();
  1289. $type = isset($_GPC['type']) ? $_GPC['type']:'normal';
  1290. $condition = ' type = "'.$type.'" and grounding = 1 and is_seckill =0 ';
  1291. if (!empty($kwd)) {
  1292. $condition .= ' AND `goodsname` LIKE "%' . $kwd . '%" ';
  1293. }
  1294. if( isset($_GPC['unselect_goodsid']) && $_GPC['unselect_goodsid'] > 0 )
  1295. {
  1296. $condition .= ' AND `id` != '.$_GPC['unselect_goodsid'];
  1297. }
  1298. if( $is_soli == 1 )
  1299. {
  1300. $head_id = $_GPC['head_id'];
  1301. $goods_ids_arr = M('lionfish_community_head_goods')->field('goods_id')->where( array('head_id' =>$head_id ) )->order('id desc')->select();
  1302. $ids_arr = array();
  1303. foreach($goods_ids_arr as $val){
  1304. $ids_arr[] = $val['goods_id'];
  1305. }
  1306. if( !empty($ids_arr) )
  1307. {
  1308. $ids_str = implode(',',$ids_arr);
  1309. $condition .= " and ( is_all_sale = 1 or id in ({$ids_str}) ) ";
  1310. }else{
  1311. $condition .= " and ( is_all_sale = 1 ) ";
  1312. }
  1313. //is_all_sale
  1314. }
  1315. //todo....
  1316. $ds = M('lionfish_comshop_goods')->field('id as gid,goodsname,subtitle,price,productprice')->where( $condition )->select();
  1317. $s_html = "";
  1318. foreach ($ds as &$d) {
  1319. //thumb
  1320. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' =>$d['gid'] ) )->order('id asc')->find();
  1321. $d['thumb'] = tomedia($thumb['image']);
  1322. $s_html.= '<tr>';
  1323. $s_html.=" <td><img src='".tomedia($d['thumb'])."' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> ".$d['goodsname']."</td>";
  1324. if ( isset($_GPC['template']) && $_GPC['template'] == 'mult' ) {
  1325. if( $is_recipe == 1 )
  1326. {
  1327. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_recipe" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1328. }else{
  1329. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_goods" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1330. }
  1331. }else{
  1332. $s_html.=' <td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($d).'\'>选择</a></td>';
  1333. }
  1334. $s_html.="</tr>";
  1335. }
  1336. unset($d);
  1337. if( isset($_GPC['is_ajax']) )
  1338. {
  1339. echo json_encode( array('code' => 0, 'html' =>$s_html ) );
  1340. die();
  1341. }
  1342. $this->ds = $ds;
  1343. $this->_GPC = $_GPC;
  1344. if ( isset($_GPC['template']) && $_GPC['template'] == 'mult' ) {
  1345. if( $is_recipe == 1 )
  1346. {
  1347. $this->display('Goods/query_normal_mult_recipe');
  1348. }else{
  1349. $this->display('Goods/query_normal_mult');
  1350. }
  1351. }else{
  1352. $this->display();
  1353. }
  1354. }
  1355. /**
  1356. * 获取商品规格情况
  1357. */
  1358. function get_ajax_search_goods_info()
  1359. {
  1360. $goods_id = I('get.goods_id');
  1361. $is_hide = I('get.is_hide',0);
  1362. $type = I('get.type','pin');
  1363. //'type' => 'bargain'
  1364. $this->is_hide = $is_hide;
  1365. $goods_info = M('goods')->field('name,goods_id,price,danprice')->where( array('goods_id' => $goods_id) )->find();
  1366. $model=new GoodsModel();
  1367. $this->goods_options=$model->get_goods_options($goods_id, UID);
  1368. $goods_option_mult_value = M('goods_option_mult_value')->where( array('goods_id' => $goods_id ) )->select();
  1369. $goods_option_mult_str = '';
  1370. if( !empty($goods_option_mult_value) )
  1371. {
  1372. $goods_option_mult_arr = array();
  1373. foreach($goods_option_mult_value as $key => $val)
  1374. {
  1375. $goods_option_mult_arr[] = 'mult_id:'.$val['rela_goodsoption_valueid'].'@@mult_qu:'.$val['quantity'].'@@mult_image:'.$val['image'];
  1376. //option_value option_value_id value_name
  1377. $option_name_arr = explode('_', $val['rela_goodsoption_valueid']);
  1378. $option_name_list = array();
  1379. foreach($option_name_arr as $option_value_id_tp)
  1380. {
  1381. $tp_op_val_info =M('option_value')->where( array('option_value_id' => $option_value_id_tp) )->find();
  1382. $option_name_list[] = $tp_op_val_info['value_name'];
  1383. }
  1384. $val['option_name_list'] = $option_name_list;
  1385. $goods_option_mult_value[$key] = $val;
  1386. }
  1387. $goods_option_mult_str = implode(',', $goods_option_mult_arr);
  1388. }
  1389. $this->goods_option_mult_value = $goods_option_mult_value;
  1390. $this->goods_option_mult_str = $goods_option_mult_str;
  1391. $this->goods_info = $goods_info;
  1392. $result = array();
  1393. if($type == 'bargain')
  1394. {
  1395. $result['html'] = $this->fetch('Goods:goods_option_fetch_bargain');
  1396. }
  1397. else if($type == 'integral'){
  1398. $result['html'] = $this->fetch('Goods:goods_option_fetch_integral');
  1399. }else{
  1400. $result['html'] = $this->fetch('Goods:goods_option_fetch');
  1401. }
  1402. echo json_encode($result);
  1403. die();
  1404. }
  1405. function toggle_index_sort()
  1406. {
  1407. $goods_id = I('post.gid',0);
  1408. $index_sort = I('post.index_sort',0,'intval');
  1409. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('index_sort' => $index_sort) );
  1410. echo json_encode( array('code' => 1) );
  1411. die();
  1412. }
  1413. function toggle_index_show()
  1414. {
  1415. $goods_id = I('post.gid',0);
  1416. $goods_info =M('Goods')->where( array('goods_id' => $goods_id) )->find();
  1417. $is_index_show = $goods_info['is_index_show'] == 1 ? 0: 1;
  1418. $res = M('Goods')->where( array('goods_id' => $goods_id) )->save( array('is_index_show' => $is_index_show) );
  1419. echo json_encode( array('code' => 1) );
  1420. die();
  1421. }
  1422. /**
  1423. * 活动商品
  1424. */
  1425. public function activity()
  1426. {
  1427. $this->breadcrumb2='活动商品信息';
  1428. $model=new GoodsModel();
  1429. $filter=I('get.');
  1430. $search=array('store_id' => SELLERUID);
  1431. if(isset($filter['name'])){
  1432. $search['name']=$filter['name'];
  1433. }
  1434. if(isset($filter['category'])){
  1435. $search['category']=$filter['category'];
  1436. $this->get_category=$search['category'];
  1437. }
  1438. if(isset($filter['status'])){
  1439. $search['status']=$filter['status'];
  1440. $this->get_status=$search['status'];
  1441. }
  1442. if(isset($filter['type'])){
  1443. $search['type']=$filter['type'];
  1444. $this->type=$search['type'];
  1445. }else {
  1446. $search['type']='activity';
  1447. $this->type=$search['type'];
  1448. }
  1449. //type
  1450. $data=$model->show_goods_page($search);
  1451. $store_bind_class = M('store_bind_class')->where( array('seller_id' => SELLERUID) )->select();
  1452. $cate_ids = array();
  1453. foreach($store_bind_class as $val)
  1454. {
  1455. if( !empty($val['class_1'])) {
  1456. $cate_ids[] = $val['class_1'];
  1457. }
  1458. if( !empty($val['class_2'])) {
  1459. $cate_ids[] = $val['class_2'];
  1460. }
  1461. if( !empty($val['class_3'])) {
  1462. $cate_ids[] = $val['class_3'];
  1463. }
  1464. }
  1465. if(empty($cate_ids)) {
  1466. $this->category = array();
  1467. } else {
  1468. $cate_ids_str = implode(',', $cate_ids);
  1469. $category=M('goods_category')->where( array('id' => array('in',$cate_ids_str)) )->select();
  1470. $category_tree =list_to_tree($category);
  1471. $this->category = $category_tree;
  1472. }
  1473. foreach($data['list'] as $key => $goods)
  1474. {
  1475. $all_comment = M('order_comment')->where( array('goods_id' => $goods['goods_id']) )->count();
  1476. $wait_comment = M('order_comment')->where( array('state' => 0 ,'goods_id' => $goods['goods_id']) )->count();
  1477. $goods['all_comment'] = $all_comment;
  1478. $goods['wait_comment'] = $wait_comment;
  1479. $data['list'][$key] = $goods;
  1480. }
  1481. $this->assign('empty',$data['empty']);// 赋值数据集
  1482. $this->assign('list',$data['list']);// 赋值数据集
  1483. $this->assign('page',$data['page']);// 赋值分页输出
  1484. $this->display();
  1485. }
  1486. /**
  1487. 回收站商品重新上架
  1488. **/
  1489. public function goback()
  1490. {
  1491. $goods_id = I('get.id',0,'intval');
  1492. $result = array('code' => 0);
  1493. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  1494. if(empty($goods_info))
  1495. {
  1496. $result['msg'] = '非法操作';
  1497. echo json_encode($result);
  1498. die();
  1499. }
  1500. $up_data = array();
  1501. $up_data['lock_type'] = 'normal';
  1502. $up_data['status'] = 2;//下架
  1503. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  1504. $result['code'] = 1;
  1505. echo json_encode($result);
  1506. die();
  1507. }
  1508. public function get_weshare_image()
  1509. {
  1510. $goods_id = I('get.id',0,'intval');
  1511. //400*400 fan_image
  1512. //get_goods_price($goods_id)
  1513. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1514. $goods_img = ROOT_PATH.'Uploads/image/'.$goods_info['image'];
  1515. if( !empty($goods_info['fan_image']) )
  1516. {
  1517. $goods_img = ROOT_PATH.'Uploads/image/'.$goods_info['fan_image'];
  1518. }
  1519. $goods_model = D('Home/Goods');
  1520. $goods_price = $goods_model->get_goods_price($goods_id);
  1521. $goods_price['market_price'] = $goods_info['price'];
  1522. //price
  1523. $goods_title = $goods_info['name'];
  1524. $need_img = $goods_model->_get_compare_zan_img($goods_img,$goods_title,$goods_price);
  1525. //贴上二维码图
  1526. //$rocede_path = $goods_model->_get_goods_user_wxqrcode($goods_id,$member_id);
  1527. //$res = $goods_model->_get_compare_qrcode_bgimg($need_img['need_path'], $rocede_path);
  1528. M('goods_description')->where( array('goods_id' =>$goods_id) )->save( array('wepro_qrcode_image' =>$need_img['need_path']) );
  1529. echo json_encode(array('code' =>1));
  1530. die();
  1531. }
  1532. /**
  1533. 加入回车站
  1534. **/
  1535. public function backhuiche()
  1536. {
  1537. $goods_id = I('get.id',0,'intval');
  1538. $result = array('code' => 0);
  1539. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  1540. if(empty($goods_info))
  1541. {
  1542. $result['msg'] = '非法操作';
  1543. echo json_encode($result);
  1544. die();
  1545. }
  1546. $lock_type = $goods_info['lock_type'];
  1547. switch($lock_type)
  1548. {
  1549. case 'lottery':
  1550. M('lottery_goods')->where( array('goods_id' => $goods_id) )->delete();
  1551. break;
  1552. case 'super_spike':
  1553. M('super_spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  1554. break;
  1555. case 'spike':
  1556. M('spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  1557. break;
  1558. case 'subject':
  1559. case 'free_trial':
  1560. case 'niyuan':
  1561. case 'oneyuan':
  1562. case 'haitao':
  1563. M('subject_goods')->where( array('goods_id' => $goods_id) )->delete();
  1564. break;
  1565. }
  1566. $up_data = array();
  1567. $up_data['type'] = 'normal';
  1568. $up_data['lock_type'] = 'normal';
  1569. $up_data['status'] = 4;//下架
  1570. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  1571. $result['code'] = 1;
  1572. echo json_encode($result);
  1573. die();
  1574. }
  1575. /**
  1576. 撤回活动申请
  1577. **/
  1578. public function backshenqing()
  1579. {
  1580. $goods_id = I('get.id',0,'intval');
  1581. $result = array('code' => 0);
  1582. $goods_info = M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->find();
  1583. if(empty($goods_info))
  1584. {
  1585. $result['msg'] = '非法操作';
  1586. echo json_encode($result);
  1587. die();
  1588. }
  1589. $lock_type = $goods_info['lock_type'];
  1590. switch($lock_type)
  1591. {
  1592. case 'lottery':
  1593. M('lottery_goods')->where( array('goods_id' => $goods_id) )->delete();
  1594. break;
  1595. case 'super_spike':
  1596. M('super_spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  1597. break;
  1598. case 'spike':
  1599. M('spike_goods')->where( array('goods_id' => $goods_id) )->delete();
  1600. break;
  1601. case 'subject':
  1602. case 'free_trial':
  1603. case 'niyuan':
  1604. case 'oneyuan':
  1605. case 'haitao':
  1606. M('subject_goods')->where( array('goods_id' => $goods_id) )->delete();
  1607. break;
  1608. }
  1609. $up_data = array();
  1610. $up_data['lock_type'] = 'normal';
  1611. $up_data['status'] = 0;//下架
  1612. M('goods')->where( array('goods_id' => $goods_id, 'store_id' => SELLERUID) )->save($up_data);
  1613. $result['code'] = 1;
  1614. echo json_encode($result);
  1615. die();
  1616. }
  1617. ///Goods/delcomment/id/1
  1618. /**
  1619. * 删除评论
  1620. */
  1621. public function delcomment()
  1622. {
  1623. $id = I('get.id');
  1624. $goods_id = I('get.goods_id');
  1625. M('order_comment')->where( array('comment_id' => $id) )->delete();
  1626. //echo
  1627. $result = array(
  1628. 'status'=>'success',
  1629. 'message'=>'删除成功',
  1630. 'jump'=>U('Goods/comment_info', array('id' => $goods_id))
  1631. );
  1632. $this->osc_alert($result);
  1633. }
  1634. /**
  1635. * 审核评论
  1636. */
  1637. public function toggle_comment_state()
  1638. {
  1639. $comment_id = I('post.comment_id');
  1640. $order_comment = M('order_comment')->where( array('comment_id' => $comment_id) )->find();
  1641. //state
  1642. $state = $order_comment['state'] == 1 ? 0: 1;
  1643. M('order_comment')->where( array('comment_id' => $comment_id) )->save( array('state' => $state) );
  1644. echo json_encode( array('code' => 1) );
  1645. die();
  1646. }
  1647. /**
  1648. * 商品评论信息
  1649. */
  1650. public function comment_info()
  1651. {
  1652. $goods_id = I('get.id');
  1653. $model=new GoodsModel();
  1654. $search = array();
  1655. $search['goods_id'] = $goods_id;
  1656. $data=$model->show_comment_page($search);
  1657. $this->assign('empty',$data['empty']);// 赋值数据集
  1658. $this->assign('list',$data['list']);// 赋值数据集
  1659. $this->assign('page',$data['page']);// 赋值分页输出
  1660. $this->display();
  1661. }
  1662. public function ajax_batchheads()
  1663. {
  1664. $goodsids = I('request.goodsids');
  1665. $head_id_arr = I('request.head_id_arr');
  1666. $is_clear_old = I('request.is_clear_old');
  1667. if( $is_clear_old == 1 )
  1668. {
  1669. foreach($goodsids as $goods_id)
  1670. {
  1671. M('lionfish_community_head_goods')->where( array('goods_id' => $goods_id) )->delete();
  1672. }
  1673. }
  1674. foreach($head_id_arr as $head_id)
  1675. {
  1676. foreach($goodsids as $goods_id)
  1677. {
  1678. D('Seller/Communityhead')->insert_head_goods($goods_id, $head_id);
  1679. }
  1680. }
  1681. show_json(1);
  1682. }
  1683. public function ajax_batchcates_headgroup()
  1684. {
  1685. $_GPC = I('request.');
  1686. $goodsids = $_GPC['goodsids'];
  1687. $groupid = $_GPC['groupid'];
  1688. if( $groupid == 'default')
  1689. {
  1690. $groupid = 0;
  1691. }
  1692. $head_list = M('lionfish_community_head')->field('id')->where( array("groupid" => $groupid, 'state' => 1 ) )->select();
  1693. $is_clear_old = $_GPC['is_clear_old'];
  1694. if( $is_clear_old == 1 )
  1695. {
  1696. foreach($goodsids as $goods_id)
  1697. {
  1698. M('lionfish_community_head_goods')->where( array('goods_id' => $goods_id ) )->delete();
  1699. }
  1700. }
  1701. if( !empty($head_list) )
  1702. {
  1703. foreach($head_list as $val)
  1704. {
  1705. foreach($goodsids as $goods_id)
  1706. {
  1707. D('Seller/Communityhead')->insert_head_goods($goods_id, $val['id']);
  1708. }
  1709. }
  1710. }
  1711. show_json(1);
  1712. }
  1713. public function ajax_batchcates()
  1714. {
  1715. $iscover = I('request.iscover');
  1716. $goodsids = I('request.goodsids');
  1717. $cates = I('request.cates');
  1718. if( !is_array($cates) )
  1719. {
  1720. $cates = array($cates);
  1721. }
  1722. foreach ($goodsids as $goods_id ) {
  1723. if( $iscover == 1)
  1724. {
  1725. //覆盖,即删除原有的分类
  1726. M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $goods_id) )->delete();
  1727. foreach($cates as $cate_id)
  1728. {
  1729. $post_data_cate = array();
  1730. $post_data_cate['cate_id'] = $cate_id;
  1731. $post_data_cate['goods_id'] = $goods_id;
  1732. M('lionfish_comshop_goods_to_category')->add($post_data_cate);
  1733. }
  1734. }else{
  1735. foreach($cates as $cate_id)
  1736. {
  1737. //仅更新
  1738. $item = M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $goods_id,'cate_id' => $cate_id) )->find();
  1739. if(empty($item))
  1740. {
  1741. $post_data_cate = array();
  1742. $post_data_cate['cate_id'] = $cate_id;
  1743. $post_data_cate['goods_id'] = $goods_id;
  1744. M('lionfish_comshop_goods_to_category')->add($post_data_cate);
  1745. }
  1746. }
  1747. }
  1748. }
  1749. show_json(1);
  1750. }
  1751. public function lotteryinfo()
  1752. {
  1753. $goods_id = I('get.id',0);
  1754. $lottery_goods = M('lottery_goods')->where( array('goods_id' =>$goods_id) )->find();
  1755. if(empty($lottery_goods)){
  1756. die('非法操作');
  1757. }//store_id
  1758. $page = I('get.page',1);
  1759. $per_page = 4;
  1760. $offset = ($page - 1) * $per_page;
  1761. $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,
  1762. ".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og,".C('DB_PREFIX')."member as m
  1763. where p.state = 1 and p.pin_id = po.pin_id and po.order_id = o.order_id
  1764. 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}
  1765. and o.date_added >= ".$lottery_goods['begin_time']." order by p.pin_id asc limit {$offset},{$per_page}";
  1766. //begin_time date_added
  1767. $list=M()->query($sql);
  1768. $this->list = $list;
  1769. $this->goods_id = $goods_id;
  1770. $this->lottery_goods = $lottery_goods;
  1771. if($page>1){
  1772. $result = array();
  1773. $result['code'] = 0;
  1774. if(!empty($list)) {
  1775. $content = $this->fetch('Goods:lottery_info_fetch');
  1776. $result['code'] = 1;
  1777. $result['html'] = $content;
  1778. }
  1779. echo json_encode($result);
  1780. die();
  1781. }
  1782. $this->display();
  1783. }
  1784. public function openlottery()
  1785. {
  1786. $goods_id = I('get.id',0);
  1787. $oids = I('post.oids');
  1788. $order_model = D('Home/Order');
  1789. $order_model->open_goods_lottery_order($goods_id,$oids,false);
  1790. //$order_model->open_goods_lottery_order($goods_id,'',true);
  1791. //$map['id'] = array('in','1,3,8')
  1792. echo json_encode( array('code' => 1) );
  1793. die();
  1794. }
  1795. public function lottery_shenqing()
  1796. {
  1797. $result = array('code' => 0);
  1798. $goods_id = I('post.goods_id',0);
  1799. if($goods_id == 0){
  1800. $result['msg'] = '商品不存在';
  1801. echo json_encode($result);
  1802. die();
  1803. }
  1804. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1805. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1806. $spike_data = array();
  1807. $spike_data['goods_id'] = $goods_id;
  1808. $spike_data['state'] = 0;
  1809. $spike_data['quantity'] = $goods_info['quantity'];
  1810. $spike_data['begin_time'] = 0;
  1811. $spike_data['end_time'] = 0;
  1812. $spike_data['addtime'] = time();
  1813. $rs = M('lottery_goods')->add($spike_data);
  1814. if($rs) {
  1815. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'lottery') );
  1816. }
  1817. $result['code'] = 1;
  1818. echo json_encode($result);
  1819. die();
  1820. } else{
  1821. $result['msg'] = '已存在其他活动中';
  1822. echo json_encode($result);
  1823. die();
  1824. }
  1825. }
  1826. public function xianshimiaosha_shenqing()
  1827. {
  1828. $result = array('code' => 0);
  1829. $goods_id = I('post.goods_id',0);
  1830. if($goods_id == 0){
  1831. $result['msg'] = '商品不存在';
  1832. echo json_encode($result);
  1833. die();
  1834. }
  1835. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1836. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1837. $spike_data = array();
  1838. $spike_data['goods_id'] = $goods_id;
  1839. $spike_data['state'] = 0;
  1840. $spike_data['quantity'] = $goods_info['quantity'];
  1841. $spike_data['begin_time'] = 0;
  1842. $spike_data['end_time'] = 0;
  1843. $spike_data['addtime'] = time();
  1844. $rs = M('spike_goods')->add($spike_data);
  1845. if($rs) {
  1846. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'spike') );
  1847. }
  1848. $result['code'] = 1;
  1849. echo json_encode($result);
  1850. die();
  1851. } else{
  1852. $result['msg'] = '已存在其他活动中';
  1853. echo json_encode($result);
  1854. die();
  1855. }
  1856. }
  1857. public function spike_sub()
  1858. {
  1859. $spike_id = I('post.spike',0);
  1860. $goods_id = I('post.goods_id',0);
  1861. if($goods_id == 0){
  1862. $result['msg'] = '商品不存在';
  1863. echo json_encode($result);
  1864. die();
  1865. }
  1866. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1867. $spike_info = M('spike')->where( array('id' => $spike_id) )->find();
  1868. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1869. $super_data = array();
  1870. $super_data['spike_id'] = $spike_id;
  1871. $super_data['goods_id'] = $goods_id;
  1872. $super_data['state'] = 0;
  1873. $super_data['begin_time'] = $spike_info['begin_time'];
  1874. $super_data['end_time'] = $spike_info['end_time'];
  1875. $super_data['addtime'] = time();
  1876. $rs = M('spike_goods')->add($super_data);
  1877. if($rs) {
  1878. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'spike') );
  1879. }
  1880. $result['code'] = 1;
  1881. echo json_encode($result);
  1882. die();
  1883. } else {
  1884. $result['msg'] = '已存在其他活动中';
  1885. echo json_encode($result);
  1886. die();
  1887. }
  1888. }
  1889. public function chaozhidapai_sub()
  1890. {
  1891. $super_spike_id = I('post.super_spike',0);
  1892. $goods_id = I('post.goods_id',0);
  1893. if($goods_id == 0){
  1894. $result['msg'] = '商品不存在';
  1895. echo json_encode($result);
  1896. die();
  1897. }
  1898. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1899. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1900. $super_data = array();
  1901. $super_data['super_spike_id'] = $super_spike_id;
  1902. $super_data['goods_id'] = $goods_id;
  1903. $super_data['state'] = 0;
  1904. $super_data['begin_time'] = 0;
  1905. $super_data['end_time'] = 0;
  1906. $super_data['addtime'] = time();
  1907. $rs = M('super_spike_goods')->add($super_data);
  1908. if($rs) {
  1909. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'super_spike') );
  1910. }
  1911. $result['code'] = 1;
  1912. echo json_encode($result);
  1913. die();
  1914. } else {
  1915. $result['msg'] = '已存在其他活动中';
  1916. echo json_encode($result);
  1917. die();
  1918. }
  1919. }
  1920. public function oneyuansubject_sub()
  1921. {
  1922. $subject_id = I('post.subject',0);
  1923. $goods_id = I('post.goods_id',0);
  1924. if($goods_id == 0){
  1925. $result['msg'] = '商品不存在';
  1926. echo json_encode($result);
  1927. die();
  1928. }
  1929. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1930. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1931. $super_data = array();
  1932. $super_data['subject_id'] = $subject_id;
  1933. $super_data['goods_id'] = $goods_id;
  1934. $super_data['state'] = 0;
  1935. $super_data['addtime'] = time();
  1936. $rs = M('subject_goods')->add($super_data);
  1937. if($rs) {
  1938. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'oneyuan') );
  1939. }
  1940. $result['code'] = 1;
  1941. echo json_encode($result);
  1942. die();
  1943. } else {
  1944. $result['msg'] = '已存在其他活动中';
  1945. echo json_encode($result);
  1946. die();
  1947. }
  1948. }
  1949. public function niyuansubject_sub()
  1950. {
  1951. $subject_id = I('post.subject',0);
  1952. $goods_id = I('post.goods_id',0);
  1953. if($goods_id == 0){
  1954. $result['msg'] = '商品不存在';
  1955. echo json_encode($result);
  1956. die();
  1957. }
  1958. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1959. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1960. $super_data = array();
  1961. $super_data['subject_id'] = $subject_id;
  1962. $super_data['goods_id'] = $goods_id;
  1963. $super_data['state'] = 0;
  1964. $super_data['addtime'] = time();
  1965. $rs = M('subject_goods')->add($super_data);
  1966. if($rs) {
  1967. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'niyuan') );
  1968. }
  1969. $result['code'] = 1;
  1970. echo json_encode($result);
  1971. die();
  1972. } else {
  1973. $result['msg'] = '已存在其他活动中';
  1974. echo json_encode($result);
  1975. die();
  1976. }
  1977. }
  1978. public function mianfei_sub()
  1979. {
  1980. $subject_id = I('post.subject',0);
  1981. $goods_id = I('post.goods_id',0);
  1982. if($goods_id == 0){
  1983. $result['msg'] = '商品不存在';
  1984. echo json_encode($result);
  1985. die();
  1986. }
  1987. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  1988. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  1989. $super_data = array();
  1990. $super_data['subject_id'] = $subject_id;
  1991. $super_data['goods_id'] = $goods_id;
  1992. $super_data['state'] = 0;
  1993. $super_data['addtime'] = time();
  1994. $rs = M('subject_goods')->add($super_data);
  1995. if($rs) {
  1996. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'zeyuan') );
  1997. }
  1998. $result['code'] = 1;
  1999. echo json_encode($result);
  2000. die();
  2001. } else {
  2002. $result['msg'] = '已存在其他活动中';
  2003. echo json_encode($result);
  2004. die();
  2005. }
  2006. }
  2007. public function putongsubject_sub()
  2008. {
  2009. $subject_id = I('post.subject',0);
  2010. $goods_id = I('post.goods_id',0);
  2011. if($goods_id == 0){
  2012. $result['msg'] = '商品不存在';
  2013. echo json_encode($result);
  2014. die();
  2015. }
  2016. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2017. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2018. $super_data = array();
  2019. $super_data['subject_id'] = $subject_id;
  2020. $super_data['goods_id'] = $goods_id;
  2021. $super_data['state'] = 0;
  2022. $super_data['addtime'] = time();
  2023. $rs = M('subject_goods')->add($super_data);
  2024. if($rs) {
  2025. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'subject') );
  2026. }
  2027. $result['code'] = 1;
  2028. echo json_encode($result);
  2029. die();
  2030. } else {
  2031. $result['msg'] = '已存在其他活动中';
  2032. echo json_encode($result);
  2033. die();
  2034. }
  2035. }
  2036. public function haitaosubject_sub()
  2037. {
  2038. $subject_id = I('post.subject',0);
  2039. $goods_id = I('post.goods_id',0);
  2040. if($goods_id == 0){
  2041. $result['msg'] = '商品不存在';
  2042. echo json_encode($result);
  2043. die();
  2044. }
  2045. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2046. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2047. $super_data = array();
  2048. $super_data['subject_id'] = $subject_id;
  2049. $super_data['goods_id'] = $goods_id;
  2050. $super_data['state'] = 0;
  2051. $super_data['addtime'] = time();
  2052. $rs = M('subject_goods')->add($super_data);
  2053. if($rs) {
  2054. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'haitao') );
  2055. }
  2056. $result['code'] = 1;
  2057. echo json_encode($result);
  2058. die();
  2059. } else {
  2060. $result['msg'] = '已存在其他活动中';
  2061. echo json_encode($result);
  2062. die();
  2063. }
  2064. }
  2065. public function yiyuan_form()
  2066. {
  2067. $result = array('code' => 0);
  2068. $goods_id = I('post.goods_id',0);
  2069. if($goods_id == 0){
  2070. $result['msg'] = '商品不存在';
  2071. echo json_encode($result);
  2072. die();
  2073. }
  2074. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2075. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2076. $subject = M('subject')->where('can_shenqing=1 and type="oneyuan"')->select();
  2077. $this->subject = $subject;
  2078. $this->goods_id = $goods_id;
  2079. $content = $this->fetch('Goods:goods_oneyuansubject_fetch');
  2080. $result['code'] = 1;
  2081. $result['html'] = $content;
  2082. echo json_encode($result);
  2083. die();
  2084. } else {
  2085. $result['msg'] = '已存在其他活动中';
  2086. echo json_encode($result);
  2087. die();
  2088. }
  2089. }
  2090. public function jiukuaijiu_form()
  2091. {
  2092. $result = array('code' => 0);
  2093. $goods_id = I('post.goods_id',0);
  2094. if($goods_id == 0){
  2095. $result['msg'] = '商品不存在';
  2096. echo json_encode($result);
  2097. die();
  2098. }
  2099. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2100. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2101. $subject = M('subject')->where('can_shenqing=1 and type="niyuan"')->select();
  2102. $this->subject = $subject;
  2103. $this->goods_id = $goods_id;
  2104. $content = $this->fetch('Goods:goods_niyuansubject_fetch');
  2105. $result['code'] = 1;
  2106. $result['html'] = $content;
  2107. echo json_encode($result);
  2108. die();
  2109. } else {
  2110. $result['msg'] = '已存在其他活动中';
  2111. echo json_encode($result);
  2112. die();
  2113. }
  2114. }
  2115. public function lottery_form()
  2116. {
  2117. $result = array('code' => 0);
  2118. $goods_id = I('post.goods_id',0);
  2119. if($goods_id == 0){
  2120. $result['msg'] = '商品不存在';
  2121. echo json_encode($result);
  2122. die();
  2123. }
  2124. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2125. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2126. $voucher_list = M('voucher')->where( "store_id=".SELLERUID." and begin_time>".time() )->select();
  2127. $this->voucher_list = $voucher_list;
  2128. $this->goods_id = $goods_id;
  2129. $content = $this->fetch('Goods:goods_lottery_fetch');
  2130. $result['code'] = 1;
  2131. $result['html'] = $content;
  2132. echo json_encode($result);
  2133. die();
  2134. } else {
  2135. $result['msg'] = '已存在其他活动中';
  2136. echo json_encode($result);
  2137. die();
  2138. }
  2139. }
  2140. public function lottery_sub()
  2141. {
  2142. $voucher_id = I('post.voucher_id',0);
  2143. $goods_id = I('post.goods_id',0);
  2144. $win_quantity = I('post.win_quantity',0);
  2145. $is_auto_open = I('post.is_auto_open',0);
  2146. $real_win_quantity = I('post.real_win_quantity',0);
  2147. if($goods_id == 0){
  2148. $result['msg'] = '商品不存在';
  2149. echo json_encode($result);
  2150. die();
  2151. }
  2152. if($voucher_id == 0){
  2153. $result['msg'] = '请选择退款时赠送的优惠券';
  2154. echo json_encode($result);
  2155. die();
  2156. }
  2157. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2158. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2159. $spike_data = array();
  2160. $spike_data['goods_id'] = $goods_id;
  2161. $spike_data['state'] = 0;
  2162. $spike_data['is_open_lottery'] = 0;
  2163. $spike_data['voucher_id'] = $voucher_id;
  2164. $spike_data['win_quantity'] = $win_quantity;
  2165. $spike_data['is_auto_open'] = $is_auto_open;
  2166. $spike_data['real_win_quantity'] = $real_win_quantity;
  2167. $spike_data['quantity'] = $goods_info['quantity'];
  2168. $spike_data['begin_time'] = 0;
  2169. $spike_data['end_time'] = 0;
  2170. $spike_data['addtime'] = time();
  2171. $rs = M('lottery_goods')->add($spike_data);
  2172. if($rs) {
  2173. M('goods')->where( array('goods_id' => $goods_id) )->save( array('lock_type' =>'lottery') );
  2174. }
  2175. $result['code'] = 1;
  2176. echo json_encode($result);
  2177. die();
  2178. die();
  2179. } else {
  2180. $result['msg'] = '已存在其他活动中';
  2181. echo json_encode($result);
  2182. die();
  2183. }
  2184. }
  2185. public function putongsubject_form()
  2186. {
  2187. $result = array('code' => 0);
  2188. $goods_id = I('post.goods_id',0);
  2189. if($goods_id == 0){
  2190. $result['msg'] = '商品不存在';
  2191. echo json_encode($result);
  2192. die();
  2193. }
  2194. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2195. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2196. $subject = M('subject')->where('can_shenqing=1 and type="normal"')->select();
  2197. $this->subject = $subject;
  2198. $this->goods_id = $goods_id;
  2199. $content = $this->fetch('Goods:goods_putongsubject_fetch');
  2200. $result['code'] = 1;
  2201. $result['html'] = $content;
  2202. echo json_encode($result);
  2203. die();
  2204. } else {
  2205. $result['msg'] = '已存在其他活动中';
  2206. echo json_encode($result);
  2207. die();
  2208. }
  2209. }
  2210. public function haitaosubject_form()
  2211. {
  2212. $result = array('code' => 0);
  2213. $goods_id = I('post.goods_id',0);
  2214. if($goods_id == 0){
  2215. $result['msg'] = '商品不存在';
  2216. echo json_encode($result);
  2217. die();
  2218. }
  2219. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2220. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2221. $subject = M('subject')->where('can_shenqing=1 and type="haitao"')->select();
  2222. $this->subject = $subject;
  2223. $this->goods_id = $goods_id;
  2224. $content = $this->fetch('Goods:goods_haitaosubject_fetch');
  2225. $result['code'] = 1;
  2226. $result['html'] = $content;
  2227. echo json_encode($result);
  2228. die();
  2229. } else {
  2230. $result['msg'] = '已存在其他活动中';
  2231. echo json_encode($result);
  2232. die();
  2233. }
  2234. }
  2235. public function mianfeishiyong_form()
  2236. {
  2237. $result = array('code' => 0);
  2238. $goods_id = I('post.goods_id',0);
  2239. if($goods_id == 0){
  2240. $result['msg'] = '商品不存在';
  2241. echo json_encode($result);
  2242. die();
  2243. }
  2244. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2245. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2246. $subject = M('subject')->where('can_shenqing=1 and type="zeyuan"')->select();
  2247. $this->subject = $subject;
  2248. $this->goods_id = $goods_id;
  2249. $content = $this->fetch('Goods:goods_mianfeishiyong_fetch');
  2250. $result['code'] = 1;
  2251. $result['html'] = $content;
  2252. echo json_encode($result);
  2253. die();
  2254. } else {
  2255. $result['msg'] = '已存在其他活动中';
  2256. echo json_encode($result);
  2257. die();
  2258. }
  2259. }
  2260. public function chaozhidapai_form()
  2261. {
  2262. $result = array('code' => 0);
  2263. $goods_id = I('post.goods_id',0);
  2264. if($goods_id == 0){
  2265. $result['msg'] = '商品不存在';
  2266. echo json_encode($result);
  2267. die();
  2268. }
  2269. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2270. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2271. $super_spike_list = M('super_spike')->where('begin_time>'.time())->select();
  2272. $this->super_spike_list = $super_spike_list;
  2273. $this->goods_id = $goods_id;
  2274. $content = $this->fetch('Goods:goods_chaozhidapai_fetch');
  2275. $result['code'] = 1;
  2276. $result['html'] = $content;
  2277. echo json_encode($result);
  2278. die();
  2279. } else {
  2280. $result['msg'] = '已存在其他活动中';
  2281. echo json_encode($result);
  2282. die();
  2283. }
  2284. }
  2285. public function spike_form()
  2286. {
  2287. $result = array('code' => 0);
  2288. $goods_id = I('post.goods_id',0);
  2289. if($goods_id == 0){
  2290. $result['msg'] = '商品不存在';
  2291. echo json_encode($result);
  2292. die();
  2293. }
  2294. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  2295. if($goods_info['type'] == 'normal' && !empty($goods_info)) {
  2296. $spike_list = M('spike')->where()->select();
  2297. //$spike_list = M('spike')->where('begin_time>'.time())->select();
  2298. $this->spike_list = $spike_list;
  2299. $this->goods_id = $goods_id;
  2300. $content = $this->fetch('Goods:goods_spike_fetch');
  2301. $result['code'] = 1;
  2302. $result['html'] = $content;
  2303. echo json_encode($result);
  2304. die();
  2305. } else {
  2306. $result['msg'] = '已存在其他活动中';
  2307. echo json_encode($result);
  2308. die();
  2309. }
  2310. }
  2311. public function get_json_category_tree($pid,$is_ajax=0)
  2312. {
  2313. // {pid:pid,is_ajax:1}
  2314. $pid = empty($_GET['pid']) ? 0: intval($_GET['pid']);
  2315. $is_ajax = empty($_GET['is_ajax']) ? 0:intval($_GET['is_ajax']);
  2316. $goods_cate_model = D('Seller/GoodsCategory');
  2317. //$list = $goods_cate_model->get_parent_cateory($pid,SELLERUID);
  2318. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid) )->order('sort_order asc')->select();
  2319. if($pid > 0)
  2320. {
  2321. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid) )->order('sort_order asc')->select();
  2322. }
  2323. $result = array();
  2324. if($is_ajax ==0)
  2325. {
  2326. return $list;
  2327. } else {
  2328. if(empty($list)){
  2329. $result['code'] = 0;
  2330. } else {
  2331. $result['code'] = 1;
  2332. $result['list'] = $list;
  2333. }
  2334. echo json_encode($result);
  2335. die();
  2336. }
  2337. }
  2338. function add(){
  2339. $model=new GoodsModel();
  2340. if(IS_POST){
  2341. $data=I('post.');
  2342. $data['goods_description']['tag'] = str_replace(',', ',', $data['goods_description']['tag']);
  2343. $data['store_id']=SELLERUID;
  2344. if($this->goods_is_shenhe()) {
  2345. $data['status'] = 2;
  2346. }
  2347. $return=$model->add_goods($data);
  2348. $this->osc_alert($return);
  2349. }
  2350. $m=new \Admin\Model\OptionModel();
  2351. //getOptions
  2352. $options_list = $m->getOptions('',SELLERUID);
  2353. $this->options_list = $options_list;
  2354. $pick_list = M('pick_up')->where( array('store_id' => SELLERUID) )->select();
  2355. $this->pick_list = $pick_list;
  2356. $member_model= D('Admin/Member');
  2357. $level_list = $member_model->show_member_level();
  2358. $member_default_levelname_info = D('Home/Front')->get_config_by_name('member_default_levelname');
  2359. $member_defualt_discount_info = D('Home/Front')->get_config_by_name('member_defualt_discount');
  2360. $default = array('id'=>'default', 'level' => 0,'levelname' => $member_default_levelname_info,'discount' => $member_defualt_discount_info);
  2361. array_unshift($level_list['list'], $default );
  2362. $need_level_list = $level_list['list'];
  2363. $set = D('Seller/Config')->get_all_config();
  2364. $this->set = $set;
  2365. /***
  2366. 是否开启 分享等级佣金 begin
  2367. **/
  2368. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  2369. if( empty($index_sort_method) || $index_sort_method == 0 )
  2370. {
  2371. $index_sort_method = 0;
  2372. }
  2373. $this->index_sort_method = $index_sort_method;
  2374. $show_fissionsharing_level = 1;
  2375. $is_open_sharing = D('Home/Front')->get_config_by_name('is_open_fissionsharing');
  2376. $show_fissionsharing_level = D('Home/Front')->get_config_by_name('show_fissionsharing_level');
  2377. $this->show_fissionsharing_level = $show_fissionsharing_level;
  2378. $this->is_open_sharing = $is_open_sharing;
  2379. /***
  2380. 是否开启 分享等级佣金 end
  2381. **/
  2382. $this->member_level_is_open_info = D('Home/Front')->get_config_by_name('member_level_is_open');
  2383. $this->need_level_list = $need_level_list;
  2384. $this->cate_data = $this->get_json_category_tree(0);
  2385. $this->action=U('Goods/add');
  2386. $this->crumbs='新增';
  2387. $this->display('edit');
  2388. }
  2389. /**
  2390. 商品是否需要审核
  2391. **/
  2392. function goods_is_shenhe()
  2393. {
  2394. $shenhegoods = M('config')->where( array('name' => 'shenhegoods') )->find();
  2395. $is_need_shen = 0;
  2396. if(!empty($shenhegoods)) {
  2397. $is_need_shen = $shenhegoods['value'];
  2398. }
  2399. return $is_need_shen;
  2400. }
  2401. public function change()
  2402. {
  2403. $id = I('request.id',0);
  2404. //ids
  2405. if (empty($id)) {
  2406. $ids = I('request.ids');
  2407. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  2408. }
  2409. if (empty($id)) {
  2410. show_json(0, array('message' => '参数错误'));
  2411. }
  2412. $type = I('request.type');
  2413. $value = I('request.value');
  2414. //type/grounding/
  2415. $is_can_do = D('Seller/Supply')->checksupply_pri( $type );
  2416. if( !$is_can_do )
  2417. {
  2418. show_json(0, array('message' => '无此操作权限','url' => $_SERVER['HTTP_REFERER'] ));
  2419. }
  2420. if (!(in_array($type, array('goodsname', 'price','index_sort','is_index_show', 'total','grounding', 'goodssn', 'productsn', 'displayorder')))) {
  2421. show_json(0, array('message' => '参数错误'));
  2422. }
  2423. $items = M('lionfish_comshop_goods')->field('id')->where( array('id' => array('in', $id)) )->select();
  2424. foreach ($items as $item ) {
  2425. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->save( array($type => $value) );
  2426. if($type == 'total')
  2427. {
  2428. D('Seller/Redisorder')->sysnc_goods_total($item['id']);
  2429. }
  2430. }
  2431. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  2432. }
  2433. public function delete()
  2434. {
  2435. $id = I('get.id');
  2436. //ids
  2437. if (empty($id)) {
  2438. $ids = I('post.ids');
  2439. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  2440. }
  2441. if (empty($id)) {
  2442. show_json(0, array('message' => '参数错误'));
  2443. }
  2444. $items = M('lionfish_comshop_goods')->field('id,goodsname')->where( array('id' => array('in', $id)) )->select();
  2445. foreach ($items as $item ) {
  2446. //pdo_update('lionfish_comshop_goods', array($type => $value), array('id' => $item['id'])); //ims_lionfish_comshop_goods
  2447. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->delete();
  2448. M('lionfish_comshop_goods_images')->where( array('goods_id' => $item['id']) )->delete();
  2449. M('lionfish_comshop_goods_option')->where( array('goods_id' => $item['id']) )->delete();
  2450. M('lionfish_comshop_goods_option_item')->where( array('goods_id' => $item['id']) )->delete();
  2451. M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $item['id']) )->delete();
  2452. M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $item['id']) )->delete();
  2453. M('lionfish_comshop_good_common')->where( array('goods_id' => $item['id']) )->delete();
  2454. }
  2455. sellerLog('删除了['.$items['goodsname'].']商品', 3);
  2456. show_json(1);
  2457. }
  2458. function edit(){
  2459. $id = I('get.id');
  2460. if (IS_POST) {
  2461. $_GPC = I('post.');
  2462. if( !isset($_GPC['thumbs']) || empty($_GPC['thumbs']) )
  2463. {
  2464. show_json(0, array('message' => '商品图片必须上传' ,'url' => $_SERVER['HTTP_REFERER']) );
  2465. die();
  2466. }
  2467. D('Seller/Goods')->modify_goods();
  2468. $http_refer = S('HTTP_REFERER');
  2469. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  2470. $goods = M('lionfish_comshop_goods')->where('id = "'.I('get.id').'"')->field('goodsname')->find();
  2471. sellerLog('编辑了['.$goods['goodsname'].']商品', 3);
  2472. show_json(1, array('message'=>'修改商品成功!','url' => $http_refer ));
  2473. }
  2474. //sss
  2475. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  2476. $this->id = $id;
  2477. $item = D('Seller/Goods')->get_edit_goods_info($id);
  2478. //-------------------------以上是获取资料
  2479. $limit_goods = array();
  2480. //limit_goods_list
  2481. if( !empty($item['relative_goods_list']) )
  2482. {
  2483. $item['relative_goods_list'] = unserialize($item['relative_goods_list']);
  2484. if( !empty($item['relative_goods_list']) )
  2485. {
  2486. $relative_goods_list_str = implode(',', $item['relative_goods_list']);
  2487. $limit_goods = M()->query("SELECT id as gid,goodsname,subtitle FROM " . C('DB_PREFIX') .
  2488. 'lionfish_comshop_goods WHERE id in('.$relative_goods_list_str.') order by id desc' );
  2489. foreach($limit_goods as $kk => $vv)
  2490. {
  2491. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $vv['gid'] ) )->order('id asc')->find();
  2492. $vv['image'] = tomedia($thumb['image']);
  2493. $limit_goods[$kk] = $vv;
  2494. }
  2495. }
  2496. }
  2497. $this->limit_goods = $limit_goods;
  2498. $category = D('Seller/GoodsCategory')->getFullCategory(true, true);
  2499. $this->category = $category;
  2500. $spec_list = D('Seller/Spec')->get_all_spec();
  2501. $this->spec_list = $spec_list;
  2502. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1, 'isdefault' => 1) )->order('sort_order desc')->select();
  2503. $this->dispatch_data = $dispatch_data;
  2504. $set = D('Seller/Config')->get_all_config();
  2505. $this->set = $set;
  2506. $commission_level = array();
  2507. $config_data = $set;
  2508. $this->config_data = $config_data;
  2509. $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']);
  2510. //$others = pdo_fetchall('SELECT * FROM ' . tablename('lionfish_comshop_commission_level') . ' WHERE uniacid = \'' . $_W['uniacid'] . '\' ORDER BY commission1 asc');
  2511. //$commission_level = array_merge(array($default), $others);
  2512. $commission_level = array();
  2513. //$level['key']
  2514. foreach($commission_level as $key => $val)
  2515. {
  2516. $val['key'] = $val['id'];
  2517. $commission_level[$key] = $val;
  2518. }
  2519. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  2520. $this->shopset_level = $shopset_level;
  2521. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  2522. $this->open_buy_send_score = $open_buy_send_score;
  2523. $delivery_type_express = $config_data['delivery_type_express'];
  2524. if( empty($delivery_type_express) )
  2525. {
  2526. $delivery_type_express = 2;
  2527. }
  2528. $this->delivery_type_express = $delivery_type_express;
  2529. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  2530. $this->is_open_fullreduction = $is_open_fullreduction;
  2531. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  2532. $head_commission_levelname = $config_data['head_commission_levelname'];
  2533. $default_comunity_money = $config_data['default_comunity_money'];
  2534. $list_default = array(
  2535. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  2536. );
  2537. $community_head_level = array_merge($list_default, $community_head_level);
  2538. $community_head_commission_info = D('Seller/Communityhead')->get_goods_head_level_bili( $id );
  2539. $mb_level = M('lionfish_comshop_member_level')->count();
  2540. $this->mb_level = $mb_level;
  2541. if( !empty($community_head_commission_info) )
  2542. {
  2543. foreach( $community_head_commission_info as $kk => $vv)
  2544. {
  2545. $item[$kk] = $vv;
  2546. }
  2547. }
  2548. $this->community_head_commission_info = $community_head_commission_info;
  2549. $this->item = $item;
  2550. $this->community_head_level = $community_head_level;
  2551. //end
  2552. $community_money_type = $config_data['community_money_type'];
  2553. $this->community_money_type = $community_money_type;
  2554. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  2555. if( empty($index_sort_method) || $index_sort_method == 0 )
  2556. {
  2557. $index_sort_method = 0;
  2558. }
  2559. $this->index_sort_method = $index_sort_method;
  2560. $is_open_only_express = $config_data['is_open_only_express'];
  2561. $this->is_open_only_express = $is_open_only_express;
  2562. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  2563. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  2564. //供应商权限begin
  2565. $is_index = true;
  2566. $is_top = true;
  2567. $is_updown = true;
  2568. $is_fullreduce = true;
  2569. $is_vir_count = true;
  2570. $is_newbuy = true;
  2571. $is_goodsspike = true;
  2572. $supply_can_goods_sendscore = true;
  2573. $sales_supply_id = 0;
  2574. if (defined('ROLE') && ROLE == 'agenter' )
  2575. {
  2576. $supply_can_goods_sendscore = empty($config_data['supply_can_goods_sendscore']) ? 0: $config_data['supply_can_goods_sendscore'];
  2577. $is_fullreduce = false;
  2578. if( isset($config_data['supply_can_goods_isindex']) && $config_data['supply_can_goods_isindex'] == 2 )
  2579. {
  2580. $is_index = false;
  2581. }
  2582. if( isset($config_data['supply_can_goods_istop']) && $config_data['supply_can_goods_istop'] == 2 )
  2583. {
  2584. $is_top = false;
  2585. }
  2586. if( isset($config_data['supply_can_goods_updown']) && $config_data['supply_can_goods_updown'] == 2 )
  2587. {
  2588. $is_updown = false;
  2589. }
  2590. if( isset($config_data['supply_can_vir_count']) && $config_data['supply_can_vir_count'] == 2 )
  2591. {
  2592. $is_vir_count = false;
  2593. }
  2594. if( isset($config_data['supply_can_goods_newbuy']) && $config_data['supply_can_goods_newbuy'] == 2 )
  2595. {
  2596. $is_newbuy = false;
  2597. }
  2598. if( isset($config_data['supply_can_goods_spike']) && $config_data['supply_can_goods_spike'] == 2 )
  2599. {
  2600. $is_goodsspike = false;
  2601. }
  2602. }
  2603. $is_open_vipcard_buy = $config_data['is_open_vipcard_buy'];
  2604. $seckill_is_open = $config_data['seckill_is_open'];
  2605. $is_head_takegoods = isset($config_data['is_head_takegoods']) && $config_data['is_head_takegoods'] == 1 ? 1 : 0;
  2606. $salesroom_count = 0;
  2607. $this->salesroom_count = $salesroom_count;
  2608. //供应商权限end
  2609. $this->supply_can_goods_sendscore = $supply_can_goods_sendscore;
  2610. $this->is_index = $is_index;
  2611. $this->is_top = $is_top;
  2612. $this->is_updown = $is_updown;
  2613. $this->is_fullreduce = $is_fullreduce;
  2614. $this->is_vir_count = $is_vir_count;
  2615. $this->is_newbuy = $is_newbuy;
  2616. $this->is_goodsspike = $is_goodsspike;
  2617. $this->is_open_vipcard_buy = $is_open_vipcard_buy;
  2618. $this->seckill_is_open = $seckill_is_open;
  2619. $this->is_head_takegoods = $is_head_takegoods;
  2620. $this->member_level_is_open_info = D('Home/Front')->get_config_by_name('member_level_is_open');
  2621. //$is_default_levellimit_buy = isset($config_data['is_default_levellimit_buy']) && $config_data['is_default_levellimit_buy'] == 1 ? 1 : 0;
  2622. //$this->is_default_levellimit_buy = $is_default_levellimit_buy;
  2623. //$is_default_vipmember_buy = isset($config_data['is_default_vipmember_buy']) && $config_data['is_default_vipmember_buy'] == 1 ? 1 : 0;
  2624. //$this->is_default_vipmember_buy = $is_default_vipmember_buy;
  2625. $this->display('Goods/addgoods');
  2626. }
  2627. public function labelfile()
  2628. {
  2629. $_GPC = I('request.');
  2630. $id = intval($_GPC['id']);
  2631. if (empty($id)) {
  2632. show_json(0, array() );
  2633. die();
  2634. }
  2635. $condition = ' id = '.$id.' and state = 1 ';
  2636. $labels = M('lionfish_comshop_goods_tags')->field('id,tagname,type,tagcontent')->where($condition)->find();
  2637. if (empty($labels)) {
  2638. $labels = array();
  2639. show_json(0, array('msg' => '您查找的标签不存在或已删除!') );
  2640. die();
  2641. }
  2642. show_json(1, array('label' => $labels['tagname'], 'id' => $labels['id']));
  2643. }
  2644. public function goodstag()
  2645. {
  2646. $_GPC = I('request.');
  2647. $this->gpc = $_GPC;
  2648. $condition = ' 1 and tag_type="normal" ';
  2649. $pindex = max(1, intval($_GPC['page']));
  2650. $psize = 20;
  2651. if ($_GPC['enabled'] != '') {
  2652. $condition .= ' and state=' . intval($_GPC['enabled']);
  2653. }
  2654. if (!empty($_GPC['keyword'])) {
  2655. $_GPC['keyword'] = trim($_GPC['keyword']);
  2656. $condition .= ' and tagname like "%'.$_GPC['keyword'].'%" ';
  2657. }
  2658. $label = M('lionfish_comshop_goods_tags')->where( $condition )->order(' id asc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  2659. $total = M('lionfish_comshop_goods_tags')->where( $condition )->count();
  2660. $pager = pagination2($total, $pindex, $psize);
  2661. $this->label = $label;
  2662. $this->pager = $pager;
  2663. $this->display();
  2664. }
  2665. function copy_goods(){
  2666. $id =I('id');
  2667. $model=new GoodsModel();
  2668. if($id){
  2669. foreach ($id as $k => $v) {
  2670. $model->copy_goods($v);
  2671. }
  2672. $data['redirect']=U('Goods/index');
  2673. $this->ajaxReturn($data);
  2674. die;
  2675. }
  2676. }
  2677. function del(){
  2678. $model=new GoodsModel();
  2679. $return=$model->del_goods(I('get.id'));
  2680. $this->osc_alert($return);
  2681. }
  2682. /**
  2683. * 置顶
  2684. * @return [json] 0 失败 1 成功
  2685. */
  2686. public function settop()
  2687. {
  2688. $id = I('request.id');
  2689. //ids
  2690. if (empty($id)) {
  2691. $ids = I('request.ids');
  2692. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  2693. }
  2694. if (empty($id)) {
  2695. show_json(0, array('message' => '参数错误'));
  2696. }
  2697. $type = I('request.type');
  2698. $value = I('request.value');
  2699. if ($type != 'istop') {
  2700. show_json(0, array('message' => '参数错误'));
  2701. }
  2702. $items = M('lionfish_comshop_goods')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  2703. foreach ($items as $item ) {
  2704. $settoptime = $value ? time() : '';
  2705. M('lionfish_comshop_goods')->where( array('id' => $item['id']) )->save( array($type => $value, 'settoptime' => $settoptime) );
  2706. }
  2707. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  2708. }
  2709. public function industrial()
  2710. {
  2711. $_GPC = I('request.');
  2712. if ( IS_POST ) {
  2713. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  2714. $data['goods_industrial'] = serialize($data['goods_industrial']);
  2715. D('Seller/Config')->update($data);
  2716. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  2717. }
  2718. $data = D('Seller/Config')->get_all_config();
  2719. $data['goods_industrial'] = unserialize($data['goods_industrial']);
  2720. $piclist = array();
  2721. if( !empty($data['goods_industrial']) )
  2722. {
  2723. foreach($data['goods_industrial'] as $val)
  2724. {
  2725. $piclist[] = array('image' =>$val, 'thumb' => tomedia($val) ); //$val['image'];
  2726. }
  2727. }
  2728. $this->piclist = $piclist;
  2729. $this->data = $data;
  2730. $this->display();
  2731. }
  2732. /**
  2733. * excel商品导入编辑
  2734. * @author liu 2020-03-03
  2735. * */
  2736. public function excel_goodslist_edit()
  2737. {
  2738. $columns = array(
  2739. array(
  2740. 'title' => '商品ID(禁止修改)',
  2741. 'field' => 'id',
  2742. 'width' => 24
  2743. ) ,
  2744. array(
  2745. 'title' => '商品名称',
  2746. 'field' => 'goodsname',
  2747. 'width' => 24
  2748. ) ,
  2749. array(
  2750. 'title' => '一级分类ID',
  2751. 'field' => 'cate1_id',
  2752. 'width' => 24
  2753. ) ,
  2754. array(
  2755. 'title' => '一级分类名称',
  2756. 'field' => 'cate1_name',
  2757. 'width' => 24
  2758. ) ,
  2759. array(
  2760. 'title' => '二级分类ID',
  2761. 'field' => 'cate2_id',
  2762. 'width' => 24
  2763. ) ,
  2764. array(
  2765. 'title' => '二级分类名称',
  2766. 'field' => 'cate2_name',
  2767. 'width' => 24
  2768. ) ,
  2769. array(
  2770. 'title' => '商品价格',
  2771. 'field' => 'price',
  2772. 'width' => 24
  2773. ) ,
  2774. array(
  2775. 'title' => '商品成本价',
  2776. 'field' => 'costprice',
  2777. 'width' => 24
  2778. ) ,
  2779. array(
  2780. 'title' => '会员卡价格',
  2781. 'field' => 'card_price',
  2782. 'width' => 24
  2783. ) ,
  2784. array(
  2785. 'title' => '商品原价',
  2786. 'field' => 'productprice',
  2787. 'width' => 24
  2788. ) ,
  2789. array(
  2790. 'title' => '商品库存',
  2791. 'field' => 'total',
  2792. 'width' => 24
  2793. ) ,
  2794. array(
  2795. 'title' => '1上架/0下架',
  2796. 'field' => 'grounding',
  2797. 'width' => 24
  2798. ) ,
  2799. array(
  2800. 'title' => '首页推荐(0:取消/1:是)',
  2801. 'field' => 'is_index_show',
  2802. 'width' => 24
  2803. ) ,
  2804. array(
  2805. 'title' => '限时秒杀(0:取消/1:是)',
  2806. 'field' => 'is_spike_buy',
  2807. 'width' => 24
  2808. ) ,
  2809. array(
  2810. 'title' => '所有团长',
  2811. 'field' => 'is_all_sale_str',
  2812. 'width' => 24
  2813. ) ,
  2814. array(
  2815. 'title' => '新人专享',
  2816. 'field' => 'is_new_buy',
  2817. 'width' => 24
  2818. ) ,
  2819. array(
  2820. 'title' => '商品排序(数字)',
  2821. 'field' => 'index_sort',
  2822. 'width' => 24
  2823. ) ,
  2824. array(
  2825. 'title' => '单次限购',
  2826. 'field' => 'one_limit_count',
  2827. 'width' => 24
  2828. ) ,
  2829. array(
  2830. 'title' => '历史限购',
  2831. 'field' => 'total_limit_count',
  2832. 'width' => 24
  2833. ) ,
  2834. array(
  2835. 'title' => '开始时间',
  2836. 'field' => 'pin_begin_time',
  2837. 'width' => 24
  2838. ) ,
  2839. array(
  2840. 'title' => '结束时间',
  2841. 'field' => 'pin_end_time',
  2842. 'width' => 24
  2843. ) ,
  2844. array(
  2845. 'title' => '商品重量(单位:g)',
  2846. 'field' => 'weight',
  2847. 'width' => 24
  2848. ) ,
  2849. array(
  2850. 'title' => '规格(1:开启/0:关闭)',
  2851. 'field' => 'hasoption',
  2852. 'width' => 24
  2853. ) ,
  2854. array(
  2855. 'title' => '规格id(禁止修改)',
  2856. 'field' => 'option_id',
  2857. 'width' => 24
  2858. ) ,
  2859. array(
  2860. 'title' => '规格名称(禁止修改)',
  2861. 'field' => 'option_title',
  2862. 'width' => 24
  2863. ) ,
  2864. array(
  2865. 'title' => '规格库存',
  2866. 'field' => 'option_stock',
  2867. 'width' => 24
  2868. ) ,
  2869. array(
  2870. 'title' => '规格现价',
  2871. 'field' => 'option_marketprice',
  2872. 'width' => 24
  2873. ) ,
  2874. array(
  2875. 'title' => '规格原价',
  2876. 'field' => 'option_productprice',
  2877. 'width' => 24
  2878. ) ,
  2879. array(
  2880. 'title' => '规格会员价',
  2881. 'field' => 'option_card_price',
  2882. 'width' => 24
  2883. ) ,
  2884. array(
  2885. 'title' => '规格成本价',
  2886. 'field' => 'option_costprice',
  2887. 'width' => 24
  2888. ) ,
  2889. array(
  2890. 'title' => '规格编码',
  2891. 'field' => 'option_goodssn',
  2892. 'width' => 24
  2893. ) ,
  2894. array(
  2895. 'title' => '规格重量(单位:g)',
  2896. 'field' => 'option_weight',
  2897. 'width' => 24
  2898. )
  2899. );
  2900. sellerLog('导入商品excel编辑', 3);
  2901. $rows = D('Seller/Excel')->import('excel');
  2902. $row_count = count($rows);
  2903. $field_arr = [];
  2904. if($row_count <= 1){
  2905. $this->error('失败','goods/index');
  2906. die;
  2907. }
  2908. foreach($rows[0] as $key => $value) {
  2909. foreach($columns as $k => $val) {
  2910. if($val['title'] == $value){
  2911. $field_arr[$key]= $val['field'];
  2912. }
  2913. }
  2914. }
  2915. unset($rows[0]);
  2916. foreach($rows as $key => $value){
  2917. $this->excelGoodsUpdate($value, $field_arr);
  2918. }
  2919. $this->success('成功','goods/index');
  2920. }
  2921. public function excelGoodsUpdate($data, $field_arr)
  2922. {
  2923. $optionId = 0;
  2924. $goodsId = 0;
  2925. $goodsData = [];
  2926. $optionData = [];
  2927. foreach($data as $key => $value){
  2928. $field = $field_arr[$key];
  2929. if(strstr($field, 'option_') > -1 && $value){// 规格
  2930. if($field == 'option_id'){// 规格id
  2931. $optionId = $value;
  2932. $goodsData = [];
  2933. }
  2934. $optionData[str_replace('option_','',$field)] = $value;
  2935. $goodsId = 0;
  2936. }else{ // 普通商品数据
  2937. if(strstr($field, 'option_') > -1 ) {// 规格
  2938. continue;
  2939. }
  2940. if($field == 'id'){// 规格id
  2941. $goodsId = $value;
  2942. $optionData = [];
  2943. }
  2944. $optionId = 0;
  2945. $goodsData[$field] = $value;
  2946. }
  2947. }
  2948. if($optionId > 0 && count($optionData) > 0){
  2949. unset($optionData['title']);
  2950. unset($optionData['id']);
  2951. M('lionfish_comshop_goods_option_item_value')->where('id = "'.$optionId.'"')->save($optionData);
  2952. unset($optionData);
  2953. }else if($goodsId > 0 && count($goodsData) > 0){
  2954. unset($goodsData['is_all_sale_str']);
  2955. unset($goodsData['cate1_id']);
  2956. unset($goodsData['cate1_name']);
  2957. unset($goodsData['cate2_id']);
  2958. unset($goodsData['cate2_name']);
  2959. unset($goodsData['id']);
  2960. $goodsCommon = M('lionfish_comshop_good_common')->where('goods_id = "'.$goodsId.'"')->field('id')->find();
  2961. if($goodsCommon['id']){
  2962. M('lionfish_comshop_good_common')
  2963. ->where('id = "'.$goodsCommon['id'].'"')
  2964. ->save([
  2965. 'one_limit_count' => $goodsData['one_limit_count'],
  2966. 'total_limit_count' => $goodsData['total_limit_count'],
  2967. 'is_spike_buy' => $goodsData['is_spike_buy'],
  2968. 'is_new_buy' => $goodsData['is_new_buy'],
  2969. ]);
  2970. unset($goodsData['one_limit_count']);
  2971. unset($goodsData['total_limit_count']);
  2972. unset($goodsData['is_spike_buy']);
  2973. unset($goodsData['is_new_buy']);
  2974. }
  2975. $goodsPin = M('lionfish_comshop_good_pin')->where('goods_id = "'.$goodsId.'"')->field('id')->find();
  2976. if($goodsPin['id']){
  2977. M('lionfish_comshop_good_pin')
  2978. ->where('id = "'.$goodsPin['id'].'"')
  2979. ->save([
  2980. 'begin_time' => $goodsData['begin_time'],
  2981. 'end_time' => $goodsData['end_time'],
  2982. ]);
  2983. unset($goodsData['begin_time']);
  2984. unset($goodsData['end_time']);
  2985. }
  2986. M('lionfish_comshop_goods')
  2987. ->where('id = "'.$goodsId.'"')
  2988. ->save($goodsData);
  2989. unset($goodsData);
  2990. }
  2991. }
  2992. }
  2993. ?>