记得上下班打卡 | git大法好,push需谨慎

Commit 2822d4ba authored by wangyifan's avatar wangyifan

admin 增加商城新banner功能

parent a97e929b
...@@ -87,8 +87,9 @@ public class GoblinRedisConst { ...@@ -87,8 +87,9 @@ public class GoblinRedisConst {
public static final String STORE_NOTICE = PREFIX.concat("store_ntc:"); public static final String STORE_NOTICE = PREFIX.concat("store_ntc:");
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
public static final String FRONT_TOP_BANNER = PREFIX.concat("front_top_banner"); //前端顶部banner public static final String FRONT_TOP_BANNER = PREFIX.concat("front_top_banner"); //前端顶部banner(旧版 bannerType=1)
public static final String FRONT_MIDDLE_BANNER = PREFIX.concat("front_middle_banner"); //前端中部banner public static final String FRONT_MIDDLE_BANNER = PREFIX.concat("front_middle_banner"); //前端中部banner(bannerType=2)
public static final String FRONT_NEW_TOP_BANNER = PREFIX.concat("front_new_top_banner"); //前端新版顶部banner(bannerType=3)
public static final String FRONT_NAVIGATION = PREFIX.concat("front_navigation"); //前端banner public static final String FRONT_NAVIGATION = PREFIX.concat("front_navigation"); //前端banner
public static final String FRONT_HOTWORD = PREFIX.concat("front_hot_word"); //前端banner public static final String FRONT_HOTWORD = PREFIX.concat("front_hot_word"); //前端banner
public static final String FRONT_HOTWORD_INDEX = PREFIX.concat("front_hot_word_index"); //前端banner index public static final String FRONT_HOTWORD_INDEX = PREFIX.concat("front_hot_word_index"); //前端banner index
......
...@@ -134,6 +134,8 @@ public class GoblinFrontBannerController extends BaseController { ...@@ -134,6 +134,8 @@ public class GoblinFrontBannerController extends BaseController {
logger.info("bannerResult,{}",bannerResult); logger.info("bannerResult,{}",bannerResult);
boolean bannerMiddle=goblinFrontBannerService.middle(); boolean bannerMiddle=goblinFrontBannerService.middle();
logger.info("banner中部{}",bannerMiddle); logger.info("banner中部{}",bannerMiddle);
boolean bannerNewTop=goblinFrontBannerService.onlineNewTopBanner();
logger.info("banner新版顶部{}",bannerNewTop);
boolean hotWordResult=goblinFrontHotWordService.online(); boolean hotWordResult=goblinFrontHotWordService.online();
logger.info("热词,{}",hotWordResult); logger.info("热词,{}",hotWordResult);
boolean navigationResult=goblinFrontNavigationService.online(); boolean navigationResult=goblinFrontNavigationService.online();
...@@ -151,7 +153,7 @@ public class GoblinFrontBannerController extends BaseController { ...@@ -151,7 +153,7 @@ public class GoblinFrontBannerController extends BaseController {
logger.debug("新品推荐{}",recommendResult); logger.debug("新品推荐{}",recommendResult);
/* boolean hejiReult=goblinFrontCompilationsService.online(); /* boolean hejiReult=goblinFrontCompilationsService.online();
logger.info("合集{}",hejiReult);*/ logger.info("合集{}",hejiReult);*/
if (bannerResult&&hotWordResult&&navigationResult&bannerMiddle&&selectGoods&&moudleIndexResult&&cubeResult ) { if (bannerResult&&hotWordResult&&navigationResult&bannerMiddle&&selectGoods&&moudleIndexResult&&cubeResult&&bannerNewTop) {
return success("操作成功"); return success("操作成功");
} else { } else {
return error("操作失败"); return error("操作失败");
......
...@@ -233,6 +233,23 @@ ...@@ -233,6 +233,23 @@
} }
modalPx() modalPx()
}) })
function openTopBannerPicker() {
layer.open({
type: 1,
title: '选择顶部Banner类型',
area: ['320px', '180px'],
content: '<div style="padding:24px 20px;">' +
'<p style="margin-bottom:16px;color:#555;">请选择要编辑的顶部Banner版本:</p>' +
'<div style="display:flex;gap:12px;">' +
'<button class="btn btn-default" style="flex:1;height:48px;" onclick="layer.closeAll();$.modal.open(\'旧版顶部Banner\', prefix2+\'/topBanner?id=6\',900,560,cancel)">' +
'旧版 Banner</button>' +
'<button class="btn btn-primary" style="flex:1;height:48px;" onclick="layer.closeAll();$.modal.open(\'新版顶部Banner\', prefix2+\'/topBanner?id=3\',900,560,cancel)">' +
'新版 Banner</button>' +
'</div></div>',
btn: false
});
}
function goArea (num) { function goArea (num) {
switch(num) { switch(num) {
case 1: case 1:
...@@ -244,8 +261,7 @@ ...@@ -244,8 +261,7 @@
// $.modal.openTab('商品搜索', prefix2 + "/searchStore?id=" + 1212) // $.modal.openTab('商品搜索', prefix2 + "/searchStore?id=" + 1212)
break; break;
case 6: case 6:
$.modal.open('顶部banner', prefix2 + "/topBanner?id=" + num,900,560, cancel) openTopBannerPicker();
// $.modal.openTab('顶部banner', prefix2 + "/topBanner?id=" + num)
break; break;
case 2: case 2:
$.modal.open('活动banner', prefix2 + "/topBanner?id=" + num,900,560, cancel) $.modal.open('活动banner', prefix2 + "/topBanner?id=" + num,900,560, cancel)
......
...@@ -194,8 +194,13 @@ ...@@ -194,8 +194,13 @@
$("#tags").hide(); $("#tags").hide();
$("#activeTags").show(); $("#activeTags").show();
$("#showMiddleBanner").show(); $("#showMiddleBanner").show();
} else if (type == 3) {
type = 3;
$("#tags").show();
$("#activeTags").hide();
$("#tall").html('新版顶部BANNER(bannerType=3)');
} else { } else {
type = 1 type = 1;
$("#tags").show(); $("#tags").show();
$("#activeTags").hide(); $("#activeTags").hide();
} }
......
...@@ -209,7 +209,32 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM ...@@ -209,7 +209,32 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_MIDDLE_BANNER,list); redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_MIDDLE_BANNER,list);
} }
return true; return true;
}
public boolean onlineNewTopBanner(){
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
queryWrapper.ne(GoblinFrontBanner::getDelTag,1);
queryWrapper.eq(GoblinFrontBanner::getBannerType,3);
queryWrapper.orderByAsc(GoblinFrontBanner::getIndexs);
List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper);
if(list.size()>0){
//mongodb
for(GoblinFrontBanner goblinFrontBanner: list){
GoblinFrontBanner goblinFrontBanner1=mongoTemplate.findOne(Query.query(Criteria.where("bannerId").is(goblinFrontBanner.getBannerId())), GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
if(null==goblinFrontBanner1){
mongoTemplate.save(goblinFrontBanner,GoblinFrontBanner.class.getSimpleName());
}else{
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontBanner)));
mongoTemplate.getCollection(GoblinFrontBanner.class.getSimpleName()).updateOne(
Query.query(Criteria.where("bannerId").is(goblinFrontBanner.getBannerId())).getQueryObject(),
orderObject
);
}
}
}
//redis 无论有无数据都刷新(支持清空情况)
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NEW_TOP_BANNER,list);
return true;
} }
......
...@@ -51,6 +51,12 @@ public class GoblinFrontController { ...@@ -51,6 +51,12 @@ public class GoblinFrontController {
return ResponseDto.success(goblinFrontService.getMiddleBanner()); return ResponseDto.success(goblinFrontService.getMiddleBanner());
} }
@GetMapping("getNewTopBanner")
@ApiOperation("获取新版顶部banner(bannerType=3,新版App专用)")
public ResponseDto<ArrayList<GoblinFrontBannerVo>> getNewTopBanner() {
return ResponseDto.success(goblinFrontService.getNewTopBanner());
}
@GetMapping("getHotWord") @GetMapping("getHotWord")
@ApiOperation("获得热词") @ApiOperation("获得热词")
public ResponseDto<GoblinFrontHotWord> getHotWord() { public ResponseDto<GoblinFrontHotWord> getHotWord() {
......
...@@ -209,6 +209,35 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -209,6 +209,35 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return list1; return list1;
} }
public ArrayList<GoblinFrontBannerVo> getNewTopBanner() {
List<GoblinFrontBanner> list = goblinRedisUtils.getNewTopBanner();
if (null == list) {
return null;
}
LocalDateTime nowTime = LocalDateTime.now();
ArrayList<GoblinFrontBanner> goblinFrontBannerArrayList = ObjectUtil.getGoblinFrontBannerArrayList();
for (GoblinFrontBanner goblinFrontBanner : list) {
if (null != goblinFrontBanner.getEndTime()) {
if (nowTime.isAfter(goblinFrontBanner.getEndTime())) {
} else {
if (nowTime.isBefore(goblinFrontBanner.getStartTime())) {
} else {
goblinFrontBannerArrayList.add(goblinFrontBanner);
}
}
} else {
goblinFrontBannerArrayList.add(goblinFrontBanner);
}
}
ArrayList<GoblinFrontBannerVo> list1 = ObjectUtil.goblinFrontBannerVoArrayList();
for (GoblinFrontBanner goblinFrontBanner : goblinFrontBannerArrayList) {
GoblinFrontBannerVo goblinFrontBannerVo = GoblinFrontBannerVo.getNew();
BeanUtils.copyProperties(goblinFrontBanner, goblinFrontBannerVo);
list1.add(goblinFrontBannerVo);
}
return list1;
}
@Override @Override
public GoblinFrontHotWord getHotWord() { public GoblinFrontHotWord getHotWord() {
List<GoblinFrontHotWord> list = goblinRedisUtils.getHotWord(); List<GoblinFrontHotWord> list = goblinRedisUtils.getHotWord();
......
...@@ -1604,6 +1604,12 @@ public class GoblinMongoUtils { ...@@ -1604,6 +1604,12 @@ public class GoblinMongoUtils {
GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName()); GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
} }
public List<GoblinFrontBanner> getNewTopBanner() {
Query query = Query.query(Criteria.where("delTag").is(0).and("bannerType").is(3));
return mongoTemplate.find(query,
GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
}
public List<GoblinFrontHotWord> getHotWord() { public List<GoblinFrontHotWord> getHotWord() {
Query query = Query.query(Criteria.where("delTag").is(0)); Query query = Query.query(Criteria.where("delTag").is(0));
return mongoTemplate.find(query, return mongoTemplate.find(query,
......
...@@ -1834,6 +1834,15 @@ public class GoblinRedisUtils { ...@@ -1834,6 +1834,15 @@ public class GoblinRedisUtils {
return vo; return vo;
} }
public List<GoblinFrontBanner> getNewTopBanner() {
List<GoblinFrontBanner> vo = (List<GoblinFrontBanner>) redisUtil.get(GoblinRedisConst.FRONT_NEW_TOP_BANNER);
if (null == vo) {
//降级
return goblinMongoUtils.getNewTopBanner();
}
return vo;
}
// 热词降级 // 热词降级
public List<GoblinFrontHotWord> getHotWord() { public List<GoblinFrontHotWord> getHotWord() {
List<GoblinFrontHotWord> vo = (List<GoblinFrontHotWord>) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD); List<GoblinFrontHotWord> vo = (List<GoblinFrontHotWord>) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment