From d18442eeb0b13b633c4146b85198211f4014b2d1 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 18 Nov 2020 14:42:32 +0800 Subject: [PATCH] modify --- 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