diff --git a/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java b/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java index 4ec52000..10351136 100644 --- a/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java @@ -400,17 +400,20 @@ public class PrinterServiceImpl implements PrinterService { obj.setGoodsType(3); // 按照 sourceId 分类照片 - // sourceId > 0: 普通照片打印 (PHOTO_PRINT) + // sourceId > 0 且 source 表存在: 普通照片打印 (PHOTO_PRINT) + // sourceId > 0 且 source 表不存在: 拼图打印 (PUZZLE),归类为特效照片价格 // sourceId == null: 手机照片打印 (PHOTO_PRINT_MU) // sourceId == 0: 特效照片打印 (PHOTO_PRINT_FX) long normalCount = userPhotoList.stream() .filter(item -> Objects.nonNull(item.getQuantity()) && item.getSourceId() != null && item.getSourceId() > 0) + .filter(item -> sourceMapper.getById(item.getSourceId()) != null) .mapToInt(MemberPrintResp::getQuantity) .sum(); List normalAttrs = userPhotoList.stream() .filter(item -> Objects.nonNull(item.getQuantity()) && item.getSourceId() != null && item.getSourceId() > 0) + .filter(item -> sourceMapper.getById(item.getSourceId()) != null) .map(MemberPrintResp::getSourceId) .map(id -> { SourceEntity source = sourceRepository.getSource(id); @@ -436,7 +439,15 @@ public class PrinterServiceImpl implements PrinterService { .mapToInt(MemberPrintResp::getQuantity) .sum(); - long totalCount = normalCount + mobileCount + effectCount; + // 拼图:sourceId > 0 但 source 表中不存在(即来自 puzzle_generation_record 表) + long puzzleCount = userPhotoList.stream() + .filter(item -> Objects.nonNull(item.getQuantity()) + && item.getSourceId() != null && item.getSourceId() > 0) + .filter(item -> sourceMapper.getById(item.getSourceId()) == null) + .mapToInt(MemberPrintResp::getQuantity) + .sum(); + + long totalCount = normalCount + mobileCount + effectCount + puzzleCount; if (totalCount == 0) { // 如果没有照片,返回零价格 @@ -479,15 +490,15 @@ public class PrinterServiceImpl implements PrinterService { } // 添加特效照片打印商品项 (sourceId == 0) - if (effectCount > 0) { + if (effectCount > 0 || puzzleCount > 0) { ProductItem effectPhotoItem = new ProductItem(); effectPhotoItem.setProductType(ProductType.PHOTO_PRINT_FX); effectPhotoItem.setProductId(scenicId.toString()); - effectPhotoItem.setQuantity(Long.valueOf(effectCount).intValue()); + effectPhotoItem.setQuantity(Long.valueOf(effectCount + puzzleCount).intValue()); effectPhotoItem.setPurchaseCount(1); effectPhotoItem.setScenicId(scenicId.toString()); productItems.add(effectPhotoItem); - log.debug("特效照片打印数量: {}", effectCount); + log.debug("特效照片打印数量: {}", effectCount + puzzleCount); } request.setProducts(productItems); @@ -660,12 +671,14 @@ public class PrinterServiceImpl implements PrinterService { List userPhotoList = getUserPhotoList(memberId, scenicId, faceId); // 按照 sourceId 分类照片 - // sourceId > 0: 普通照片打印 (PHOTO_PRINT) + // sourceId > 0 且 source 表存在: 普通照片打印 (PHOTO_PRINT) + // sourceId > 0 且 source 表不存在: 拼图打印 (PUZZLE),归类为特效照片价格 // sourceId == null: 手机照片打印 (PHOTO_PRINT_MU) // sourceId == 0: 特效照片打印 (PHOTO_PRINT_FX) long normalCount = userPhotoList.stream() .filter(item -> Objects.nonNull(item.getQuantity()) && item.getSourceId() != null && item.getSourceId() > 0) + .filter(item -> sourceMapper.getById(item.getSourceId()) != null) .mapToInt(MemberPrintResp::getQuantity) .sum(); @@ -681,7 +694,14 @@ public class PrinterServiceImpl implements PrinterService { .mapToInt(MemberPrintResp::getQuantity) .sum(); - long totalCount = normalCount + mobileCount + effectCount; + // 拼图:sourceId > 0 但 source 表中不存在(即来自 puzzle_generation_record 表) + long puzzleCount = userPhotoList.stream() + .filter(item -> Objects.nonNull(item.getQuantity()) + && item.getSourceId() != null && item.getSourceId() > 0) + .filter(item -> sourceMapper.getById(item.getSourceId()) == null) + .mapToInt(MemberPrintResp::getQuantity) + .sum(); + long totalCount = normalCount + mobileCount + effectCount + puzzleCount; if (totalCount == 0) { throw new BaseException("没有可打印的照片"); @@ -741,15 +761,15 @@ public class PrinterServiceImpl implements PrinterService { } // 添加特效照片打印商品项 (sourceId == 0) - if (effectCount > 0) { + if (effectCount > 0 || puzzleCount > 0) { ProductItem effectPhotoItem = new ProductItem(); effectPhotoItem.setProductType(ProductType.PHOTO_PRINT_FX); effectPhotoItem.setProductId(scenicId.toString()); - effectPhotoItem.setQuantity(Long.valueOf(effectCount).intValue()); + effectPhotoItem.setQuantity(Long.valueOf(effectCount + puzzleCount).intValue()); effectPhotoItem.setPurchaseCount(1); effectPhotoItem.setScenicId(scenicId.toString()); productItems.add(effectPhotoItem); - log.debug("创建订单-特效照片打印数量: {}", effectCount); + log.debug("创建订单-特效照片打印数量: {}", effectCount + puzzleCount); } request.setProducts(productItems);