更新10.8

This commit is contained in:
许允枞 2024-10-08 11:09:12 +08:00
parent c866a4237b
commit 1bc439ec54
2 changed files with 44 additions and 0 deletions

View File

@ -105,4 +105,11 @@ public interface FleetInfoService {
* @param orderId * @param orderId
*/ */
int payFleet(String orderId, Double money); int payFleet(String orderId, Double money);
/**
* 车队卡退款
* @param orderId
* @return
*/
int refundFleet(String orderId);
} }

View File

@ -464,6 +464,43 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
return fleetConsumeRecordMapper.updateById(fleetConsumeRecord); return fleetConsumeRecordMapper.updateById(fleetConsumeRecord);
} }
/**
* 车队卡退款
*
* @param orderId
* @return
*/
@Override
public int refundFleet(String orderId) {
//通过订单id查询订单信息
AllOrderInfo allOrderInfo = allOrderInfoMapper.selectOne(new LambdaQueryWrapper<AllOrderInfo>()
.eq(AllOrderInfo::getId, orderId));
if (ObjectUtil.isEmpty(allOrderInfo)) {
throw new RuntimeException("订单不存在");
}
FleetConsumeRecord fleetConsumeRecord = fleetConsumeRecordMapper.selectOne(new LambdaQueryWrapper<FleetConsumeRecord>()
.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<FleetInfo>()
.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;
}
/** /**
* 创建用户的基础信息 * 创建用户的基础信息