订单折扣问题

付款金额0的问题
This commit is contained in:
2025-03-03 14:19:19 +08:00
parent 9c35a6e2cc
commit f757f0698d
7 changed files with 69 additions and 33 deletions

View File

@@ -95,6 +95,15 @@ public class CzgControllerAdvice {
return CzgResult.failure(ex.getCode(), ex.getMsg());
}
/**
* 支付成功
* 支付金额为零的统一处理
*/
@ExceptionHandler(PaySuccessException.class)
public CzgResult<Object> handlePaySuccessException() {
return CzgResult.success();
}
/**
* 处理Hutool的断言抛出异常
*/

View File

@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@@ -93,7 +94,10 @@ public class CheckOrderPay implements Serializable {
}
public BigDecimal getDiscountRatio() {
return discountRatio == null ? BigDecimal.ONE : discountRatio;
if (discountRatio == null) {
return BigDecimal.ZERO;
}
return discountRatio.setScale(2, RoundingMode.UP);
}
public BigDecimal getFullCouponDiscountAmount() {

View File

@@ -1,5 +1,3 @@
package com.czg.exception;
import com.czg.resp.CzgRespCode;

View File

@@ -0,0 +1,16 @@
package com.czg.exception;
import java.io.Serial;
/**
* 自定义异常
*
* @author admin admin@cashier.com
* @since 1.0.0
*/
public class PaySuccessException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
}