更新10.16

This commit is contained in:
许允枞 2024-10-16 09:44:17 +08:00
parent dc8d178882
commit 9ad6fcb18d

View File

@ -415,6 +415,7 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
public int payFleet(String orderId, Double money) {
AllOrderInfo allOrderInfo = allOrderInfoMapper.selectOne(new LambdaQueryWrapper<AllOrderInfo>()
.eq(AllOrderInfo::getId, orderId));
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
if (ObjectUtil.isEmpty(allOrderInfo)) {
throw new RuntimeException("订单不存在");
}
@ -432,6 +433,14 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
throw new RuntimeException("支付金额超过当前余额");
}
//查找车队成员
FleetMember fleetMember = fleetMemberMapper.selectOne(new LambdaQueryWrapper<FleetMember>()
.eq(FleetMember::getId, fleetConsumeRecord.getFleetMemberId()));
//判断成员的余额是否足够支付
if (money > fleetMember.getRemainingCreditLimit()) {
throw new RuntimeException("支付金额超过当前余额");
}
//更新时间
DateTime now = DateUtil.date();
@ -444,13 +453,22 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
fleetInfo.setRechargeAmount(fleetInfo.getRechargeAmount() - (money * recharge));
fleetInfo.setGiveAmount(fleetInfo.getGiveAmount() - (money * give));
fleetInfo.setUpdateTime(now);
fleetInfo.setUpdateBy(nowAccountInfo.getId().toString());
//更新车队卡余额
baseMapper.updateById(fleetInfo);
//计算车队成员剩余额度和已用额度
fleetMember.setRemainingCreditLimit(fleetMember.getRemainingCreditLimit() - money);
fleetMember.setUsedCreditLimit(fleetMember.getUsedCreditLimit() + money);
fleetMember.setUpdateTime(now);
fleetMember.setUpdateBy(nowAccountInfo.getId().toString());
fleetMemberMapper.updateById(fleetMember);
//更新订单状态
allOrderInfo.setStatus("paid");
allOrderInfo.setPayTime(now);
allOrderInfo.setUpdateTime(now);
allOrderInfo.setUpdateBy(nowAccountInfo.getId().toString());
allOrderInfoMapper.updateById(allOrderInfo);
@ -458,6 +476,7 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
fleetConsumeRecord.setOrderStatus("paid");
fleetConsumeRecord.setPaymentTime(now);
fleetConsumeRecord.setUpdateTime(now);
fleetConsumeRecord.setUpdateBy(nowAccountInfo.getId().toString());
//计算扣完款后的余额
fleetConsumeRecord.setAfterTheChange(fleetInfo.getTotalBalance());