diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java index 9cc5a0b99..fced3df7c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java @@ -105,4 +105,11 @@ public interface FleetInfoService { * @param orderId */ int payFleet(String orderId, Double money); + + /** + * 车队卡退款 + * @param orderId + * @return + */ + int refundFleet(String orderId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java index 583bcf42e..133659b35 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java @@ -464,6 +464,43 @@ public class FleetInfoServiceImpl extends ServiceImpl() + .eq(AllOrderInfo::getId, orderId)); + if (ObjectUtil.isEmpty(allOrderInfo)) { + throw new RuntimeException("订单不存在"); + } + FleetConsumeRecord fleetConsumeRecord = fleetConsumeRecordMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetConsumeRecord::getOrderNo, allOrderInfo.getOrderNo())); + if (ObjectUtil.isEmpty(fleetConsumeRecord)) { + throw new RuntimeException("车队订单不存在"); + } + if ("paid".equals(fleetConsumeRecord.getOrderStatus())) { + //退款金额 + Double refundMoney = fleetConsumeRecord.getNetReceiptsAmount(); + //获取当前车队卡 + FleetInfo fleetInfo = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetInfo::getId, fleetConsumeRecord.getFleetId())); + //计算赠送金额与充值金额比例 + double recharge = fleetInfo.getRechargeAmount() / fleetInfo.getTotalBalance(); + double give = fleetInfo.getGiveAmount() / fleetInfo.getTotalBalance(); + fleetInfo.setTotalBalance(fleetInfo.getTotalBalance() + refundMoney); + fleetInfo.setRechargeAmount(fleetInfo.getRechargeAmount() + (refundMoney * recharge)); + fleetInfo.setGiveAmount(fleetInfo.getGiveAmount() + (refundMoney * give)); + //将退款金额修改回去 + baseMapper.updateById(fleetInfo); + } + return 0; + } + /** * 创建用户的基础信息