You've already forked FrameTour-BE
fix(printer): 解决图片类型设置逻辑问题
- 添加source为空时的图片类型判断逻辑 - 当source为空时将图片类型设置为PUZZLE - 保持原有source不为空时的IPC类型设置逻辑 - 确保PHONE类型的设置逻辑不受影响
This commit is contained in:
@@ -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<String> 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<MemberPrintResp> 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);
|
||||
|
||||
Reference in New Issue
Block a user