fix: 代客下单折扣为空导致详情金额有误修复

This commit is contained in:
SongZhang 2024-10-28 16:50:07 +08:00
parent 9988723044
commit 267c24e16a
2 changed files with 6 additions and 5 deletions

View File

@ -176,8 +176,7 @@ public class PayServiceImpl implements PayService {
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
.in(TbOrderDetail::getStatus, "unpaid")
.setSql(StrUtil.format("price_amount=price*num*{}", orderInfo.getDiscountRatio()))
.setSql(StrUtil.format("price_amount=price*num*{}", orderInfo.getDiscountRatio() == null ? 1 : orderInfo.getDiscountRatio()))
.set(TbOrderDetail::getStatus, "closed"));
//修改主单状态

View File

@ -1631,8 +1631,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
orderInfo.setPaidTime(DateUtil.current());
orderInfo.setPayAmount(finalAmount);
orderInfo.setStatus("closed");
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));
orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(finalAmount));
if (payDTO.getDiscount() != null) {
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));
orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(finalAmount));
}
orderInfoMapper.updateById(orderInfo);
//更新购物车状态
@ -1649,7 +1651,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
.eq(TbOrderDetail::getStatus, "unpaid")
.setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount()))
.setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount() == null ? 1: payDTO.getDiscount()))
.set(TbOrderDetail::getStatus, "closed"));
JSONObject jsonObject = new JSONObject();