fix: 退款修改

This commit is contained in:
张松 2024-11-21 09:25:12 +08:00
parent a15eafdb57
commit 425a3a3f37
1 changed files with 4 additions and 1 deletions

View File

@ -2718,6 +2718,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal saleAmount = BigDecimal.ZERO;
ArrayList<TbOrderDetail> remainOrderDetailList = new ArrayList<>();
boolean hasNormalReturn = false;
for (TbOrderDetail orderDetail : detailList) {
// 退款数量
BigDecimal returnNum = returnNumMap.get(orderDetail.getId().toString());
@ -2754,6 +2755,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.add(returnPackFee);
// 使用了满减或积分获取普通付款商品计算退款比例退部分现金
}else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){
hasNormalReturn = true;
// 计算当前商品占比
BigDecimal ratio = calcDetailRatio(orderDetail);
BigDecimal realAmount = orderDetail.getPriceAmount().multiply(ratio);
@ -2767,6 +2769,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.multiply(returnNum)).setScale(2, RoundingMode.HALF_UP);
}else {
hasNormalReturn = true;
currentDetailAMount = orderDetail.getPriceAmount()
.divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
.multiply(returnNum).setScale(2, RoundingMode.HALF_UP);
@ -2785,7 +2788,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
orderDetail.setStatus("refund");
}
if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) {
if (hasNormalReturn && returnAmount.compareTo(BigDecimal.ZERO) <= 0) {
throw new BadRequestException("退款金额必须大于0");
}