1.代客下单,折扣

This commit is contained in:
2024-08-29 17:57:56 +08:00
parent 297ccc0233
commit 71bc936074

View File

@@ -321,7 +321,9 @@ public class TbPayServiceImpl implements TbPayService {
throw new BadRequestException("用户不存在或已被禁用");
}
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), orderInfo.getOrderAmount());
BigDecimal payMount = discount == null ? orderInfo.getOrderAmount() : orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.UP);
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), payMount);
if (flag < 1) {
throw new BadRequestException("余额不足或扣除余额失败");
}
@@ -336,7 +338,7 @@ public class TbPayServiceImpl implements TbPayService {
userFlow.setType("-");
shopUserFlowMapper.insert(userFlow);
orderInfo.setPayAmount(discount == null ? orderInfo.getOrderAmount() : orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.UP));
orderInfo.setPayAmount(payMount);
if (discount != null && discount != 1) {
orderInfo.setDiscountAmount(orderInfo.getOrderAmount().subtract(orderInfo.getPayAmount()));
orderInfo.setDiscountRatio(BigDecimal.valueOf(discount));