生成订单
优惠券字段
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
import com.czg.order.dto.*;
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.order.service.OrderInfoService;
|
import com.czg.order.service.OrderInfoService;
|
||||||
import com.czg.order.vo.OrderInfoVo;
|
import com.czg.order.vo.OrderInfoVo;
|
||||||
@@ -11,6 +10,7 @@ import com.czg.utils.AssertUtil;
|
|||||||
import com.czg.utils.ServletUtil;
|
import com.czg.utils.ServletUtil;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -40,7 +40,7 @@ public class AdminOrderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/createOrder")
|
@PostMapping("/createOrder")
|
||||||
public CzgResult<OrderInfo> createOrder(@RequestBody OrderInfoAddDTO addDto) {
|
public CzgResult<OrderInfo> createOrder(@Validated @RequestBody OrderInfoAddDTO addDto) {
|
||||||
AssertUtil.isNull(addDto.getUserId(), "请选择下单用户后使用");
|
AssertUtil.isNull(addDto.getUserId(), "请选择下单用户后使用");
|
||||||
addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||||
addDto.setStaffId(StpKit.USER.getLoginIdAsLong());
|
addDto.setStaffId(StpKit.USER.getLoginIdAsLong());
|
||||||
@@ -48,4 +48,23 @@ public class AdminOrderController {
|
|||||||
addDto.setOrderType("cash");
|
addDto.setOrderType("cash");
|
||||||
return CzgResult.success(orderInfoService.createOrder(addDto));
|
return CzgResult.success(orderInfoService.createOrder(addDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @PostMapping("/updateOrder")
|
||||||
|
// public CzgResult<OrderInfo> updateOrder(@Validated @RequestBody OrderInfoUpDTO upDTO) {
|
||||||
|
// AssertUtil.isListEmpty(upDTO.getDetailList(), "订单详情不能为空");
|
||||||
|
// orderInfoService.updateOrder(upDTO);
|
||||||
|
// return CzgResult.success();
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单全额退款 只传订单id
|
||||||
|
* 部分退款 传参refundDetailMap {"详情id":"数量","详情id":"数量"}
|
||||||
|
*
|
||||||
|
* @param refundDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// @PostMapping("/refundOrder")
|
||||||
|
// public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||||
|
// return orderInfoService.refundOrder(refundDTO);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,12 @@ public class ShopCouponDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal discountAmount;
|
private BigDecimal discountAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品id
|
||||||
|
*/
|
||||||
|
private Long proId;
|
||||||
|
private String proName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
|
||||||
|
package com.czg.order.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-02-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CheckOrderPay implements Serializable {
|
||||||
|
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用餐人数
|
||||||
|
*/
|
||||||
|
private Integer seatNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||||
|
*/
|
||||||
|
private BigDecimal originAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 折扣比例(计算时 向上取整保留 两位小数)
|
||||||
|
*/
|
||||||
|
private BigDecimal discountRatio;
|
||||||
|
/**
|
||||||
|
* 手动优惠金额
|
||||||
|
*/
|
||||||
|
private BigDecimal discountAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品优惠券抵扣金额
|
||||||
|
*/
|
||||||
|
private BigDecimal productCouponDiscountAmount;
|
||||||
|
/**
|
||||||
|
* 满减优惠券抵扣金额
|
||||||
|
*/
|
||||||
|
private BigDecimal fullCouponDiscountAmount;
|
||||||
|
/**
|
||||||
|
* 用户使用的卡券
|
||||||
|
*/
|
||||||
|
private List<Long> couponList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
*/
|
||||||
|
private BigDecimal orderAmount;
|
||||||
|
/**
|
||||||
|
* 抹零金额 减免多少钱
|
||||||
|
*/
|
||||||
|
private BigDecimal roundAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分抵扣金额(tb_points_basic_setting表)
|
||||||
|
*/
|
||||||
|
private BigDecimal pointsDiscountAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||||
|
*/
|
||||||
|
private Integer pointsNum;
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getSeatNum() {
|
||||||
|
return seatNum == null ? 0 : seatNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPointsNum() {
|
||||||
|
return pointsNum == null ? 0 : pointsNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单表 实体类。
|
* 订单表 实体类。
|
||||||
@@ -47,47 +46,6 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal originAmount;
|
private BigDecimal originAmount;
|
||||||
|
|
||||||
/**
|
|
||||||
* 折扣比例(计算时 向上取整保留 两位小数)
|
|
||||||
*/
|
|
||||||
private BigDecimal discountRatio;
|
|
||||||
/**
|
|
||||||
* 手动优惠金额
|
|
||||||
*/
|
|
||||||
private BigDecimal discountAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品优惠券抵扣金额
|
|
||||||
*/
|
|
||||||
private BigDecimal productCouponDiscountAmount;
|
|
||||||
/**
|
|
||||||
* 满减优惠券抵扣金额
|
|
||||||
*/
|
|
||||||
private BigDecimal fullCouponDiscountAmount;
|
|
||||||
/**
|
|
||||||
* 用户使用的卡券
|
|
||||||
*/
|
|
||||||
private List<Long> couponList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单金额
|
|
||||||
*/
|
|
||||||
private BigDecimal orderAmount;
|
|
||||||
/**
|
|
||||||
* 抹零金额 减免多少钱
|
|
||||||
*/
|
|
||||||
private BigDecimal roundAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 积分抵扣金额(tb_points_basic_setting表)
|
|
||||||
*/
|
|
||||||
private BigDecimal pointsDiscountAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
|
||||||
*/
|
|
||||||
private Integer pointsNum;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 台桌Id
|
* 台桌Id
|
||||||
*/
|
*/
|
||||||
@@ -109,6 +67,13 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
* APP APP管理端
|
* APP APP管理端
|
||||||
*/
|
*/
|
||||||
private String platformType;
|
private String platformType;
|
||||||
|
/**
|
||||||
|
* 支付模式:
|
||||||
|
* 后付费 after-pay
|
||||||
|
* 先付费 before-pay
|
||||||
|
* 无桌码 no-table
|
||||||
|
*/
|
||||||
|
private String payMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||||
@@ -116,12 +81,6 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
@NotBlank(message = "用餐模式不能为空")
|
@NotBlank(message = "用餐模式不能为空")
|
||||||
private String dineMode;
|
private String dineMode;
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "付款模式不能为空")
|
|
||||||
private String payMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@@ -152,8 +111,4 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
public String getDineMode() {
|
public String getDineMode() {
|
||||||
return StrUtil.isBlank(dineMode) ? "dine-in" : dineMode;
|
return StrUtil.isBlank(dineMode) ? "dine-in" : dineMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPointsNum() {
|
|
||||||
return pointsNum == null ? 0 : pointsNum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class OrderInfoDTO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 折扣比例
|
* 折扣比例
|
||||||
*/
|
*/
|
||||||
private String discountRatio;
|
private BigDecimal discountRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打包费
|
* 打包费
|
||||||
@@ -143,7 +143,10 @@ public class OrderInfoDTO implements Serializable {
|
|||||||
private String dineMode;
|
private String dineMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
* 支付模式:
|
||||||
|
* 后付费 after-pay
|
||||||
|
* 先付费 before-pay
|
||||||
|
* 无桌码 no-table
|
||||||
*/
|
*/
|
||||||
private String payMode;
|
private String payMode;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
package com.czg.order.dto;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.czg.order.entity.OrderDetail;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退单Dto。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-02-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class OrderInfoRefundDTO implements Serializable {
|
||||||
|
|
||||||
|
@NotNull(message = "订单Id不能为空")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退单总金额
|
||||||
|
*/
|
||||||
|
@NotNull(message = "退单金额不能为空")
|
||||||
|
private BigDecimal refundAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款金额 默认为 退单数量*单价 的和
|
||||||
|
* 整单退款 为订单orderAmount
|
||||||
|
* 如果自定义退款金额 则金额不进行校验 直接退款
|
||||||
|
*/
|
||||||
|
private boolean modify;
|
||||||
|
|
||||||
|
private String refundReason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退单明细
|
||||||
|
* id: orderDetailId
|
||||||
|
* num: 退单数量
|
||||||
|
* returnAmount: 退单金额
|
||||||
|
*/
|
||||||
|
private List<OrderDetail> refundDetails;
|
||||||
|
|
||||||
|
public String getRefundReason() {
|
||||||
|
if (StrUtil.isNotBlank(refundReason)) {
|
||||||
|
refundReason = refundReason.trim().replaceAll(" ", ",");
|
||||||
|
return refundReason;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
package com.czg.order.dto;
|
||||||
|
|
||||||
|
import com.czg.order.entity.OrderDetail;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-02-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class OrderInfoUpDTO implements Serializable {
|
||||||
|
|
||||||
|
@NotNull(message = "订单Id不能为空")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
private Integer seatNum;
|
||||||
|
|
||||||
|
private List<OrderDetail> detailList;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.czg.order.entity;
|
package com.czg.order.entity;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.mybatisflex.annotation.Column;
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
@@ -157,4 +158,15 @@ public class OrderDetail implements Serializable {
|
|||||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
public BigDecimal getRefundNum() {
|
||||||
|
return refundNum == null ? BigDecimal.ZERO : refundNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getReturnAmount() {
|
||||||
|
return returnAmount == null ? BigDecimal.ZERO : returnAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefundRemark() {
|
||||||
|
return StrUtil.isBlank(refundRemark) ? "" : refundRemark + " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class OrderInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 折扣比例
|
* 折扣比例
|
||||||
*/
|
*/
|
||||||
private String discountRatio;
|
private BigDecimal discountRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打包费
|
* 打包费
|
||||||
@@ -148,7 +148,10 @@ public class OrderInfo implements Serializable {
|
|||||||
private String dineMode;
|
private String dineMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
* 支付模式:
|
||||||
|
* 后付费 after-pay
|
||||||
|
* 先付费 before-pay
|
||||||
|
* 无桌码 no-table
|
||||||
*/
|
*/
|
||||||
private String payMode;
|
private String payMode;
|
||||||
|
|
||||||
@@ -164,6 +167,7 @@ public class OrderInfo implements Serializable {
|
|||||||
private String payType;
|
private String payType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* OrderStatusEnums 枚举类
|
||||||
* 状态: unpaid-待支付;in-production 制作中;wait-out 待取餐;;done-订单完成;refunding-申请退单;refund-退单;part-refund 部分退单;cancelled-取消订单
|
* 状态: unpaid-待支付;in-production 制作中;wait-out 待取餐;;done-订单完成;refunding-申请退单;refund-退单;part-refund 部分退单;cancelled-取消订单
|
||||||
*/
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
@@ -258,47 +262,8 @@ public class OrderInfo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer isDel;
|
private Integer isDel;
|
||||||
|
|
||||||
public BigDecimal getOriginAmount() {
|
|
||||||
return originAmount == null ? BigDecimal.ZERO : originAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getRoundAmount() {
|
public String getRefundRemark() {
|
||||||
return roundAmount == null ? BigDecimal.ZERO : roundAmount;
|
return StrUtil.isBlank(refundRemark) ? "" : refundRemark + " ";
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getOrderAmount() {
|
|
||||||
return orderAmount == null ? BigDecimal.ZERO : orderAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPointsDiscountAmount() {
|
|
||||||
return pointsDiscountAmount == null ? BigDecimal.ZERO : pointsDiscountAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPointsNum() {
|
|
||||||
return pointsNum == null ? 0 : pointsNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getProductCouponDiscountAmount() {
|
|
||||||
return productCouponDiscountAmount == null ? BigDecimal.ZERO : productCouponDiscountAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCouponInfoList() {
|
|
||||||
return StrUtil.isBlank(couponInfoList) ? "" : couponInfoList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getFullCouponDiscountAmount() {
|
|
||||||
return fullCouponDiscountAmount == null ? BigDecimal.ZERO : fullCouponDiscountAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getDiscountAmount() {
|
|
||||||
return discountAmount == null ? BigDecimal.ZERO : discountAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDiscountRatio() {
|
|
||||||
return discountRatio == null ? "" : discountRatio + ",";
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPackFee() {
|
|
||||||
return packFee == null ? BigDecimal.ZERO : packFee;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.czg.order.service;
|
package com.czg.order.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
import com.czg.order.dto.*;
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.order.enums.PayEnums;
|
import com.czg.order.enums.PayEnums;
|
||||||
import com.czg.order.vo.OrderInfoVo;
|
import com.czg.order.vo.OrderInfoVo;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@@ -25,6 +25,12 @@ public interface OrderInfoService extends IService<OrderInfo> {
|
|||||||
Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param);
|
Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param);
|
||||||
OrderInfo createOrder(OrderInfoAddDTO param);
|
OrderInfo createOrder(OrderInfoAddDTO param);
|
||||||
|
|
||||||
|
// void updateOrder(OrderInfoUpDTO upDTO);
|
||||||
|
|
||||||
|
BigDecimal checkOrderPay(CheckOrderPay param);
|
||||||
|
|
||||||
|
CzgResult<Object> refundOrder(OrderInfoRefundDTO param);
|
||||||
|
|
||||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||||
|
|
||||||
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import com.czg.account.entity.Product;
|
import com.czg.account.entity.Product;
|
||||||
import com.czg.account.service.ProductService;
|
import com.czg.account.service.ProductService;
|
||||||
import com.czg.service.account.mapper.ProductMapper;
|
import com.czg.service.account.mapper.ProductMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品 服务层实现。
|
* 商品 服务层实现。
|
||||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author zs
|
* @author zs
|
||||||
* @since 2025-02-20
|
* @since 2025-02-20
|
||||||
*/
|
*/
|
||||||
@Service
|
@DubboService
|
||||||
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService{
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ package com.czg.service.account.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.czg.account.dto.ShopCouponDTO;
|
import com.czg.account.dto.ShopCouponDTO;
|
||||||
|
import com.czg.account.entity.Product;
|
||||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||||
import com.czg.account.entity.ShopCoupon;
|
import com.czg.account.entity.ShopCoupon;
|
||||||
|
import com.czg.account.service.ProductService;
|
||||||
import com.czg.account.service.ShopActivateCouponRecordService;
|
import com.czg.account.service.ShopActivateCouponRecordService;
|
||||||
import com.czg.account.service.ShopCouponService;
|
import com.czg.account.service.ShopCouponService;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.account.mapper.ShopCouponMapper;
|
import com.czg.service.account.mapper.ShopCouponMapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,13 +28,22 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopActivateCouponRecordService couponRecordService;
|
private ShopActivateCouponRecordService couponRecordService;
|
||||||
|
@DubboReference
|
||||||
|
private ProductService productService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ShopCouponDTO> getList(Long shopId, Integer type, Integer status) {
|
public List<ShopCouponDTO> getList(Long shopId, Integer type, Integer status) {
|
||||||
return queryChain().select().eq(ShopCoupon::getShopId, shopId)
|
List<ShopCouponDTO> coupons = queryChain().select().eq(ShopCoupon::getShopId, shopId)
|
||||||
.eq(ShopCoupon::getType, type)
|
.eq(ShopCoupon::getType, type)
|
||||||
.eq(ShopCoupon::getStatus, status)
|
.eq(ShopCoupon::getStatus, status)
|
||||||
.orderBy(ShopCoupon::getCreateTime).desc().listAs(ShopCouponDTO.class);
|
.orderBy(ShopCoupon::getCreateTime).desc().listAs(ShopCouponDTO.class);
|
||||||
|
coupons.forEach(coupon -> {
|
||||||
|
if (coupon.getProId() != null) {
|
||||||
|
Product product = productService.getById(coupon.getProId());
|
||||||
|
coupon.setProName(product.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return coupons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,13 +63,14 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ShopActivateCouponRecord> find(Long shopUserId, Integer status) {
|
public List<ShopActivateCouponRecord> find(Long shopUserId, Integer status) {
|
||||||
return couponRecordService.queryChain()
|
List<ShopActivateCouponRecord> list = couponRecordService.queryChain()
|
||||||
.eq(ShopActivateCouponRecord::getShopId, StpKit.USER.getShopId())
|
.eq(ShopActivateCouponRecord::getShopId, StpKit.USER.getShopId())
|
||||||
.eq(ShopActivateCouponRecord::getShopUserId, shopUserId)
|
.eq(ShopActivateCouponRecord::getShopUserId, shopUserId)
|
||||||
.eq(ShopActivateCouponRecord::getStatus, status)
|
.eq(ShopActivateCouponRecord::getStatus, status)
|
||||||
.orderBy(ShopActivateCouponRecord::getStatus).asc()
|
.orderBy(ShopActivateCouponRecord::getStatus).asc()
|
||||||
.orderBy(ShopActivateCouponRecord::getCreateTime).desc()
|
.orderBy(ShopActivateCouponRecord::getCreateTime).desc()
|
||||||
.select().list();
|
.select().list();
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import com.czg.config.RedisCst;
|
|||||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
import com.czg.order.dto.*;
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
|
||||||
import com.czg.order.entity.OrderDetail;
|
import com.czg.order.entity.OrderDetail;
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
@@ -27,6 +26,8 @@ import com.czg.order.service.OrderInfoService;
|
|||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
import com.czg.order.vo.OrderDetailSmallVO;
|
import com.czg.order.vo.OrderDetailSmallVO;
|
||||||
import com.czg.order.vo.OrderInfoVo;
|
import com.czg.order.vo.OrderInfoVo;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.service.order.enums.OrderStatusEnums;
|
import com.czg.service.order.enums.OrderStatusEnums;
|
||||||
import com.czg.service.order.mapper.OrderInfoMapper;
|
import com.czg.service.order.mapper.OrderInfoMapper;
|
||||||
@@ -123,6 +124,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public OrderInfo createOrder(OrderInfoAddDTO param) {
|
public OrderInfo createOrder(OrderInfoAddDTO param) {
|
||||||
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
|
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
|
||||||
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
||||||
@@ -132,26 +134,98 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
if (!shopInfo.getEatModel().contains(param.getDineMode())) {
|
if (!shopInfo.getEatModel().contains(param.getDineMode())) {
|
||||||
throw new ValidateException("生成订单失败,店铺不支持该用餐模式");
|
throw new ValidateException("生成订单失败,店铺不支持该用餐模式");
|
||||||
}
|
}
|
||||||
if ("afterPay".equals(param.getPayMode()) && !"restaurant".equals(shopInfo.getRegisterType())) {
|
|
||||||
throw new ValidateException("生成订单失败,该店铺不支持后付费");
|
|
||||||
}
|
|
||||||
if (param.isVipPrice() && !shopInfo.getIsMemberPrice().equals(1)) {
|
if (param.isVipPrice() && !shopInfo.getIsMemberPrice().equals(1)) {
|
||||||
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
|
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
|
||||||
}
|
}
|
||||||
PointsBasicSetting pointSetting = pointsBasicService.getById(shopInfo.getId());
|
|
||||||
if (param.getPointsNum() > 0 && !pointSetting.getEnableDeduction().equals(1)) {
|
|
||||||
throw new ValidateException("生成订单失败,该店铺未开启积分抵扣");
|
|
||||||
}
|
|
||||||
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
||||||
AssertUtil.isNull(userInfo, "生成订单失败,用户信息不存在");
|
AssertUtil.isNull(userInfo, "生成订单失败,用户信息不存在");
|
||||||
ShopUser shopUser = shopUserService.getShopUserInfo(param.getShopId(), param.getUserId());
|
|
||||||
if (!shopUser.getIsVip().equals(1) && pointSetting.getDeductionGroup().contains("vip")) {
|
|
||||||
throw new ValidateException("生成订单失败,该店铺仅会员可使用积分抵扣");
|
|
||||||
}
|
|
||||||
ShopTable table = shopTableService.getOneByTableCode(param.getShopId(), param.getTableCode());
|
ShopTable table = shopTableService.getOneByTableCode(param.getShopId(), param.getTableCode());
|
||||||
AssertUtil.isNull(table, "生成订单失败,桌台信息不存在");
|
if (table == null) {
|
||||||
|
param.setPayMode("no-table");
|
||||||
|
} else {
|
||||||
|
if ("before".equals(shopInfo.getRegisterType())) {
|
||||||
|
param.setPayMode("before-pay");
|
||||||
|
} else if ("after".equals(shopInfo.getRegisterType())) {
|
||||||
|
param.setPayMode("after-pay");
|
||||||
|
} else {
|
||||||
|
param.setPayMode("未知");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
||||||
|
List<OrderDetail> orderDetails = cartService.getCartByTableCode(param.getTableCode(), param.isVipPrice() ? 1 : 0, param.getPlaceNum());
|
||||||
|
//总打包费
|
||||||
|
BigDecimal packAmount = BigDecimal.ZERO;
|
||||||
|
//总商品支付金额 不包含打包费 用来计算后续
|
||||||
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
processOrderDetails(orderDetails, packAmount, totalAmount);
|
||||||
|
if (packAmount.compareTo(param.getPackFee()) != 0) {
|
||||||
|
throw new ValidateException("生成订单失败,打包费不正确");
|
||||||
|
}
|
||||||
|
//总金额
|
||||||
|
if (totalAmount.add(param.getPackFee()).compareTo(param.getOriginAmount()) != 0) {
|
||||||
|
throw new ValidateException("生成订单失败,订单金额不正确");
|
||||||
|
}
|
||||||
|
//生成订单
|
||||||
|
OrderInfo orderInfo = initOrderInfo(param, shopInfo, table);
|
||||||
|
orderDetailService.createOrderDetails(orderInfo.getId(), orderDetails);
|
||||||
|
return orderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// @Transactional
|
||||||
|
// public void updateOrder(OrderInfoUpDTO upDTO) {
|
||||||
|
// OrderInfo orderInfo = getById(upDTO.getOrderId());
|
||||||
|
// AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
|
// ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||||
|
// AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||||
|
// BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
|
// BigDecimal packAmount = BigDecimal.ZERO;
|
||||||
|
// List<Long> collect = upDTO.getDetailList().stream().map(OrderDetail::getId).toList();
|
||||||
|
// List<OrderDetail> orderDetails = detailService.queryChain().eq(OrderDetail::getOrderId, orderInfo.getId()).select().list();
|
||||||
|
// List<OrderDetail> updateList = new ArrayList<>();
|
||||||
|
// List<Long> removeList = new ArrayList<>();
|
||||||
|
// for (OrderDetail orderDetail : orderDetails) {
|
||||||
|
// if (!collect.contains(orderDetail.getId())) {
|
||||||
|
// removeList.add(orderDetail.getId());
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// OrderDetail detail = new OrderDetail();
|
||||||
|
// detail.setId(orderDetail.getId());
|
||||||
|
// detail.setNum(orderDetail.getNum());
|
||||||
|
// detail.setPackNumber(orderDetail.getPackNumber());
|
||||||
|
// detail.setIsWaitCall(orderDetail.getIsWaitCall());
|
||||||
|
// detail.setRemark(orderDetail.getRemark());
|
||||||
|
// detail.setPayAmount(orderDetail.getNum().multiply(detail.getPrice()));
|
||||||
|
// packAmount = packAmount.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
||||||
|
// totalAmount = totalAmount.add(detail.getPayAmount());
|
||||||
|
// }
|
||||||
|
// detailService.updateBatch(updateList);
|
||||||
|
// detailService.removeByIds(removeList);
|
||||||
|
// orderInfo.setPackFee(packAmount);
|
||||||
|
// orderInfo.setOriginAmount(totalAmount.add(orderInfo.getSeatAmount()));
|
||||||
|
//
|
||||||
|
// orderInfo.setSeatNum(upDTO.getSeatNum());
|
||||||
|
// orderInfo.setSeatAmount(shopInfo.getTableFee().multiply(new BigDecimal(upDTO.getSeatNum())));
|
||||||
|
// updateById(orderInfo);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal checkOrderPay(CheckOrderPay param) {
|
||||||
|
OrderInfo orderInfo = getById(param.getOrderId());
|
||||||
|
Long shopId = StpKit.USER.getShopId();
|
||||||
|
PointsBasicSetting pointSetting = pointsBasicService.getById(shopId);
|
||||||
|
if (param.getPointsNum() > 0 && !pointSetting.getEnableDeduction().equals(1)) {
|
||||||
|
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||||
|
}
|
||||||
|
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
||||||
|
AssertUtil.isNull(userInfo, "生成支付订单失败,用户信息不存在");
|
||||||
|
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, param.getUserId());
|
||||||
|
if (!shopUser.getIsVip().equals(1) && pointSetting.getDeductionGroup().contains("vip")) {
|
||||||
|
throw new ValidateException("生成支付订单失败,该店铺仅会员可使用积分抵扣");
|
||||||
|
}
|
||||||
if (param.getDiscountRatio().compareTo(BigDecimal.ZERO) <= 0 && param.getDiscountRatio().compareTo(BigDecimal.ONE) > 0) {
|
if (param.getDiscountRatio().compareTo(BigDecimal.ZERO) <= 0 && param.getDiscountRatio().compareTo(BigDecimal.ONE) > 0) {
|
||||||
throw new ValidateException("生成订单失败,折扣比例不正确");
|
throw new ValidateException("生成支付订单失败,折扣比例不正确");
|
||||||
}
|
}
|
||||||
//商品券 <商品id,数量>
|
//商品券 <商品id,数量>
|
||||||
Map<Long, Integer> prodCouponMap = new HashMap<>();
|
Map<Long, Integer> prodCouponMap = new HashMap<>();
|
||||||
@@ -162,63 +236,166 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
checkCoupon(prodCouponMap, fullAmount, discountAmount, param);
|
checkCoupon(prodCouponMap, fullAmount, discountAmount, param);
|
||||||
|
|
||||||
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
||||||
List<OrderDetail> orderDetails = cartService.getCartByTableCode(table.getTableCode(), param.isVipPrice() ? 1 : 0, param.getPlaceNum());
|
List<OrderDetail> orderDetails = orderDetailService.queryChain().eq(OrderDetail::getOrderId, param.getOrderId()).select().list();
|
||||||
//总打包费
|
|
||||||
BigDecimal packAmount = BigDecimal.ZERO;
|
|
||||||
//商品优惠券金额
|
//商品优惠券金额
|
||||||
BigDecimal prodCouponAmount = BigDecimal.ZERO;
|
BigDecimal prodCouponAmount = BigDecimal.ZERO;
|
||||||
//总商品支付金额 不包含打包费 用来计算后续
|
//总商品支付金额 不包含打包费 用来计算后续
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
processOrderDetails(orderDetails, prodCouponMap, prodCouponAmount, packAmount, totalAmount);
|
processOrderDetails2(orderDetails, prodCouponMap, prodCouponAmount, totalAmount);
|
||||||
if (packAmount.compareTo(param.getPackFee()) != 0) {
|
|
||||||
throw new ValidateException("生成订单失败,打包费不正确");
|
|
||||||
}
|
|
||||||
if (prodCouponAmount.compareTo(param.getProductCouponDiscountAmount()) != 0) {
|
if (prodCouponAmount.compareTo(param.getProductCouponDiscountAmount()) != 0) {
|
||||||
throw new ValidateException("生成订单失败,商品优惠券优惠金额不正确");
|
throw new ValidateException("生成支付订单失败,商品优惠券优惠金额不正确");
|
||||||
}
|
}
|
||||||
//折扣金额 如 9折 计算 为 订单金额*0.9 向上取整
|
//折扣金额 如 9折 计算 为 订单金额*0.9 向上取整
|
||||||
BigDecimal newTotalAmount = BigDecimal.ZERO;
|
BigDecimal newTotalAmount = BigDecimal.ZERO;
|
||||||
if (param.getDiscountRatio().compareTo(BigDecimal.ONE) != 0) {
|
if (param.getDiscountRatio().compareTo(BigDecimal.ONE) != 0) {
|
||||||
newTotalAmount = totalAmount.multiply(param.getDiscountRatio()).setScale(2, RoundingMode.UP);
|
newTotalAmount = totalAmount.multiply(param.getDiscountRatio()).setScale(2, RoundingMode.UP);
|
||||||
if (param.getDiscountAmount().compareTo(totalAmount.subtract(newTotalAmount)) != 0) {
|
if (param.getDiscountAmount().compareTo(totalAmount.subtract(newTotalAmount)) != 0) {
|
||||||
throw new ValidateException("生成订单失败,折扣金额不正确");
|
throw new ValidateException("生成支付订单失败,折扣金额不正确");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//满减券 校验
|
//满减券 校验
|
||||||
if (newTotalAmount.compareTo(fullAmount) < 0) {
|
if (newTotalAmount.compareTo(fullAmount) < 0) {
|
||||||
throw new ValidateException("生成订单失败,满减券不满足条件");
|
throw new ValidateException("生成支付订单失败,满减券不满足条件");
|
||||||
}
|
}
|
||||||
//减去满减优惠券
|
//减去满减优惠券
|
||||||
newTotalAmount = newTotalAmount.subtract(discountAmount);
|
newTotalAmount = newTotalAmount.subtract(discountAmount);
|
||||||
//积分抵扣 金额范围校验 抵扣金额校验
|
//积分抵扣 金额范围校验 抵扣金额校验
|
||||||
if (param.getPointsNum() > 0) {
|
if (param.getPointsNum() > 0) {
|
||||||
if (pointSetting.getMinPaymentAmount().compareTo(newTotalAmount) > 0) {
|
if (pointSetting.getMinPaymentAmount().compareTo(newTotalAmount) > 0) {
|
||||||
throw new ValidateException("生成订单失败,未满足积分抵扣最低门槛");
|
throw new ValidateException("生成支付订单失败,未满足积分抵扣最低门槛");
|
||||||
}
|
}
|
||||||
if (pointSetting.getMaxDeductionRatio().multiply(newTotalAmount).compareTo(param.getPointsDiscountAmount()) < 0) {
|
if (pointSetting.getMaxDeductionRatio().multiply(newTotalAmount).compareTo(param.getPointsDiscountAmount()) < 0) {
|
||||||
throw new ValidateException("生成订单失败,积分抵扣金额已超出最大抵扣金额");
|
throw new ValidateException("生成支付订单失败,积分抵扣金额已超出最大抵扣金额");
|
||||||
}
|
}
|
||||||
BigDecimal pointAmount = new BigDecimal(param.getPointsNum()).divide(new BigDecimal(pointSetting.getEquivalentPoints()), 2, RoundingMode.DOWN);
|
BigDecimal pointAmount = new BigDecimal(param.getPointsNum()).divide(new BigDecimal(pointSetting.getEquivalentPoints()), 2, RoundingMode.DOWN);
|
||||||
if (pointAmount.compareTo(param.getPointsDiscountAmount()) != 0) {
|
if (pointAmount.compareTo(param.getPointsDiscountAmount()) != 0) {
|
||||||
throw new ValidateException("生成订单失败,积分抵扣金额不正确");
|
throw new ValidateException("生成支付订单失败,积分抵扣金额不正确");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newTotalAmount = newTotalAmount.subtract(param.getPointsDiscountAmount());
|
newTotalAmount = newTotalAmount.subtract(param.getPointsDiscountAmount());
|
||||||
//抹零
|
//抹零
|
||||||
newTotalAmount = newTotalAmount.subtract(param.getRoundAmount());
|
newTotalAmount = newTotalAmount.subtract(param.getRoundAmount());
|
||||||
//校验最终金额(订单金额 (扣除各类折扣)+打包费 餐位费)
|
//校验最终金额(订单金额 (扣除各类折扣)+打包费 餐位费)
|
||||||
newTotalAmount = newTotalAmount.add(param.getPackFee()).add(new BigDecimal(param.getSeatNum()).multiply(shopInfo.getTableFee()));
|
newTotalAmount = newTotalAmount.add(orderInfo.getPackFee()).add(orderInfo.getSeatAmount());
|
||||||
if (newTotalAmount.compareTo(param.getOrderAmount()) != 0) {
|
if (newTotalAmount.compareTo(param.getOrderAmount()) != 0) {
|
||||||
throw new ValidateException("生成订单失败,订单金额不正确");
|
throw new ValidateException("生成支付订单失败,订单金额不正确");
|
||||||
}
|
}
|
||||||
//生成订单 //discount_info 所有折扣 几折 折扣金额 满减金额 优惠券金额 积分抵扣金额 抹零
|
//生成订单 //discount_info 所有折扣 几折 折扣金额 满减金额 优惠券金额 积分抵扣金额 抹零
|
||||||
OrderInfo orderInfo = initOrderInfo(param, shopInfo, table);
|
upOrderPayInfo(orderInfo, param);
|
||||||
orderDetailService.createOrderDetails(orderInfo.getId(), orderDetails);
|
//更新优惠券信息
|
||||||
|
orderDetailService.updateBatch(orderDetails);
|
||||||
//券消耗
|
//券消耗
|
||||||
couponService.use(param.getCouponList(), shopUser.getId(), orderInfo.getId());
|
couponService.use(param.getCouponList(), shopUser.getId(), orderInfo.getId());
|
||||||
return orderInfo;
|
return newTotalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CzgResult<Object> refundOrder(OrderInfoRefundDTO param) {
|
||||||
|
OrderInfo orderInfo = getById(param.getOrderId());
|
||||||
|
//退款总额
|
||||||
|
BigDecimal refundAmountTotal = BigDecimal.ZERO;
|
||||||
|
boolean isPay = true;
|
||||||
|
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||||
|
isPay = false;
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(param.getRefundDetails())) {
|
||||||
|
for (OrderDetail refundDetail : param.getRefundDetails()) {
|
||||||
|
AssertUtil.isNull(refundDetail.getNum(), "退单数量不能为空");
|
||||||
|
AssertUtil.isNull(refundDetail.getReturnAmount(), "退单金额不能为空");
|
||||||
|
//退款金额
|
||||||
|
BigDecimal refundAmount;
|
||||||
|
//退款数量
|
||||||
|
BigDecimal refNum;
|
||||||
|
OrderDetail orderDetail = detailService.getById(refundDetail.getId());
|
||||||
|
//可退数量=订单数量-退单数量-退菜数量
|
||||||
|
BigDecimal returnNum = orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum());
|
||||||
|
if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) {
|
||||||
|
throw new ValidateException("退单失败,可退数量不足");
|
||||||
|
}
|
||||||
|
//可退数量 大于优惠券数量
|
||||||
|
if (returnNum.compareTo(orderDetail.getCouponNum()) > 0) {
|
||||||
|
//实际计算金额的数量
|
||||||
|
refNum = returnNum.subtract(orderDetail.getCouponNum());
|
||||||
|
if (refundDetail.getNum().compareTo(refNum) > 0) {
|
||||||
|
refundAmount = (refNum).multiply(orderDetail.getPrice());
|
||||||
|
refNum = refundDetail.getNum();
|
||||||
|
} else {
|
||||||
|
refNum = refundDetail.getNum();
|
||||||
|
refundAmount = refundDetail.getNum().multiply(orderDetail.getPrice());
|
||||||
|
if (param.isModify()) {
|
||||||
|
refundAmount = refundDetail.getReturnAmount();
|
||||||
|
} else {
|
||||||
|
if (refundAmount.compareTo(refundDetail.getReturnAmount()) != 0) {
|
||||||
|
throw new ValidateException("退单失败," + refundDetail.getProductName() + "退单金额不正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (param.isModify()) {
|
||||||
|
refundAmount = refundDetail.getReturnAmount();
|
||||||
|
refNum = refundDetail.getNum();
|
||||||
|
} else {
|
||||||
|
refNum = refundDetail.getNum();
|
||||||
|
refundAmount = BigDecimal.ZERO;
|
||||||
|
if (refundAmount.compareTo(refundDetail.getReturnAmount()) != 0) {
|
||||||
|
throw new ValidateException("退单失败," + refundDetail.getProductName() + "退单金额不正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refundAmountTotal = refundAmountTotal.add(refundAmount);
|
||||||
|
if (refundDetail.getReturnAmount().compareTo(refundDetail.getNum().multiply(orderDetail.getPrice())) != 0) {
|
||||||
|
throw new ValidateException("退单失败," + refundDetail.getProductName() + "退单金额不正确");
|
||||||
|
}
|
||||||
|
if (isPay) {
|
||||||
|
orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum));
|
||||||
|
orderDetail.setReturnAmount(orderDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
||||||
|
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
|
||||||
|
throw new ValidateException("退单失败," + refundDetail.getProductName() + "退单金额不正确");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
orderDetail.setReturnNum(orderDetail.getRefundNum().add(refNum));
|
||||||
|
}
|
||||||
|
refundDetail.setRefundRemark(refundDetail.getRefundRemark() + param.getRefundReason());
|
||||||
|
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum())
|
||||||
|
.subtract(orderDetail.getCouponNum())).multiply(orderDetail.getPrice()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
refundAmountTotal = param.getRefundAmount();
|
||||||
|
}
|
||||||
|
if (param.isModify()) {
|
||||||
|
orderInfo.setOrderAmount(orderInfo.getOrderAmount().subtract(param.getRefundAmount()));
|
||||||
|
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
throw new ValidateException("退单失败,订单金额不正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isPay) {
|
||||||
|
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(refundAmountTotal));
|
||||||
|
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
||||||
|
//退钱 refundAmountTotal
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充 优惠券使用数量 以及 付款金额
|
||||||
|
*
|
||||||
|
* @param orderDetails 订单详情 需要回填
|
||||||
|
* @param packAmount 打包费
|
||||||
|
* @param totalAmount 最终总金额
|
||||||
|
*/
|
||||||
|
private void processOrderDetails(List<OrderDetail> orderDetails, BigDecimal packAmount, BigDecimal totalAmount) {
|
||||||
|
for (OrderDetail detail : orderDetails) {
|
||||||
|
if (detail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && detail.getPackAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
packAmount = packAmount.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
||||||
|
}
|
||||||
|
detail.setPayAmount(detail.getNum().multiply(detail.getPrice()));
|
||||||
|
totalAmount = totalAmount.add(detail.getPayAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填充 优惠券使用数量 以及 付款金额
|
* 填充 优惠券使用数量 以及 付款金额
|
||||||
@@ -226,17 +403,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
* @param orderDetails 订单详情 需要回填 优惠券抵扣数量
|
* @param orderDetails 订单详情 需要回填 优惠券抵扣数量
|
||||||
* @param prodCouponMap 使用优惠券<商品id,数量>
|
* @param prodCouponMap 使用优惠券<商品id,数量>
|
||||||
* @param prodCouponAmount 商品券优惠金额 商品单价*优惠数量 的总和
|
* @param prodCouponAmount 商品券优惠金额 商品单价*优惠数量 的总和
|
||||||
* @param packAmount 打包费
|
|
||||||
* @param totalAmount 最终总金额(没加打包费 餐位费) 去除优惠券金额后的
|
* @param totalAmount 最终总金额(没加打包费 餐位费) 去除优惠券金额后的
|
||||||
*/
|
*/
|
||||||
private void processOrderDetails(List<OrderDetail> orderDetails, Map<Long, Integer> prodCouponMap,
|
private void processOrderDetails2(List<OrderDetail> orderDetails, Map<Long, Integer> prodCouponMap,
|
||||||
BigDecimal prodCouponAmount, BigDecimal packAmount, BigDecimal totalAmount) {
|
BigDecimal prodCouponAmount, BigDecimal totalAmount) {
|
||||||
Map<Long, List<OrderDetail>> detailMap = new HashMap<>();
|
Map<Long, List<OrderDetail>> detailMap = new HashMap<>();
|
||||||
for (OrderDetail detail : orderDetails) {
|
for (OrderDetail detail : orderDetails) {
|
||||||
detailMap.computeIfAbsent(detail.getProductId(), k -> new ArrayList<>()).add(detail);
|
detailMap.computeIfAbsent(detail.getProductId(), k -> new ArrayList<>()).add(detail);
|
||||||
if (detail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && detail.getPackAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
||||||
packAmount = packAmount.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
List<OrderDetail> resultList = new ArrayList<>();
|
List<OrderDetail> resultList = new ArrayList<>();
|
||||||
for (Map.Entry<Long, List<OrderDetail>> entry : detailMap.entrySet()) {
|
for (Map.Entry<Long, List<OrderDetail>> entry : detailMap.entrySet()) {
|
||||||
@@ -269,31 +442,32 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
resultList.add(orderDetail);
|
resultList.add(orderDetail);
|
||||||
}
|
}
|
||||||
if (couponNum.compareTo(BigDecimal.ZERO) != 0) {
|
if (couponNum.compareTo(BigDecimal.ZERO) != 0) {
|
||||||
throw new ValidateException("生成订单失败,优惠券数量不正确");
|
throw new ValidateException("生成支付订单失败,优惠券数量不正确");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
orderDetails = resultList;
|
orderDetails = resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验优惠券可用性 回填优惠券信息
|
* 校验优惠券可用性
|
||||||
*/
|
*/
|
||||||
private void checkCoupon(Map<Long, Integer> prodCouponMap, BigDecimal fullAmount, BigDecimal discountAmount, OrderInfoAddDTO param) {
|
private void checkCoupon(Map<Long, Integer> prodCouponMap, BigDecimal fullAmount, BigDecimal discountAmount, CheckOrderPay param) {
|
||||||
if (CollUtil.isNotEmpty(param.getCouponList())) {
|
if (CollUtil.isNotEmpty(param.getCouponList())) {
|
||||||
//校验优惠券
|
//校验优惠券
|
||||||
List<ShopActivateCouponRecord> records = couponRecordService.list(QueryWrapper.create()
|
List<ShopActivateCouponRecord> records = couponRecordService.list(QueryWrapper.create()
|
||||||
.where(ShopActivateCouponRecord::getId).in(param.getCouponList())
|
.where(ShopActivateCouponRecord::getId).in(param.getCouponList())
|
||||||
.and(ShopActivateCouponRecord::getStatus).eq(0));
|
.and(ShopActivateCouponRecord::getStatus).eq(0));
|
||||||
if (CollUtil.isEmpty(records)) {
|
if (CollUtil.isEmpty(records)) {
|
||||||
throw new ValidateException("生成订单失败,优惠券信息不存在");
|
throw new ValidateException("生成支付订单失败,优惠券信息不存在");
|
||||||
} else if (records.size() != param.getCouponList().size()) {
|
} else if (records.size() != param.getCouponList().size()) {
|
||||||
throw new ValidateException("生成订单失败,优惠券信息不正确");
|
throw new ValidateException("生成支付订单失败,优惠券信息不正确");
|
||||||
}
|
}
|
||||||
boolean isFullMinus = false;
|
boolean isFullMinus = false;
|
||||||
for (ShopActivateCouponRecord record : records) {
|
for (ShopActivateCouponRecord record : records) {
|
||||||
if (record.getType().equals(1)) {
|
if (record.getType().equals(1)) {
|
||||||
if (isFullMinus) {
|
if (isFullMinus) {
|
||||||
throw new ValidateException("生成订单失败,满减券仅可使用一张");
|
throw new ValidateException("生成支付订单失败,满减券仅可使用一张");
|
||||||
}
|
}
|
||||||
fullAmount = record.getFullAmount();
|
fullAmount = record.getFullAmount();
|
||||||
discountAmount = record.getDiscountAmount();
|
discountAmount = record.getDiscountAmount();
|
||||||
@@ -304,7 +478,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (discountAmount.compareTo(param.getFullCouponDiscountAmount()) != 0) {
|
if (discountAmount.compareTo(param.getFullCouponDiscountAmount()) != 0) {
|
||||||
throw new ValidateException("生成订单失败,满减券减免金额不正确");
|
throw new ValidateException("生成支付订单失败,满减券减免金额不正确");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,12 +579,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
rabbitPublisher.sendOrderPrintMsg(orderId.toString());
|
rabbitPublisher.sendOrderPrintMsg(orderId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化订单信息
|
||||||
|
*/
|
||||||
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) {
|
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) {
|
||||||
OrderInfo orderInfo = new OrderInfo();
|
OrderInfo orderInfo = new OrderInfo();
|
||||||
if (param.getOrderId() != null) {
|
if (param.getOrderId() != null) {
|
||||||
orderInfo = getById(param.getOrderId());
|
orderInfo = getById(param.getOrderId());
|
||||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||||
throw new ValidateException("生成订单失败,订单已结束,请重新下单");
|
throw new ValidateException("生成订单失败,订单已结束,请重新下单");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -420,7 +596,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
orderInfo.setTableCode(table.getTableCode());
|
orderInfo.setTableCode(table.getTableCode());
|
||||||
orderInfo.setTableName(table.getName());
|
orderInfo.setTableName(table.getName());
|
||||||
orderInfo.setDineMode(param.getDineMode());
|
orderInfo.setDineMode(param.getDineMode());
|
||||||
orderInfo.setSeatNum(param.getSeatNum());
|
|
||||||
orderInfo.setRefundAmount(BigDecimal.ZERO);
|
orderInfo.setRefundAmount(BigDecimal.ZERO);
|
||||||
orderInfo.setPayAmount(BigDecimal.ZERO);
|
orderInfo.setPayAmount(BigDecimal.ZERO);
|
||||||
|
|
||||||
@@ -428,7 +603,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
orderInfo.setPlatformType(param.getPlatformType());
|
orderInfo.setPlatformType(param.getPlatformType());
|
||||||
orderInfo.setDineMode(param.getDineMode());
|
orderInfo.setDineMode(param.getDineMode());
|
||||||
orderInfo.setPayMode(param.getPayMode());
|
orderInfo.setPayMode(param.getPayMode());
|
||||||
orderInfo.setStatus("unpaid");
|
orderInfo.setStatus(OrderStatusEnums.UNPAID.getCode());
|
||||||
orderInfo.setRefundAble(0);
|
orderInfo.setRefundAble(0);
|
||||||
orderInfo.setTradeDay(DateUtil.formatDate(new Date()));
|
orderInfo.setTradeDay(DateUtil.formatDate(new Date()));
|
||||||
orderInfo.setRemark(param.getRemark());
|
orderInfo.setRemark(param.getRemark());
|
||||||
@@ -438,40 +613,44 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
orderInfo.setIsDel(0);
|
orderInfo.setIsDel(0);
|
||||||
//取餐码 多端一致
|
//取餐码 多端一致
|
||||||
orderInfo.setTakeCode(getCode(shopInfo.getId()));
|
orderInfo.setTakeCode(getCode(shopInfo.getId()));
|
||||||
|
}
|
||||||
|
// 餐位费
|
||||||
|
if (shopInfo.getIsTableFee().equals(1)) {
|
||||||
orderInfo.setSeatAmount(shopInfo.getTableFee().multiply(new BigDecimal(param.getSeatNum())));
|
orderInfo.setSeatAmount(shopInfo.getTableFee().multiply(new BigDecimal(param.getSeatNum())));
|
||||||
|
orderInfo.setSeatNum(param.getSeatNum());
|
||||||
}
|
}
|
||||||
orderInfo.setPlaceNum(param.getPlaceNum());
|
orderInfo.setPlaceNum(param.getPlaceNum());
|
||||||
|
orderInfo.setOriginAmount(orderInfo.getOriginAmount().add(param.getOriginAmount()).add(orderInfo.getSeatAmount()));
|
||||||
orderInfo.setPointsNum(orderInfo.getPointsNum() + param.getPointsNum());
|
|
||||||
orderInfo.setOriginAmount(orderInfo.getOriginAmount().add(param.getOriginAmount()));
|
|
||||||
orderInfo.setRoundAmount(orderInfo.getRoundAmount().add(param.getRoundAmount()));
|
|
||||||
orderInfo.setOrderAmount(orderInfo.getOrderAmount().add(param.getOrderAmount()));
|
|
||||||
orderInfo.setPointsDiscountAmount(orderInfo.getPointsDiscountAmount().add(param.getPointsDiscountAmount()));
|
|
||||||
orderInfo.setProductCouponDiscountAmount(orderInfo.getProductCouponDiscountAmount().add(param.getProductCouponDiscountAmount()));
|
|
||||||
orderInfo.setFullCouponDiscountAmount(orderInfo.getFullCouponDiscountAmount().add(param.getFullCouponDiscountAmount()));
|
|
||||||
orderInfo.setDiscountAmount(orderInfo.getDiscountAmount().add(param.getDiscountAmount()));
|
|
||||||
orderInfo.setPackFee(orderInfo.getPackFee().add(param.getPackFee()));
|
orderInfo.setPackFee(orderInfo.getPackFee().add(param.getPackFee()));
|
||||||
orderInfo.setDiscountRatio(orderInfo.getDiscountRatio() + param.getDiscountRatio());
|
orderInfo.setRoundAmount(BigDecimal.ZERO);
|
||||||
//优惠券
|
orderInfo.setPointsNum(0);
|
||||||
orderInfo.setCouponInfoList(orderInfo.getCouponInfoList() + "," + JSONObject.toJSONString(param.getCouponList()));
|
|
||||||
//折扣信息
|
|
||||||
orderInfo.setDiscountInfo(buildDiscountInfo(orderInfo));
|
|
||||||
saveOrUpdate(orderInfo);
|
saveOrUpdate(orderInfo);
|
||||||
return orderInfo;
|
return orderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCode(Long shopId) {
|
/**
|
||||||
String key = RedisCst.SHOP_CODE + DateUtil.today() + ":" + shopId;
|
* 更新订单 优惠信息
|
||||||
int count = 1;
|
*/
|
||||||
if (redisService.hasKey(key)) {
|
private void upOrderPayInfo(OrderInfo orderInfo, CheckOrderPay param) {
|
||||||
count = Integer.parseInt(redisService.get(key).toString());
|
orderInfo.setPointsNum(param.getPointsNum());
|
||||||
count++;
|
orderInfo.setOriginAmount(param.getOriginAmount());
|
||||||
}
|
orderInfo.setRoundAmount(param.getRoundAmount());
|
||||||
// 设置缓存并设置过期时间
|
orderInfo.setOrderAmount(param.getOrderAmount());
|
||||||
redisService.set(key, count, 24 * 60 * 60);
|
orderInfo.setPointsDiscountAmount(param.getPointsDiscountAmount());
|
||||||
return "#" + count;
|
orderInfo.setProductCouponDiscountAmount(param.getProductCouponDiscountAmount());
|
||||||
|
orderInfo.setFullCouponDiscountAmount(param.getFullCouponDiscountAmount());
|
||||||
|
orderInfo.setDiscountAmount(param.getDiscountAmount());
|
||||||
|
orderInfo.setDiscountRatio(param.getDiscountRatio());
|
||||||
|
//优惠券
|
||||||
|
orderInfo.setCouponInfoList(JSONObject.toJSONString(param.getCouponList()));
|
||||||
|
//折扣信息
|
||||||
|
orderInfo.setDiscountInfo(buildDiscountInfo(orderInfo));
|
||||||
|
saveOrUpdate(orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建优惠内容
|
||||||
|
*/
|
||||||
private String buildDiscountInfo(OrderInfo orderInfo) {
|
private String buildDiscountInfo(OrderInfo orderInfo) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if (orderInfo.getProductCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
if (orderInfo.getProductCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
@@ -491,4 +670,19 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
}
|
}
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成取餐码
|
||||||
|
*/
|
||||||
|
private String getCode(Long shopId) {
|
||||||
|
String key = RedisCst.SHOP_CODE + DateUtil.today() + ":" + shopId;
|
||||||
|
int count = 1;
|
||||||
|
if (redisService.hasKey(key)) {
|
||||||
|
count = Integer.parseInt(redisService.get(key).toString());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
// 设置缓存并设置过期时间
|
||||||
|
redisService.set(key, count, 24 * 60 * 60);
|
||||||
|
return "#" + count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.czg.service.RedisService;
|
|||||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipPayParamDTO;
|
import com.czg.service.order.dto.VipPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipRefundDTO;
|
import com.czg.service.order.dto.VipRefundDTO;
|
||||||
|
import com.czg.service.order.enums.OrderStatusEnums;
|
||||||
import com.czg.service.order.service.PayService;
|
import com.czg.service.order.service.PayService;
|
||||||
import com.czg.system.enums.SysParamCodeEnum;
|
import com.czg.system.enums.SysParamCodeEnum;
|
||||||
import com.czg.system.service.SysParamsService;
|
import com.czg.system.service.SysParamsService;
|
||||||
@@ -83,10 +84,10 @@ public class PayServiceImpl implements PayService {
|
|||||||
private OrderInfo checkPay(Long orderId) {
|
private OrderInfo checkPay(Long orderId) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||||
throw new ValidateException("该订单已不可支付");
|
throw new ValidateException("该订单已不可支付");
|
||||||
}
|
}
|
||||||
if (!"afterPay".equals(orderInfo.getPayMode())
|
if (!"after-pay".equals(orderInfo.getPayMode())
|
||||||
&& orderInfo.getCreateTime().isAfter(LocalDateTimeUtil.offset(LocalDateTime.now(), -15, ChronoUnit.SECONDS))) {
|
&& orderInfo.getCreateTime().isAfter(LocalDateTimeUtil.offset(LocalDateTime.now(), -15, ChronoUnit.SECONDS))) {
|
||||||
throw new ValidateException("订单十五分钟内有效,当前已超时,请重新下单。");
|
throw new ValidateException("订单十五分钟内有效,当前已超时,请重新下单。");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
skus.spec_info as skuName,
|
skus.spec_info as skuName,
|
||||||
'wait-pay' as status,
|
'wait-pay' as status,
|
||||||
#{placeNum} as placeNum,
|
#{placeNum} as placeNum,
|
||||||
#{dineMode} as dineMode,
|
|
||||||
case cart.is_temporary
|
case cart.is_temporary
|
||||||
when 1 then cart.product_name
|
when 1 then cart.product_name
|
||||||
else pros.name
|
else pros.name
|
||||||
|
|||||||
Reference in New Issue
Block a user