From 20dd2005d3801eb8cedd47ccbdd1960d0d207e6e Mon Sep 17 00:00:00 2001 From: gaowdong Date: Wed, 11 Jun 2025 16:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=A2=9E=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E9=80=81=E6=96=B9=E5=BC=8F=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/constants/DeliveryTypeEnum.java | 20 +++++++++++++++++++ .../canteen/core/order/domain/OrderInfo.java | 12 ++++++++++- .../order/domain/param/OrderAddParam.java | 1 + .../service/impl/OrderInfoServiceImpl.java | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/DeliveryTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/DeliveryTypeEnum.java index 5bfa9b2..4f48cb2 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/DeliveryTypeEnum.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/DeliveryTypeEnum.java @@ -1,6 +1,8 @@ package com.bonus.canteen.core.order.constants; +import org.apache.commons.lang3.StringUtils; + public enum DeliveryTypeEnum { SELF_TAKE(1, "自取堂食"), MERCHANT(2, "商家配送"), @@ -26,4 +28,22 @@ public enum DeliveryTypeEnum { public String getDesc() { return this.desc; } + + public static boolean isValidKey(Integer key) { + for (DeliveryTypeEnum type : DeliveryTypeEnum.values()) { + if (type.getKey().equals(key)) { + return true; + } + } + return false; + } + + public static String getDescByKey(Integer key) { + for (DeliveryTypeEnum deliveryTypeEnum : DeliveryTypeEnum.values()) { + if (deliveryTypeEnum.getKey().equals(key)) { + return deliveryTypeEnum.getDesc(); + } + } + return StringUtils.EMPTY; + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java index c9fc656..79ca02b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java @@ -6,6 +6,7 @@ import com.bonus.canteen.core.order.domain.param.*; import com.bonus.canteen.core.pay.constants.PayChannelEnum; import com.bonus.canteen.core.pay.constants.PayStateEnum; import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.web.domain.BaseEntity; import com.bonus.common.security.utils.SecurityUtils; @@ -169,6 +170,8 @@ public class OrderInfo extends BaseEntity @Excel(name = "配送方式") private Integer deliveryType; + private String deliveryTypeName; + /** 评论状态 1 已评论 2 未评论 */ @Excel(name = "评论状态 1 已评论 2 未评论") private Integer commentState; @@ -220,7 +223,14 @@ public class OrderInfo extends BaseEntity orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); orderInfo.setDeliveryAmount(BigDecimal.ZERO); orderInfo.setPackingAmount(BigDecimal.ZERO); - orderInfo.setDeliveryType(DeliveryTypeEnum.SELF_TAKE.getKey()); + if(Objects.isNull(param.getDeliveryType())) { + orderInfo.setDeliveryType(DeliveryTypeEnum.SELF_TAKE.getKey()); + }else { + if(!DeliveryTypeEnum.isValidKey(param.getDeliveryType())) { + throw new ServiceException("配送方式参数错误"); + } + orderInfo.setDeliveryType(param.getDeliveryType()); + } orderInfo.setCommentState(CommentStateEnum.UN_COMMENT.getKey()); orderInfo.setOrderTime(DateUtils.getNowDate()); orderInfo.setPayableAmount(BigDecimal.ZERO); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderAddParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderAddParam.java index 4b4f70f..f5bbabc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderAddParam.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderAddParam.java @@ -35,6 +35,7 @@ public class OrderAddParam { private Integer sourceType; private Integer isOnline; private String remark; + private Integer deliveryType; @Valid @NotNull(message = "订单列表不能为空") private List orderList; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java index 21f0ebc..617180b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java @@ -16,6 +16,7 @@ import com.bonus.canteen.core.basic.service.IBasicStallService; import com.bonus.canteen.core.common.utils.MqUtil; import com.bonus.canteen.core.common.utils.RedisUtil; import com.bonus.canteen.core.order.business.OrderBusiness; +import com.bonus.canteen.core.order.constants.DeliveryTypeEnum; import com.bonus.canteen.core.order.constants.OrderDetailStateEnum; import com.bonus.canteen.core.order.constants.OrderRefundStateEnum; import com.bonus.canteen.core.order.constants.OrderStateEnum; @@ -96,6 +97,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService orderDetail.setOrderId(orderId); List orderDetailList = orderDetailService.selectOrderDetailList(orderDetail); orderInfo.setOrderDetailList(orderDetailList); + orderInfo.setDeliveryTypeName(DeliveryTypeEnum.getDescByKey(orderInfo.getDeliveryType())); return orderInfo; } @@ -129,6 +131,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService List orderDetailList = orderDetailService.selectOrderDetailList(orderDetail); order.setOrderDetailList(orderDetailList); order.setPhoneNumber(SM4EncryptUtils.sm4Decrypt(order.getPhoneNumber())); + order.setDeliveryTypeName(DeliveryTypeEnum.getDescByKey(order.getDeliveryType())); }); } return orderInfoList;