Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
2c58b91c45
@ -122,4 +122,11 @@ public interface GoodsService extends IService<Goods> {
|
||||
* @param quantity 库存数量
|
||||
*/
|
||||
void updateStock(String goodsId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 更新SKU评价数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void updateGoodsCommentNum(String goodsId);
|
||||
}
|
@ -2,6 +2,7 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -23,6 +24,9 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.store.entity.vos.StoreVO;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
@ -73,6 +77,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
//店铺详情
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
@Autowired
|
||||
private MemberEvaluationService memberEvaluationService;
|
||||
//rocketMq
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
@ -80,6 +86,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
|
||||
@Override
|
||||
public void underStoreGoods(String storeId) {
|
||||
this.baseMapper.underStoreGoods(storeId);
|
||||
@ -234,7 +241,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
public Integer goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum) {
|
||||
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();
|
||||
|
||||
queryWrapper.eq(Goods::getDeleteFlag,false);
|
||||
queryWrapper.eq(Goods::getDeleteFlag, false);
|
||||
|
||||
if (goodsStatusEnum != null) {
|
||||
queryWrapper.eq(Goods::getMarketEnable, goodsStatusEnum.name());
|
||||
@ -313,6 +320,26 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsCommentNum(String goodsId) {
|
||||
|
||||
//获取商品信息
|
||||
Goods goods = this.getById(goodsId);
|
||||
//修改商品评价数量
|
||||
goods.setCommentNum(goods.getCommentNum() + 1);
|
||||
|
||||
//修改商品好评率
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
// 好评数量
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
// 好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
|
||||
goods.setGrade(grade);
|
||||
this.updateById(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品默认图片
|
||||
*
|
||||
|
@ -413,18 +413,15 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
|
||||
// 好评率
|
||||
double grade = NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2) * 100;
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100);
|
||||
goodsSku.setGrade(grade);
|
||||
//修改规格
|
||||
this.update(goodsSku);
|
||||
//修改规格索引
|
||||
goodsIndexService.updateIndexCommentNum(goodsSku.getId(), goodsSku.getCommentNum(), (int) highPraiseNum, grade);
|
||||
|
||||
//修改商品评价数量
|
||||
Goods goods = goodsService.getById(goodsSku.getGoodsId());
|
||||
goods.setCommentNum(goods.getCommentNum() + 1);
|
||||
goodsService.updateById(goods);
|
||||
|
||||
//修改商品的评价数量
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user