diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java index 2ab5560..de7b8f6 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java @@ -204,5 +204,5 @@ public interface AsUserMapper /** * 获取押金余额 */ - BigDecimal getDepositBalance(String formattedDate); + BigDecimal getDepositBalance(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java index c0d26e6..10ea45c 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java @@ -266,5 +266,5 @@ public interface IAsUserService /** * 根据日期查询用户余额 */ - BigDecimal getDepositBalance(String formattedDate); + BigDecimal getDepositBalance(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java index f2a8c23..ff01380 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java @@ -665,8 +665,8 @@ public class AsUserServiceImpl implements IAsUserService * 根据日期查询用户余额 */ @Override - public BigDecimal getDepositBalance(String formattedDate) { - return asUserMapper.getDepositBalance(formattedDate); + public BigDecimal getDepositBalance() { + return asUserMapper.getDepositBalance(); } } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index 16f8786..1a11870 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -1156,7 +1156,6 @@ public class EtOrderServiceImpl implements IEtOrderService getTodayData(today, incomeVos, incomeCosts, depositVos); calendar.add(Calendar.DAY_OF_MONTH, -1); - for (int i = 0; i < 13; i++) { String day = dateFormat.format(calendar.getTime()); getDataByDate(day, incomeVos, incomeCosts, depositVos); @@ -1299,7 +1298,6 @@ public class EtOrderServiceImpl implements IEtOrderService calendar.add(Calendar.DATE, -1); String previousDay = dateFormat.format(calendar.getTime()); - // 初始化统计变量 BigDecimal serviceFeeTotal = BigDecimal.ZERO; BigDecimal handlingFeeTotal = BigDecimal.ZERO; @@ -1313,6 +1311,7 @@ public class EtOrderServiceImpl implements IEtOrderService BigDecimal depositRefund = BigDecimal.ZERO; BigDecimal depositDeduction = BigDecimal.ZERO; BigDecimal depositSurplus = BigDecimal.ZERO; + BigDecimal todayBalance = BigDecimal.ZERO; List channelVOS = etChannelService.selectSmChannelList(new ChannelQuery()); for (ChannelVO channel:channelVOS) { @@ -1346,9 +1345,13 @@ public class EtOrderServiceImpl implements IEtOrderService depositDeduction = depositDeduction.add(selfReconciliationVO.getDeductionAmount()); } // 押金盈余 - if (selfReconciliationVO.getDepositChange() != null) { + if (selfReconciliationVO.getDepositChange() != null && channel.getChannelId() == 2) { depositSurplus = depositSurplus.add(selfReconciliationVO.getDepositChange()); } + + if (selfReconciliationVO.getDepositBalance() != null && channel.getChannelId() == 2) { + todayBalance = reconciliationMapper.getDepositBalance(previousDay).add(depositSurplus); + } } // 设置 IncomeCostVo 的值 @@ -1365,7 +1368,7 @@ public class EtOrderServiceImpl implements IEtOrderService depositVo.setRefund(depositRefund); depositVo.setDeduction(depositDeduction); depositVo.setSurplus(depositSurplus); - depositVo.setBalance(reconciliationMapper.getDepositBalance(previousDay).add(depositSurplus)); + depositVo.setBalance(todayBalance); incomeVo.setDay(today); incomeVo.setOrderNum(etOrderMapper.getOrderNum(startDateStr, endDateStr, null,null)); diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index cd4b03d..e7395be 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -886,14 +886,32 @@ public class EtTask { /** 总收入*/ SelfReconciliationVO selfReconciliationVO = buildSelfReconciliation(startDateStr,endDateStr, formattedDate,aLong,channel.getChannelId()); calendar.add(Calendar.DATE, -1); - String previousDay = dateFormat.format(calendar.getTime()); - setBalance(previousDay,selfReconciliationVO); // 保存 saveRecon(formattedDate, selfReconciliationVO,channel.getChannelId()); } } } +// /** +// * 统计用户押金余额 +// * */ +// public void statisticsUserBalance() { +// +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// Calendar calendar = Calendar.getInstance(); +// String formattedDate = dateFormat.format(calendar.getTime()); +// EtReconciliation etReconciliation = new EtReconciliation(); +// etReconciliation.setDay(formattedDate); +// etReconciliation.setBalance(depositBalance); +// etReconciliation.setPayChannel(2L); +// int i1 = etReconciliationMapper.updateDepositBalance(etReconciliation); +// if (i1 > 0) { +// log.info("【定时任务】更新用户押金余额成功"); +// } else { +// log.info("【定时任务】更新用户押金余额失败"); +// } +// } + private void setBalance(String previousDay, SelfReconciliationVO selfReconciliationVO) { BigDecimal depositBalance = defaultIfNull(etReconciliationMapper.getDepositBalance(previousDay),BigDecimal.ZERO); selfReconciliationVO.setDepositBalance(depositBalance.add(selfReconciliationVO.getDepositChange())); @@ -919,9 +937,6 @@ public class EtTask { selfReconciliationVO.setDepositPaid(depositAmount); selfReconciliationVO.setHandlingCharge(handlingFee); selfReconciliationVO.setPlatformServiceFee(platformServiceFee); - if(channelId == 2){ - selfReconciliationVO.setChannelCost(cost); - } selfReconciliationVO.setWithdrawServiceFee(withdrawServiceFee); /** 总支出*/ @@ -934,8 +949,11 @@ public class EtTask { selfReconciliationVO.setOrderRefund(orderRefund); selfReconciliationVO.setDepositRefund(depositRefundFee); - BigDecimal depositBalance = depositAmount.subtract(depositRefundFee).subtract(deductionAmount); - selfReconciliationVO.setDepositBalance(depositBalance); + if(channelId == 2){ + selfReconciliationVO.setChannelCost(cost); + BigDecimal depositBalance = asUserMapper.getDepositBalance(); + selfReconciliationVO.setDepositBalance(depositBalance); + } selfReconciliationVO.setUserReceipts(userReceipts); // 结算金额等于totalFlowAmount减去orderRefund减去depositRefundFee selfReconciliationVO.setSettlementAmount(totalFlowAmount.subtract(orderRefund).subtract(depositRefundFee)); diff --git a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml index 91b8ee7..d98e847 100644 --- a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml @@ -192,9 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" COALESCE(SUM(balance), 0) AS total_balance FROM et_user - WHERE - update_time <= #{formattedDate} - AND appid = 'wx3428c498d5061192' + WHERE appid = 'wx3428c498d5061192'