src/main/java/com/xcong/excoin/modules/member/entity/TrcAddressEntity.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/member/mapper/TrcAddressDao.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/application-dev.yml | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/modules/MemberWalletCoinMapper.xml | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/modules/TrcAddressDao.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/xcong/excoin/modules/member/entity/TrcAddressEntity.java
New file @@ -0,0 +1,30 @@ package com.xcong.excoin.modules.member.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; /** * @author wzy * @date 2020-11-09 **/ @Data @TableName("trc_address") public class TrcAddressEntity { public static final Integer SYSTEM_FLAG_YJS = 1; public static final Integer SYSTEM_FLAG_SL = 2; @TableId(type = IdType.AUTO) private Long id; private String address; private int isUse; private Long memberId; private Integer systemFlag; } src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java
@@ -16,6 +16,7 @@ TdCoinWallet selectTdCoinWalletByAddress(@Param("address") String address, @Param("symbol") String symbol); int updateTdCoinWalletAvaliable(@Param("money") BigDecimal money, @Param("address") String address); int updateTdCoinWalletTrc20(@Param("money") BigDecimal money, @Param("memberId") Long memberId); HashMap<String, Object> selectMemberWalletCoinByMemberId(@Param("memberId") Long memberId); } src/main/java/com/xcong/excoin/modules/member/mapper/TrcAddressDao.java
New file @@ -0,0 +1,18 @@ package com.xcong.excoin.modules.member.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.member.entity.TrcAddressEntity; import org.apache.ibatis.annotations.Param; /** * @author wzy * @date 2020-11-09 **/ public interface TrcAddressDao extends BaseMapper<TrcAddressEntity> { TrcAddressEntity selectSrcAddressByMemberId(@Param("memberId") Long memberId); TrcAddressEntity selectOneSrcAddressUnUse(); TrcAddressEntity selectTrcAddressByAddress(@Param("address") String address); } src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -78,6 +78,8 @@ private final RedisUtils redisUtils; private final TrcAddressDao trcAddressDao; @Override public IPage<AgentFriendRelationEntity> findAgentInfoListInPage(AgentFriendRelationEntity agentFriendRelationEntity, QueryRequest request) { @@ -488,6 +490,9 @@ if ("Y".equals(selectById.getIsInside())) { // 查询算力系统中是否存在该地址 TdCoinWallet tdCoinWallet = memberWalletCoinMapper.selectTdCoinWalletByAddress(address, "USDT"); TrcAddressEntity trcAddressEntity = trcAddressDao.selectTrcAddressByAddress(address); // 判断是否为TRC20地址 if (trcAddressEntity == null) { if (tdCoinWallet != null) { // 更新算力系统中用户钱包余额 memberWalletCoinMapper.updateTdCoinWalletAvaliable(amount, address); @@ -533,6 +538,44 @@ memberAccountMoneyChangeEntity.setUpdateTime(new Date()); memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); } } else { if (trcAddressEntity.getSystemFlag().equals(TrcAddressEntity.SYSTEM_FLAG_SL)) { memberWalletCoinMapper.updateTdCoinWalletTrc20(amount, trcAddressEntity.getMemberId()); TdFinancialReord tdFinancialReord = new TdFinancialReord(); tdFinancialReord.setAmount(amount); tdFinancialReord.setCreateTime(new Date()); tdFinancialReord.setMemId(trcAddressEntity.getMemberId()); tdFinancialReord.setSymbol("USDT"); tdFinancialReord.setTitle("USDT交易所转账"); tdFinancialReord.setContent("USDT交易所转账"); // 插入算力系统中财务记录 tdFinancialReordDao.insert(tdFinancialReord); } else { Long aimMemberId = trcAddressEntity.getMemberId(); MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol); BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount); BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount); aimWalletCoin.setTotalBalance(addTotal); aimWalletCoin.setAvailableBalance(addAvailable); memberWalletCoinMapper.updateById(aimWalletCoin); MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity(); memberAccountMoneyChangeEntity.setContent("收款"); memberAccountMoneyChangeEntity.setMemberId(aimMemberId); memberAccountMoneyChangeEntity.setAmount(amount); memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER); memberAccountMoneyChangeEntity.setSymbol(selectById.getSymbol()); memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN); memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy()); memberAccountMoneyChangeEntity.setCreateTime(new Date()); memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy()); memberAccountMoneyChangeEntity.setUpdateTime(new Date()); memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity); } } } Map<String, Object> columnMaps = new HashMap<>(); @@ -547,18 +590,20 @@ selectById.setStatus(MemberCoinWithdrawEntity.IS_STATUS_Y); memberCoinWithdrawMapper.updateById(selectById); if (!"Y".equals(selectById.getIsInside())) { if ("TRC20".equals(selectById.getLabel())) { Thread thread = new Thread(new Runnable() { @Override public void run() { log.info("远程调用TRC执行:{}", selectById.getId()); String orderNo = generateOrderNo(memberId); TRC20ApiUtils.coinApply(orderNo, memberId.toString(), selectById.getSymbol(), selectById.getAmount().toPlainString(), selectById.getAddress()); TRC20ApiUtils.coinApply(orderNo, memberId.toString(), selectById.getSymbol(), selectById.getAmount().subtract(selectById.getFeeAmount()).toPlainString(), selectById.getAddress()); selectById.setTag(orderNo); memberCoinWithdrawMapper.updateById(selectById); } }); thread.start(); } } MemberEntity memberEntity = memberMapper.selectById(memberId); @@ -567,7 +612,6 @@ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String time = format.format(new Date()); // 将当前时间袼式化为指定的格式 log.info("---->{}", phone); if(StrUtil.isNotBlank(phone)) { Sms106Send.sendWithdrawalCoinMsg(phone, time); } src/main/resources/application-dev.yml
@@ -18,17 +18,17 @@ username: ct_test password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://120.27.238.55:3306/kss_framework?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 url: jdbc:mysql://120.27.238.55:3306/pilot_test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 redis: # Redis数据库索引(默认为 0) database: 1 # Redis服务器地址 host: 47.114.114.219 # Redis服务器连接端口 database: 0 ## Redis服务器地址 host: 180.215.221.145 ## Redis服务器连接端口 port: 6379 # Redis 密码 password: biyi123 ## Redis服务器连接密码(默认为空) password: pilot123!@# lettuce: pool: # 连接池中的最小空闲连接 src/main/resources/mapper/modules/MemberWalletCoinMapper.xml
@@ -18,6 +18,12 @@ where address=#{address} </update> <update id="updateTdCoinWalletTrc20"> update td_coin_wallet set available_balance=available_balance+#{money} where mem_id=#{memberId} and symbol ='USDT' </update> <select id="selectMemberWalletCoinByMemberId" resultType="java.util.HashMap"> select member_id, src/main/resources/mapper/modules/TrcAddressDao.xml
New file @@ -0,0 +1,16 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.xcong.excoin.modules.member.mapper.TrcAddressDao"> <select id="selectSrcAddressByMemberId" resultType="com.xcong.excoin.modules.member.entity.TrcAddressEntity"> select * from trc_address where member_id=#{memberId} and is_use=1 and system_flag = 1 </select> <select id="selectOneSrcAddressUnUse" resultType="com.xcong.excoin.modules.member.entity.TrcAddressEntity"> select * from trc_address where is_use=2 limit 1 </select> <select id="selectTrcAddressByAddress" resultType="com.xcong.excoin.modules.member.entity.TrcAddressEntity"> select * from trc_address where address = #{address} </select> </mapper>