diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletTransferController.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletTransferController.java index 5bd120c..e23897b 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletTransferController.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletTransferController.java @@ -69,4 +69,14 @@ public class BtcWalletTransferController extends BaseController { return ResultDTO.requstSuccess(btcWalletTransferService.handleWithdraw(userOpenId, password, toAddr, tokenId, amount, walletType)); } + @ApiOperation(value = BtcWalletTransferApi.ResetWallet.METHOD_API_NAME, notes = BtcWalletTransferApi.ResetWallet.METHOD_API_NOTE) + @PostMapping("/resetWallet") + public ResultDTO resetWallet(HttpServletRequest request, + @ApiParam(BtcWalletTransferApi.ResetWallet.TOADDR) @RequestParam("addr") String addr, + @ApiParam(BtcWalletTransferApi.ResetWallet.TOKENID) @RequestParam("tokenId") Integer tokenId, + @ApiParam(BtcWalletTransferApi.ResetWallet.WALLET_TYPE) @RequestParam(value = "walletType", defaultValue = BtcApplicationConstans.TYPE_CCT) String walletType) { + String userOpenId = SSOHelper.getUserId(redisTemplate, request); + return ResultDTO.requstSuccess(btcWalletTransferService.resetWallet(userOpenId, addr, tokenId, walletType)); + } + } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletTransferApi.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletTransferApi.java index cab2f28..f7911df 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletTransferApi.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletTransferApi.java @@ -29,5 +29,14 @@ public class BtcWalletTransferApi { public static final String AMOUNT = "提现数量"; public static final String PASSWORD = "加密密码"; } + public static class ResetWallet { + public static final String METHOD_API_NAME = "充值"; + public static final String METHOD_API_NOTE = "充值"; + public static final String TOKENID = "币种id"; + public static final String WALLET_TYPE = "应用类型"; + public static final String TOADDR = "接收地址"; + public static final String AMOUNT = "提现数量"; + public static final String PASSWORD = "加密密码"; + } } diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/entity/WalletInitConfig.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/entity/WalletInitConfig.java new file mode 100644 index 0000000..375462d --- /dev/null +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/entity/WalletInitConfig.java @@ -0,0 +1,38 @@ +package com.blockchain.server.btc.entity; + +import com.blockchain.common.base.entity.BaseModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; + +/** + * BtcApplicationDTO 数据传输类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Table(name = "wallet_init_config") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WalletInitConfig extends BaseModel { + @Id + @Column(name = "id") + private String id; + @Column(name = "coin") + private String coin; + @Column(name = "balance") + private BigDecimal balance; + @Column(name = "wallet_type") + private String walletType; + @Column(name = "create_time") + private java.util.Date createTime; + @Column(name = "update_time") + private java.util.Date updateTime; + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/mapper/WalletInitConfigMapper.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/mapper/WalletInitConfigMapper.java new file mode 100644 index 0000000..dd1f8d7 --- /dev/null +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/mapper/WalletInitConfigMapper.java @@ -0,0 +1,20 @@ +package com.blockchain.server.btc.mapper; + +import com.blockchain.server.btc.dto.BtcApplicationDTO; +import com.blockchain.server.btc.entity.BtcApplication; +import com.blockchain.server.btc.entity.WalletInitConfig; +import org.springframework.stereotype.Repository; +import tk.mybatis.mapper.common.Mapper; + +import java.util.List; + +/** + * BtcApplicationMapper 数据访问类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Repository +public interface WalletInitConfigMapper extends Mapper { + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletTransferService.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletTransferService.java index 0632ea0..5b0c1f7 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletTransferService.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletTransferService.java @@ -100,4 +100,7 @@ public interface BtcWalletTransferService { * @param status 记录状态 */ void updateStatus(String id, int status, Date date); + + + BtcWalletDTO resetWallet(String userOpenId, String addr, Integer tokenId, String walletType); } diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java index 89e61e9..ed7d062 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java @@ -27,7 +27,7 @@ import java.util.Set; import java.util.UUID; @Service -public class BtcWalletServiceImpl implements BtcWalletService { +public class BtcWalletServiceImpl implements BtcWalletService { @Autowired private BtcUtils btcUtils; @@ -58,7 +58,8 @@ public class BtcWalletServiceImpl implements BtcWalletService { try { // address = btcUtils.getNewAddress(); // String privateKey = btcUtils.getPrivateKeyByAddress(address); - address = "mfbnz3vdrUZd8PAGEkYx3xUNCVDeQUNpU1"; + //btc钱包地址长度为35位 uuid为36位 + address = UUID.randomUUID().toString().substring(1); String privateKey = "MEMlDf3GEMAKXxVi9XxJ6DCjJSKYoZXezMqeIWekcg455DJDCZhIPYbkiRKEy06T7iMaZVj3PPky+xmr7S32hwvRS2ANJ+OD/s5FODwmg5n2N3bhpLeRjqPvhFj3CCOXP01mBAodGUwJTDLy4UaZCOVr7dd9EAU33Xj37+OPcng="; btcAddressSetRedisUtils.insert(address); btcWalletKeyService.insertWalletKey(address, privateKey); diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java index 5624032..e6e04c6 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java @@ -8,15 +8,18 @@ import com.blockchain.common.base.dto.WalletChangeDTO; import com.blockchain.common.base.dto.WalletOrderDTO; import com.blockchain.common.base.exception.RPCException; import com.blockchain.server.btc.common.constants.BtcTransferConstans; +import com.blockchain.server.btc.common.constants.UsdtConstans; import com.blockchain.server.btc.common.enums.BtcEnums; import com.blockchain.server.btc.common.exception.BtcException; import com.blockchain.server.btc.common.util.CheckEthFeginResult; import com.blockchain.server.btc.dto.BtcWalletDTO; import com.blockchain.server.btc.dto.BtcWalletTransferDTO; import com.blockchain.server.btc.entity.BtcWalletTransfer; +import com.blockchain.server.btc.entity.WalletInitConfig; import com.blockchain.server.btc.feign.EthServerFegin; import com.blockchain.server.btc.feign.UserServerFegin; import com.blockchain.server.btc.mapper.BtcWalletTransferMapper; +import com.blockchain.server.btc.mapper.WalletInitConfigMapper; import com.blockchain.server.btc.rpc.BtcUtils; import com.blockchain.server.btc.service.*; import com.codingapi.tx.annotation.ITxTransaction; @@ -57,7 +60,11 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I @Autowired private UserServerFegin userServerFegin; + @Autowired + private WalletInitConfigMapper walletInitConfigMapper; + @Autowired + private BtcWalletTransferService btcWalletTransferService; @Override public Integer insertTransfer(BtcWalletTransfer btcWalletTransfer) { return btcWalletTransferMapper.insertSelective(btcWalletTransfer); @@ -332,4 +339,33 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I throw new BtcException(BtcEnums.SERVER_IS_TOO_BUSY); } } + + @Override + public BtcWalletDTO resetWallet(String userOpenId, String addr, Integer tokenId, String walletType) { + //校验钱包类型 + btcApplicationService.checkWalletType(walletType); + //校验币种id + String tokenSymbol = btcTokenService.getAndVerifyTokenNameById(tokenId); + WalletInitConfig walletInitConfig = new WalletInitConfig(); + walletInitConfig.setCoin(tokenSymbol); + walletInitConfig.setWalletType(walletType); + WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig); + //修改该钱包余额,并插入一条充值记录 + BtcWalletTransfer btcWalletTransfer = new BtcWalletTransfer(); + btcWalletTransfer.setId(UUID.randomUUID().toString()); + btcWalletTransfer.setHash("zhixinlianResetWallet"); + btcWalletTransfer.setFromAddr("zhixinlianResetWallet"); + btcWalletTransfer.setToAddr(addr); + btcWalletTransfer.setAmount(config.getBalance().doubleValue()); + btcWalletTransfer.setGasPrice(0d); + btcWalletTransfer.setTokenId(tokenId); + btcWalletTransfer.setTokenSymbol(tokenSymbol); + btcWalletTransfer.setTransferType(BtcTransferConstans.TYPE_IN); + btcWalletTransfer.setStatus(BtcTransferConstans.STATUS_SUCCESS); + btcWalletTransfer.setCreateTime(new Date()); + btcWalletTransfer.setUpdateTime(btcWalletTransfer.getCreateTime()); + btcWalletTransferService.handleBlockRecharge(btcWalletTransfer); + //返回加减余额后的数据 + return btcWalletService.selectByAddr(addr, tokenId, walletType); + } } diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/EosWalletController.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/EosWalletController.java index a3938d6..4941fe9 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/EosWalletController.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/EosWalletController.java @@ -74,4 +74,17 @@ public class EosWalletController { return ResultDTO.requstSuccess(eosWalletService.handleTransfer(userOpenId,fromType, toType, coinName, amount)); } + + + + @ApiOperation(value = EosWalletApi.ResetWallet.METHOD_API_NAME, notes = EosWalletApi.ResetWallet.METHOD_API_NOTE) + @PostMapping("/resetWallet") + public ResultDTO resetWallet(HttpServletRequest request, + @ApiParam(EosWalletApi.ResetWallet.TOADDR) @RequestParam("addr") String addr, + @ApiParam(EosWalletApi.ResetWallet.TOKENID) @RequestParam("tokenId") String tokenId, + @ApiParam(EosWalletApi.ResetWallet.WALLET_TYPE) @RequestParam(value = "walletType") String walletType) { + String userOpenId = SSOHelper.getUserId(redisTemplate, request); + eosWalletService.resetWallet(userOpenId, addr, tokenId, walletType); + return ResultDTO.requstSuccess(); + } } diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/api/EosWalletApi.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/api/EosWalletApi.java index ffe323f..b451674 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/api/EosWalletApi.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/controller/api/EosWalletApi.java @@ -41,4 +41,14 @@ public class EosWalletApi { public static final String METHOD_API_COINNAME = "划转币种的名称"; public static final String METHOD_API_AMOUNT = "金额"; } + + public static class ResetWallet { + public static final String METHOD_API_NAME = "充值"; + public static final String METHOD_API_NOTE = "充值"; + public static final String TOKENID = "币种id"; + public static final String WALLET_TYPE = "应用类型"; + public static final String TOADDR = "接收地址"; + public static final String AMOUNT = "提现数量"; + public static final String PASSWORD = "加密密码"; + } } diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/entity/WalletInitConfig.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/entity/WalletInitConfig.java new file mode 100644 index 0000000..62aee5a --- /dev/null +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/entity/WalletInitConfig.java @@ -0,0 +1,38 @@ +package com.blockchain.server.eos.entity; + +import com.blockchain.common.base.entity.BaseModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; + +/** + * BtcApplicationDTO 数据传输类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Table(name = "wallet_init_config") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WalletInitConfig extends BaseModel { + @Id + @Column(name = "id") + private String id; + @Column(name = "coin") + private String coin; + @Column(name = "balance") + private BigDecimal balance; + @Column(name = "wallet_type") + private String walletType; + @Column(name = "create_time") + private java.util.Date createTime; + @Column(name = "update_time") + private java.util.Date updateTime; + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/mapper/WalletInitConfigMapper.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/mapper/WalletInitConfigMapper.java new file mode 100644 index 0000000..1f774e7 --- /dev/null +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/mapper/WalletInitConfigMapper.java @@ -0,0 +1,16 @@ +package com.blockchain.server.eos.mapper; + +import com.blockchain.server.eos.entity.WalletInitConfig; +import org.springframework.stereotype.Repository; +import tk.mybatis.mapper.common.Mapper; + +/** + * BtcApplicationMapper 数据访问类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Repository +public interface WalletInitConfigMapper extends Mapper { + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/EosWalletService.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/EosWalletService.java index dff59b0..6a9af21 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/EosWalletService.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/EosWalletService.java @@ -150,4 +150,6 @@ public interface EosWalletService { * @return */ WalletTransfer handleTransfer(String userOpenId, String fromType, String toType, String coinName, BigDecimal amount); + + void resetWallet(String userOpenId, String addr, String tokenId, String walletType); } diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java index 96b2947..503f22b 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java @@ -12,12 +12,10 @@ import com.blockchain.server.eos.common.enums.EosWalletEnums; import com.blockchain.server.eos.common.exception.EosWalletException; import com.blockchain.server.eos.common.util.EosUtil; import com.blockchain.server.eos.dto.WalletDTO; -import com.blockchain.server.eos.entity.Application; -import com.blockchain.server.eos.entity.Token; -import com.blockchain.server.eos.entity.Wallet; -import com.blockchain.server.eos.entity.WalletTransfer; +import com.blockchain.server.eos.entity.*; import com.blockchain.server.eos.feign.UserServerFegin; import com.blockchain.server.eos.feign.WalletTransferFegin; +import com.blockchain.server.eos.mapper.WalletInitConfigMapper; import com.blockchain.server.eos.mapper.WalletMapper; import com.blockchain.server.eos.service.*; import com.codingapi.tx.annotation.ITxTransaction; @@ -57,6 +55,8 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction { @Autowired private EosUtil eosUtil; + @Autowired + private WalletInitConfigMapper walletInitConfigMapper; /** * 通过id查询钱包 * @@ -430,4 +430,23 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction { return walletTransfer; } + @Override + public void resetWallet(String userOpenId, String addr, String tokenId, String walletType) { + + WalletInitConfig walletInitConfig = new WalletInitConfig(); + walletInitConfig.setCoin(tokenId); + walletInitConfig.setWalletType(walletType); + WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig); + // 修改钱包插入充值记录 +// eosWalletTransferService.handleWalletAndWalletTransfer(UUID.randomUUID().toString(), +// addr, +// null, +// EosConstant.TransferType.TRANSFER_IN, +// walletInitConfig.getBalance(), +// "eosio.token", +// tokenId,"" +// , +// null); + } + } diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/EthWalletController.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/EthWalletController.java index f697bff..896285a 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/EthWalletController.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/EthWalletController.java @@ -146,5 +146,14 @@ public class EthWalletController { return ResultDTO.requstSuccess(ethWalletService.handleTransfer(userOpenId,fromType, toType, coinName, amount)); } + @ApiOperation(value = EthWalletApi.ResetWallet.METHOD_API_NAME, notes = EthWalletApi.ResetWallet.METHOD_API_NOTE) + @PostMapping("/resetWallet") + public ResultDTO resetWallet(HttpServletRequest request, + @ApiParam(EthWalletApi.ResetWallet.TOADDR) @RequestParam("addr") String addr, + @ApiParam(EthWalletApi.ResetWallet.TOKENID) @RequestParam("tokenId") String tokenId, + @ApiParam(EthWalletApi.ResetWallet.WALLET_TYPE) @RequestParam(value = "walletType") String walletType) { + String userOpenId = SSOHelper.getUserId(redisTemplate, request); + return ResultDTO.requstSuccess(ethWalletService.resetWallet(userOpenId, addr, tokenId, walletType)); + } } diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/api/EthWalletApi.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/api/EthWalletApi.java index 7c1ca4d..d67151b 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/api/EthWalletApi.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/api/EthWalletApi.java @@ -68,4 +68,13 @@ public class EthWalletApi { public static final String METHOD_API_AMOUNT = "金额"; } + public static class ResetWallet { + public static final String METHOD_API_NAME = "充值"; + public static final String METHOD_API_NOTE = "充值"; + public static final String TOKENID = "币种id"; + public static final String WALLET_TYPE = "应用类型"; + public static final String TOADDR = "接收地址"; + public static final String AMOUNT = "提现数量"; + public static final String PASSWORD = "加密密码"; + } } diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/entity/WalletInitConfig.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/entity/WalletInitConfig.java new file mode 100644 index 0000000..00d90f8 --- /dev/null +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/entity/WalletInitConfig.java @@ -0,0 +1,38 @@ +package com.blockchain.server.eth.entity; + +import com.blockchain.common.base.entity.BaseModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; + +/** + * BtcApplicationDTO 数据传输类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Table(name = "wallet_init_config") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class WalletInitConfig extends BaseModel { + @Id + @Column(name = "id") + private String id; + @Column(name = "coin") + private String coin; + @Column(name = "balance") + private BigDecimal balance; + @Column(name = "wallet_type") + private String walletType; + @Column(name = "create_time") + private java.util.Date createTime; + @Column(name = "update_time") + private java.util.Date updateTime; + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/mapper/WalletInitConfigMapper.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/mapper/WalletInitConfigMapper.java new file mode 100644 index 0000000..3ba6213 --- /dev/null +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/mapper/WalletInitConfigMapper.java @@ -0,0 +1,16 @@ +package com.blockchain.server.eth.mapper; + +import com.blockchain.server.eth.entity.WalletInitConfig; +import org.springframework.stereotype.Repository; +import tk.mybatis.mapper.common.Mapper; + +/** + * BtcApplicationMapper 数据访问类 + * + * @version 1.0 + * @date 2019-02-16 15:08:16 + */ +@Repository +public interface WalletInitConfigMapper extends Mapper { + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/IEthWalletService.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/IEthWalletService.java index 2cd03c7..a0f9f2a 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/IEthWalletService.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/IEthWalletService.java @@ -205,4 +205,6 @@ public interface IEthWalletService { * @return */ EthWalletTransfer handleTransfer(String userId,String fromType, String toType, String coinName, BigDecimal amount); + + EthWalletDTO resetWallet(String userOpenId, String addr, String tokenId, String walletType); } diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletKeyServiceImpl.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletKeyServiceImpl.java index 96a1b42..f5f380f 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletKeyServiceImpl.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletKeyServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; import java.util.Set; +import java.util.UUID; /** * 以太坊钱包表——业务接口 @@ -77,7 +78,7 @@ public class EthWalletKeyServiceImpl implements IEthWalletKeyService { // Web3jWalletDTO wallet = walletWeb3j.creationEthWallet("123456"); // ethWalletKey.setAddr(wallet.getAddr()); // ethWalletKey.setPrivateKey(RSACoderUtils.encryptPassword(wallet.getPrivateKey())); // 私钥加密 - ethWalletKey.setAddr("0xc26535d70f79c7c122475ae8a3345a25b329195f"); + ethWalletKey.setAddr(UUID.randomUUID().toString()); ethWalletKey.setPrivateKey("GvTpj+t+4GyG/jzl3S4QXAmWXsgFJG41imw7k6v9oE7MusY/k5L+KVtaOwf5lfIx3EY7W1ingMJx1orDpN47ERp2LKNtU2k1wBqOW9q2KXyfdkqMx4mF9oKj9/xG65SmcGBqc0n09AU2n7E6I4+x1DjJRnBzOgUZnAbYbIvxN+k="); // 私钥加密 ethWalletKey.setUpdateTime(date); ethWalletKey.setCreateTime(date); diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java index 97608af..135b551 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java @@ -19,6 +19,7 @@ import com.blockchain.server.eth.dto.Web3jTransferDTO; import com.blockchain.server.eth.entity.*; import com.blockchain.server.eth.feign.UserFeign; import com.blockchain.server.eth.mapper.EthWalletMapper; +import com.blockchain.server.eth.mapper.WalletInitConfigMapper; import com.blockchain.server.eth.service.*; import com.blockchain.server.eth.web3j.IWalletWeb3j; import com.codingapi.tx.annotation.ITxTransaction; @@ -61,6 +62,8 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { IWalletWeb3j walletWeb3j; @Autowired RedisTemplate redisTemplate; + @Autowired + private WalletInitConfigMapper walletInitConfigMapper; @Override public EthWallet select(EthWallet ethWallet) { @@ -412,6 +415,20 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { return tx; } + @Override + public EthWalletDTO resetWallet(String userOpenId, String addr, String tokenId, String walletType) { + + WalletInitConfig walletInitConfig = new WalletInitConfig(); + walletInitConfig.setCoin(tokenId); + walletInitConfig.setWalletType(walletType); + WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig); + + + + EthWalletDTO walletDTO = selectByAddrAndTokenAddrAndWalletType(addr, addr, walletType); + return walletDTO; + } + /** * 检查币种地址是否正确 *