初始化充值

pull/1/head
liushaodong 5 years ago
parent 1182129368
commit 326f076d91
  1. 12
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletController.java
  2. 9
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/BtcWalletTransferController.java
  3. 10
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletApi.java
  4. 9
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/controller/api/BtcWalletTransferApi.java
  5. 11
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/mapper/BtcWalletMapper.java
  6. 2
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletService.java
  7. 2
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/BtcWalletTransferService.java
  8. 16
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java
  9. 30
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java
  10. 13
      blockchain-server/blockchain-server-btc/src/main/resources/mapper/BtcWalletMapper.xml
  11. 10
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/mapper/WalletMapper.java
  12. 12
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java
  13. 15
      blockchain-server/blockchain-server-eos/src/main/resources/mapper/WalletMapper.xml
  14. 10
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/mapper/EthWalletMapper.java
  15. 2
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java
  16. 13
      blockchain-server/blockchain-server-eth/src/main/resources/mapper/EthWalletMapper.xml

@ -4,6 +4,7 @@ import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.util.SSOHelper; import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.server.btc.common.constants.BtcApplicationConstans; import com.blockchain.server.btc.common.constants.BtcApplicationConstans;
import com.blockchain.server.btc.controller.api.BtcWalletApi; import com.blockchain.server.btc.controller.api.BtcWalletApi;
import com.blockchain.server.btc.controller.api.BtcWalletTransferApi;
import com.blockchain.server.btc.service.BtcWalletService; import com.blockchain.server.btc.service.BtcWalletService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -51,4 +52,15 @@ public class BtcWalletController {
String userOpenId = SSOHelper.getUserId(redisTemplate, request); String userOpenId = SSOHelper.getUserId(redisTemplate, request);
return ResultDTO.requstSuccess(btcWalletService.handleTransfer(userOpenId,fromType, toType, coinName, amount)); return ResultDTO.requstSuccess(btcWalletService.handleTransfer(userOpenId,fromType, toType, coinName, amount));
} }
@ApiOperation(value = BtcWalletApi.ResetWallet.METHOD_API_NAME, notes = BtcWalletApi.ResetWallet.METHOD_API_NOTE)
@PostMapping("/resetWallet")
public ResultDTO resetWallet(HttpServletRequest request,
@ApiParam(BtcWalletApi.ResetWallet.TOADDR) @RequestParam("addr") String addr,
@ApiParam(BtcWalletApi.ResetWallet.TOKENID) @RequestParam("tokenId") String tokenId,
@ApiParam(BtcWalletApi.ResetWallet.WALLET_TYPE) @RequestParam(value = "walletType", defaultValue = BtcApplicationConstans.TYPE_CCT) String walletType) {
String userOpenId = SSOHelper.getUserId(redisTemplate, request);
return ResultDTO.requstSuccess(btcWalletService.resetWallet(userOpenId, addr, tokenId, walletType));
}
} }

@ -69,14 +69,5 @@ public class BtcWalletTransferController extends BaseController {
return ResultDTO.requstSuccess(btcWalletTransferService.handleWithdraw(userOpenId, password, toAddr, tokenId, amount, walletType)); 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));
}
} }

@ -26,4 +26,14 @@ public class BtcWalletApi {
public static final String METHOD_API_COINNAME = "划转币种的名称"; public static final String METHOD_API_COINNAME = "划转币种的名称";
public static final String METHOD_API_AMOUNT = "金额"; 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 = "加密密码";
}
} }

@ -29,14 +29,5 @@ public class BtcWalletTransferApi {
public static final String AMOUNT = "提现数量"; public static final String AMOUNT = "提现数量";
public static final String PASSWORD = "加密密码"; 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 = "加密密码";
}
} }

@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -67,4 +68,14 @@ public interface BtcWalletMapper extends Mapper<BtcWallet> {
* @return * @return
*/ */
List<BtcWalletDTO> selectAllByUserOpenId(@Param("userOpenId") String userOpenId, @Param("walletType") String walletType); List<BtcWalletDTO> selectAllByUserOpenId(@Param("userOpenId") String userOpenId, @Param("walletType") String walletType);
/**
* 用户充值修改钱包金额
*
*/
int updateWalletBalanceByUserOpenId(@Param("balance") BigDecimal balance,
@Param("userOpenId") String userOpenId,
@Param("tokenSymbol") String tokenSymbol,
@Param("walletType") String walletType,
@Param("modifyTime") Date modifyTime);
} }

@ -102,4 +102,6 @@ public interface BtcWalletService {
* @return * @return
*/ */
BtcWalletTransfer handleTransfer(String userId, String fromType, String toType, String coinName, Double amount); BtcWalletTransfer handleTransfer(String userId, String fromType, String toType, String coinName, Double amount);
int resetWallet(String userOpenId, String addr, String tokenId, String walletType);
} }

@ -101,6 +101,4 @@ public interface BtcWalletTransferService {
*/ */
void updateStatus(String id, int status, Date date); void updateStatus(String id, int status, Date date);
BtcWalletDTO resetWallet(String userOpenId, String addr, Integer tokenId, String walletType);
} }

@ -10,7 +10,9 @@ import com.blockchain.server.btc.dto.BtcWalletDTO;
import com.blockchain.server.btc.entity.BtcToken; import com.blockchain.server.btc.entity.BtcToken;
import com.blockchain.server.btc.entity.BtcWallet; import com.blockchain.server.btc.entity.BtcWallet;
import com.blockchain.server.btc.entity.BtcWalletTransfer; import com.blockchain.server.btc.entity.BtcWalletTransfer;
import com.blockchain.server.btc.entity.WalletInitConfig;
import com.blockchain.server.btc.mapper.BtcWalletMapper; import com.blockchain.server.btc.mapper.BtcWalletMapper;
import com.blockchain.server.btc.mapper.WalletInitConfigMapper;
import com.blockchain.server.btc.rpc.BtcUtils; import com.blockchain.server.btc.rpc.BtcUtils;
import com.blockchain.server.btc.service.BtcApplicationService; import com.blockchain.server.btc.service.BtcApplicationService;
import com.blockchain.server.btc.service.BtcTokenService; import com.blockchain.server.btc.service.BtcTokenService;
@ -48,6 +50,8 @@ public class BtcWalletServiceImpl<psvm> implements BtcWalletService {
@Autowired @Autowired
private BtcWalletKeyServiceImpl btcWalletKeyService; private BtcWalletKeyServiceImpl btcWalletKeyService;
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@Override @Override
@Transactional @Transactional
@ -194,4 +198,16 @@ public class BtcWalletServiceImpl<psvm> implements BtcWalletService {
return btcWalletTransfer; return btcWalletTransfer;
} }
@Override
public int resetWallet(String userOpenId, String addr, String tokenId, String walletType) {
WalletInitConfig walletInitConfig = new WalletInitConfig();
walletInitConfig.setCoin(tokenId);
walletInitConfig.setWalletType(walletType);
WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig);
btcWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date());
return 1;
}
} }

@ -60,8 +60,6 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I
@Autowired @Autowired
private UserServerFegin userServerFegin; private UserServerFegin userServerFegin;
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@Autowired @Autowired
private BtcWalletTransferService btcWalletTransferService; private BtcWalletTransferService btcWalletTransferService;
@ -340,32 +338,4 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I
} }
} }
@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);
}
} }

@ -60,4 +60,17 @@
<include refid="tableName"/> <include refid="tableName"/>
</select> </select>
<update id="updateWalletBalanceByUserOpenId">
UPDATE
<include refid="tableName"/>
wallet
SET
wallet.balance = wallet.freeze_balance + #{balance},
wallet.free_balance = #{balance},
wallet.update_time = #{modifyTime}
WHERE
wallet.user_open_id = #{userOpenId}
AND wallet.token_symbol = #{tokenSymbol}
AND wallet.wallet_type = #{walletType}
</update>
</mapper> </mapper>

@ -80,4 +80,14 @@ public interface WalletMapper extends Mapper<Wallet> {
* @return * @return
*/ */
WalletDTO selectWalletByTokenSymbol(@Param("userId") String userId, @Param("tokenSymbol") String tokenSymbol, @Param("walletType") String walletType); WalletDTO selectWalletByTokenSymbol(@Param("userId") String userId, @Param("tokenSymbol") String tokenSymbol, @Param("walletType") String walletType);
/**
* 用户充值修改钱包金额
*
*/
int updateWalletBalanceByUserOpenId(@Param("balance") BigDecimal balance,
@Param("userOpenId") String userOpenId,
@Param("tokenSymbol") String tokenSymbol,
@Param("walletType") String walletType,
@Param("modifyTime") Date modifyTime);
} }

@ -432,21 +432,13 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction {
@Override @Override
public void resetWallet(String userOpenId, String addr, String tokenId, String walletType) { public void resetWallet(String userOpenId, String addr, String tokenId, String walletType) {
//查询配置信息
WalletInitConfig walletInitConfig = new WalletInitConfig(); WalletInitConfig walletInitConfig = new WalletInitConfig();
walletInitConfig.setCoin(tokenId); walletInitConfig.setCoin(tokenId);
walletInitConfig.setWalletType(walletType); walletInitConfig.setWalletType(walletType);
WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig); WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig);
// 修改钱包插入充值记录 // 修改钱包插入充值记录
// eosWalletTransferService.handleWalletAndWalletTransfer(UUID.randomUUID().toString(), walletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date());
// addr,
// null,
// EosConstant.TransferType.TRANSFER_IN,
// walletInitConfig.getBalance(),
// "eosio.token",
// tokenId,""
// ,
// null);
} }
} }

@ -78,4 +78,19 @@
from <include refid="tableName"/> from <include refid="tableName"/>
where user_open_id = #{userId} where user_open_id = #{userId}
</select> </select>
<update id="updateWalletBalanceByUserOpenId">
UPDATE
<include refid="tableName"/>
wallet
SET
wallet.balance = wallet.freeze_balance + #{balance},
wallet.free_balance = #{balance},
wallet.update_time = #{modifyTime}
WHERE
wallet.user_open_id = #{userOpenId}
AND wallet.token_symbol = #{tokenSymbol}
AND wallet.wallet_type = #{walletType}
</update>
</mapper> </mapper>

@ -113,5 +113,13 @@ public interface EthWalletMapper extends Mapper<EthWallet> {
@Param("freezeBalance") BigDecimal freezeBalance, @Param("freezeBalance") BigDecimal freezeBalance,
@Param("updateTime") Date updateTime); @Param("updateTime") Date updateTime);
/**
* 用户充值修改钱包金额
*
*/
int updateWalletBalanceByUserOpenId(@Param("balance") BigDecimal balance,
@Param("userOpenId") String userOpenId,
@Param("tokenSymbol") String tokenSymbol,
@Param("walletType") String walletType,
@Param("modifyTime") Date modifyTime);
} }

@ -422,7 +422,7 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
walletInitConfig.setCoin(tokenId); walletInitConfig.setCoin(tokenId);
walletInitConfig.setWalletType(walletType); walletInitConfig.setWalletType(walletType);
WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig); WalletInitConfig config = walletInitConfigMapper.selectOne(walletInitConfig);
ethWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date());
EthWalletDTO walletDTO = selectByAddrAndTokenAddrAndWalletType(addr, addr, walletType); EthWalletDTO walletDTO = selectByAddrAndTokenAddrAndWalletType(addr, addr, walletType);

@ -122,4 +122,17 @@
AND wallet.freeze_balance + #{freezeBalance} >= 0 AND wallet.freeze_balance + #{freezeBalance} >= 0
</update> </update>
<update id="updateWalletBalanceByUserOpenId">
UPDATE
<include refid="tableName"/>
wallet
SET
wallet.balance = wallet.freeze_balance + #{balance},
wallet.free_balance = #{balance},
wallet.update_time = #{modifyTime}
WHERE
wallet.user_open_id = #{userOpenId}
AND wallet.token_symbol = #{tokenSymbol}
AND wallet.wallet_type = #{walletType}
</update>
</mapper> </mapper>
Loading…
Cancel
Save