Skip to content

Commit

Permalink
修复商品审核关闭后,修改商品不生成索引问题。升级mybatis-plus版本至 3.4.3.4 和hutool版本至 5.7.16。适配新…
Browse files Browse the repository at this point in the history
…版本mybatis-plus
  • Loading branch information
LeiGaoRobot committed Dec 15, 2021
1 parent c3fbad7 commit a9ddcfe
Show file tree
Hide file tree
Showing 62 changed files with 193 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public void onMessage(MessageExt messageExt) {
//生成索引
case GENERATOR_GOODS_INDEX:
try {
String goodsJsonStr = new String(messageExt.getBody());
Goods goods = JSONUtil.toBean(goodsJsonStr, Goods.class);
String goodsId = new String(messageExt.getBody());
Goods goods = this.goodsService.getById(goodsId);
updateGoodsIndex(goods);
} catch (Exception e) {
log.error("生成商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ private void saveMemberMessage(Message message) {
//查询所有会员总数,因为会员总数比较大 如果一次性查出来会占用数据库资源,所以要分页查询
MemberSearchVO memberSearchVO = new MemberSearchVO();
memberSearchVO.setDisabled(SwitchEnum.OPEN.name());
Integer memberNum = memberService.getMemberNum(memberSearchVO);
long memberNum = memberService.getMemberNum(memberSearchVO);
//构建分页查询参数
//100条查一次
Integer pageSize = 100;
Integer pageCount = 0;
pageCount = memberNum / pageSize;
int pageSize = 100;
int pageCount;
pageCount = (int) (memberNum / pageSize);
pageCount = memberNum % pageSize > 0 ? pageCount + 1 : pageCount;
for (int i = 1; i <= pageCount; i++) {
PageVO pageVO = new PageVO();
Expand Down
2 changes: 1 addition & 1 deletion framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>1.3.2</version>
<version>2.2.0</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import cn.lili.mybatis.BaseIdEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
Expand All @@ -31,11 +30,6 @@ public class DistributionOrder extends BaseIdEntity {

private static final long serialVersionUID = 501799944909496507L;

@TableId
@TableField
@ApiModelProperty(value = "唯一标识", hidden = true)
private String id;

@CreatedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface GoodsService extends IService<Goods> {
* @param categoryId 分类ID
* @return 商品数量
*/
Integer getGoodsCountByCategory(String categoryId);
long getGoodsCountByCategory(String categoryId);

/**
* 添加商品
Expand Down Expand Up @@ -143,7 +143,8 @@ public interface GoodsService extends IService<Goods> {
/**
* 统计店铺的商品数量
* @param storeId 店铺id
* @return
*/
Integer countStoreGoodsNum(String storeId);
long countStoreGoodsNum(String storeId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void updateGoodsParams(String goodsId, String params) {
}

@Override
public final Integer getGoodsCountByCategory(String categoryId) {
public final long getGoodsCountByCategory(String categoryId) {
QueryWrapper<Goods> queryWrapper = Wrappers.query();
queryWrapper.like("category_path", categoryId);
queryWrapper.eq("delete_flag", false);
Expand Down Expand Up @@ -362,7 +362,7 @@ public void updateGoodsCommentNum(String goodsId) {
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
//好评数量
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
//好评率
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
goods.setGrade(grade);
Expand All @@ -380,7 +380,7 @@ public void updateStoreDetail(Store store) {
}

@Override
public Integer countStoreGoodsNum(String storeId) {
public long countStoreGoodsNum(String storeId) {
return this.count(
new LambdaQueryWrapper<Goods>()
.eq(Goods::getStoreId, storeId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public void updateGoodsSkuCommentNum(String skuId) {
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());

//好评数量
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);

//更新商品评价数量
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
Expand Down Expand Up @@ -539,7 +539,7 @@ public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) {
public void generateEs(Goods goods) {
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
//发送mq消息
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback());
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cn.lili.mybatis.BaseIdEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
Expand All @@ -27,11 +26,6 @@ public class MemberReceipt extends BaseIdEntity {

private static final long serialVersionUID = -8210927482915675995L;

@TableId
@TableField
@ApiModelProperty(value = "唯一标识", hidden = true)
private String id;

@ApiModelProperty(value = "发票抬头")
private String receiptTitle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public class EvaluationNumberVO {
private Integer worse;

@ApiModelProperty(value = "有图数量")
private Integer haveImage;
private Long haveImage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ public interface FootprintService extends IService<FootPrint> {
*
* @return 当前会员的浏览记录数量
*/
Integer getFootprintNum();
long getFootprintNum();
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public interface MemberService extends IService<Member> {
* @param memberSearchVO
* @return 会员总数
*/
Integer getMemberNum(MemberSearchVO memberSearchVO);
long getMemberNum(MemberSearchVO memberSearchVO);

/**
* 获取指定会员数据
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package cn.lili.modules.member.serviceimpl;

import cn.lili.common.security.context.UserContext;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.member.entity.dos.FootPrint;
import cn.lili.modules.member.mapper.FootprintMapper;
import cn.lili.modules.member.service.FootprintService;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.service.EsGoodsSearchService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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 java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -81,19 +82,19 @@ public List<EsGoodsIndex> footPrintPage(PageVO pageVO) {
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
lambdaQueryWrapper.orderByDesc(FootPrint::getUpdateTime);
List<String> skuIdList = this.baseMapper.footprintSkuIdList(PageUtil.initPage(pageVO), lambdaQueryWrapper);
if (skuIdList.size() > 0) {
if (!skuIdList.isEmpty()) {
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(skuIdList);
//去除为空的商品数据
list.removeIf(Objects::isNull);
return list;
}
return null;
return Collections.emptyList();
}

@Override
public Integer getFootprintNum() {
public long getFootprintNum() {
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
lambdaQueryWrapper.eq(FootPrint::getMemberId, Objects.requireNonNull(UserContext.getCurrentUser()).getId());
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
return this.count(lambdaQueryWrapper);
}
Expand Down
Loading

0 comments on commit a9ddcfe

Please sign in to comment.