feat(printer): 优化自动发券逻辑并支持多种产品类型

- 移除了对source类型为3的检查逻辑
- 简化了自动发券的触发条件判断
- 新增对effectCount大于0时发放PHOTO_PRINT_FX类型优惠券的支持
- 保留了原有的异常处理机制确保不影响主流程
- 维持了mobileCount相关的业务逻辑不变
This commit is contained in:
2025-12-18 11:13:38 +08:00
parent 8dc0e993e1
commit cd4422eb23

View File

@@ -473,32 +473,30 @@ public class PrinterServiceImpl implements PrinterService {
request.setProducts(productItems); request.setProducts(productItems);
// 检查是否存在type=3的source记录,存在才自动发券 if (normalCount > 0) {
boolean hasType3Source = userPhotoList.stream() try {
.filter(item -> item.getSourceId() != null && item.getSourceId() > 0) autoCouponService.autoGrantCoupon(
.anyMatch(item -> { memberId,
try { faceId,
SourceEntity source = sourceMapper.getEntity(item.getSourceId()); scenicId,
return source != null && Integer.valueOf(3).equals(source.getType()); ProductType.PHOTO_PRINT
} catch (Exception e) { );
log.warn("查询source失败: sourceId={}, error={}", item.getSourceId(), e.getMessage()); } catch (Exception e) {
return false; log.warn("自动发券失败,不影响下单流程: memberId={}, faceId={}, scenicId={}, error={}",
} memberId, faceId, scenicId, e.getMessage());
}); }
}
if (hasType3Source) { if (effectCount > 0) {
if (normalCount > 0) { try {
try { autoCouponService.autoGrantCoupon(
autoCouponService.autoGrantCoupon( memberId,
memberId, faceId,
faceId, scenicId,
scenicId, ProductType.PHOTO_PRINT_FX
ProductType.PHOTO_PRINT );
); } catch (Exception e) {
} catch (Exception e) { log.warn("自动发券失败,不影响下单流程: memberId={}, faceId={}, scenicId={}, error={}",
log.warn("自动发券失败,不影响下单流程: memberId={}, faceId={}, scenicId={}, error={}", memberId, faceId, scenicId, e.getMessage());
memberId, faceId, scenicId, e.getMessage());
}
} }
} }
if (mobileCount > 0) { if (mobileCount > 0) {