|
|
@@ -520,6 +520,7 @@ public class StoreProductDiscountServiceImpl implements StoreProductDiscountServ
|
|
|
StoreProductDiscountRule e = new StoreProductDiscountRule();
|
|
|
e.setStoreId(dto.getStoreId());
|
|
|
e.setProductId(dto.getProductId());
|
|
|
+ e.setRuleProductType(dto.getRuleProductType() == null ? 1 : dto.getRuleProductType());
|
|
|
e.setRuleName(dto.getRuleName().trim());
|
|
|
e.setDiscountType(dto.getDiscountType());
|
|
|
e.setDiscountRate(dto.getDiscountRate());
|
|
|
@@ -537,6 +538,18 @@ public class StoreProductDiscountServiceImpl implements StoreProductDiscountServ
|
|
|
if (dto == null) return "参数不能为空";
|
|
|
if (dto.getStoreId() == null) return "门店ID不能为空";
|
|
|
if (dto.getProductId() == null) return "菜品ID不能为空";
|
|
|
+ // 规则商品类型校验与默认值
|
|
|
+ Integer rpt = dto.getRuleProductType() == null ? 1 : dto.getRuleProductType();
|
|
|
+ if (rpt != 1 && rpt != 2) return "规则商品类型不合法,仅支持1或2";
|
|
|
+ dto.setRuleProductType(rpt);
|
|
|
+ // 基于类型校验 productId 是否存在
|
|
|
+ if (rpt == 1) {
|
|
|
+ StoreCuisine cuisine = storeCuisineService.getById(dto.getProductId());
|
|
|
+ if (cuisine == null || !dto.getStoreId().equals(cuisine.getStoreId())) return "美食不存在或不属于该门店";
|
|
|
+ } else {
|
|
|
+ StorePrice price = storePriceService.getById(dto.getProductId());
|
|
|
+ if (price == null || !dto.getStoreId().equals(price.getStoreId())) return "通用价目不存在或不属于该门店";
|
|
|
+ }
|
|
|
if (!StringUtils.hasText(dto.getRuleName())) return "规则名称不能为空";
|
|
|
if (!StringUtils.hasText(dto.getDiscountType())) return "优惠类型不能为空";
|
|
|
if (!TYPE_FREE.equals(dto.getDiscountType()) && !TYPE_DISCOUNT.equals(dto.getDiscountType())) return "优惠类型不合法";
|