Administrator
2025-04-21 a217652d33c75df23202828000d82d0ca8555ac2
src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java
@@ -103,14 +103,16 @@
            }
            ChannelAgent agent = channelAgentService.selectByPrimaryKey(agentId);
            settle(ChannelAgentSettleRecord.builder()
                    .agentId(agentId)
                    .settleDay(day)
                    .settleMoney(totalMoney)
                    .alipayAccount(agent.getAlipayAccount())
                    .alipayName(agent.getAlipayName())
                    .detailList(detailList)
                    .build());
            if(agent!=null) {
                settle(ChannelAgentSettleRecord.builder()
                        .agentId(agentId)
                        .settleDay(day)
                        .settleMoney(totalMoney)
                        .alipayAccount(agent.getAlipayAccount())
                        .alipayName(agent.getAlipayName())
                        .detailList(detailList)
                        .build());
            }
        }
    }
@@ -164,4 +166,63 @@
        }
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void processWithdraw(List<Long> ids, boolean pass) throws ChannelAgentSettleException {
        for (Long id : ids) {
            ChannelAgentSettleRecord old = channelAgentSettleRecordMapper.selectByPrimaryKeyForUpdate(id);
            if (old.getStatus() != ChannelAgentSettleRecord.STATUS_WITHDRAWING) {
                throw new ChannelAgentSettleException("提现已处理");
            }
            channelAgentSettleRecordMapper.updateByPrimaryKeySelective(ChannelAgentSettleRecord.builder().id(id)
                    .status(pass ? ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS : ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED)
                    .withDrawProcessTime(new Date())
                    .updateTime(new Date())
                    .payTime(pass ? new Date() : null).build());
        }
    }
    @Override
    public void actualSettle(Long id, BigDecimal money) throws ChannelAgentSettleException {
        ChannelAgentSettleRecord old = channelAgentSettleRecordMapper.selectByPrimaryKeyForUpdate(id);
        if (old == null) {
            throw new ChannelAgentSettleException("结算ID为空");
        }
        if (old.getStatus() != ChannelAgentSettleRecord.STATUS_NOT_SETTLE) {
            throw new ChannelAgentSettleException("已经结算");
        }
        channelAgentSettleRecordMapper.updateByPrimaryKeySelective(ChannelAgentSettleRecord.builder()
                .id(id)
                .actualSettleMoney(money)
                .settleTime(new Date())
                .status(ChannelAgentSettleRecord.STATUS_SETTLED)
                .updateTime(new Date())
                .build());
    }
    @Override
    public void applyWithdraw(Long id) throws ChannelAgentSettleException {
        ChannelAgentSettleRecord old = channelAgentSettleRecordMapper.selectByPrimaryKeyForUpdate(id);
        if (old == null) {
            throw new ChannelAgentSettleException("结算ID为空");
        }
        if (old.getStatus() != ChannelAgentSettleRecord.STATUS_SETTLED) {
            throw new ChannelAgentSettleException("处于不可提现状态");
        }
        channelAgentSettleRecordMapper.updateByPrimaryKeySelective(ChannelAgentSettleRecord.builder()
                .id(id)
                .withDrawApplyTime(new Date())
                .settleTime(new Date())
                .status(ChannelAgentSettleRecord.STATUS_WITHDRAWING)
                .updateTime(new Date())
                .build());
    }
}