From 1bc439ec54b7b2c1334ea6528687e3986bf36bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Tue, 8 Oct 2024 11:09:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B010.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fleet/service/FleetInfoService.java | 7 ++++ .../service/impl/FleetInfoServiceImpl.java | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+) 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; + } + /** * 创建用户的基础信息