Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
c85bc7b8ea
@ -8,7 +8,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.GoodsCommentCompleteEvent;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionGoods;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionSelectedGoods;
|
||||
import cn.lili.modules.distribution.entity.dto.DistributionGoodsSearchParams;
|
||||
import cn.lili.modules.distribution.service.DistributionGoodsService;
|
||||
import cn.lili.modules.distribution.service.DistributionSelectedGoodsService;
|
||||
import cn.lili.modules.goods.entity.dos.*;
|
||||
@ -31,8 +31,6 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
@ -258,7 +256,10 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
|
||||
for (Goods goods : goodsList) {
|
||||
//如果商品通过审核&&并且已上架
|
||||
List<GoodsSku> goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId()).gt(GoodsSku::getQuantity, 0));
|
||||
GoodsSearchParams searchParams = new GoodsSearchParams();
|
||||
searchParams.setGoodsId(goods.getId());
|
||||
searchParams.setGeQuantity(0);
|
||||
List<GoodsSku> goodsSkuList = this.goodsSkuService.getGoodsSkuByList(searchParams);
|
||||
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
|
||||
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
|
||||
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
|
||||
@ -287,7 +288,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
*/
|
||||
private void updateGoodsIndex(Goods goods) {
|
||||
//如果商品通过审核&&并且已上架
|
||||
List<GoodsSku> goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId()));
|
||||
GoodsSearchParams searchParams = new GoodsSearchParams();
|
||||
searchParams.setGoodsId(goods.getId());
|
||||
List<GoodsSku> goodsSkuList = this.goodsSkuService.getGoodsSkuByList(searchParams);
|
||||
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
|
||||
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
|
||||
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
|
||||
@ -373,16 +376,19 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
private void deleteGoods(MessageExt messageExt) {
|
||||
Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
|
||||
|
||||
DistributionGoodsSearchParams searchParams = new DistributionGoodsSearchParams();
|
||||
searchParams.setGoodsId(goods.getId());
|
||||
//删除获取分销商品
|
||||
DistributionGoods distributionGoods = distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
|
||||
.eq(DistributionGoods::getGoodsId, goods.getId()));
|
||||
DistributionGoods distributionGoods = distributionGoodsService.getDistributionGoods(searchParams);
|
||||
|
||||
//删除分销商品绑定关系
|
||||
distributionSelectedGoodsService.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoods.getId()));
|
||||
if (distributionGoods != null) {
|
||||
|
||||
//删除分销商品
|
||||
distributionGoodsService.removeById(distributionGoods.getId());
|
||||
//删除分销商品绑定关系
|
||||
distributionSelectedGoodsService.deleteByDistributionGoodsId(distributionGoods.getId());
|
||||
|
||||
//删除分销商品
|
||||
distributionGoodsService.removeById(distributionGoods.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,9 +427,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
goods.setBuyCount(0);
|
||||
}
|
||||
int buyCount = goods.getBuyCount() + goodsCompleteMessage.getBuyNum();
|
||||
goodsService.update(new LambdaUpdateWrapper<Goods>()
|
||||
.eq(Goods::getId, goodsCompleteMessage.getGoodsId())
|
||||
.set(Goods::getBuyCount, buyCount));
|
||||
this.goodsService.updateGoodsBuyCount(goodsCompleteMessage.getGoodsId(), buyCount);
|
||||
} else {
|
||||
log.error("商品Id为[" + goodsCompleteMessage.getGoodsId() + "的商品不存在,更新商品失败!");
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package cn.lili.modules.distribution.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 分销员商品查询条件
|
||||
@ -13,15 +15,25 @@ import lombok.Data;
|
||||
* @author pikachu
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DistributionGoodsSearchParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private String goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@ApiModelProperty(value = "是否已选择")
|
||||
private boolean isChecked;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = this.distributionQueryWrapper();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(goodsId), "goods_id", goodsId);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(goodsName), "goods_name", goodsId);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> storeQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = this.distributionQueryWrapper();
|
||||
|
@ -21,10 +21,34 @@ public interface DistributionGoodsService extends IService<DistributionGoods> {
|
||||
* 根据条件分页查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 商品条件
|
||||
* @return
|
||||
* @return 分页分销商品信息
|
||||
*/
|
||||
IPage<DistributionGoodsVO> goodsPage(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息列表
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息列表
|
||||
*/
|
||||
List<DistributionGoods> getDistributionGoodsList(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息
|
||||
*/
|
||||
DistributionGoods getDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 根据条件删除分销商品
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
*/
|
||||
boolean deleteDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 获取分销商品
|
||||
*
|
||||
|
@ -23,4 +23,11 @@ public interface DistributionSelectedGoodsService extends IService<DistributionS
|
||||
* @return
|
||||
*/
|
||||
boolean delete(String distributionGoodsId);
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
*/
|
||||
boolean deleteByDistributionGoodsId(String distributionGoodsId);
|
||||
}
|
||||
|
@ -70,6 +70,38 @@ public class DistributionGoodsServiceImpl extends ServiceImpl<DistributionGoodsM
|
||||
return this.baseMapper.getDistributionGoodsVO(PageUtil.initPage(searchParams), searchParams.distributionQueryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息列表
|
||||
*
|
||||
* @param distributionGoodsSearchParams 商品条件
|
||||
* @return 分销商品信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<DistributionGoods> getDistributionGoodsList(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.list(distributionGoodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息
|
||||
*/
|
||||
@Override
|
||||
public DistributionGoods getDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.getOne(distributionGoodsSearchParams.queryWrapper(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件删除分销商品
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.remove(distributionGoodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionGoods distributionGoodsVO(String id) {
|
||||
|
||||
|
@ -46,4 +46,16 @@ public class DistributionSelectedGoodsServiceImpl extends ServiceImpl<Distributi
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoodsId)
|
||||
.eq(DistributionSelectedGoods::getDistributionId, distributionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
*
|
||||
* @param distributionGoodsId 商品ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteByDistributionGoodsId(String distributionGoodsId) {
|
||||
return this.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoodsId));
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ public class GoodsSearchParams extends PageVO {
|
||||
private String authFlag;
|
||||
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Integer quantity;
|
||||
private Integer leQuantity;
|
||||
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Integer geQuantity;
|
||||
|
||||
@ApiModelProperty(value = "是否为推荐商品")
|
||||
private Boolean recommend;
|
||||
@ -106,8 +109,11 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(authFlag)) {
|
||||
queryWrapper.eq("auth_flag", authFlag);
|
||||
}
|
||||
if (quantity != null) {
|
||||
queryWrapper.le("quantity", quantity);
|
||||
if (leQuantity != null) {
|
||||
queryWrapper.le("quantity", leQuantity);
|
||||
}
|
||||
if (geQuantity != null) {
|
||||
queryWrapper.ge("quantity", geQuantity);
|
||||
}
|
||||
if (recommend != null) {
|
||||
queryWrapper.le("recommend", recommend);
|
||||
|
@ -147,12 +147,20 @@ public interface GoodsService extends IService<Goods> {
|
||||
void updateStock(String goodsId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 更新SKU评价数量
|
||||
* 更新商品评价数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void updateGoodsCommentNum(String goodsId);
|
||||
|
||||
/**
|
||||
* 更新商品的购买数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
void updateGoodsBuyCount(String goodsId, int buyCount);
|
||||
|
||||
/**
|
||||
* 批量更新商品的店铺信息
|
||||
* @param store
|
||||
|
@ -406,6 +406,19 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
this.updateById(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品的购买数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsBuyCount(String goodsId, int buyCount) {
|
||||
this.update(new LambdaUpdateWrapper<Goods>()
|
||||
.eq(Goods::getId, goodsId)
|
||||
.set(Goods::getBuyCount, buyCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreDetail(Store store) {
|
||||
UpdateWrapper updateWrapper = new UpdateWrapper<>()
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
@ -538,9 +539,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
*/
|
||||
@Override
|
||||
public void generateEs(Goods goods) {
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
// 延时执行,防止商品未保存完成就去生成商品索引导致生成索引时找不到商品问题
|
||||
Thread.sleep(2000);
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||
} catch (InterruptedException e) {
|
||||
log.error("发送商品索引信息失败!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,6 +41,13 @@ public interface EsGoodsSearchService {
|
||||
*/
|
||||
void setHotWords(HotWordsDTO hotWords);
|
||||
|
||||
/**
|
||||
* 删除热门关键词
|
||||
*
|
||||
* @param keywords 热词
|
||||
*/
|
||||
void deleteHotWords(String keywords);
|
||||
|
||||
/**
|
||||
* 获取筛选器
|
||||
*
|
||||
|
@ -115,6 +115,16 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除热门关键词
|
||||
*
|
||||
* @param keywords 热词
|
||||
*/
|
||||
@Override
|
||||
public void deleteHotWords(String keywords) {
|
||||
cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) {
|
||||
NativeSearchQueryBuilder builder = createSearchQueryBuilder(goodsSearch, null);
|
||||
|
@ -92,7 +92,6 @@ public class StoreDetail extends BaseIdEntity {
|
||||
@ApiModelProperty(value = "营业执照号")
|
||||
private String licenseNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "法定经营范围长度为1-200位字符")
|
||||
@ApiModelProperty(value = "法定经营范围")
|
||||
private String scope;
|
||||
|
||||
|
@ -99,7 +99,6 @@ public class AdminStoreApplyDTO {
|
||||
@ApiModelProperty(value = "营业执照号")
|
||||
private String licenseNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "法定经营范围长度为1-200位字符")
|
||||
@ApiModelProperty(value = "法定经营范围")
|
||||
private String scope;
|
||||
|
||||
|
@ -78,7 +78,6 @@ public class StoreEditDTO {
|
||||
@ApiModelProperty(value = "营业执照号")
|
||||
private String licenseNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "法定经营范围长度为1-200位字符")
|
||||
@ApiModelProperty(value = "法定经营范围")
|
||||
private String scope;
|
||||
|
||||
|
@ -8,10 +8,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 管理端,app版本控制器
|
||||
@ -29,16 +26,22 @@ public class HotWordsManagerController {
|
||||
|
||||
@ApiOperation(value = "获取热词")
|
||||
@GetMapping
|
||||
public ResultMessage getHotWords() {
|
||||
public ResultMessage<Object> getHotWords() {
|
||||
return ResultUtil.data(esGoodsSearchService.getHotWords(100));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设置热词")
|
||||
@PostMapping
|
||||
public ResultMessage paymentForm(@Validated HotWordsDTO hotWords) {
|
||||
|
||||
public ResultMessage<Object> paymentForm(@Validated HotWordsDTO hotWords) {
|
||||
esGoodsSearchService.setHotWords(hotWords);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设置热词")
|
||||
@DeleteMapping("/{words}")
|
||||
public ResultMessage<Object> deleteWords(@PathVariable String words) {
|
||||
esGoodsSearchService.deleteHotWords(words);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class GoodsStoreController {
|
||||
StoreDetail storeDetail = OperationalJudgment.judgment(storeDetailService.getStoreDetail(storeId));
|
||||
Integer stockWarnNum = storeDetail.getStockWarning();
|
||||
goodsSearchParams.setStoreId(storeId);
|
||||
goodsSearchParams.setQuantity(stockWarnNum);
|
||||
goodsSearchParams.setLeQuantity(stockWarnNum);
|
||||
goodsSearchParams.setMarketEnable(GoodsStatusEnum.UPPER.name());
|
||||
IPage<GoodsSku> goodsSku = goodsSkuService.getGoodsSkuByPage(goodsSearchParams);
|
||||
StockWarningVO stockWarning = new StockWarningVO(stockWarnNum, goodsSku);
|
||||
|
Loading…
x
Reference in New Issue
Block a user