Merge pull request !147 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-04-21 08:28:26 +00:00 committed by Gitee
commit 29ed211519
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
25 changed files with 237 additions and 105 deletions

View File

@ -3,7 +3,7 @@ package cn.lili.controller.other.broadcast;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Studio;
import cn.lili.modules.goods.entity.vos.StudioVO;
import cn.lili.modules.goods.service.StudioService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
@ -35,7 +35,7 @@ public class StudioController {
@ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query", dataType = "String")
})
@GetMapping
public ResultMessage<IPage<Studio>> page(PageVO pageVO, Integer recommend, String status) {
public ResultMessage<IPage<StudioVO>> page(PageVO pageVO, Integer recommend, String status) {
return ResultUtil.data(studioService.studioList(pageVO, recommend, status));
}

View File

@ -19,6 +19,7 @@ import cn.lili.modules.order.cart.entity.vo.CartVO;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.order.order.entity.dto.OrderMessage;
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
import cn.lili.modules.order.order.entity.dto.PriceDetailDTO;
import cn.lili.modules.order.order.entity.enums.*;
import cn.lili.modules.order.order.service.OrderItemService;
@ -96,6 +97,15 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
if (orderMessage.getNewStatus().equals(OrderStatusEnum.PAID)) {
log.debug("满减活动,订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn());
renderGift(JSONUtil.toBean(cache.getString(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), CartVO.class), orderMessage);
} else if (orderMessage.getNewStatus().equals(OrderStatusEnum.CANCELLED)) {
log.debug("满减活动,取消订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn());
OrderSearchParams searchParams = new OrderSearchParams();
searchParams.setParentOrderSn(orderMessage.getOrderSn());
searchParams.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name());
List<Order> orders = orderService.queryListByParams(searchParams);
if (orders != null && !orders.isEmpty()) {
orderService.systemCancel(orders.get(0).getSn(),"主订单取消,赠送订单字段自动取消");
}
}
}
@ -190,6 +200,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
BeanUtil.copyProperties(priceDetailDTO, order, "id");
//生成订单参数
order.setSn(SnowFlake.createStr("G"));
order.setParentOrderSn(originOrder.getSn());
order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name());
order.setOrderStatus(OrderStatusEnum.UNPAID.name());
order.setPayStatus(PayStatusEnum.PAID.name());

View File

@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 库存扣减他表示了订单状态是否出库成功
@ -156,7 +157,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
* @param stocks
*/
private void checkStocks(List<Integer> stocks, OrderDetailVO order) {
if (order.getOrderItems().size() == stocks.size()) {
if (!stocks.isEmpty() && order.getOrderItems().size() == stocks.size() && stocks.stream().anyMatch(Objects::nonNull)) {
return;
}
initSkuCache(order.getOrderItems());

View File

@ -140,6 +140,14 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
log.error("生成商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody()));
}
break;
case GENERATOR_STORE_GOODS_INDEX:
try {
String storeId = new String(messageExt.getBody());
this.updateGoodsIndex(storeId);
} catch (Exception e) {
log.error("生成店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody()));
}
break;
case UPDATE_GOODS_INDEX_PROMOTIONS:
this.updateGoodsIndexPromotions(new String(messageExt.getBody()));
break;
@ -220,6 +228,14 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
List<String> skuIds = JSONUtil.toList(message, String.class);
goodsCollectionService.deleteSkuCollection(skuIds);
break;
case STORE_GOODS_DELETE:
try {
String storeId = new String(messageExt.getBody());
goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("storeId", storeId).build());
} catch (Exception e) {
log.error("删除店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody()));
}
break;
//商品评价
case GOODS_COMMENT_COMPLETE:
MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class);
@ -308,6 +324,22 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
goodsIndexService.updateBulkIndex(goodsIndices);
}
/**
* 更新商品索引根据店铺id
*
* @param storeId 店铺id
*/
private void updateGoodsIndex(String storeId) {
//如果商品通过审核&&并且已上架
GoodsSearchParams searchParams = new GoodsSearchParams();
searchParams.setStoreId(storeId);
for (Goods goods : this.goodsService.queryListByParams(searchParams)) {
this.updateGoodsIndex(goods);
}
}
/**
* 更新商品索引
*

View File

@ -10,10 +10,15 @@ import org.springframework.context.ApplicationEvent;
@Data
public class GeneratorEsGoodsIndexEvent extends ApplicationEvent {
private String goodsId;
private static final long serialVersionUID = -6206752641309458207L;
public GeneratorEsGoodsIndexEvent(Object source, String goodsId) {
private String id;
private String tag;
public GeneratorEsGoodsIndexEvent(Object source, String tag, String id) {
super(source);
this.goodsId = goodsId;
this.tag = tag;
this.id = id;
}
}

View File

@ -3,7 +3,6 @@ package cn.lili.modules.goods.listener;
import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.GoodsTagsEnum;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -30,9 +29,9 @@ public class GeneratorEsGoodsIndexListener {
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) {
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + esGoodsIndexEvent.getTag();
//发送mq消息
rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getGoodsId(), RocketmqSendCallbackBuilder.commonCallback());
rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getId(), RocketmqSendCallbackBuilder.commonCallback());
}
}

View File

@ -112,6 +112,17 @@ public interface GoodsService extends IService<Goods> {
*/
Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
/**
* 更新商品上架状态状态
*
* @param storeId 店铺ID
* @param goodsStatusEnum 更新的商品状态
* @param underReason 下架原因
* @return 更新结果
*/
Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason);
/**
* 更新商品上架状态状态
*

View File

@ -151,6 +151,15 @@ public interface GoodsSkuService extends IService<GoodsSku> {
*/
void updateGoodsSkuStatus(Goods goods);
/**
* 更新商品sku状态根据店铺id
*
* @param storeId 店铺id
* @param marketEnable 市场启用状态
* @param authFlag 审核状态
*/
void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag);
/**
* 发送生成ES商品索引
*

View File

@ -70,7 +70,7 @@ public interface StudioService extends IService<Studio> {
* @param status 直播间状态
* @return 直播间分页
*/
IPage<Studio> studioList(PageVO pageVO, Integer recommend, String status);
IPage<StudioVO> studioList(PageVO pageVO, Integer recommend, String status);
/**
* 修改直播间状态

View File

@ -316,6 +316,29 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
return result;
}
/**
* 更新商品上架状态状态
*
* @param storeId 店铺ID
* @param goodsStatusEnum 更新的商品状态
* @param underReason 下架原因
* @return 更新结果
*/
@Override
public Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason) {
boolean result;
LambdaUpdateWrapper<Goods> updateWrapper = this.getUpdateWrapperByStoreAuthority();
updateWrapper.set(Goods::getMarketEnable, goodsStatusEnum.name());
updateWrapper.set(Goods::getUnderMessage, underReason);
updateWrapper.eq(Goods::getStoreId, storeId);
result = this.update(updateWrapper);
//修改规格商品
this.goodsSkuService.updateGoodsSkuStatusByStoreId(storeId, goodsStatusEnum.name(), null);
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {

View File

@ -325,7 +325,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
@Transactional(rollbackFor = Exception.class)
public void updateGoodsSkuStatus(Goods goods) {
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GoodsSku::getGoodsId, goods.getId());
updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getId()), GoodsSku::getGoodsId, goods.getId());
updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getStoreId()), GoodsSku::getStoreId, goods.getStoreId());
updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable());
updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag());
updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag());
@ -342,6 +343,31 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
}
/**
* 更新商品sku状态根据店铺id
*
* @param storeId 店铺id
* @param marketEnable 市场启用状态
* @param authFlag 审核状态
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag) {
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(GoodsSku::getStoreId, storeId);
updateWrapper.set(CharSequenceUtil.isNotEmpty(marketEnable), GoodsSku::getMarketEnable, marketEnable);
updateWrapper.set(CharSequenceUtil.isNotEmpty(authFlag), GoodsSku::getAuthFlag, authFlag);
boolean update = this.update(updateWrapper);
if (Boolean.TRUE.equals(update)) {
if (GoodsStatusEnum.UPPER.name().equals(marketEnable)) {
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成店铺商品", GoodsTagsEnum.GENERATOR_STORE_GOODS_INDEX.name(), storeId));
} else if (GoodsStatusEnum.DOWN.name().equals(marketEnable)) {
cache.vagueDel(CachePrefix.GOODS_SKU.getPrefix());
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("删除店铺商品", GoodsTagsEnum.STORE_GOODS_DELETE.name(), storeId));
}
}
}
@Override
public List<GoodsSku> getGoodsSkuByIdFromCache(List<String> ids) {
List<String> keys = new ArrayList<>();
@ -563,7 +589,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
return;
}
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId()));
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品", GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId()));
}
/**

View File

@ -1,6 +1,7 @@
package cn.lili.modules.goods.serviceimpl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
@ -32,12 +33,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -209,15 +213,27 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
}
@Override
public IPage<Studio> studioList(PageVO pageVO, Integer recommend, String status) {
public IPage<StudioVO> studioList(PageVO pageVO, Integer recommend, String status) {
QueryWrapper queryWrapper = new QueryWrapper<Studio>()
.eq(recommend != null, "recommend", true)
.eq(status != null, "status", status)
.eq(CharSequenceUtil.isNotEmpty(status), "status", status)
.orderByDesc("create_time");
if (UserContext.getCurrentUser() != null && UserContext.getCurrentUser().getRole().equals(UserEnums.STORE)) {
queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId());
}
return this.page(PageUtil.initPage(pageVO), queryWrapper);
Page page = this.page(PageUtil.initPage(pageVO), queryWrapper);
List<Studio> records = page.getRecords();
List<StudioVO> studioVOS = new ArrayList<>();
for (Studio record : records) {
StudioVO studioVO = new StudioVO();
//获取直播间信息
BeanUtil.copyProperties(record, studioVO);
//获取直播间商品信息
studioVO.setCommodityList(commodityMapper.getCommodityByRoomId(studioVO.getRoomId()));
studioVOS.add(studioVO);
}
page.setRecords(studioVOS);
return page;
}

View File

@ -125,6 +125,13 @@ public interface MemberCouponService extends IService<MemberCoupon> {
*/
void cancellation(String memberId, String id);
/**
* 作废无效的会员优惠券
*
* @return 是否操作成功
*/
boolean expireInvalidMemberCoupon(String memberId);
/**
* 关闭会员优惠券
*

View File

@ -1,5 +1,8 @@
package cn.lili.modules.promotion.service;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import java.util.List;
import java.util.Map;
/**
@ -15,7 +18,7 @@ public interface PromotionService {
*
* @return 当前促销活动集合
*/
Map<String, Object> getCurrentPromotion();
Map<String, List<PromotionGoods>> getCurrentPromotion();
/**
* 根据商品索引获取当前商品索引的所有促销活动信息

View File

@ -1,5 +1,6 @@
package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.cache.Cache;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
@ -23,6 +24,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
@ -108,7 +110,12 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
@Override
public IPage<MemberCoupon> getMemberCoupons(MemberCouponSearchParams param, PageVO pageVo) {
QueryWrapper<MemberCoupon> queryWrapper = param.queryWrapper();
return this.page(PageUtil.initPage(pageVo), queryWrapper);
Page<MemberCoupon> page = this.page(PageUtil.initPage(pageVo), queryWrapper);
if (page.getRecords().stream().anyMatch(i -> i.getEndTime().before(new Date()))) {
this.expireInvalidMemberCoupon(param.getMemberId());
return this.page(PageUtil.initPage(pageVo), queryWrapper);
}
return page;
}
/**
@ -119,7 +126,12 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
*/
@Override
public List<MemberCoupon> getMemberCoupons(MemberCouponSearchParams param) {
return this.list(param.queryWrapper());
List<MemberCoupon> list = this.list(param.queryWrapper());
if (list.stream().anyMatch(i -> i.getEndTime().before(new Date()))) {
this.expireInvalidMemberCoupon(param.getMemberId());
return this.list(param.queryWrapper());
}
return list;
}
/**
@ -273,6 +285,23 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
this.update(memberCouponLambdaUpdateWrapper);
}
/**
* 清除无效的会员优惠券
*
* @return 是否操作成功
*/
@Override
@CacheEvict(key = "#memberId")
public boolean expireInvalidMemberCoupon(String memberId) {
//将过期优惠券变更为过期状体
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
.eq(CharSequenceUtil.isNotEmpty(memberId), MemberCoupon::getMemberId, memberId)
.eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name())
.le(MemberCoupon::getEndTime, new Date())
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name());
return this.update(updateWrapper);
}
private void receiverCoupon(String couponId, String memberId, String memberName, Coupon coupon) {
this.checkCouponLimit(couponId, memberId);
MemberCoupon memberCoupon = new MemberCoupon(coupon);

View File

@ -2,8 +2,7 @@ package cn.lili.modules.promotion.serviceimpl;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.modules.promotion.entity.dos.*;
import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams;
import cn.lili.modules.promotion.entity.dto.search.PintuanSearchParams;
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.service.*;
@ -16,6 +15,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 促销业务层实现
@ -69,37 +69,11 @@ public class PromotionServiceImpl implements PromotionService {
* @return 当前促销活动集合
*/
@Override
public Map<String, Object> getCurrentPromotion() {
Map<String, Object> resultMap = new HashMap<>(16);
SeckillSearchParams seckillSearchParams = new SeckillSearchParams();
seckillSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
//获取当前进行的秒杀活动活动
List<Seckill> seckillList = seckillService.listFindAll(seckillSearchParams);
if (seckillList != null && !seckillList.isEmpty()) {
for (Seckill seckill : seckillList) {
resultMap.put(PromotionTypeEnum.SECKILL.name(), seckill);
}
}
FullDiscountSearchParams fullDiscountSearchParams = new FullDiscountSearchParams();
fullDiscountSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
//获取当前进行的满优惠活动
List<FullDiscount> fullDiscountList = fullDiscountService.listFindAll(fullDiscountSearchParams);
if (fullDiscountList != null && !fullDiscountList.isEmpty()) {
for (FullDiscount fullDiscount : fullDiscountList) {
resultMap.put(PromotionTypeEnum.FULL_DISCOUNT.name(), fullDiscount);
}
}
PintuanSearchParams pintuanSearchParams = new PintuanSearchParams();
pintuanSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
//获取当前进行的拼团活动
List<Pintuan> pintuanList = pintuanService.listFindAll(pintuanSearchParams);
if (pintuanList != null && !pintuanList.isEmpty()) {
for (Pintuan pintuan : pintuanList) {
resultMap.put(PromotionTypeEnum.PINTUAN.name(), pintuan);
}
}
return resultMap;
public Map<String, List<PromotionGoods>> getCurrentPromotion() {
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
List<PromotionGoods> promotionGoods = promotionGoodsService.listFindAll(searchParams);
return promotionGoods.stream().collect(Collectors.groupingBy(PromotionGoods::getPromotionType));
}
/**

View File

@ -71,9 +71,9 @@ public interface EsGoodsIndexService {
/**
* 删除索引
*
* @param goods 商品索引信息
* @param queryFields 查询条件 (key 为字段value为字段值)
*/
void deleteIndex(EsGoodsIndex goods);
void deleteIndex(Map<String, Object> queryFields);
/**
* 删除索引

View File

@ -59,7 +59,6 @@ import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.io.IOException;
import java.lang.reflect.Field;
@ -287,13 +286,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
}
}
/**
* 删除索引
*
* @param queryFields 查询条件
*/
@Override
public void deleteIndex(EsGoodsIndex goods) {
if (ObjectUtils.isEmpty(goods)) {
//如果对象为空则删除全量
goodsIndexRepository.deleteAll();
public void deleteIndex(Map<String, Object> queryFields) {
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
for (Map.Entry<String, Object> entry : queryFields.entrySet()) {
boolQueryBuilder.filter(QueryBuilders.termsQuery(entry.getKey(), entry.getValue()));
}
goodsIndexRepository.delete(goods);
queryBuilder.withQuery(boolQueryBuilder);
this.restTemplate.delete(queryBuilder.build(), EsGoodsIndex.class);
}
/**
@ -316,7 +322,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();
queryBuilder.withQuery(QueryBuilders.termsQuery("id", ids.toArray()));
this.restTemplate.delete(queryBuilder.build(), EsGoodsIndex.class);
}
@Override

View File

@ -130,7 +130,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
*/
@Override
public void deleteHotWords(String keywords) {
cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords);
if (CharSequenceUtil.isEmpty(keywords)) {
cache.vagueDel(CachePrefix.HOT_WORD.getPrefix());
} else {
cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords);
}
}
@Override

View File

@ -10,6 +10,10 @@ public enum GoodsTagsEnum {
* "生成商品索引"
*/
GENERATOR_GOODS_INDEX("生成商品索引"),
/**
* "生成店铺商品索引"
*/
GENERATOR_STORE_GOODS_INDEX("生成店铺商品索引"),
/**
* "更新商品索引"
*/
@ -31,6 +35,10 @@ public enum GoodsTagsEnum {
* "重置商品索引"
*/
RESET_GOODS_INDEX("重置商品索引"),
/**
* "删除店铺商品索引"
*/
STORE_GOODS_DELETE("删除店铺商品索引"),
/**
* "删除商品"
*/

View File

@ -37,11 +37,18 @@ public class HotWordsManagerController {
return ResultUtil.success();
}
@ApiOperation(value = "设置热词")
@ApiOperation(value = "删除热词")
@DeleteMapping("/{words}")
public ResultMessage<Object> deleteWords(@PathVariable String words) {
esGoodsSearchService.deleteHotWords(words);
return ResultUtil.success();
}
@ApiOperation(value = "删除全部热词")
@DeleteMapping("")
public ResultMessage<Object> deleteWordsAll() {
esGoodsSearchService.deleteHotWords(null);
return ResultUtil.success();
}
}

View File

@ -36,7 +36,7 @@ public class StudioManagerController {
@ApiOperation(value = "获取店铺直播间列表")
@ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query")
@GetMapping
public ResultMessage<IPage<Studio>> page(PageVO pageVO, String status) {
public ResultMessage<IPage<StudioVO>> page(PageVO pageVO, String status) {
return ResultUtil.data(studioService.studioList(pageVO, null, status));
}

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
@ -37,8 +38,8 @@ public class PromotionManagerController {
@GetMapping("/current")
@ApiOperation(value = "获取当前进行中的促销活动")
public ResultMessage<Map<String, Object>> getCurrentPromotion() {
Map<String, Object> currentPromotion = promotionService.getCurrentPromotion();
public ResultMessage<Map<String, List<PromotionGoods>>> getCurrentPromotion() {
Map<String, List<PromotionGoods>> currentPromotion = promotionService.getCurrentPromotion();
return ResultUtil.data(currentPromotion);
}

View File

@ -1,39 +0,0 @@
package cn.lili.test.promotion;
import cn.lili.modules.promotion.entity.dos.BasePromotions;
import cn.lili.modules.promotion.service.PromotionGoodsService;
import cn.lili.modules.promotion.service.PromotionService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.Map;
/**
* @author paulG
* @since 2020/11/23
**/
@ExtendWith(SpringExtension.class)
@SpringBootTest
class PromotionPriceTest {
@Autowired
private PromotionService promotionService;
@Autowired
private PromotionGoodsService promotionGoodsServiceService;
@Test
void testSeckillPrice() {
Map<String, Object> currentPromotion = promotionService.getCurrentPromotion();
for (Map.Entry<String, Object> entry : currentPromotion.entrySet()) {
BasePromotions promotion = (BasePromotions) entry.getValue();
System.out.println(entry.getKey() + "-" + promotion.getId());
}
Assertions.assertTrue(true);
}
}

View File

@ -38,7 +38,7 @@ public class StudioStoreController {
@ApiOperation(value = "获取店铺直播间列表")
@ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query", dataType = "String")
@GetMapping
public ResultMessage<IPage<Studio>> page(PageVO pageVO, String status) {
public ResultMessage<IPage<StudioVO>> page(PageVO pageVO, String status) {
return ResultUtil.data(studioService.studioList(pageVO, null, status));
}