优化榜单排序及定时任务
This commit is contained in:
@@ -16,8 +16,8 @@ import javax.validation.constraints.Size;
|
|||||||
@Setter
|
@Setter
|
||||||
public class ProductReplyParam {
|
public class ProductReplyParam {
|
||||||
|
|
||||||
@NotBlank(message = "评论不能为空")
|
// @NotBlank(message = "评论不能为空")
|
||||||
@Size(min = 1, max = 200,message = "长度超过了限制")
|
@Size(min = 0, max = 200,message = "长度超过了限制")
|
||||||
@ApiModelProperty(value = "商品评论内容")
|
@ApiModelProperty(value = "商品评论内容")
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public interface ShopConstants {
|
|||||||
/**
|
/**
|
||||||
* 热门搜索
|
* 热门搜索
|
||||||
*/
|
*/
|
||||||
String ZSW_HOT_SEARCH = "zsw_hot_search";
|
String ZSW_HOT_SEARCH = "yshop_hot_search";
|
||||||
/**
|
/**
|
||||||
* 个人中心菜单
|
* 个人中心菜单
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ public interface YxStoreCouponUserMapper extends CoreMapper<YxStoreCouponUser> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime} AND tenant_id = 138")
|
@Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime}")
|
||||||
List<YxStoreCouponUser> selectUserCouponList(@Param("endTime") Date endTime);
|
List<YxStoreCouponUser> selectUserCouponList(@Param("endTime") Date endTime);
|
||||||
//"状态(0:未使用,1:已使用, 2:已过期)"
|
//"状态(0:未使用,1:已使用, 2:已过期)"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package co.yixiang.modules.category.rest;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
import cn.iocoder.yudao.framework.common.exception.YshopException;
|
||||||
import co.yixiang.constant.ShopConstants;
|
import co.yixiang.constant.ShopConstants;
|
||||||
|
import co.yixiang.exception.BadRequestException;
|
||||||
import co.yixiang.logging.aop.log.Log;
|
import co.yixiang.logging.aop.log.Log;
|
||||||
import co.yixiang.modules.aop.ForbidSubmit;
|
import co.yixiang.modules.aop.ForbidSubmit;
|
||||||
import co.yixiang.modules.category.domain.YxStoreCategory;
|
import co.yixiang.modules.category.domain.YxStoreCategory;
|
||||||
|
|||||||
+5
-3
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package co.yixiang.modules.hotList.service.impl;
|
package co.yixiang.modules.hotList.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||||
import co.yixiang.common.utils.QueryHelpPlus;
|
import co.yixiang.common.utils.QueryHelpPlus;
|
||||||
import co.yixiang.domain.PageResult;
|
import co.yixiang.domain.PageResult;
|
||||||
@@ -59,9 +61,9 @@ public class YxStoreHotListRecordServiceImpl extends BaseServiceImpl<YxStoreHotL
|
|||||||
PageInfo<YxStoreHotListRecord> page = new PageInfo<>(queryAll(criteria));
|
PageInfo<YxStoreHotListRecord> page = new PageInfo<>(queryAll(criteria));
|
||||||
PageResult<YxStoreHotListRecordDto> result=generator.convertPageInfo(page,YxStoreHotListRecordDto.class);
|
PageResult<YxStoreHotListRecordDto> result=generator.convertPageInfo(page,YxStoreHotListRecordDto.class);
|
||||||
result.getContent().forEach(i->{
|
result.getContent().forEach(i->{
|
||||||
i.setHotListName(yxStoreHotListMapper.selectById(i.getHotListId()).getListName());
|
i.setHotListName(ObjectUtil.isEmpty(yxStoreHotListMapper.selectById(i.getHotListId()))?"*原绑定榜单已被删除":yxStoreHotListMapper.selectById(i.getHotListId()).getListName());
|
||||||
i.setCateName(storeCategoryMapper.selectById(i.getCateId()).getCateName());
|
i.setCateName(ObjectUtil.isEmpty(storeCategoryMapper.selectById(i.getCateId()))?"*原商品分类已被删除":storeCategoryMapper.selectById(i.getCateId()).getCateName());
|
||||||
i.setProductName(yxStoreProductService.getById(i.getProductId()).getStoreName());
|
i.setProductName(ObjectUtil.isEmpty(yxStoreProductService.getById(i.getProductId()))?"*原绑定商品已被删除":yxStoreProductService.getById(i.getProductId()).getStoreName());
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-5
@@ -162,7 +162,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
|
|||||||
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
|
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
|
||||||
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
|
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
|
||||||
//获取所有评测列表(后期限制一年?)
|
//获取所有榜单记录列表(后期限制一年?)
|
||||||
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper);
|
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
return null;
|
return null;
|
||||||
@@ -182,8 +182,13 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
|
|||||||
hotIdList.add(cate.getHotListId());
|
hotIdList.add(cate.getHotListId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//批量查询榜单信息,并进行排序
|
||||||
|
LambdaQueryWrapper<YxStoreHotList> wrapperList=new LambdaQueryWrapper<>();
|
||||||
|
wrapperList.in(YxStoreHotList::getId,hotIdList).orderByAsc(YxStoreHotList::getSort);
|
||||||
|
ArrayList <Integer> list1=new ArrayList<>();
|
||||||
|
yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId()));
|
||||||
ArrayList<HotListDTO> hotListDTOS=new ArrayList<>();
|
ArrayList<HotListDTO> hotListDTOS=new ArrayList<>();
|
||||||
hotIdList.forEach(hotId->{
|
list1.forEach(hotId->{
|
||||||
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper);
|
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper);
|
||||||
//查出当前月份当前榜单的记录
|
//查出当前月份当前榜单的记录
|
||||||
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth));
|
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth));
|
||||||
@@ -254,7 +259,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
|
|||||||
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
|
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
|
||||||
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
|
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
|
||||||
//获取所有评测列表(后期限制一年?)
|
//获取所有榜单记录列表(后期限制一年?)
|
||||||
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper);
|
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
return null;
|
return null;
|
||||||
@@ -265,14 +270,19 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
|
|||||||
String mouth=Collections.max(mouthList);
|
String mouth=Collections.max(mouthList);
|
||||||
List<YxStoreHotListRecord> recordList=yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth,mouth));
|
List<YxStoreHotListRecord> recordList=yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth,mouth));
|
||||||
LinkedHashSet<Integer> hotIdList=new LinkedHashSet<>();
|
LinkedHashSet<Integer> hotIdList=new LinkedHashSet<>();
|
||||||
//获得不重复的榜单信息
|
//获得不重复的榜单id
|
||||||
recordList.forEach(cate->{
|
recordList.forEach(cate->{
|
||||||
if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){
|
if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){
|
||||||
hotIdList.add(cate.getHotListId());
|
hotIdList.add(cate.getHotListId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//批量查询榜单信息,并进行排序
|
||||||
|
LambdaQueryWrapper<YxStoreHotList> wrapperList=new LambdaQueryWrapper<>();
|
||||||
|
wrapperList.in(YxStoreHotList::getId,hotIdList).orderByAsc(YxStoreHotList::getSort);
|
||||||
|
ArrayList <Integer> list1=new ArrayList<>();
|
||||||
|
yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId()));
|
||||||
ArrayList<HotListDTO> hotListDTOS=new ArrayList<>();
|
ArrayList<HotListDTO> hotListDTOS=new ArrayList<>();
|
||||||
hotIdList.forEach(hotId->{
|
list1.forEach(hotId->{
|
||||||
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper);
|
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper);
|
||||||
//查出当前月份当前榜单的记录
|
//查出当前月份当前榜单的记录
|
||||||
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth));
|
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth));
|
||||||
|
|||||||
@@ -112,6 +112,32 @@ public class StoreProductController {
|
|||||||
return new ResponseEntity<>(queryAll,HttpStatus.OK);
|
return new ResponseEntity<>(queryAll,HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("查询所有商品分类及下面的商品")
|
||||||
|
@ApiOperation(value = "查询所有商品分类及下面的商品")
|
||||||
|
@GetMapping(value = "/yxStoreProductAndCart")
|
||||||
|
public ResponseEntity getYxStoreProductsAndCart(){
|
||||||
|
//商品分类
|
||||||
|
List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
|
||||||
|
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||||
|
.list();
|
||||||
|
List<Map<String,Object>> cateList = new ArrayList<>();
|
||||||
|
storeCategories.forEach(yxStoreCategory -> {
|
||||||
|
String html = "|-----";
|
||||||
|
String newHtml = "";
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
newHtml = String.join("", Collections.nCopies(1,html));
|
||||||
|
map.put("value",yxStoreCategory.getId());
|
||||||
|
map.put("label",newHtml + yxStoreCategory.getCateName());
|
||||||
|
List<YxStoreProduct> list=yxStoreProductService.lambdaQuery()
|
||||||
|
.eq(YxStoreProduct::getIsShow,ShopCommonEnum.SHOW_1.getValue())
|
||||||
|
.eq(YxStoreProduct::getCateId,yxStoreCategory.getId())
|
||||||
|
.list();
|
||||||
|
map.put("children",list);
|
||||||
|
cateList.add(map);
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(cateList,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@ForbidSubmit
|
@ForbidSubmit
|
||||||
@Log("新增/修改商品")
|
@Log("新增/修改商品")
|
||||||
@ApiOperation(value = "新增/修改商品")
|
@ApiOperation(value = "新增/修改商品")
|
||||||
|
|||||||
+13
-6
@@ -1,6 +1,8 @@
|
|||||||
package co.yixiang.modules.hotList.service.impl;
|
package co.yixiang.utils;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
|
import co.yixiang.annotation.AnonymousAccess;
|
||||||
import co.yixiang.enums.CommonEnum;
|
import co.yixiang.enums.CommonEnum;
|
||||||
import co.yixiang.enums.ShopCommonEnum;
|
import co.yixiang.enums.ShopCommonEnum;
|
||||||
import co.yixiang.event.TemplateBean;
|
import co.yixiang.event.TemplateBean;
|
||||||
@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -42,10 +45,11 @@ public class TaskMsg {
|
|||||||
|
|
||||||
//定时器,每天下午17点触发
|
//定时器,每天下午17点触发
|
||||||
@Scheduled(cron = "0 0 17 * * ?")
|
@Scheduled(cron = "0 0 17 * * ?")
|
||||||
// @Scheduled(cron = "0 50 17 * * ?")
|
// @Scheduled(cron = "0/8 * * * * ? ")
|
||||||
public void scheduled(){
|
public void scheduled(){
|
||||||
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
||||||
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
||||||
|
TenantContextHolder.setIgnore(true);
|
||||||
//查出所有用户拥有的券使用时间小于24小时且未使用的券
|
//查出所有用户拥有的券使用时间小于24小时且未使用的券
|
||||||
Date now=new Date();
|
Date now=new Date();
|
||||||
Date endTime = DateUtil.offsetDay(now,1);
|
Date endTime = DateUtil.offsetDay(now,1);
|
||||||
@@ -62,9 +66,10 @@ public class TaskMsg {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(fixedRate = 20000)
|
// @Scheduled(fixedRate = 20000)
|
||||||
public void execute() {
|
// public void execute() {
|
||||||
log.info("[execute][定时第 ({}) 次执行]", System.currentTimeMillis());
|
// log.info("[execute][定时第 ({}) 次执行]", System.currentTimeMillis());
|
||||||
|
// TenantContextHolder.setIgnore(true);
|
||||||
// Date now=new Date();
|
// Date now=new Date();
|
||||||
// Date endTime = DateUtil.offsetDay(now,1);
|
// Date endTime = DateUtil.offsetDay(now,1);
|
||||||
// List<YxStoreCouponUser> storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime);
|
// List<YxStoreCouponUser> storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime);
|
||||||
@@ -78,14 +83,16 @@ public class TaskMsg {
|
|||||||
// .build();
|
// .build();
|
||||||
// publisher.publishEvent(new TemplateEvent(this, templateBean));
|
// publisher.publishEvent(new TemplateEvent(this, templateBean));
|
||||||
// });
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//每个月最后一天23:30生成该月的榜单
|
//每个月最后一天23:30生成该月的榜单
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Scheduled(cron = "0 30 23 L * ?")
|
@Scheduled(cron = "0 30 23 L * ?")
|
||||||
public void setYxStoreHotListRecord(){
|
public void setYxStoreHotListRecord(){
|
||||||
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
||||||
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
log.info("=====>>>>>使用cron {}",System.currentTimeMillis());
|
||||||
|
TenantContextHolder.setIgnore(true);
|
||||||
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||||
.eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue())
|
.eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue())
|
||||||
Reference in New Issue
Block a user