Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
095cf81ce8
@ -3,14 +3,12 @@ package cn.lili.listener;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.event.GoodsCommentCompleteEvent;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
@ -18,7 +16,6 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
@ -96,9 +93,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
break;
|
||||
//商品评价
|
||||
case GOODS_COMMENT_COMPLETE:
|
||||
MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class);
|
||||
for (GoodsCommentCompleteEvent goodsCommentCompleteEvent : goodsCommentCompleteEvents) {
|
||||
try {
|
||||
MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class);
|
||||
goodsCommentCompleteEvent.goodsComment(memberEvaluation);
|
||||
} catch (Exception e) {
|
||||
log.error("评价{},在{}业务中,状态修改事件执行异常",
|
||||
|
@ -407,10 +407,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
|
||||
// 好评数量
|
||||
double highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
|
||||
// 更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() + 1);
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
|
||||
// 好评率
|
||||
double grade = NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2) * 100;
|
||||
@ -419,6 +419,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user