订单下单
This commit is contained in:
parent
16ef1edc6b
commit
03217ee2ab
|
|
@ -1,17 +1,25 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.order.dto.OrderInfoAddDTO;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
|
|
@ -30,4 +38,14 @@ public class AdminOrderController {
|
|||
queryDTO.setShopId(StpKit.USER.getShopId());
|
||||
return CzgResult.success(orderInfoService.getOrderByPage(queryDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/createOrder")
|
||||
public CzgResult<OrderInfo> createOrder(@RequestBody OrderInfoAddDTO addDto) {
|
||||
AssertUtil.isNull(addDto.getUserId(), "请选择下单用户后使用");
|
||||
addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
addDto.setStaffId(StpKit.USER.getLoginIdAsLong());
|
||||
addDto.setShopId(StpKit.USER.getShopId());
|
||||
addDto.setOrderType("cash");
|
||||
return CzgResult.success(orderInfoService.createOrder(addDto));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.czg.order.dto.OrderInfoAddDTO;
|
|||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.vo.OrderInfoCreateVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
|
|
@ -39,7 +38,7 @@ public class UserOrderController {
|
|||
}
|
||||
|
||||
@PostMapping("/createOrder")
|
||||
public CzgResult<OrderInfoCreateVo> createOrder(@RequestBody OrderInfoAddDTO addDto) {
|
||||
public CzgResult<OrderInfo> createOrder(@RequestBody OrderInfoAddDTO addDto) {
|
||||
addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
addDto.setUserId(StpKit.USER.getLoginIdAsLong());
|
||||
addDto.setShopId(StpKit.USER.getShopId());
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ public interface RedisCst {
|
|||
// 店铺会员动态支付码
|
||||
String SHOP_USER_DYNAMIC_CODE = "shop:user:dynamic:code:";
|
||||
|
||||
//店铺取餐码key
|
||||
String SHOP_CODE = "shop:code:";
|
||||
|
||||
|
||||
// 排队取号全局号码
|
||||
String TABLE_CALL_NUMBER = "TABLE_CALL_NUMBER:";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,151 +0,0 @@
|
|||
|
||||
package com.czg.order.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单详情 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-14
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderDetailDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long orderId;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String productImg;
|
||||
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品类型:单规格商品 single 多规格商品 sku 套餐商品 package 称重商品 weigh 团购券 coupon
|
||||
*/
|
||||
private String productType;
|
||||
|
||||
private Long skuId;
|
||||
|
||||
private String skuName;
|
||||
|
||||
/**
|
||||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
*/
|
||||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 单价:原价/会员价/临时改价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 折扣金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
private BigDecimal packAmount;
|
||||
|
||||
/**
|
||||
* 总金额/实付金额,包含打包费 不包括优惠金额
|
||||
*/
|
||||
private BigDecimal payAmount;
|
||||
|
||||
/**
|
||||
* 已退款金额
|
||||
*/
|
||||
private BigDecimal returnAmount;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 退菜数量(不管价格)
|
||||
*/
|
||||
private BigDecimal returnNum;
|
||||
|
||||
/**
|
||||
* 退单数量
|
||||
*/
|
||||
private BigDecimal refundNum;
|
||||
|
||||
/**
|
||||
* 退款单号
|
||||
*/
|
||||
private String refundNo;
|
||||
|
||||
/**
|
||||
* 临时改价备注
|
||||
*/
|
||||
private String discountSaleNote;
|
||||
|
||||
/**
|
||||
* 状态: in-production 制作中;wait-out 待取餐;refunding 退款中; part-refund 部分退单; refund-退单; done 完成;
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 当前下单次数
|
||||
*/
|
||||
private Integer placeNum;
|
||||
|
||||
/**
|
||||
* 是否是临时菜品
|
||||
*/
|
||||
private Integer isTemporary;
|
||||
|
||||
/**
|
||||
* 是否打票
|
||||
*/
|
||||
private Integer isPrint;
|
||||
|
||||
/**
|
||||
* 是否等叫
|
||||
*/
|
||||
private Integer isWaitCall;
|
||||
|
||||
/**
|
||||
* 套餐商品选择信息
|
||||
*/
|
||||
private String proGroupInfo;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 退款备注
|
||||
*/
|
||||
private String refundRemark;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -3,10 +3,14 @@ package com.czg.order.dto;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单表 实体类。
|
||||
|
|
@ -27,6 +31,8 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
private Long shopId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long staffId;
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
|
|
@ -61,12 +67,16 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
/**
|
||||
* 用户使用的卡券
|
||||
*/
|
||||
private String couponInfoList;
|
||||
private List<Long> couponList;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
/**
|
||||
* 抹零金额 减免多少钱
|
||||
*/
|
||||
private BigDecimal roundAmount;
|
||||
|
||||
/**
|
||||
* 积分抵扣金额(tb_points_basic_setting表)
|
||||
|
|
@ -76,7 +86,7 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
/**
|
||||
* 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||
*/
|
||||
private BigDecimal pointsNum;
|
||||
private Integer pointsNum;
|
||||
|
||||
/**
|
||||
* 台桌Id
|
||||
|
|
@ -91,7 +101,12 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
private String orderType;
|
||||
|
||||
/**
|
||||
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
|
||||
* 平台类型
|
||||
* PC 收银机客户端
|
||||
* WX 微信小程序
|
||||
* ALI 支付宝小程序
|
||||
* WEB PC管理端
|
||||
* APP APP管理端
|
||||
*/
|
||||
private String platformType;
|
||||
|
||||
|
|
@ -99,10 +114,10 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
*/
|
||||
@NotBlank(message = "用餐模式不能为空")
|
||||
private String eatModel;
|
||||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 支付模式: afterPay 后付费 normal 正常模式
|
||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
||||
*/
|
||||
@NotBlank(message = "付款模式不能为空")
|
||||
private String payMode;
|
||||
|
|
@ -116,6 +131,10 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
* 当前订单下单次数
|
||||
*/
|
||||
private Integer placeNum;
|
||||
/**
|
||||
* 挂账人
|
||||
*/
|
||||
private Long creditBuyerId;
|
||||
|
||||
/**
|
||||
* 是否等叫 0 否 1 等叫
|
||||
|
|
@ -130,11 +149,11 @@ public class OrderInfoAddDTO implements Serializable {
|
|||
return seatNum == null ? 0 : seatNum;
|
||||
}
|
||||
|
||||
public String getEatModel() {
|
||||
return StrUtil.isBlank(eatModel) ? "dine-in" : eatModel;
|
||||
public String getDineMode() {
|
||||
return StrUtil.isBlank(dineMode) ? "dine-in" : dineMode;
|
||||
}
|
||||
|
||||
public BigDecimal getPointsNum() {
|
||||
return pointsNum == null ? BigDecimal.ZERO : pointsNum;
|
||||
public Integer getPointsNum() {
|
||||
return pointsNum == null ? 0 : pointsNum;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ public class OrderInfoDTO implements Serializable {
|
|||
* 订单原金额 不含折扣价格
|
||||
*/
|
||||
private BigDecimal originAmount;
|
||||
/**
|
||||
* 抹零金额 减免多少钱
|
||||
*/
|
||||
private BigDecimal roundAmount;
|
||||
|
||||
/**
|
||||
* 订单金额 (扣除各类折扣)
|
||||
|
|
@ -79,7 +83,7 @@ public class OrderInfoDTO implements Serializable {
|
|||
/**
|
||||
* 使用的积分数量
|
||||
*/
|
||||
private BigDecimal pointsNum;
|
||||
private Integer pointsNum;
|
||||
|
||||
/**
|
||||
* 商品优惠券抵扣金额
|
||||
|
|
@ -104,7 +108,7 @@ public class OrderInfoDTO implements Serializable {
|
|||
/**
|
||||
* 折扣比例
|
||||
*/
|
||||
private BigDecimal discountRatio;
|
||||
private String discountRatio;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
|
|
@ -139,7 +143,7 @@ public class OrderInfoDTO implements Serializable {
|
|||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 支付模式: afterPay 后付费 normal 正常模式
|
||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
||||
*/
|
||||
private String payMode;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ public class CashierCart implements Serializable {
|
|||
* 数量
|
||||
*/
|
||||
private BigDecimal number;
|
||||
/**
|
||||
* 打包数量
|
||||
*/
|
||||
private BigDecimal packNumber;
|
||||
|
||||
/**
|
||||
* 台桌桌码
|
||||
|
|
@ -77,11 +81,6 @@ public class CashierCart implements Serializable {
|
|||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 是否打包
|
||||
*/
|
||||
private Integer isPack;
|
||||
|
||||
/**
|
||||
* 是否赠送
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.mybatisflex.annotation.Column;
|
|||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -53,28 +54,23 @@ public class OrderDetail implements Serializable {
|
|||
|
||||
private String skuName;
|
||||
|
||||
/**
|
||||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
*/
|
||||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 单价:原价/会员价/临时改价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 折扣金额
|
||||
* 折扣金额(商品优惠券抵扣金额)
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
* 打包费(单价)
|
||||
*/
|
||||
private BigDecimal packAmount;
|
||||
|
||||
/**
|
||||
* 总金额/实付金额,包含打包费 不包括优惠金额
|
||||
* 支付金额,去除优惠券优惠金额的商品金额 不包含打包费
|
||||
*/
|
||||
private BigDecimal payAmount;
|
||||
|
||||
|
|
@ -87,6 +83,14 @@ public class OrderDetail implements Serializable {
|
|||
* 数量
|
||||
*/
|
||||
private BigDecimal num;
|
||||
/**
|
||||
* 打包数量
|
||||
*/
|
||||
private BigDecimal packNumber;
|
||||
/**
|
||||
* 优惠券抵扣数量
|
||||
*/
|
||||
private BigDecimal couponNum;
|
||||
|
||||
/**
|
||||
* 退菜数量(不管价格)
|
||||
|
|
@ -109,7 +113,7 @@ public class OrderDetail implements Serializable {
|
|||
private String discountSaleNote;
|
||||
|
||||
/**
|
||||
* 状态: in-production 制作中;wait-out 待取餐;refunding 退款中; part-refund 部分退单; refund-退单; done 完成;
|
||||
* 状态: in-production 制作中;wait-out 待取餐;refunding 退款中; part-refund 部分退单; refund-退单; done 完成;
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
|
@ -117,7 +121,6 @@ public class OrderDetail implements Serializable {
|
|||
* 当前下单次数
|
||||
*/
|
||||
private Integer placeNum;
|
||||
|
||||
/**
|
||||
* 是否是临时菜品
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.order.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
|
|
@ -64,6 +65,10 @@ public class OrderInfo implements Serializable {
|
|||
* 订单原金额 不含折扣价格
|
||||
*/
|
||||
private BigDecimal originAmount;
|
||||
/**
|
||||
* 抹零金额 减免多少钱
|
||||
*/
|
||||
private BigDecimal roundAmount;
|
||||
|
||||
/**
|
||||
* 订单金额 (扣除各类折扣)
|
||||
|
|
@ -83,7 +88,7 @@ public class OrderInfo implements Serializable {
|
|||
/**
|
||||
* 使用的积分数量
|
||||
*/
|
||||
private BigDecimal pointsNum;
|
||||
private Integer pointsNum;
|
||||
|
||||
/**
|
||||
* 商品优惠券抵扣金额
|
||||
|
|
@ -108,7 +113,7 @@ public class OrderInfo implements Serializable {
|
|||
/**
|
||||
* 折扣比例
|
||||
*/
|
||||
private BigDecimal discountRatio;
|
||||
private String discountRatio;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
|
|
@ -143,7 +148,7 @@ public class OrderInfo implements Serializable {
|
|||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 支付模式: afterPay 后付费 normal 正常模式
|
||||
* 支付模式: afterPay 后付费 normal 正常模式 buyer 挂账模式
|
||||
*/
|
||||
private String payMode;
|
||||
|
||||
|
|
@ -253,4 +258,47 @@ public class OrderInfo implements Serializable {
|
|||
*/
|
||||
private Integer isDel;
|
||||
|
||||
public BigDecimal getOriginAmount() {
|
||||
return originAmount == null ? BigDecimal.ZERO : originAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getRoundAmount() {
|
||||
return roundAmount == null ? BigDecimal.ZERO : roundAmount;
|
||||
}
|
||||
|
||||
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,9 +1,10 @@
|
|||
package com.czg.order.service;
|
||||
|
||||
import com.czg.order.entity.CashierCart;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.order.entity.CashierCart;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -17,7 +18,10 @@ public interface CashierCartService extends IService<CashierCart> {
|
|||
|
||||
/**
|
||||
* 获取到的结果 是针对tb_order_detail的
|
||||
*
|
||||
* @param tableCode 桌码
|
||||
* @param isUseVip 是否使用会员价
|
||||
* @param placeNum 第几次下单
|
||||
*/
|
||||
List<OrderDetail> getCartByTableCode(@NotBlank String tableCode);
|
||||
List<OrderDetail> getCartByTableCode(@NotBlank String tableCode, @NotNull Integer isUseVip,@NotNull Integer placeNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.czg.order.service;
|
|||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单详情 服务层。
|
||||
*
|
||||
|
|
@ -11,4 +13,6 @@ import com.czg.order.entity.OrderDetail;
|
|||
*/
|
||||
public interface OrderDetailService extends IService<OrderDetail> {
|
||||
|
||||
void createOrderDetails(Long orderId, List<OrderDetail> orderDetails);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.czg.order.dto.OrderInfoAddDTO;
|
|||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.vo.OrderInfoCreateVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
|
@ -24,7 +23,7 @@ import java.time.LocalDateTime;
|
|||
public interface OrderInfoService extends IService<OrderInfo> {
|
||||
|
||||
Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param);
|
||||
OrderInfoCreateVo createOrder(OrderInfoAddDTO param);
|
||||
OrderInfo createOrder(OrderInfoAddDTO param);
|
||||
|
||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class OrderDetailSmallVO implements Serializable {
|
|||
private String productName;
|
||||
private String skuName;
|
||||
private BigDecimal num;
|
||||
private BigDecimal packNum;
|
||||
private BigDecimal refundNum;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
package com.czg.order.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class OrderInfoCreateVo {
|
||||
}
|
||||
|
|
@ -15,5 +15,11 @@ import java.util.List;
|
|||
public interface CashierCartMapper extends BaseMapper<CashierCart> {
|
||||
|
||||
|
||||
List<OrderDetail> getCartByTableCode(String tableCode);
|
||||
/**
|
||||
*
|
||||
* @param tableCode 桌码
|
||||
* @param isUseVip 是否使用会员价
|
||||
* @param placeNum 第几次下单
|
||||
*/
|
||||
List<OrderDetail> getCartByTableCode(String tableCode,Integer isUseVip,Integer placeNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.czg.service.order.mapper;
|
|||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单详情 映射层。
|
||||
|
|
@ -10,5 +13,5 @@ import com.czg.order.entity.OrderDetail;
|
|||
* @since 2025-02-13
|
||||
*/
|
||||
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
|
||||
|
||||
void createOrderDetails(@Param("orderId") Long orderId,@Param("orderDetails") List<OrderDetail> orderDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import java.util.List;
|
|||
* @since 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class CashierCartServiceImpl extends ServiceImpl<CashierCartMapper, CashierCart> implements CashierCartService{
|
||||
public class CashierCartServiceImpl extends ServiceImpl<CashierCartMapper, CashierCart> implements CashierCartService {
|
||||
|
||||
@Override
|
||||
public List<OrderDetail> getCartByTableCode(String tableCode) {
|
||||
return getMapper().getCartByTableCode(tableCode);
|
||||
public List<OrderDetail> getCartByTableCode(String tableCode, Integer isUseVip, Integer placeNum) {
|
||||
return getMapper().getCartByTableCode(tableCode, isUseVip, placeNum);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.czg.order.service.OrderDetailService;
|
|||
import com.czg.service.order.mapper.OrderDetailMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单详情 服务层实现。
|
||||
*
|
||||
|
|
@ -15,4 +17,8 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements OrderDetailService{
|
||||
|
||||
@Override
|
||||
public void createOrderDetails(Long orderId, List<OrderDetail> orderDetails) {
|
||||
getMapper().createOrderDetails(orderId, orderDetails);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
|
@ -9,6 +11,7 @@ import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
|||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
|
|
@ -23,8 +26,8 @@ import com.czg.order.service.OrderDetailService;
|
|||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.order.vo.OrderDetailSmallVO;
|
||||
import com.czg.order.vo.OrderInfoCreateVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.mapper.OrderInfoMapper;
|
||||
import com.czg.utils.AssertUtil;
|
||||
|
|
@ -43,8 +46,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 订单表 服务层实现。
|
||||
|
|
@ -58,27 +62,31 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
|
||||
@Resource
|
||||
private OrderPaymentService paymentService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@Resource
|
||||
private CashierCartService cartService;
|
||||
@Resource
|
||||
private OrderDetailService detailService;
|
||||
@DubboReference
|
||||
private ShopTableService shopTableService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private PointsBasicSettingService pointsBasicService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private ShopTableService shopTableService;
|
||||
@DubboReference
|
||||
private ShopActivateService activateService;
|
||||
@DubboReference
|
||||
private PointsBasicSettingService pointsBasicService;
|
||||
@DubboReference
|
||||
private ShopActivateCouponRecordService couponRecordService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
@Override
|
||||
public Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param) {
|
||||
|
|
@ -114,13 +122,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
|
||||
@Override
|
||||
public OrderInfoCreateVo createOrder(OrderInfoAddDTO param) {
|
||||
public OrderInfo createOrder(OrderInfoAddDTO param) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
||||
if (shopInfo.getIsTableFee().equals(0) && param.getSeatNum() == 0) {
|
||||
throw new ValidateException("生成订单失败,请选择用餐人数后下单");
|
||||
}
|
||||
if (!shopInfo.getEatModel().contains(param.getEatModel())) {
|
||||
if (!shopInfo.getEatModel().contains(param.getDineMode())) {
|
||||
throw new ValidateException("生成订单失败,店铺不支持该用餐模式");
|
||||
}
|
||||
if ("afterPay".equals(param.getPayMode()) && !"restaurant".equals(shopInfo.getRegisterType())) {
|
||||
|
|
@ -130,7 +138,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
|
||||
}
|
||||
PointsBasicSetting pointSetting = pointsBasicService.getById(shopInfo.getId());
|
||||
if (param.getPointsNum().compareTo(BigDecimal.ZERO) > 0 && !pointSetting.getEnableDeduction().equals(1)) {
|
||||
if (param.getPointsNum() > 0 && !pointSetting.getEnableDeduction().equals(1)) {
|
||||
throw new ValidateException("生成订单失败,该店铺未开启积分抵扣");
|
||||
}
|
||||
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
||||
|
|
@ -141,11 +149,151 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
ShopTable table = shopTableService.getOneByTableCode(param.getShopId(), param.getTableCode());
|
||||
AssertUtil.isNull(table, "生成订单失败,桌台信息不存在");
|
||||
|
||||
// List<CashierCart> cashierCarts = cartService.
|
||||
if (param.getDiscountRatio().compareTo(BigDecimal.ZERO) <= 0 && param.getDiscountRatio().compareTo(BigDecimal.ONE) > 0) {
|
||||
throw new ValidateException("生成订单失败,折扣比例不正确");
|
||||
}
|
||||
//商品券
|
||||
Map<Long, Integer> prodCouponMap = new HashMap<>();
|
||||
//满减券 满fullCouponAmount 减disCouponAmount
|
||||
BigDecimal fullAmount = BigDecimal.ZERO;
|
||||
BigDecimal discountAmount = BigDecimal.ZERO;
|
||||
if (CollUtil.isNotEmpty(param.getCouponList())) {
|
||||
//校验优惠券
|
||||
List<ShopActivateCouponRecord> records = couponRecordService.list(QueryWrapper.create()
|
||||
.where(ShopActivateCouponRecord::getId).in(param.getCouponList())
|
||||
.and(ShopActivateCouponRecord::getStatus).eq("not_used"));
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
throw new ValidateException("生成订单失败,优惠券信息不存在");
|
||||
} else if (records.size() != param.getCouponList().size()) {
|
||||
throw new ValidateException("生成订单失败,优惠券信息不正确");
|
||||
}
|
||||
boolean isFullMinus = false;
|
||||
for (ShopActivateCouponRecord record : records) {
|
||||
if (record.getType().equals(1)) {
|
||||
if (isFullMinus) {
|
||||
throw new ValidateException("生成订单失败,满减券仅可使用一张");
|
||||
}
|
||||
fullAmount = record.getFullAmount();
|
||||
discountAmount = record.getDiscountAmount();
|
||||
isFullMinus = true;
|
||||
} else if (record.getType().equals(2)) {
|
||||
prodCouponMap.compute(record.getProId(), (key, oldValue) -> oldValue == null ? 1 : oldValue + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (discountAmount.compareTo(param.getFullCouponDiscountAmount()) != 0) {
|
||||
throw new ValidateException("生成订单失败,满减券减免金额不正确");
|
||||
}
|
||||
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
||||
List<OrderDetail> orderDetails = cartService.getCartByTableCode(table.getTableCode(), param.isVipPrice() ? 1 : 0, param.getPlaceNum());
|
||||
//总打包费
|
||||
BigDecimal packAmount = BigDecimal.ZERO;
|
||||
//商品优惠券金额
|
||||
BigDecimal prodCouponAmount = BigDecimal.ZERO;
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
processOrderDetails(orderDetails, prodCouponMap, prodCouponAmount, packAmount, totalAmount);
|
||||
if (packAmount.compareTo(param.getPackFee()) != 0) {
|
||||
throw new ValidateException("生成订单失败,打包费不正确");
|
||||
}
|
||||
if (prodCouponAmount.compareTo(param.getProductCouponDiscountAmount()) != 0) {
|
||||
throw new ValidateException("生成订单失败,商品优惠券优惠金额不正确");
|
||||
}
|
||||
//折扣金额 如 9折 计算 为 订单金额*0.9 向上取整
|
||||
BigDecimal newTotalAmount = BigDecimal.ZERO;
|
||||
if (param.getDiscountRatio().compareTo(BigDecimal.ONE) != 0) {
|
||||
newTotalAmount = totalAmount.multiply(param.getDiscountRatio()).setScale(2, RoundingMode.UP);
|
||||
if (param.getDiscountAmount().compareTo(totalAmount.subtract(newTotalAmount)) != 0) {
|
||||
throw new ValidateException("生成订单失败,折扣金额不正确");
|
||||
}
|
||||
}
|
||||
//满减券 校验
|
||||
if (newTotalAmount.compareTo(fullAmount) < 0) {
|
||||
throw new ValidateException("生成订单失败,满减券不满足条件");
|
||||
}
|
||||
//减去满减优惠券
|
||||
newTotalAmount = newTotalAmount.subtract(discountAmount);
|
||||
//积分抵扣 金额范围校验 抵扣金额校验
|
||||
if (param.getPointsNum() > 0) {
|
||||
if (pointSetting.getMinPaymentAmount().compareTo(newTotalAmount) > 0) {
|
||||
throw new ValidateException("生成订单失败,未满足积分抵扣最低门槛");
|
||||
}
|
||||
if (pointSetting.getMaxDeductionRatio().multiply(newTotalAmount).compareTo(param.getPointsDiscountAmount()) < 0) {
|
||||
throw new ValidateException("生成订单失败,积分抵扣金额已超出最大抵扣金额");
|
||||
}
|
||||
BigDecimal pointAmount = new BigDecimal(param.getPointsNum()).divide(new BigDecimal(pointSetting.getEquivalentPoints()), 2, RoundingMode.DOWN);
|
||||
if (pointAmount.compareTo(param.getPointsDiscountAmount()) != 0) {
|
||||
throw new ValidateException("生成订单失败,积分抵扣金额不正确");
|
||||
}
|
||||
}
|
||||
newTotalAmount = newTotalAmount.subtract(param.getPointsDiscountAmount());
|
||||
//抹零
|
||||
newTotalAmount = newTotalAmount.subtract(param.getRoundAmount());
|
||||
//校验最终金额(订单金额 (扣除各类折扣)+打包费 餐位费)
|
||||
newTotalAmount = newTotalAmount.add(param.getPackFee()).add(new BigDecimal(param.getSeatNum()).multiply(shopInfo.getTableFee()));
|
||||
if (newTotalAmount.compareTo(param.getOrderAmount()) != 0) {
|
||||
throw new ValidateException("生成订单失败,订单金额不正确");
|
||||
}
|
||||
//生成订单 //discount_info 所有折扣 几折 折扣金额 满减金额 优惠券金额 积分抵扣金额 抹零
|
||||
OrderInfo orderInfo = initOrderInfo(param, shopInfo, table);
|
||||
orderDetailService.createOrderDetails(orderInfo.getId(), orderDetails);
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
/**
|
||||
* 填充 优惠券使用数量 以及 付款金额
|
||||
*
|
||||
* @param orderDetails 订单详情 需要回填 优惠券抵扣数量
|
||||
* @param prodCouponMap 使用优惠券<商品id,数量>
|
||||
* @param prodCouponAmount 商品券优惠金额 商品单价*优惠数量 的总和
|
||||
* @param packAmount 打包费
|
||||
* @param totalAmount 最终总金额(没加打包费 餐位费) 去除优惠券金额后的
|
||||
*/
|
||||
private void processOrderDetails(List<OrderDetail> orderDetails, Map<Long, Integer> prodCouponMap,
|
||||
BigDecimal prodCouponAmount, BigDecimal packAmount, BigDecimal totalAmount) {
|
||||
Map<Long, List<OrderDetail>> detailMap = new HashMap<>();
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
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<>();
|
||||
for (Map.Entry<Long, List<OrderDetail>> entry : detailMap.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
List<OrderDetail> value = entry.getValue();
|
||||
BigDecimal couponNum = BigDecimal.ZERO;
|
||||
if (prodCouponMap.containsKey(key)) {
|
||||
couponNum = new BigDecimal(prodCouponMap.get(key));
|
||||
if (value.size() > 1) {
|
||||
value.sort(Comparator.comparing(OrderDetail::getPrice));
|
||||
}
|
||||
}
|
||||
for (OrderDetail orderDetail : value) {
|
||||
if (couponNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (couponNum.compareTo(orderDetail.getNum()) >= 0) {
|
||||
orderDetail.setCouponNum(orderDetail.getNum());
|
||||
orderDetail.setPayAmount(BigDecimal.ZERO);
|
||||
couponNum = couponNum.subtract(orderDetail.getNum());
|
||||
} else {
|
||||
orderDetail.setCouponNum(couponNum);
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(couponNum)).multiply(orderDetail.getPrice()));
|
||||
couponNum = BigDecimal.ZERO;
|
||||
}
|
||||
prodCouponAmount = prodCouponAmount.add(orderDetail.getPrice().multiply(orderDetail.getCouponNum()));
|
||||
} else {
|
||||
orderDetail.setCouponNum(BigDecimal.ZERO);
|
||||
orderDetail.setPayAmount(orderDetail.getNum().multiply(orderDetail.getPrice()));
|
||||
}
|
||||
totalAmount = totalAmount.add(orderDetail.getPayAmount());
|
||||
resultList.add(orderDetail);
|
||||
}
|
||||
if (couponNum.compareTo(BigDecimal.ZERO) != 0) {
|
||||
throw new ValidateException("生成订单失败,优惠券数量不正确");
|
||||
}
|
||||
}
|
||||
orderDetails = resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -244,4 +392,91 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(orderId.toString());
|
||||
}
|
||||
|
||||
|
||||
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) {
|
||||
OrderInfo orderInfo = new OrderInfo();
|
||||
if (param.getOrderId() != null) {
|
||||
orderInfo = getById(param.getOrderId());
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
throw new ValidateException("生成订单失败,订单已结束,请重新下单");
|
||||
}
|
||||
} else {
|
||||
orderInfo.setOrderNo(param.getPlatformType() + IdUtil.getSnowflakeNextId());
|
||||
orderInfo.setShopId(param.getShopId());
|
||||
orderInfo.setUserId(param.getUserId());
|
||||
orderInfo.setTableCode(table.getTableCode());
|
||||
orderInfo.setTableName(table.getName());
|
||||
orderInfo.setDineMode(param.getDineMode());
|
||||
orderInfo.setSeatNum(param.getSeatNum());
|
||||
orderInfo.setRefundAmount(BigDecimal.ZERO);
|
||||
orderInfo.setPayAmount(BigDecimal.ZERO);
|
||||
|
||||
orderInfo.setOrderType(param.getOrderType());
|
||||
orderInfo.setPlatformType(param.getPlatformType());
|
||||
orderInfo.setDineMode(param.getDineMode());
|
||||
orderInfo.setPayMode(param.getPayMode());
|
||||
orderInfo.setStatus("unpaid");
|
||||
orderInfo.setRefundAble(0);
|
||||
orderInfo.setTradeDay(DateUtil.formatDate(new Date()));
|
||||
orderInfo.setRemark(param.getRemark());
|
||||
orderInfo.setStaffId(param.getStaffId());
|
||||
orderInfo.setIsWaitCall(param.isWaitCall() ? 1 : 0);
|
||||
orderInfo.setCreditBuyerId(param.getCreditBuyerId());
|
||||
orderInfo.setIsDel(0);
|
||||
//取餐码 多端一致
|
||||
orderInfo.setTakeCode(getCode(shopInfo.getId()));
|
||||
orderInfo.setSeatAmount(shopInfo.getTableFee().multiply(new BigDecimal(param.getSeatNum())));
|
||||
}
|
||||
orderInfo.setPlaceNum(param.getPlaceNum());
|
||||
|
||||
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.setDiscountRatio(orderInfo.getDiscountRatio() + param.getDiscountRatio());
|
||||
//优惠券
|
||||
orderInfo.setCouponInfoList(orderInfo.getCouponInfoList() + "," + JSONObject.toJSONString(param.getCouponList()));
|
||||
//折扣信息
|
||||
orderInfo.setDiscountInfo(buildDiscountInfo(orderInfo));
|
||||
saveOrUpdate(orderInfo);
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private String buildDiscountInfo(OrderInfo orderInfo) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (orderInfo.getProductCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
jsonObject.put("商品券抵扣", orderInfo.getProductCouponDiscountAmount());
|
||||
}
|
||||
if (orderInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
jsonObject.put("打折优惠", orderInfo.getDiscountAmount());
|
||||
}
|
||||
if (orderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
jsonObject.put("满减券抵扣", orderInfo.getFullCouponDiscountAmount());
|
||||
}
|
||||
if (orderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
jsonObject.put("积分抵扣", orderInfo.getPointsDiscountAmount());
|
||||
}
|
||||
if (orderInfo.getRoundAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
jsonObject.put("抹零", orderInfo.getPointsNum());
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,44 @@
|
|||
<mapper namespace="com.czg.service.order.mapper.CashierCartMapper">
|
||||
|
||||
<select id="getCartByTableCode" resultType="com.czg.order.entity.OrderDetail">
|
||||
select cart.shop_id as shopId,
|
||||
cart.product_id as productId,
|
||||
pros.product_name as productName,
|
||||
cart.sku_id as skuId,
|
||||
skus.spec_info as skuName,
|
||||
cart.number as number,
|
||||
select cart.shop_id as shopId,
|
||||
cart.number as number,
|
||||
pros.pack_fee as packAmount,
|
||||
cart.pack_number as packNumber,
|
||||
cart.is_temporary as isTemporary,
|
||||
cart.discount_sale_note as discountSaleNote,
|
||||
cart.is_print as isPrint,
|
||||
cart.is_wait_call as isWaitCall,
|
||||
cart.pro_group_info as proGroupInfo,
|
||||
cart.remark as remark,
|
||||
cart.product_id as productId,
|
||||
pros.cover_img as productImg,
|
||||
pros.type as productType,
|
||||
cart.sku_id as skuId,
|
||||
skus.spec_info as skuName,
|
||||
'wait-pay' as status,
|
||||
#{placeNum} as placeNum,
|
||||
#{dineMode} as dineMode,
|
||||
case cart.is_temporary
|
||||
when 1 then cart.product_name
|
||||
else pros.name
|
||||
end as productName,
|
||||
case cart.is_gift
|
||||
when 1 then 0
|
||||
else
|
||||
CASE
|
||||
cart.is_temporary
|
||||
WHEN 1 THEN
|
||||
cart.discount_sale_amount
|
||||
ELSE
|
||||
IF(cart.discount_sale_amount > 0,
|
||||
cart.discount_sale_amount,
|
||||
CASE #{isUseVip}
|
||||
WHEN 1 THEN skus.member_price
|
||||
ELSE skus.sale_price END)
|
||||
end
|
||||
END as price
|
||||
|
||||
from tb_cashier_cart cart
|
||||
left join tb_product pros on cart.product_id = pros.id
|
||||
left join tb_prod_sku skus on cart.sku_id = skus.id
|
||||
|
|
|
|||
|
|
@ -4,4 +4,20 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.order.mapper.OrderDetailMapper">
|
||||
|
||||
<insert id="createOrderDetails">
|
||||
INSERT INTO tb_order_detail(order_id, shop_id, product_id, product_img, product_name, product_type, sku_id,
|
||||
sku_name, price, discount_amount, pack_amount, pay_amount, return_amount, num, pack_number, coupon_num,
|
||||
return_num, refund_num, refund_no, discount_sale_note, status, place_num, is_temporary, is_print, is_wait_call,
|
||||
pro_group_info, remark, refund_remark, create_time, update_time)
|
||||
VALUES
|
||||
<foreach collection="orderDetails" item="entity" separator=",">
|
||||
(#{orderId}, #{entity.shopId}, #{entity.productId}, #{entity.productImg}, #{entity.productName},
|
||||
#{entity.productType}, #{entity.skuId}, #{entity.skuName}, #{entity.price}, #{entity.discountAmount},
|
||||
#{entity.packAmount}, #{entity.payAmount}, #{entity.returnAmount}, #{entity.num}, #{entity.packNumber},
|
||||
#{entity.couponNum}, #{entity.returnNum}, #{entity.refundNum}, #{entity.refundNo},
|
||||
#{entity.discountSaleNote}, #{entity.status}, #{entity.placeNum}, #{entity.isTemporary}, #{entity.isPrint},
|
||||
#{entity.isWaitCall}, #{entity.proGroupInfo}, #{entity.remark}, #{entity.refundRemark},
|
||||
#{entity.createTime}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue