| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |