From c9c4d9454ae5da88d16202722d0131277a86680a Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 14 Dec 2025 12:51:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(goods):=20=E4=BC=98=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AF=A6=E6=83=85=E8=B4=AD=E4=B9=B0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入OrderRepository依赖以支持新的购买状态查询 - 替换原有的视频购买状态判断逻辑,使用更准确的checkUserBuyFaceItem方法 - 增加对模板ID的购买状态检查,提高判断准确性 - 简化价格查询前的条件判断流程 - 移除冗余的实体查询和复杂的嵌套判断逻辑 - 保持原有价格展示逻辑不变,确保前端显示一致 --- .../service/mobile/impl/GoodsServiceImpl.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java b/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java index f7a10b46..b1715a36 100644 --- a/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java @@ -6,6 +6,7 @@ import com.ycwl.basic.integration.common.manager.ScenicConfigManager; import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO; import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity; import com.ycwl.basic.repository.MemberRelationRepository; +import com.ycwl.basic.repository.OrderRepository; import com.ycwl.basic.utils.JacksonUtil; import com.ycwl.basic.biz.CouponBiz; import com.ycwl.basic.biz.OrderBiz; @@ -106,6 +107,8 @@ public class GoodsServiceImpl implements GoodsService { private MemberRelationRepository memberRelationRepository; @Autowired private PrinterMapper printerMapper; + @Autowired + private OrderRepository orderRepository; @Override public List sourceGoodsList(GoodsReqQuery query) { @@ -220,31 +223,25 @@ public class GoodsServiceImpl implements GoodsService { goodsDetailVO.setShare(true); goodsDetailVO.setPrice("未登录"); } else { - MemberVideoEntity entity = videoMapper.queryUserVideo(userId, videoId); - if (entity == null) { - goodsDetailVO.setIsBuy(0); - goodsDetailVO.setShare(true); - goodsDetailVO.setPrice("未登录"); - } else { - goodsDetailVO.setShare(false); - goodsDetailVO.setFaceId(entity.getFaceId()); - goodsDetailVO.setIsBuy(entity.getIsBuy()); - if (Integer.valueOf(0).equals(entity.getIsBuy())) { - IsBuyRespVO buy = orderBiz.isBuy(videoRespVO.getScenicId(), userId, entity.getFaceId(), 0, videoId); - if (!buy.isBuy()) { - PriceObj priceObj = orderBiz.queryPrice(videoRespVO.getScenicId(), 0, videoId); - if (priceObj.isFree()) { - goodsDetailVO.setIsBuy(1); - } else { - goodsDetailVO.setIsBuy(0); - goodsDetailVO.setPrice(priceObj.getPrice().toString()); - goodsDetailVO.setOrigPrice(priceObj.getPrice()); - goodsDetailVO.setSlashPrice(priceObj.getSlashPrice()); - } - } else { - goodsDetailVO.setIsBuy(1); - } + VideoEntity entity = videoMapper.getEntity(videoId); + TaskEntity taskEntity = videoTaskRepository.getTaskById(entity.getTaskId()); + goodsDetailVO.setFaceId(taskEntity.getFaceId()); + boolean isBuy = orderRepository.checkUserBuyFaceItem(userId, taskEntity.getFaceId(), 0, videoId); + if (!isBuy) { + isBuy = orderRepository.checkUserBuyFaceItem(userId, taskEntity.getFaceId(), -1, taskEntity.getTemplateId()); + } + if (!isBuy) { + PriceObj priceObj = orderBiz.queryPrice(videoRespVO.getScenicId(), 0, videoId); + if (priceObj.isFree()) { + goodsDetailVO.setIsBuy(1); + } else { + goodsDetailVO.setIsBuy(0); + goodsDetailVO.setPrice(priceObj.getPrice().toString()); + goodsDetailVO.setOrigPrice(priceObj.getPrice()); + goodsDetailVO.setSlashPrice(priceObj.getSlashPrice()); } + } else { + goodsDetailVO.setIsBuy(1); } } TaskEntity task = videoTaskRepository.getTaskById(videoRespVO.getTaskId());