admin
2024-08-04 bc56870059cca013649077af0e53891cba8dbfd1
src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java
@@ -164,4 +164,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());
    }
}