fix:【商城】已删除的商品,无法评论,导致 TradeOrderAutoCommentJob 重复持续运行
This commit is contained in:
parent
361e50e5de
commit
95b8cf00fd
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -13,6 +15,9 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
||||
|
||||
@Select("SELECT * FROM product_sku WHERE id = #{id}")
|
||||
ProductSkuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||
|
||||
default List<ProductSkuDO> selectListBySpuId(Long spuId) {
|
||||
return selectList(ProductSkuDO::getSpuId, spuId);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.enums.ProductConstants;
|
|||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
@ -18,6 +20,9 @@ import java.util.Set;
|
|||
@Mapper
|
||||
public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
|
||||
|
||||
@Select("SELECT * FROM product_spu WHERE id = #{id}")
|
||||
ProductSpuDO selectByIdIncludeDeleted(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 获取商品 SPU 分页列表数据
|
||||
*
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
|||
}
|
||||
|
||||
private ProductSkuDO validateSku(Long skuId) {
|
||||
ProductSkuDO sku = productSkuService.getSku(skuId);
|
||||
ProductSkuDO sku = productSkuService.getSku(skuId, true);
|
||||
if (sku == null) {
|
||||
throw exception(SKU_NOT_EXISTS);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
|||
}
|
||||
|
||||
private ProductSpuDO validateSpu(Long spuId) {
|
||||
ProductSpuDO spu = productSpuService.getSpu(spuId);
|
||||
ProductSpuDO spu = productSpuService.getSpu(spuId, true);
|
||||
if (null == spu) {
|
||||
throw exception(SPU_NOT_EXISTS);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,15 @@ public interface ProductSkuService {
|
|||
*/
|
||||
ProductSkuDO getSku(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品 SKU 信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @param includeDeleted 是否包含已删除的
|
||||
* @return 商品 SKU 信息
|
||||
*/
|
||||
ProductSkuDO getSku(Long id, boolean includeDeleted);
|
||||
|
||||
/**
|
||||
* 获得商品 SKU 列表
|
||||
*
|
||||
|
|
|
@ -68,6 +68,14 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
|||
return productSkuMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSkuDO getSku(Long id, boolean includeDeleted) {
|
||||
if (includeDeleted) {
|
||||
return productSkuMapper.selectByIdIncludeDeleted(id);
|
||||
}
|
||||
return getSku(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSkuDO> getSkuList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
|
|
@ -51,6 +51,15 @@ public interface ProductSpuService {
|
|||
*/
|
||||
ProductSpuDO getSpu(Long id);
|
||||
|
||||
/**
|
||||
* 获得商品 SPU
|
||||
*
|
||||
* @param id 编号
|
||||
* @param includeDeleted 是否包含已删除的
|
||||
* @return 商品 SPU
|
||||
*/
|
||||
ProductSpuDO getSpu(Long id, boolean includeDeleted);
|
||||
|
||||
/**
|
||||
* 获得商品 SPU 列表
|
||||
*
|
||||
|
|
|
@ -189,6 +189,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||
return productSpuMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSpuDO getSpu(Long id, boolean includeDeleted) {
|
||||
if (includeDeleted) {
|
||||
return productSpuMapper.selectByIdIncludeDeleted(id);
|
||||
}
|
||||
return getSpu(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuDO> getSpuList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
|
Loading…
Reference in New Issue