fix: 添加订单和商品存在性检查以改善评价流程 (pg)
- 在MemberEvaluationServiceImpl中引入订单和商品存在性检查。 - 当订单或商品不存在时,抛出异常以避免错误日志的产生。 - 同时,在OrderEveryDayTaskExecute中捕获异常时更新评价状态。
This commit is contained in:
parent
554aed024c
commit
478dd1d201
@ -29,14 +29,14 @@ import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2021/3/11
|
||||
@ -198,8 +198,9 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
|
||||
try {
|
||||
memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, false);
|
||||
|
||||
} catch (Exception e) {
|
||||
// 修改订单货物评价状态为已评价避免无限调用评价异常
|
||||
orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
@ -102,8 +102,18 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf) {
|
||||
//获取子订单信息
|
||||
OrderItem orderItem = orderItemService.getBySn(memberEvaluationDTO.getOrderItemSn());
|
||||
|
||||
if (orderItem == null) {
|
||||
throw new ServiceException(ResultCode.ORDER_ITEM_NOT_EXIST);
|
||||
}
|
||||
|
||||
//获取订单信息
|
||||
Order order = orderService.getBySn(orderItem.getOrderSn());
|
||||
|
||||
if (order == null) {
|
||||
throw new ServiceException(ResultCode.ORDER_NOT_EXIST);
|
||||
}
|
||||
|
||||
//检测是否可以添加会员评价
|
||||
Member member;
|
||||
|
||||
@ -119,13 +129,12 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
//获取商品信息
|
||||
GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(memberEvaluationDTO.getSkuId());
|
||||
|
||||
// 商品是否存在
|
||||
if (goodsSku == null) {
|
||||
log.error("商品不存在,商品ID:" + memberEvaluationDTO.getSkuId());
|
||||
return null;
|
||||
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
|
||||
}
|
||||
|
||||
//新增用户评价
|
||||
|
Loading…
x
Reference in New Issue
Block a user