diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java index 1e568da..1febf55 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java @@ -29,19 +29,18 @@ public class OrderBusiness { private IMenuRecipeDishesService menuRecipeDishesService; @Transactional(rollbackFor = Exception.class) - public List orderPlaceHandler(OrderAddParam orderAddParam) { - AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); - accInfoService.checkAccStatus(accInfoVO); - List orderInfoList = new OrderInfo().of(orderAddParam); - if(CollUtil.isEmpty(orderInfoList) || CollUtil.isEmpty(orderInfoList.get(0).getOrderDetailList())) { + public List orderPlaceHandler(List orderInfoList) { + if(CollUtil.isEmpty(orderInfoList)) { throw new ServiceException("订单明细不能为空"); } orderInfoMapper.batchInsertOrderInfo(orderInfoList); - orderInfoList.forEach(orderInfo -> { - List orderDetailList = orderInfo.getOrderDetailList(); - orderDetailService.batchInsertOrderDetail(orderDetailList); - reduceMenuDishSupplyNum(orderDetailList); - }); + if(CollUtil.isNotEmpty(orderInfoList.get(0).getOrderDetailList())) { + orderInfoList.forEach(orderInfo -> { + List orderDetailList = orderInfo.getOrderDetailList(); + orderDetailService.batchInsertOrderDetail(orderDetailList); + reduceMenuDishSupplyNum(orderDetailList); + }); + } return orderInfoList; } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/OrderTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/OrderTypeEnum.java index 476c185..c6603b1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/OrderTypeEnum.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/constants/OrderTypeEnum.java @@ -3,8 +3,23 @@ package com.bonus.canteen.core.order.constants; public enum OrderTypeEnum { CURR_MEAL(1, "当餐点餐"), RESERVE_MEAL(2, "预订餐"), - ANDROID(3, "线下消费"), - DEDUCT(4, "补扣"); + BOOK_MEAL(3, "自定义报餐"), + SHOP(4, "商城"), + RESERVE_SHOP(5, "预订商城"), + ROOM(6, "包间"), + TABLE(7, "餐桌"), + BUS(8, "班车"), + BOOK_MEAL_3DAY(9, "3天报餐"), + BOOK_MEAL_7DAY(10, "7天报餐"), + ANDROID(11, "线下消费"), + BUFFET(12, "自助餐"), + MOBILE_SCAN(13, "到店扫码"), + MOBILE_SCAN_SHOP(14, "到店扫码"), + MOBILE_TAKEAWAY(15, "美团外卖"), + MOBILE_TAKEAWAY_STORE(16, "美团到店"), + DEDUCT(21, "补扣"), + OUT(22, "外部订单"), + OTHER(99, "其他"); private final Integer key; private final String desc; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/controller/OrderInfoController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/controller/OrderInfoController.java index 366e73b..c3da82a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/controller/OrderInfoController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/controller/OrderInfoController.java @@ -6,6 +6,8 @@ import java.util.Objects; import com.bonus.canteen.core.order.domain.OrderInfo; import com.bonus.canteen.core.order.domain.param.OrderAddParam; import com.bonus.canteen.core.order.domain.param.OrderInfoAddParam; +import com.bonus.canteen.core.order.domain.param.OrderQueryParam; +import com.bonus.canteen.core.order.domain.param.ShopOrderAddParam; import com.bonus.canteen.core.order.service.IOrderInfoService; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.poi.ExcelUtil; @@ -14,6 +16,7 @@ import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.common.log.annotation.SysLog; import com.bonus.common.log.enums.OperaType; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -40,9 +43,22 @@ public class OrderInfoController extends BaseController */ @PostMapping("/list") @ResponseBody - public TableDataInfo list(OrderInfo orderInfo) + public TableDataInfo list(OrderQueryParam orderQueryParam) { startPage(); + OrderInfo orderInfo = new OrderInfo(); + BeanUtils.copyProperties(orderQueryParam, orderInfo); + List list = orderInfoService.selectOrderInfoList(orderInfo); + return getDataTable(list); + } + + @PostMapping("/device/list") + @ResponseBody + public TableDataInfo deviceList(OrderQueryParam orderQueryParam) + { + startPage(); + OrderInfo orderInfo = new OrderInfo(); + BeanUtils.copyProperties(orderQueryParam, orderInfo); List list = orderInfoService.selectOrderInfoList(orderInfo); return getDataTable(list); } @@ -52,7 +68,7 @@ public class OrderInfoController extends BaseController */ @PostMapping("/{orderId}") @ResponseBody - public AjaxResult list(@PathVariable("orderId") Long orderId) + public AjaxResult get(@PathVariable("orderId") Long orderId) { if(Objects.isNull(orderId)) { throw new ServiceException("订单ID不能为空"); @@ -61,6 +77,17 @@ public class OrderInfoController extends BaseController return AjaxResult.success(orderInfo); } + @PostMapping("/device/{deviceOrderId}") + @ResponseBody + public AjaxResult deviceGet(@PathVariable("deviceOrderId") String deviceOrderId) + { + if(Objects.isNull(deviceOrderId)) { + throw new ServiceException("订单ID不能为空"); + } + OrderInfo orderInfo = orderInfoService.selectOrderInfoBydeviceOrderId(deviceOrderId); + return AjaxResult.success(orderInfo); + } + /** * 导出订单列表 */ @@ -82,7 +109,15 @@ public class OrderInfoController extends BaseController @ResponseBody public AjaxResult addSave(OrderAddParam orderAddParam) { - return toAjax(orderInfoService.insertOrderInfo(orderAddParam)); + return toAjax(orderInfoService.insertCanteenOrderInfo(orderAddParam)); + } + + @SysLog(title = "下单", module = "订单", businessType = OperaType.INSERT) + @PostMapping("/shop/add") + @ResponseBody + public AjaxResult deviceAddSave(ShopOrderAddParam orderAddParam) + { + return toAjax(orderInfoService.insertShopOrderInfo(orderAddParam)); } @SysLog(title = "退单", module = "订单", businessType = OperaType.UPDATE) @@ -94,6 +129,19 @@ public class OrderInfoController extends BaseController return AjaxResult.success(); } + @SysLog(title = "退单", module = "订单", businessType = OperaType.UPDATE) + @PostMapping("/device/refund/{deviceOrderId}") + @ResponseBody + public AjaxResult deviceRefund(@PathVariable("deviceOrderId") String deviceOrderId) + { + if(Objects.isNull(deviceOrderId)) { + throw new ServiceException("订单ID不能为空"); + } + OrderInfo orderInfo = orderInfoService.selectOrderInfoBydeviceOrderId(deviceOrderId); + orderInfoService.refund(orderInfo.getOrderId()); + return AjaxResult.success(); + } + @SysLog(title = "付款", module = "订单", businessType = OperaType.INSERT) @PostMapping("/pay/{orderId}") @ResponseBody @@ -102,7 +150,18 @@ public class OrderInfoController extends BaseController orderInfoService.pay(orderId); return AjaxResult.success(); } - + @SysLog(title = "付款", module = "订单", businessType = OperaType.INSERT) + @PostMapping("/device/pay/{deviceOrderId}") + @ResponseBody + public AjaxResult devicePay(@PathVariable("deviceOrderId") String deviceOrderId) + { + if(Objects.isNull(deviceOrderId)) { + throw new ServiceException("订单ID不能为空"); + } + OrderInfo orderInfo = orderInfoService.selectOrderInfoBydeviceOrderId(deviceOrderId); + orderInfoService.pay(orderInfo.getOrderId()); + return AjaxResult.success(); + } /** * 修改订单 */ 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 f2a19c8..4b77434 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 @@ -7,6 +7,7 @@ import java.util.List; import java.util.Objects; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import com.bonus.canteen.core.order.constants.*; import com.bonus.canteen.core.order.domain.param.OrderAddParam; import com.bonus.canteen.core.order.domain.param.OrderDetailInfoAddParam; @@ -20,6 +21,8 @@ import com.bonus.common.houqin.utils.id.Id; import com.bonus.common.security.utils.SecurityUtils; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; /** * 订单对象 order_info @@ -176,20 +179,26 @@ public class OrderInfo extends BaseEntity for(OrderInfoAddParam orderInfoAddParam : orderList) { OrderInfo orderInfo = new OrderInfo(); orderInfo.setOrderId(Id.next()); - orderInfo.setDeviceOrderId(orderInfoAddParam.getDeviceOrderId()); - orderInfo.setDeviceSn(orderInfoAddParam.getDeviceSn()); - orderInfo.setDeviceNum(orderInfoAddParam.getDeviceNum()); + orderInfo.setDeviceOrderId(StringUtils.defaultString(orderInfoAddParam.getDeviceOrderId(), StringUtils.EMPTY)); + orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); + orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setUserId(param.getUserId()); orderInfo.setPayableAmount(param.getPayableAmount()); orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); + orderInfo.setCreateTime(DateUtils.getNowDate()); + orderInfo.setUpdateBy(SecurityUtils.getUsername()); + orderInfo.setUpdateTime(DateUtils.getNowDate()); orderInfo.setPayType(param.getPayType()); - orderInfo.setCanteenId(orderInfoAddParam.getCanteenId()); - orderInfo.setStallId(orderInfoAddParam.getStallId()); + Long canteenId = orderInfoAddParam.getCanteenId(); + orderInfo.setCanteenId(Objects.isNull(canteenId) ? -1 : canteenId); + Long stallId = orderInfoAddParam.getStallId(); + orderInfo.setStallId(Objects.isNull(stallId) ? -1 : stallId); orderInfo.setOrderDate(orderInfoAddParam.getOrderDate()); orderInfo.setOrderType(orderInfoAddParam.getOrderType()); - orderInfo.setMealtimeType(orderInfoAddParam.getMealtimeType()); + Integer mealtimeType = orderInfoAddParam.getMealtimeType(); + orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1 : mealtimeType); orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName()); orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline()); orderInfo.setOrderState(OrderStateEnum.PLACE.getKey()); @@ -206,6 +215,8 @@ public class OrderInfo extends BaseEntity orderInfo.setPayableAmount(BigDecimal.ZERO); orderInfo.setDiscountsAmount(BigDecimal.ZERO); orderInfo.setRealAmount(BigDecimal.ZERO); + orderInfo.setExternalPayAmount(BigDecimal.ZERO); + orderInfo.setRefundAmount(BigDecimal.ZERO); List orderDetailInfoAddParams =orderInfoAddParam.getOrderDetailList(); if(CollUtil.isNotEmpty(orderDetailInfoAddParams)) { List orderDetailList = CollUtil.newArrayList(); @@ -217,9 +228,9 @@ public class OrderInfo extends BaseEntity orderInfo.setPayableAmount(orderInfo.getPayableAmount().add(saleTotalAmount)); orderInfo.setDiscountsAmount(orderInfo.getDiscountsAmount().add(discountTotalAmount)); orderInfo.setRealAmount(orderInfo.getRealAmount().add(orderDetail.getTotalAmount())); + orderInfo.setAccountPayAmount(orderInfo.getRealAmount().add(orderDetail.getTotalAmount())); } } - } } return orderInfoList; @@ -233,17 +244,25 @@ public class OrderInfo extends BaseEntity orderDetail.setGoodsName(orderDetailInfoAddParam.getGoodsName()); orderDetail.setGoodsImgUrl(orderDetailInfoAddParam.getGoodsImgUrl()); orderDetail.setMenuDetailId(orderDetailInfoAddParam.getMenuDetailId()); - orderDetail.setSalesMode(orderDetailInfoAddParam.getSalesMode()); orderDetail.setSalePrice(orderDetailInfoAddParam.getSalePrice()); orderDetail.setDiscountPrice(orderDetailInfoAddParam.getDiscountPrice()); orderDetail.setFinalPrice(orderDetailInfoAddParam.getFinalPrice()); orderDetail.setQuantity(orderDetailInfoAddParam.getQuantity()); + orderDetail.setSalesMode(orderDetailInfoAddParam.getSalesMode()); orderDetail.setDetailType(orderDetailInfoAddParam.getDetailType()); - orderDetail.setDetailState(OrderDetailStateEnum.NORMAL.getKey()); - orderDetail.setCreateBy(SecurityUtils.getUsername()); BigDecimal totalAmount = orderDetail.getFinalPrice().multiply(new BigDecimal(orderDetail.getQuantity())); orderDetail.setTotalAmount(totalAmount); orderDetail.setCalcTotalAmount(totalAmount); + orderDetail.setRealAmount(totalAmount); + orderDetail.setDetailState(OrderDetailStateEnum.NORMAL.getKey()); + orderDetail.setRefundAmount(BigDecimal.ZERO); + orderDetail.setRefundNum(0); + orderDetail.setDeviceSn(StringUtils.defaultString(orderInfo.getDeviceSn(), StringUtils.EMPTY)); + orderDetail.setSerialNum(StringUtils.EMPTY); + orderDetail.setCreateBy(SecurityUtils.getUsername()); + orderDetail.setCreateTime(DateUtils.getNowDate()); + orderDetail.setUpdateBy(SecurityUtils.getUsername()); + orderDetail.setUpdateTime(DateUtils.getNowDate()); return orderDetail; } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderQueryParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderQueryParam.java new file mode 100644 index 0000000..48b16eb --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/OrderQueryParam.java @@ -0,0 +1,101 @@ +package com.bonus.canteen.core.order.domain.param; + +import com.bonus.common.core.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; + +/** + * 订单对象 order_info + * + * @author ruoyi + * @date 2025-04-14 + */ + +@Data +public class OrderQueryParam +{ + private static final long serialVersionUID = 1L; + + /** 订单号 */ + private Long orderId; + + /** 设备订单号 */ + private String deviceOrderId; + + /** 设备sn */ + private String deviceSn; + + /** 设备编号 */ + private String deviceNum; + + /** 人员编号 */ + @Excel(name = "人员编号") + private Long userId; + + /** 身份验证方式 1 刷卡 2 刷脸 3 扫码 */ + private Integer identityVerification; + + /** 订单来源类型 */ + @Excel(name = "订单来源类型") + private Integer sourceType; + + /** 是否在线订单 1 是 2 否 */ + private Integer isOnline; + + /** 食堂id */ + @Excel(name = "食堂id") + private Long canteenId; + + /** 档口id */ + private Long stallId; + + /** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */ + private Integer mealtimeType; + + /** 订单日期 yyyy-MM-dd */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date orderDate; + + /** 下单时间 yyyy-MM-dd HH:mm:ss */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @Excel(name = "下单时间 yyyy-MM-dd HH:mm:ss", width = 30, dateFormat = "yyyy-MM-dd") + private Date orderTime; + + /** 订单类型 1 当餐 2 预订餐 3 报餐 4 商城 11 线下消费 12 自助餐 21 补扣 22 外部订单 */ + @Excel(name = "订单类型 1 当餐 2 预订餐 3 报餐 4 商城 11 线下消费 12 自助餐 21 补扣 22 外部订单") + private Integer orderType; + + /** 订单状态 1 已下单 2 已完成 3 已取消 */ + @Excel(name = "订单状态 1 已下单 2 已完成 3 已取消") + private Integer orderState; + + /** 订单退款状态 1 未退单 2 已退单 3 部分退单 */ + @Excel(name = "订单退款状态 1 未退单 2 已退单 3 部分退单") + private Integer orderRefundState; + + /** 扣款类型 1 下单扣款 2 核销扣款 */ + @Excel(name = "扣款类型 1 下单扣款 2 核销扣款") + private Integer deductionType; + + /** 支付时间 yyyy-MM-dd HH:mm:ss */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date payTime; + + /** 支付方式 */ + @Excel(name = "支付方式") + private Integer payType; + + /** 支付渠道 */ + @Excel(name = "支付渠道") + private Integer payChannel; + + /** 支付状态 1 待支付 2 支付中 3 支付成功 4 支付失败 5 支付取消 6 部分支付 */ + @Excel(name = "支付状态 1 待支付 2 支付中 3 支付成功 4 支付失败 5 支付取消 6 部分支付") + private Integer payState; + + /** 评论状态 1 已评论 2 未评论 */ + @Excel(name = "评论状态 1 已评论 2 未评论") + private Integer commentState; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java new file mode 100644 index 0000000..ecddcc6 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java @@ -0,0 +1,103 @@ +package com.bonus.canteen.core.order.domain.param; + +import cn.hutool.core.collection.CollUtil; +import com.bonus.canteen.core.order.constants.*; +import com.bonus.canteen.core.order.domain.OrderDetail; +import com.bonus.canteen.core.order.domain.OrderInfo; +import com.bonus.canteen.core.pay.constants.PayChannelEnum; +import com.bonus.canteen.core.pay.constants.PayStateEnum; +import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.houqin.utils.id.Id; +import com.bonus.common.security.utils.SecurityUtils; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +@Data +public class ShopOrderAddParam { + private @NotNull( + message = "订单实付金额不能为空" + ) @DecimalMin( + value = "0", + message = "订单实付金额不能小于0" + ) BigDecimal realAmount; + private @NotNull( + message = "订单应付金额不能为空" + ) @DecimalMin( + value = "0", + message = "订单应付金额不能小于0" + ) BigDecimal payableAmount; + @NotNull(message = "用户ID不能为空") + private Long userId; + @NotNull(message = "下单日期不能为空") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date placeDate; + @NotNull(message = "支付类型不能为空") + private Integer payType; + @NotNull(message = "订单来源不能为空") + private Integer sourceType; + private Integer isOnline; + List orderList; + + public List of(ShopOrderAddParam param) { + List orderInfoList = new ArrayList<>(); + List orderList = param.getOrderList(); + if(CollUtil.isNotEmpty(orderList)) { + for(OrderInfoAddParam orderInfoAddParam : orderList) { + OrderInfo orderInfo = new OrderInfo(); + orderInfo.setOrderId(Id.next()); + orderInfo.setDeviceOrderId(StringUtils.defaultString(orderInfoAddParam.getDeviceOrderId(), StringUtils.EMPTY)); + orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); + orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); + orderInfo.setUserId(param.getUserId()); + orderInfo.setPayableAmount(param.getPayableAmount()); + orderInfo.setRealAmount(param.getRealAmount()); + orderInfo.setSourceType(param.getSourceType()); + orderInfo.setCreateBy(SecurityUtils.getUsername()); + orderInfo.setCreateTime(DateUtils.getNowDate()); + orderInfo.setUpdateBy(SecurityUtils.getUsername()); + orderInfo.setUpdateTime(DateUtils.getNowDate()); + orderInfo.setPayType(param.getPayType()); + Long canteenId = orderInfoAddParam.getCanteenId(); + orderInfo.setCanteenId(Objects.isNull(canteenId) ? -1 : canteenId); + Long stallId = orderInfoAddParam.getStallId(); + orderInfo.setStallId(Objects.isNull(stallId) ? -1 : stallId); + orderInfo.setOrderDate(orderInfoAddParam.getOrderDate()); + orderInfo.setOrderType(orderInfoAddParam.getOrderType()); + Integer mealtimeType = orderInfoAddParam.getMealtimeType(); + orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1 : mealtimeType); + orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName()); + orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline()); + orderInfo.setOrderState(OrderStateEnum.PLACE.getKey()); + orderInfo.setOrderRefundState(OrderRefundStateEnum.UN_REFUND.getKey()); + orderInfo.setDeductionType(DeductionTypeEnum.PAY_PLACE.getKey()); + orderInfo.setPayType(param.getPayType()); + orderInfo.setPayChannel(PayChannelEnum.ACC.getKey()); + orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); + orderInfo.setDeliveryAmount(BigDecimal.ZERO); + orderInfo.setPackingAmount(BigDecimal.ZERO); + orderInfo.setDeliveryType(DeliveryTypeEnum.SELF_TAKE.getKey()); + orderInfo.setCommentState(CommentStateEnum.UN_COMMENT.getKey()); + orderInfo.setOrderTime(DateUtils.getNowDate()); + orderInfo.setPayableAmount(BigDecimal.ZERO); + orderInfo.setDiscountsAmount(BigDecimal.ZERO); + orderInfo.setRealAmount(BigDecimal.ZERO); + orderInfo.setExternalPayAmount(BigDecimal.ZERO); + orderInfo.setRefundAmount(BigDecimal.ZERO); + orderInfo.setPayableAmount(param.getRealAmount()); + orderInfo.setDiscountsAmount(BigDecimal.ZERO); + orderInfo.setRealAmount(param.getRealAmount()); + orderInfo.setAccountPayAmount(param.getRealAmount()); + } + } + return orderInfoList; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderInfoAddParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderInfoAddParam.java new file mode 100644 index 0000000..b2491cf --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderInfoAddParam.java @@ -0,0 +1,17 @@ +package com.bonus.canteen.core.order.domain.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +@Data +public class ShopOrderInfoAddParam { + @NotNull(message = "订单类型不能为空") + private Integer orderType; + private String deviceOrderId; + private String deviceSn; + private String deviceNum; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java index 7a536a1..5330504 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java @@ -21,6 +21,7 @@ public interface OrderInfoMapper * @return 订单 */ public OrderInfo selectOrderInfoByOrderId(Long orderId); + public OrderInfo selectOrderInfoByDeviceOrderId(String orderId); /** * 查询订单列表 diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/IOrderInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/IOrderInfoService.java index bdf44c9..f44b62a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/IOrderInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/IOrderInfoService.java @@ -3,6 +3,7 @@ package com.bonus.canteen.core.order.service; import com.bonus.canteen.core.order.domain.OrderInfo; import com.bonus.canteen.core.order.domain.param.OrderAddParam; import com.bonus.canteen.core.order.domain.param.OrderInfoAddParam; +import com.bonus.canteen.core.order.domain.param.ShopOrderAddParam; import java.util.List; @@ -22,6 +23,8 @@ public interface IOrderInfoService */ public OrderInfo selectOrderInfoByOrderId(Long orderId); + public OrderInfo selectOrderInfoBydeviceOrderId(String deviceOrderId); + /** * 查询订单列表 * @@ -33,10 +36,12 @@ public interface IOrderInfoService /** * 新增订单 * - * @param orderInfo 订单 + * @param * @return 结果 */ - public int insertOrderInfo(OrderAddParam orderAddParam); + public int insertCanteenOrderInfo(OrderAddParam orderAddParam); + + public int insertShopOrderInfo(ShopOrderAddParam orderAddParam); /** * 修改订单 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 326a43c..9a316a9 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 @@ -22,7 +22,7 @@ import com.bonus.canteen.core.order.domain.OrderInfo; import com.bonus.canteen.core.order.domain.OrderPayDTO; import com.bonus.canteen.core.order.domain.OrderPayResultDTO; import com.bonus.canteen.core.order.domain.param.OrderAddParam; -import com.bonus.canteen.core.order.domain.param.OrderInfoAddParam; +import com.bonus.canteen.core.order.domain.param.ShopOrderAddParam; import com.bonus.canteen.core.order.mapper.OrderInfoMapper; import com.bonus.canteen.core.order.service.IOrderDetailService; import com.bonus.canteen.core.order.service.IOrderInfoService; @@ -82,6 +82,12 @@ public class OrderInfoServiceImpl implements IOrderInfoService return orderInfoMapper.selectOrderInfoByOrderId(orderId); } + @Override + public OrderInfo selectOrderInfoBydeviceOrderId(String deviceOrderId) + { + return orderInfoMapper.selectOrderInfoByDeviceOrderId(deviceOrderId); + } + /** * 查询订单列表 * @@ -94,24 +100,38 @@ public class OrderInfoServiceImpl implements IOrderInfoService return orderInfoMapper.selectOrderInfoList(orderInfo); } - /** - * 新增订单 - * - * @param orderAddParam 订单 - * @return 结果 - */ @Override - public int insertOrderInfo(OrderAddParam orderAddParam) { - log.info("[下单]入参:{}", JacksonUtil.writeValueAsString(orderAddParam)); - String paramMd5 = DigestUtil.md5Hex(JacksonUtil.writeValueAsString(orderAddParam)); + public int insertCanteenOrderInfo(OrderAddParam orderAddParam) { + log.info("[食堂下单]入参:{}", JacksonUtil.writeValueAsString(orderAddParam)); + String paramMd5 = "sc:canteen_order_"+DigestUtil.md5Hex(JacksonUtil.writeValueAsString(orderAddParam)); if (!RedisUtil.setNx(paramMd5, 1, 2)) { - log.info("[下单]重复提交:{}", paramMd5); + log.info("[食堂下单]重复提交:{}", paramMd5); throw new ServiceException("请勿重复提交订单"); } - List orderInfoList = orderBusiness.orderPlaceHandler(orderAddParam); + AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); + accInfoService.checkAccStatus(accInfoVO); + List canteenOrderInfoList = new OrderInfo().of(orderAddParam); + List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); orderPay(orderInfoList); return 1; } + + @Override + public int insertShopOrderInfo(ShopOrderAddParam orderAddParam) { + log.info("[超市下单]入参:{}", JacksonUtil.writeValueAsString(orderAddParam)); + String paramMd5 = "sc:shop_order_"+DigestUtil.md5Hex(JacksonUtil.writeValueAsString(orderAddParam)); + if (!RedisUtil.setNx(paramMd5, 1, 2)) { + log.info("[超市下单]重复提交:{}", paramMd5); + throw new ServiceException("请勿重复提交订单"); + } + AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); + accInfoService.checkAccStatus(accInfoVO); + List canteenOrderInfoList = new ShopOrderAddParam().of(orderAddParam); + List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); + orderPay(orderInfoList); + return 1; + } + @Override public void pay(Long orderId) { if(Objects.isNull(orderId) || orderId <= 0) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderDetailMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderDetailMapper.xml index 27ce1bb..075b3df 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderDetailMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderDetailMapper.xml @@ -145,7 +145,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" refund_num, device_sn, serial_num, - create_by + create_by, + update_by ) values @@ -171,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{orderDetail.deviceSn}, #{orderDetail.serialNum}, #{orderDetail.createBy}, + #{orderDetail.createBy} ) diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml index d5cf756..fdd711b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml @@ -92,6 +92,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where order_id = #{orderId} + + insert into order_info @@ -213,9 +218,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" comment_state, remark, create_by, - create_time, - update_by, - update_time + update_by ) values @@ -255,9 +258,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{orderInfo.commentState}, #{orderInfo.remark}, #{orderInfo.createBy}, - #{orderInfo.createTime}, - #{orderInfo.updateBy}, - #{orderInfo.updateTime} + #{orderInfo.updateBy} )