From 231c4a3b97fff265545e88931d230b97290a9832 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 03 Nov 2020 16:19:14 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/member/service/RocService.java | 6 src/main/resources/mapper/modules/TdFinancialRecordDao.xml | 5 + src/main/java/com/xcong/excoin/modules/member/entity/TdCoinWallet.java | 73 ++++++++++++++ src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java | 101 ++++++++++--------- src/main/resources/templates/febs/views/modules/orderCoin/orderCoin.html | 2 src/main/java/com/xcong/excoin/modules/member/entity/TdFinancialReord.java | 59 +++++++++++ src/main/java/com/xcong/excoin/modules/member/mapper/TdFinancialReordDao.java | 7 + src/main/resources/mapper/modules/MemberWalletCoinMapper.xml | 10 ++ src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java | 6 + src/main/resources/application-prod.yml | 2 10 files changed, 217 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/TdCoinWallet.java b/src/main/java/com/xcong/excoin/modules/member/entity/TdCoinWallet.java new file mode 100644 index 0000000..698b1f5 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/member/entity/TdCoinWallet.java @@ -0,0 +1,73 @@ +package com.xcong.excoin.modules.member.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 会员资产表 Entity + * + * @author MrBird + * @date 2020-09-26 19:21:08 + */ +@Data +@TableName("td_coin_wallet") +public class TdCoinWallet { + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 会员ID + */ + @TableField("mem_id") + private Long memId; + + /** + * 地址 + */ + @TableField("address") + private String address; + + /** + * 币种 + */ + @TableField("symbol") + private String symbol; + + /** + * 私钥 + */ + @TableField("private_key") + private String privateKey; + + /** + * 币种细类 + */ + @TableField("tag") + private String tag; + + /** + * 用户标识 + */ + @TableField("mem_code") + private String memCode; + + /** + * 可用余额 + */ + @TableField("available_balance") + private BigDecimal availableBalance; + /** + * 冻结金额 + */ + @TableField("frozen_balance") + private BigDecimal frozenBalance; +} diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/TdFinancialReord.java b/src/main/java/com/xcong/excoin/modules/member/entity/TdFinancialReord.java new file mode 100644 index 0000000..fe15c1e --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/member/entity/TdFinancialReord.java @@ -0,0 +1,59 @@ +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; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@TableName("td_financial_reord") +public class TdFinancialReord { + + private static final long serialVersionUID = 1L; + + + /** + * 主键 + */ + @TableId(value = "id", type= IdType.AUTO) + private Long id; + + + /** + * 会员ID + */ + private Long memId; + + + /** + * 类型 + */ + private String symbol; + + + /** + * 标题 + */ + private String title; + + + /** + * 明细内容 + */ + private String content; + + + /** + * 金额 + */ + private BigDecimal amount; + + + /** + * 创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java b/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java index 1c61502..c522bfd 100644 --- a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java +++ b/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java @@ -1,12 +1,18 @@ package com.xcong.excoin.modules.member.mapper; +import com.xcong.excoin.modules.member.entity.TdCoinWallet; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; +import java.math.BigDecimal; + public interface MemberWalletCoinMapper extends BaseMapper<MemberWalletCoinEntity> { MemberWalletCoinEntity findWalletCoinByMemberIdAndWalletCode(@Param("memberId")Long memberId, @Param("walletCode")String walletCode); + TdCoinWallet selectTdCoinWalletByAddress(@Param("address") String address, @Param("symbol") String symbol); + + int updateTdCoinWalletAvaliable(@Param("money") BigDecimal money, @Param("address") String address); } diff --git a/src/main/java/com/xcong/excoin/modules/member/mapper/TdFinancialReordDao.java b/src/main/java/com/xcong/excoin/modules/member/mapper/TdFinancialReordDao.java new file mode 100644 index 0000000..946f379 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/member/mapper/TdFinancialReordDao.java @@ -0,0 +1,7 @@ +package com.xcong.excoin.modules.member.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.xcong.excoin.modules.member.entity.TdFinancialReord; + +public interface TdFinancialReordDao extends BaseMapper<TdFinancialReord> { +} diff --git a/src/main/java/com/xcong/excoin/modules/member/service/RocService.java b/src/main/java/com/xcong/excoin/modules/member/service/RocService.java index b0e9686..f9410a7 100644 --- a/src/main/java/com/xcong/excoin/modules/member/service/RocService.java +++ b/src/main/java/com/xcong/excoin/modules/member/service/RocService.java @@ -10,13 +10,13 @@ */ public class RocService { - private final static String URL = "http://api.rocwallet.cc"; + private final static String URL = "http://wallet.rfncwallet.vip"; private final static String CREATE_WALLET= "/init/createaccount"; private final static String TRANSFER_METHOD= "/transfer/transferWithPrivateKey"; - private final static String TOTAL_ADDRESS = "ROC0f23b4d74e63473497d342fe98fcd436"; - private final static String TOTAL_PRIVATE_KEY = "5dd9f1caa18d46dfa3063e349eff32992b3043f510c645"; + private final static String TOTAL_ADDRESS = "RFNCe0cdafb0b8d945bcbcce39f416e292c0"; + private final static String TOTAL_PRIVATE_KEY = "fb603d3339534f6cbf92465e0ee2738068358f2861fb41"; private final static BigDecimal fee = new BigDecimal("0.006"); public static String transfer(BigDecimal balance,String toAddress,String symbol){ TransferModel transferModel = new TransferModel(); diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java index e5bda2a..73aff17 100644 --- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java @@ -11,24 +11,8 @@ import com.xcong.excoin.common.entity.QueryRequest; import com.xcong.excoin.modules.Sms106Send; import com.xcong.excoin.modules.member.dto.MemberDetailConfirmDto; -import com.xcong.excoin.modules.member.entity.AgentFriendRelationEntity; -import com.xcong.excoin.modules.member.entity.MemberAccountMoneyChangeEntity; -import com.xcong.excoin.modules.member.entity.MemberAuthenticationEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity; -import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity; -import com.xcong.excoin.modules.member.entity.MemberEntity; -import com.xcong.excoin.modules.member.entity.MemberQuickBuySaleEntity; -import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; -import com.xcong.excoin.modules.member.mapper.AgentFriendRelationMapper; -import com.xcong.excoin.modules.member.mapper.MemberAccountMoneyChangeMapper; -import com.xcong.excoin.modules.member.mapper.MemberAuthenticationMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinAddressMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinChargeMapper; -import com.xcong.excoin.modules.member.mapper.MemberCoinWithdrawMapper; -import com.xcong.excoin.modules.member.mapper.MemberMapper; -import com.xcong.excoin.modules.member.mapper.MemberQuickBuySaleMapper; -import com.xcong.excoin.modules.member.mapper.MemberWalletCoinMapper; +import com.xcong.excoin.modules.member.entity.*; +import com.xcong.excoin.modules.member.mapper.*; import com.xcong.excoin.modules.member.service.EthService; import com.xcong.excoin.modules.member.service.IMemberService; import com.xcong.excoin.modules.member.service.RocService; @@ -85,6 +69,8 @@ private final MemberAuthenticationMapper memberAuthenticationMapper; private final AgentFriendRelationMapper agentFriendRelationMapper; + + private final TdFinancialReordDao tdFinancialReordDao; @Override public IPage<AgentFriendRelationEntity> findAgentInfoListInPage(AgentFriendRelationEntity agentFriendRelationEntity, @@ -471,9 +457,9 @@ } // 转币 需要扣除手续费 amount = amount.subtract(selectById.getFeeAmount()); - if("ROC".equals(symbol) && !"Y".equals(selectById.getIsInside())){ + if("RFNC".equals(symbol) && !"Y".equals(selectById.getIsInside())){ // 如果是ROC 则自动转 - String transfer = RocService.transfer(amount, address, "ROC"); + String transfer = RocService.transfer(amount, address, "RFNC"); if(!"success".equals(transfer)){ FebsResponse febsResponse = new FebsResponse(); return febsResponse.fail().message(transfer); @@ -490,36 +476,53 @@ memberWalletCoinMapper.updateById(walletCoin); if ("Y".equals(selectById.getIsInside())) { - Map<String, Object> columnMap = new HashMap<>(); - columnMap.put("symbol", symbol); - columnMap.put("address", address); - // 如果是内部转账 则需要将币加到内部地址 - List<MemberCoinAddressEntity> selectByMap = memberCoinAddressMapper.selectByMap(columnMap); - if(selectByMap == null || selectByMap.isEmpty()) { - return new FebsResponse().fail().message("地址有误,请拒绝!"); + // 查询算力系统中是否存在该地址 + TdCoinWallet tdCoinWallet = memberWalletCoinMapper.selectTdCoinWalletByAddress(address, "USDT"); + if (tdCoinWallet != null) { + // 更新算力系统中用户钱包余额 + memberWalletCoinMapper.updateTdCoinWalletAvaliable(amount, address); + + TdFinancialReord tdFinancialReord = new TdFinancialReord(); + tdFinancialReord.setAmount(amount); + tdFinancialReord.setCreateTime(new Date()); + tdFinancialReord.setMemId(tdCoinWallet.getMemId()); + tdFinancialReord.setSymbol("USDT"); + tdFinancialReord.setTitle("USDT交易所转账"); + tdFinancialReord.setContent("USDT交易所转账"); + // 插入算力系统中财务记录 + tdFinancialReordDao.insert(tdFinancialReord); + } else { + Map<String, Object> columnMap = new HashMap<>(); + columnMap.put("symbol", symbol); + columnMap.put("address", address); + // 如果是内部转账 则需要将币加到内部地址 + List<MemberCoinAddressEntity> selectByMap = memberCoinAddressMapper.selectByMap(columnMap); + if (selectByMap == null || selectByMap.isEmpty()) { + return new FebsResponse().fail().message("地址有误,请拒绝!"); + } + Long aimMemberId = selectByMap.get(0).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); } - Long aimMemberId = selectByMap.get(0).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<>(); diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 145ecb3..e037295 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -2,7 +2,7 @@ datasource: dynamic: # 是否开启 SQL日志输出,生产环境建议关闭,有性能损耗 - p6spy: false + p6spy: true hikari: connection-timeout: 30000 max-lifetime: 1800000 diff --git a/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml b/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml index 5980ed9..761c431 100644 --- a/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml +++ b/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml @@ -7,4 +7,14 @@ select * from member_wallet_coin where member_id = #{memberId} and wallet_code = #{walletCode} </select> + <select id="selectTdCoinWalletByAddress" resultType="com.xcong.excoin.modules.member.entity.TdCoinWallet"> + select * from td_coin_wallet + where address=#{address} and symbol=#{symbol} + </select> + + <update id="updateTdCoinWalletAvaliable"> + update td_coin_wallet + set available_balance=available_balance+#{money} + where address=#{address} + </update> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/modules/TdFinancialRecordDao.xml b/src/main/resources/mapper/modules/TdFinancialRecordDao.xml new file mode 100644 index 0000000..c918f1c --- /dev/null +++ b/src/main/resources/mapper/modules/TdFinancialRecordDao.xml @@ -0,0 +1,5 @@ +<?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.TdFinancialReordDao"> + +</mapper> \ No newline at end of file diff --git a/src/main/resources/templates/febs/views/modules/orderCoin/orderCoin.html b/src/main/resources/templates/febs/views/modules/orderCoin/orderCoin.html index 3a48a34..a2f84be 100644 --- a/src/main/resources/templates/febs/views/modules/orderCoin/orderCoin.html +++ b/src/main/resources/templates/febs/views/modules/orderCoin/orderCoin.html @@ -116,7 +116,7 @@ } else if (d.ipo == 0) { return '<span style="color:gray;">否</span>' } else{ - return '<span style="color:red;">是</span>' + return '<span>-</span>' } }, minWidth: 20,align:'center'}, -- Gitblit v1.9.1