霸王餐 餐位费

This commit is contained in:
wangw 2025-03-24 17:00:51 +08:00
parent f065ad6b5a
commit 93f5b8e8ee
2 changed files with 9 additions and 1 deletions

View File

@ -29,6 +29,7 @@ public class VipPayParamDTO {
* 用户端 使用 全打包 或者 全不打包
*/
private Integer userAllPack;
private Integer seatNum;
@NotNull(message = "充值金额不为空")
private BigDecimal amount;

View File

@ -133,6 +133,13 @@ public class PayServiceImpl implements PayService {
}
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
AssertUtil.isNull(orderInfo, "订单不存在");
orderInfo.setSeatNum(payParam.getSeatNum());
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
if (shopInfo.getIsTableFee() != 1 && shopInfo.getTableFee().compareTo(BigDecimal.ZERO) != 0) {
orderInfo.setSeatAmount(new BigDecimal(orderInfo.getSeatNum()).multiply(shopInfo.getTableFee()));
} else {
orderInfo.setSeatAmount(BigDecimal.ZERO);
}
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
List<OrderDetail> orderDetails = orderDetailService.queryChain().eq(OrderDetail::getOrderId, orderInfo.getId()).select().list();
//总商品支付金额 不包含打包费 用来计算后续
@ -144,7 +151,7 @@ public class PayServiceImpl implements PayService {
if (total.compareTo(freeConfig.getRechargeThreshold()) < 0) {
throw new CzgException("霸王餐满" + freeConfig.getRechargeThreshold() + "可用,当前订单金额为" + total);
}
BigDecimal payAmount = (totalAmount.getPrice().add(packAmount.getPrice())).multiply(new BigDecimal(freeConfig.getMultiple()));
BigDecimal payAmount = (totalAmount.getPrice().add(packAmount.getPrice()).add(orderInfo.getSeatAmount())).multiply(new BigDecimal(freeConfig.getMultiple()));
log.info("霸王餐应支付金额:{},充值金额为:{}", payAmount, payParam.getAmount());
if (payAmount.compareTo(payParam.getAmount()) != 0) {
throw new ValidateException("霸王餐支付金额不正确");