From 734dfe9eb0a2176103dce8245c69b1194574c68e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 29 七月 2024 20:16:15 +0800
Subject: [PATCH] 代理新功能完善

---
 src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java b/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java
index 6b5e0f6..bc006c4 100644
--- a/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentSettleServiceImpl.java
+++ b/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());
+    }
 }

--
Gitblit v1.8.0