购物车

This commit is contained in:
gaowdong 2025-04-14 11:33:05 +08:00
parent 9cba426a01
commit 09f58bf26a
4 changed files with 34 additions and 9 deletions

View File

@ -28,4 +28,12 @@ public enum OrderDetailTypeEnum {
return this.desc; return this.desc;
} }
public static boolean isValidKey(Integer key) {
for (OrderDetailTypeEnum type : OrderDetailTypeEnum.values()) {
if (type.getKey().equals(key)) {
return true;
}
}
return false;
}
} }

View File

@ -21,4 +21,13 @@ public enum OrderTypeEnum {
public String getDesc() { public String getDesc() {
return this.desc; return this.desc;
} }
public static boolean isValidKey(Integer key) {
for (OrderTypeEnum type : OrderTypeEnum.values()) {
if (type.getKey().equals(key)) {
return true;
}
}
return false;
}
} }

View File

@ -51,15 +51,15 @@ public class OrderShoppingCart extends BaseEntity
/** 数量/重量 */ /** 数量/重量 */
@Excel(name = "数量/重量") @Excel(name = "数量/重量")
private Long quantity; private Integer quantity;
/** 订单类型 */ /** 订单类型 */
@Excel(name = "订单类型") @Excel(name = "订单类型")
private Long orderType; private Integer orderType;
/** 明细类别 1 菜品 2 套餐 3 商品 4 按键 5 补扣 6 报餐 */ /** 明细类别 1 菜品 2 套餐 3 商品 4 按键 5 补扣 6 报餐 */
@Excel(name = "明细类别 1 菜品 2 套餐 3 商品 4 按键 5 补扣 6 报餐") @Excel(name = "明细类别 1 菜品 2 套餐 3 商品 4 按键 5 补扣 6 报餐")
private Long detailType; private Integer detailType;
/** 订单日期 yyyy-MM-dd */ /** 订单日期 yyyy-MM-dd */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ -150,32 +150,32 @@ public class OrderShoppingCart extends BaseEntity
return goodsImgUrl; return goodsImgUrl;
} }
public void setQuantity(Long quantity) public void setQuantity(Integer quantity)
{ {
this.quantity = quantity; this.quantity = quantity;
} }
public Long getQuantity() public Integer getQuantity()
{ {
return quantity; return quantity;
} }
public void setOrderType(Long orderType) public void setOrderType(Integer orderType)
{ {
this.orderType = orderType; this.orderType = orderType;
} }
public Long getOrderType() public Integer getOrderType()
{ {
return orderType; return orderType;
} }
public void setDetailType(Long detailType) public void setDetailType(Integer detailType)
{ {
this.detailType = detailType; this.detailType = detailType;
} }
public Long getDetailType() public Integer getDetailType()
{ {
return detailType; return detailType;
} }

View File

@ -1,5 +1,7 @@
package com.bonus.canteen.core.order.utils; package com.bonus.canteen.core.order.utils;
import com.bonus.canteen.core.order.constants.OrderDetailTypeEnum;
import com.bonus.canteen.core.order.constants.OrderTypeEnum;
import com.bonus.canteen.core.order.domain.OrderShoppingCart; import com.bonus.canteen.core.order.domain.OrderShoppingCart;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
@ -87,6 +89,9 @@ public class ShoppingCartParamChecker {
if (orderShoppingCart.getDetailType() == null) { if (orderShoppingCart.getDetailType() == null) {
throw new ServiceException("订单明细类别为空"); throw new ServiceException("订单明细类别为空");
} }
if(OrderDetailTypeEnum.isValidKey(orderShoppingCart.getDetailType())) {
throw new ServiceException("订单明细类别错误");
}
} }
private static void checkMenuId(OrderShoppingCart orderShoppingCart) { private static void checkMenuId(OrderShoppingCart orderShoppingCart) {
@ -98,6 +103,9 @@ public class ShoppingCartParamChecker {
if (orderShoppingCart.getOrderType() == null) { if (orderShoppingCart.getOrderType() == null) {
throw new ServiceException("订单类型为空"); throw new ServiceException("订单类型为空");
} }
if(OrderTypeEnum.isValidKey(orderShoppingCart.getOrderType())) {
throw new ServiceException("订单类型错误");
}
} }
} }