Skip to content

Commit

Permalink
fix: 优化更新商品索引评论条件
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Oct 17, 2023
1 parent 074e4ed commit a910a97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ public void updateGoodsCommentNum(String goodsId, String skuId) {
Goods goods = this.getById(goodsId);

//修改商品评价数量
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).build());
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).status("OPEN").build());
goods.setCommentNum((int) (commentNum));

//好评数量
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).grade(EvaluationGradeEnum.GOOD.name()).build());
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).status("OPEN").grade(EvaluationGradeEnum.GOOD.name()).build());
//好评率
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
goods.setGrade(grade);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,10 @@ public void updateGoodsSkuCommentNum(String skuId) {
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);

//好评数量
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().grade(EvaluationGradeEnum.GOOD.name()).skuId(skuId).build());
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().status("OPEN").grade(EvaluationGradeEnum.GOOD.name()).skuId(skuId).build());

//更新商品评价数量
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().skuId(skuId).build());
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().status("OPEN").skuId(skuId).build());
goodsSku.setCommentNum((int) commentNum);

//好评率
Expand Down

0 comments on commit a910a97

Please sign in to comment.