You've already forked FrameTour-BE
feat(print): 支持多种照片打印类型的价格计算
- 新增手机照片打印(PHOTO_PRINT_MU)和特效照片打印(PHOTO_PRINT_FX)枚举类型 - 在价格计算服务中增加isPrintProduct方法统一判断打印类商品 - 修改订单服务跳过打印类商品重复购买检查逻辑 -优化打印机服务根据sourceId分类统计不同照片类型数量 - 分别计算普通、手机、特效照片打印的价格和数量- 更新价格计算逻辑以支持多种打印类型商品项
This commit is contained in:
@@ -14,6 +14,8 @@ public enum ProductType {
|
||||
RECORDING_SET("RECORDING_SET", "录像集"),
|
||||
PHOTO_SET("PHOTO_SET", "照相集"),
|
||||
PHOTO_PRINT("PHOTO_PRINT", "照片打印"),
|
||||
PHOTO_PRINT_MU("PHOTO_PRINT_MU", "手机照片打印"),
|
||||
PHOTO_PRINT_FX("PHOTO_PRINT_FX", "特效照片打印"),
|
||||
MACHINE_PRINT("MACHINE_PRINT", "一体机打印");
|
||||
|
||||
private final String code;
|
||||
|
||||
@@ -29,7 +29,18 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
private final IPriceBundleService bundleService;
|
||||
private final IDiscountDetectionService discountDetectionService;
|
||||
private final IVoucherService voucherService;
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否为打印类商品
|
||||
* 打印类商品的价格计算方式为:单价 × 数量
|
||||
*/
|
||||
private boolean isPrintProduct(ProductType productType) {
|
||||
return productType == ProductType.PHOTO_PRINT
|
||||
|| productType == ProductType.PHOTO_PRINT_MU
|
||||
|| productType == ProductType.PHOTO_PRINT_FX
|
||||
|| productType == ProductType.MACHINE_PRINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PriceCalculationResult calculatePrice(PriceCalculationRequest request) {
|
||||
if (request.getProducts() == null || request.getProducts().isEmpty()) {
|
||||
@@ -190,7 +201,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
try {
|
||||
PriceProductConfig baseConfig = productConfigService.getProductConfig(productType.getCode(), productId);
|
||||
if (baseConfig != null) {
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
if (isPrintProduct(productType)) {
|
||||
return baseConfig.getBasePrice().multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
} else {
|
||||
return baseConfig.getBasePrice();
|
||||
@@ -205,7 +216,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
try {
|
||||
PriceProductConfig defaultConfig = productConfigService.getProductConfig(productType.getCode(), "default");
|
||||
if (defaultConfig != null) {
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
if (isPrintProduct(productType)) {
|
||||
return defaultConfig.getBasePrice().multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
} else {
|
||||
return defaultConfig.getBasePrice();
|
||||
@@ -219,7 +230,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
List<PriceProductConfig> configs = productConfigService.getProductConfig(productType.getCode());
|
||||
if (!configs.isEmpty()) {
|
||||
PriceProductConfig baseConfig = configs.get(0); // 使用第一个配置作为默认
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
if (isPrintProduct(productType)) {
|
||||
return baseConfig.getBasePrice().multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
} else {
|
||||
return baseConfig.getBasePrice();
|
||||
@@ -252,8 +263,8 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
if (baseConfig != null) {
|
||||
actualPrice = baseConfig.getBasePrice();
|
||||
originalPrice = baseConfig.getOriginalPrice();
|
||||
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
|
||||
if (isPrintProduct(productType)) {
|
||||
actualPrice = actualPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
if (originalPrice != null) {
|
||||
originalPrice = originalPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
@@ -272,8 +283,8 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
if (defaultConfig != null) {
|
||||
actualPrice = defaultConfig.getBasePrice();
|
||||
originalPrice = defaultConfig.getOriginalPrice();
|
||||
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
|
||||
if (isPrintProduct(productType)) {
|
||||
actualPrice = actualPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
if (originalPrice != null) {
|
||||
originalPrice = originalPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
@@ -291,8 +302,8 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
PriceProductConfig baseConfig = configs.getFirst(); // 使用第一个配置作为默认
|
||||
actualPrice = baseConfig.getBasePrice();
|
||||
originalPrice = baseConfig.getOriginalPrice();
|
||||
|
||||
if (productType == ProductType.PHOTO_PRINT || productType == ProductType.MACHINE_PRINT) {
|
||||
|
||||
if (isPrintProduct(productType)) {
|
||||
actualPrice = actualPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
if (originalPrice != null) {
|
||||
originalPrice = originalPrice.multiply(BigDecimal.valueOf(product.getQuantity()));
|
||||
|
||||
Reference in New Issue
Block a user