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