From 292a4634d9c52ce193eca9de356d65960bdc35f4 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 15 Jan 2021 18:20:37 +0800
Subject: [PATCH] 20210115
---
src/main/java/com/xcong/excoin/quartz/job/TRC20OrderJob.java | 81 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/quartz/job/TRC20OrderJob.java b/src/main/java/com/xcong/excoin/quartz/job/TRC20OrderJob.java
index 4240da6..934373e 100644
--- a/src/main/java/com/xcong/excoin/quartz/job/TRC20OrderJob.java
+++ b/src/main/java/com/xcong/excoin/quartz/job/TRC20OrderJob.java
@@ -1,7 +1,78 @@
-package com.xcong.excoin.quartz.job;/**
-*
-* @author wzy
-* @date 2020-11-05
-**/
+package com.xcong.excoin.quartz.job;
+
+import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
+import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
+import com.xcong.excoin.modules.member.dao.MemberCoinWithdrawDao;
+import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
+import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity;
+import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
+import com.xcong.excoin.utils.TRC20ApiUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author wzy
+ * @date 2020-11-05
+ **/
+@Slf4j
+@Component
+@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true")
public class TRC20OrderJob {
+
+ @Resource
+ private MemberCoinWithdrawDao memberCoinWithdrawDao;
+ @Resource
+ private MemberWalletCoinDao memberWalletCoinDao;
+ @Resource
+ private MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
+
+
+ @Transactional(rollbackFor = Exception.class)
+ public void trc20WithdrawOrder() {
+ log.info("trc20订单查询");
+ Map<String, Object> param = new HashMap<>();
+ param.put("label", "TRC20");
+ param.put("status", 1);
+ List<MemberCoinWithdrawEntity> withdrawEntities = memberCoinWithdrawDao.selectByMap(param);
+ if (CollUtil.isNotEmpty(withdrawEntities)) {
+ for (MemberCoinWithdrawEntity withdrawEntity : withdrawEntities) {
+ MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(withdrawEntity.getMemberId(), withdrawEntity.getSymbol());
+ String applyOrderInfo = TRC20ApiUtils.getApplyOrderInfo(withdrawEntity.getTag());
+ Integer transStatus = JSONObject.parseObject(applyOrderInfo).getInteger("transStatus");
+
+ Map<String, Object> columnMaps = new HashMap<>();
+ columnMaps.put("withdraw_id", withdrawEntity.getId());
+ MemberAccountMoneyChange accountMoneyChanges = memberAccountMoneyChangeDao.selectByMap(columnMaps).get(0);
+ // 状态:2待审核3提币中(审核成功)4提币成功5审核失败
+ if (transStatus == 4) {
+ memberWalletCoinDao.updateWalletBalance(wallet.getId(), null, null, withdrawEntity.getAmount().negate());
+
+ accountMoneyChanges.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+ accountMoneyChanges.setAmount(withdrawEntity.getAmount().negate());
+ memberAccountMoneyChangeDao.updateById(accountMoneyChanges);
+
+ withdrawEntity.setStatus(MemberCoinWithdrawEntity.IS_STATUS_Y);
+ memberCoinWithdrawDao.updateById(withdrawEntity);
+ } else if (transStatus == 5) {
+ memberWalletCoinDao.updateWalletBalance(wallet.getId(), withdrawEntity.getAmount(), null, withdrawEntity.getAmount().negate());
+
+ accountMoneyChanges.setStatus(MemberAccountMoneyChange.STATUS_FAIL_INTEGER);
+ accountMoneyChanges.setAmount(withdrawEntity.getAmount());
+ memberAccountMoneyChangeDao.updateById(accountMoneyChanges);
+
+ withdrawEntity.setStatus(MemberCoinWithdrawEntity.IS_STATUS_N);
+ memberCoinWithdrawDao.updateById(withdrawEntity);
+ }
+ }
+ }
+ }
}
--
Gitblit v1.9.1