订单折扣问题
付款金额0的问题
This commit is contained in:
@@ -242,7 +242,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
param.setUserId(userInfo.getId());
|
||||
}
|
||||
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("生成支付订单失败,折扣比例不正确");
|
||||
}
|
||||
//商品券 <商品id,数量>
|
||||
@@ -266,16 +266,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
throw new ValidateException("生成支付订单失败,商品优惠券优惠金额不正确");
|
||||
}
|
||||
orderInfo.setOriginAmount(totalAmount.getPrice());
|
||||
BigDecimal newTotalAmount;
|
||||
BigDecimal newTotalAmount = totalAmount.getPrice();
|
||||
//折扣金额 如 9折 计算 为 订单金额*0.9 向上取整
|
||||
if (param.getDiscountRatio().compareTo(BigDecimal.ONE) != 0) {
|
||||
if(param.getDiscountRatio().compareTo(BigDecimal.ZERO) > 0) {
|
||||
newTotalAmount = totalAmount.getPrice().multiply(param.getDiscountRatio()).setScale(2, RoundingMode.UP);
|
||||
if (param.getDiscountAmount().compareTo(totalAmount.getPrice().subtract(newTotalAmount)) != 0) {
|
||||
throw new ValidateException("生成支付订单失败,折扣金额不正确");
|
||||
}
|
||||
} else {
|
||||
newTotalAmount = totalAmount.getPrice();
|
||||
|
||||
}else if(param.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
newTotalAmount = totalAmount.getPrice().subtract(param.getDiscountAmount());
|
||||
}
|
||||
|
||||
//满减券 校验
|
||||
if (newTotalAmount.compareTo(fullAmount.getPrice()) < 0) {
|
||||
throw new ValidateException("生成支付订单失败,满减券不满足条件");
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.czg.config.RedisCst;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.PaySuccessException;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
@@ -89,7 +90,14 @@ public class PayServiceImpl implements PayService {
|
||||
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
private OrderInfo checkPay(CheckOrderPay checkOrderPay) {
|
||||
return orderInfoService.checkOrderPay(checkOrderPay);
|
||||
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay);
|
||||
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.CASH_PAY);
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
throw new PaySuccessException();
|
||||
}
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,34 +5,36 @@
|
||||
<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,
|
||||
cart.discount_sale_amount as discountSaleAmount,
|
||||
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,
|
||||
case cart.is_gift
|
||||
when 1 then 0
|
||||
else skus.sale_price end as price,
|
||||
else cart.discount_sale_amount end as discountSaleAmount,
|
||||
case cart.is_gift
|
||||
when 1 then 0
|
||||
else skus.member_price end as memberPrice,
|
||||
'wait-pay' as status,
|
||||
#{placeNum} as placeNum,
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user