Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3db724435c
|
|
@ -48,9 +48,21 @@ public class OrderDetailDTO implements Serializable {
|
|||
private String skuName;
|
||||
|
||||
/**
|
||||
* 单价:原价/会员价/临时改价
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 会员价
|
||||
*/
|
||||
private BigDecimal memberPrice;
|
||||
/**
|
||||
* 临时改价/临时菜价
|
||||
*/
|
||||
private BigDecimal discountSaleAmount;
|
||||
/**
|
||||
* 最终单价
|
||||
*/
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 折扣金额
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public class CheckOrderPay implements Serializable {
|
|||
|
||||
private Long userId;
|
||||
|
||||
private Integer vipPrice;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
|
|
@ -115,4 +117,7 @@ public class CheckOrderPay implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public boolean isVipPrice() {
|
||||
return vipPrice != null && vipPrice == 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@ 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;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单详情 实体类。
|
||||
*
|
||||
|
|
@ -56,9 +54,21 @@ public class OrderDetail implements Serializable {
|
|||
private String skuName;
|
||||
|
||||
/**
|
||||
* 单价:原价/会员价/临时改价
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 会员价
|
||||
*/
|
||||
private BigDecimal memberPrice;
|
||||
/**
|
||||
* 临时改价/临时菜价
|
||||
*/
|
||||
private BigDecimal discountSaleAmount;
|
||||
/**
|
||||
* 最终单价
|
||||
*/
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 折扣金额(商品优惠券抵扣金额)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class OrderDetailSmallVO implements Serializable {
|
|||
private BigDecimal packNum;
|
||||
private BigDecimal returnNum;
|
||||
private BigDecimal refundNum;
|
||||
private BigDecimal price;
|
||||
private BigDecimal unitPrice;
|
||||
private BigDecimal payAmount;
|
||||
private String remark;
|
||||
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
BigDecimalDTO prodCouponAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
BigDecimalDTO totalAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
processOrderDetails2(orderDetails, prodCouponMap, prodCouponAmount, totalAmount);
|
||||
processOrderDetails2(orderDetails, prodCouponMap, prodCouponAmount, totalAmount, param.isVipPrice());
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
log.info("支付前置,商品金额{} 商品优惠券金额{} 总金额{}", totalAmount, prodCouponAmount, totalAmount.getPrice().add(orderInfo.getPackFee()));
|
||||
if (prodCouponAmount.getPrice().compareTo(param.getProductCouponDiscountAmount()) != 0) {
|
||||
|
|
@ -355,7 +355,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
* @param totalAmount 最终总金额(没加打包费 餐位费) 去除优惠券金额后的
|
||||
*/
|
||||
private void processOrderDetails2(List<OrderDetail> orderDetails, Map<Long, Integer> prodCouponMap,
|
||||
BigDecimalDTO prodCouponAmount, BigDecimalDTO totalAmount) {
|
||||
BigDecimalDTO prodCouponAmount, BigDecimalDTO totalAmount, boolean isVipPrice) {
|
||||
Map<Long, List<OrderDetail>> detailMap = new HashMap<>();
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
detailMap.computeIfAbsent(detail.getProductId(), k -> new ArrayList<>()).add(detail);
|
||||
|
|
@ -372,6 +372,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
}
|
||||
for (OrderDetail orderDetail : value) {
|
||||
if (orderDetail.getDiscountSaleAmount() != null && orderDetail.getDiscountSaleAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setUnitPrice(orderDetail.getDiscountSaleAmount());
|
||||
}else {
|
||||
if (isVipPrice) {
|
||||
orderDetail.setUnitPrice(orderDetail.getMemberPrice());
|
||||
}else {
|
||||
orderDetail.setUnitPrice(orderDetail.getPrice());
|
||||
}
|
||||
}
|
||||
if (couponNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (couponNum.compareTo(orderDetail.getNum()) >= 0) {
|
||||
orderDetail.setCouponNum(orderDetail.getNum());
|
||||
|
|
@ -379,15 +388,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
couponNum = couponNum.subtract(orderDetail.getNum());
|
||||
} else {
|
||||
orderDetail.setCouponNum(couponNum);
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(couponNum)).multiply(orderDetail.getPrice()));
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(couponNum)).multiply(orderDetail.getUnitPrice()));
|
||||
couponNum = BigDecimal.ZERO;
|
||||
}
|
||||
prodCouponAmount.setPrice(prodCouponAmount.getPrice().add(orderDetail.getPrice().multiply(orderDetail.getCouponNum())));
|
||||
prodCouponAmount.setPrice(prodCouponAmount.getPrice().add(orderDetail.getUnitPrice().multiply(orderDetail.getCouponNum())));
|
||||
} else {
|
||||
orderDetail.setCouponNum(BigDecimal.ZERO);
|
||||
orderDetail.setPayAmount(orderDetail.getNum().multiply(orderDetail.getPrice()));
|
||||
orderDetail.setPayAmount(orderDetail.getNum().multiply(orderDetail.getUnitPrice()));
|
||||
}
|
||||
totalAmount.setPrice(totalAmount.getPrice().add(orderDetail.getPayAmount()));
|
||||
totalAmount.setPrice(totalAmount.getPrice().add(orderDetail.getUnitPrice()));
|
||||
resultList.add(orderDetail);
|
||||
}
|
||||
if (couponNum.compareTo(BigDecimal.ZERO) != 0) {
|
||||
|
|
|
|||
|
|
@ -454,10 +454,10 @@ public class PayServiceImpl implements PayService {
|
|||
refNum = returnNum.subtract(orderDetail.getCouponNum());
|
||||
//退单数量 大于 实际计算金额的数量
|
||||
if (refundDetail.getNum().compareTo(refNum) > 0) {
|
||||
refundAmount = refNum.multiply(orderDetail.getPrice());
|
||||
refundAmount = refNum.multiply(orderDetail.getUnitPrice());
|
||||
returnCouponMap.put(orderDetail.getProductId(), refundDetail.getNum().subtract(refNum).intValue());
|
||||
} else {
|
||||
refundAmount = refundDetail.getNum().multiply(orderDetail.getPrice());
|
||||
refundAmount = refundDetail.getNum().multiply(orderDetail.getUnitPrice());
|
||||
}
|
||||
}
|
||||
if (refundAmount.compareTo(refundDetail.getReturnAmount()) != 0) {
|
||||
|
|
@ -474,7 +474,7 @@ public class PayServiceImpl implements PayService {
|
|||
} else {
|
||||
orderDetail.setReturnNum(orderDetail.getRefundNum().add(refNum));
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum())
|
||||
.subtract(orderDetail.getCouponNum())).multiply(orderDetail.getPrice()));
|
||||
.subtract(orderDetail.getCouponNum())).multiply(orderDetail.getUnitPrice()));
|
||||
}
|
||||
orderDetail.setRefundNo(refPayOrderNo);
|
||||
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
|
||||
|
|
|
|||
|
|
@ -5,43 +5,34 @@
|
|||
<mapper namespace="com.czg.service.order.mapper.CashierCartMapper">
|
||||
|
||||
<select id="getCartByTableCode" resultType="com.czg.order.entity.OrderDetail">
|
||||
select cart.shop_id as shopId,
|
||||
cart.number as num,
|
||||
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,
|
||||
select cart.shop_id as shopId,
|
||||
cart.number as num,
|
||||
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,
|
||||
cart.discount_sale_amount as discountSaleAmount,
|
||||
case cart.is_gift
|
||||
when 1 then 0
|
||||
else skus.sale_price end as price,
|
||||
case cart.is_gift
|
||||
when 1 then 0
|
||||
else skus.member_price end as memberPrice,
|
||||
'wait-pay' as status,
|
||||
#{placeNum} as placeNum,
|
||||
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
|
||||
|
||||
end as productName
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue