Commit 95b8cf00fd58082ebaf45864501514254dcf9df6
1 parent
361e50e5
fix:【商城】已删除的商品,无法评论,导致 TradeOrderAutoCommentJob 重复持续运行
Showing
7 changed files
with
46 additions
and
2 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
| @@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | @@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 7 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 7 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | +import org.apache.ibatis.annotations.Param; | ||
| 10 | +import org.apache.ibatis.annotations.Select; | ||
| 9 | 11 | ||
| 10 | import java.util.Collection; | 12 | import java.util.Collection; |
| 11 | import java.util.List; | 13 | import java.util.List; |
| @@ -13,6 +15,9 @@ import java.util.List; | @@ -13,6 +15,9 @@ import java.util.List; | ||
| 13 | @Mapper | 15 | @Mapper |
| 14 | public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> { | 16 | public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> { |
| 15 | 17 | ||
| 18 | + @Select("SELECT * FROM product_sku WHERE id = #{id}") | ||
| 19 | + ProductSkuDO selectByIdIncludeDeleted(@Param("id") Long id); | ||
| 20 | + | ||
| 16 | default List<ProductSkuDO> selectListBySpuId(Long spuId) { | 21 | default List<ProductSkuDO> selectListBySpuId(Long spuId) { |
| 17 | return selectList(ProductSkuDO::getSpuId, spuId); | 22 | return selectList(ProductSkuDO::getSpuId, spuId); |
| 18 | } | 23 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java
| @@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.enums.ProductConstants; | @@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.enums.ProductConstants; | ||
| 11 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | 11 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | import org.apache.ibatis.annotations.Mapper; | 13 | import org.apache.ibatis.annotations.Mapper; |
| 14 | +import org.apache.ibatis.annotations.Param; | ||
| 15 | +import org.apache.ibatis.annotations.Select; | ||
| 14 | 16 | ||
| 15 | import java.util.Objects; | 17 | import java.util.Objects; |
| 16 | import java.util.Set; | 18 | import java.util.Set; |
| @@ -18,6 +20,9 @@ import java.util.Set; | @@ -18,6 +20,9 @@ import java.util.Set; | ||
| 18 | @Mapper | 20 | @Mapper |
| 19 | public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { | 21 | public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { |
| 20 | 22 | ||
| 23 | + @Select("SELECT * FROM product_spu WHERE id = #{id}") | ||
| 24 | + ProductSpuDO selectByIdIncludeDeleted(@Param("id") Long id); | ||
| 25 | + | ||
| 21 | /** | 26 | /** |
| 22 | * 获取商品 SPU 分页列表数据 | 27 | * 获取商品 SPU 分页列表数据 |
| 23 | * | 28 | * |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
| @@ -91,7 +91,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { | @@ -91,7 +91,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { | ||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | private ProductSkuDO validateSku(Long skuId) { | 93 | private ProductSkuDO validateSku(Long skuId) { |
| 94 | - ProductSkuDO sku = productSkuService.getSku(skuId); | 94 | + ProductSkuDO sku = productSkuService.getSku(skuId, true); |
| 95 | if (sku == null) { | 95 | if (sku == null) { |
| 96 | throw exception(SKU_NOT_EXISTS); | 96 | throw exception(SKU_NOT_EXISTS); |
| 97 | } | 97 | } |
| @@ -99,7 +99,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { | @@ -99,7 +99,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { | ||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | private ProductSpuDO validateSpu(Long spuId) { | 101 | private ProductSpuDO validateSpu(Long spuId) { |
| 102 | - ProductSpuDO spu = productSpuService.getSpu(spuId); | 102 | + ProductSpuDO spu = productSpuService.getSpu(spuId, true); |
| 103 | if (null == spu) { | 103 | if (null == spu) { |
| 104 | throw exception(SPU_NOT_EXISTS); | 104 | throw exception(SPU_NOT_EXISTS); |
| 105 | } | 105 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| @@ -30,6 +30,15 @@ public interface ProductSkuService { | @@ -30,6 +30,15 @@ public interface ProductSkuService { | ||
| 30 | ProductSkuDO getSku(Long id); | 30 | ProductSkuDO getSku(Long id); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | + * 获得商品 SKU 信息 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + * @param includeDeleted 是否包含已删除的 | ||
| 37 | + * @return 商品 SKU 信息 | ||
| 38 | + */ | ||
| 39 | + ProductSkuDO getSku(Long id, boolean includeDeleted); | ||
| 40 | + | ||
| 41 | + /** | ||
| 33 | * 获得商品 SKU 列表 | 42 | * 获得商品 SKU 列表 |
| 34 | * | 43 | * |
| 35 | * @param ids 编号 | 44 | * @param ids 编号 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| @@ -69,6 +69,14 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -69,6 +69,14 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | @Override | 71 | @Override |
| 72 | + public ProductSkuDO getSku(Long id, boolean includeDeleted) { | ||
| 73 | + if (includeDeleted) { | ||
| 74 | + return productSkuMapper.selectByIdIncludeDeleted(id); | ||
| 75 | + } | ||
| 76 | + return getSku(id); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 72 | public List<ProductSkuDO> getSkuList(Collection<Long> ids) { | 80 | public List<ProductSkuDO> getSkuList(Collection<Long> ids) { |
| 73 | if (CollUtil.isEmpty(ids)) { | 81 | if (CollUtil.isEmpty(ids)) { |
| 74 | return ListUtil.empty(); | 82 | return ListUtil.empty(); |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| @@ -52,6 +52,15 @@ public interface ProductSpuService { | @@ -52,6 +52,15 @@ public interface ProductSpuService { | ||
| 52 | ProductSpuDO getSpu(Long id); | 52 | ProductSpuDO getSpu(Long id); |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | + * 获得商品 SPU | ||
| 56 | + * | ||
| 57 | + * @param id 编号 | ||
| 58 | + * @param includeDeleted 是否包含已删除的 | ||
| 59 | + * @return 商品 SPU | ||
| 60 | + */ | ||
| 61 | + ProductSpuDO getSpu(Long id, boolean includeDeleted); | ||
| 62 | + | ||
| 63 | + /** | ||
| 55 | * 获得商品 SPU 列表 | 64 | * 获得商品 SPU 列表 |
| 56 | * | 65 | * |
| 57 | * @param ids 编号数组 | 66 | * @param ids 编号数组 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -190,6 +190,14 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -190,6 +190,14 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | @Override | 192 | @Override |
| 193 | + public ProductSpuDO getSpu(Long id, boolean includeDeleted) { | ||
| 194 | + if (includeDeleted) { | ||
| 195 | + return productSpuMapper.selectByIdIncludeDeleted(id); | ||
| 196 | + } | ||
| 197 | + return getSpu(id); | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + @Override | ||
| 193 | public List<ProductSpuDO> getSpuList(Collection<Long> ids) { | 201 | public List<ProductSpuDO> getSpuList(Collection<Long> ids) { |
| 194 | if (CollUtil.isEmpty(ids)) { | 202 | if (CollUtil.isEmpty(ids)) { |
| 195 | return Collections.emptyList(); | 203 | return Collections.emptyList(); |