| | |
| | | * @author wzy |
| | | */ |
| | | public enum CoinTypeEnum { |
| | | USDT, BTC, ETH, LTC, EOS, XRP, BCH, ETC, XCT |
| | | USDT, BTC, ETH, LTC, EOS, XRP, BCH, ETC, XCC |
| | | } |
| | |
| | | */ |
| | | @Getter |
| | | public enum SymbolEnum { |
| | | XCT("XCT", "XCT/USDT") |
| | | XCC("XCC", "XCC/USDT") |
| | | ,BTC("BTC", "BTC/USDT") |
| | | ,ETH("ETH", "ETH/USDT") |
| | | ,LTC("LTC", "LTC/USDT") |
| | |
| | | public interface Symbol{ |
| | | String USDT_ERC20 = "USDT_ERC20"; |
| | | String USDT_TRC20 = "USDT_TRC20"; |
| | | String COIN_TRC20 = "XCT_TRC20"; |
| | | String COIN_TRC20 = "XCC_TRC20"; |
| | | } |
| | | |
| | | public EthUsdtChargeDto() { |
| | |
| | | // 发送新增的地址到监听集合
|
| | | usdtUpdateProducer.sendAddressMsg(address+","+"ERC20");
|
| | | } else if ("TRC20".equals(lable)) {
|
| | | MemberCoinAddressEntity coinAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), CoinTypeEnum.XCT.name());
|
| | | MemberCoinAddressEntity coinAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), CoinTypeEnum.XCC.name());
|
| | | if (coinAddress != null) {
|
| | | address = coinAddress.getAddress();
|
| | | key = coinAddress.getPrivateKey();
|
| | |
| | | address = RocService.createWallet();
|
| | | map.put("address", address);
|
| | | break;
|
| | | case "XCT" :
|
| | | case "XCC" :
|
| | | MemberCoinAddressEntity trc20Usdt = memberMapper.selectBlockAddressWithTag(Long.parseLong(mId), CoinTypeEnum.USDT.name(), "TRC20");
|
| | | if (trc20Usdt != null) {
|
| | | address = trc20Usdt.getAddress();
|
| | |
| | | coinAddress.setPrivateKey(key);
|
| | | coinAddress.setSymbol(symbol);
|
| | | coinAddress.setLabel(uuid);
|
| | | if (symbol.equals("USDT") || "XCT".equals(symbol)) {
|
| | | if (symbol.equals("USDT") || "XCC".equals(symbol)) {
|
| | | coinAddress.setTag(lable);
|
| | | }
|
| | |
|
| | |
| | | /** |
| | | * 代币合约地址 |
| | | */ |
| | | public static String COIN_CONTRACT_ADDRESS = "TRTE68V3TJBLduBoJPLMgBsvwkq8LJBin6"; |
| | | public static String COIN_CONTRACT_ADDRESS = "TL2pea32CTtxJ48pJmnLQuoRHeoX79dLCT"; |
| | | /** |
| | | * 手续费 |
| | | */ |
| | |
| | | } |
| | | |
| | | public boolean poolCoin(String address) { |
| | | MemberCoinAddressEntity coinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.XCT.name()); |
| | | MemberCoinAddressEntity coinAddress = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.XCC.name()); |
| | | if (coinAddress == null) { |
| | | return false; |
| | | } |
| | |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result add(@RequestBody GbzAddDto gbzAddDto) { |
| | | // String status = redisUtils.getString("xct_order_status"); |
| | | // String status = redisUtils.getString("xcc_order_status"); |
| | | // if ("1".equals(status)) { |
| | | // return Result.fail("无法购买"); |
| | | // } |
| | | |
| | | String start = redisUtils.getString("xct_start"); |
| | | String start = redisUtils.getString("xcc_start"); |
| | | if ("2".equals(start)) { |
| | | return Result.fail("暂无法购买"); |
| | | } |
| | |
| | | return Result.fail("最少购买数量为10个"); |
| | | } |
| | | |
| | | String total = redisUtils.getString("xct_coin_total"); |
| | | String total = redisUtils.getString("xcc_coin_total"); |
| | | MemberEntity loginUser = LoginUserUtils.getAppLoginUser(); |
| | | BigDecimal price = new BigDecimal(redisUtils.getString("xct_order_new_price")); |
| | | BigDecimal price = new BigDecimal(redisUtils.getString("xcc_order_new_price")); |
| | | BigDecimal amount = BigDecimal.valueOf(gbzAddDto.getCount()).multiply(price); |
| | | |
| | | MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(loginUser.getId(), CoinTypeEnum.USDT.name()); |
| | |
| | | } |
| | | |
| | | if (Integer.parseInt(total) < gbzAddDto.getCount()) { |
| | | return Result.fail("XCT数量不足"); |
| | | return Result.fail("XCC数量不足"); |
| | | } |
| | | |
| | | GbzOrderEntity gbzOrder = new GbzOrderEntity(); |
| | |
| | | gbzOrder.setAmount(amount); |
| | | gbzOrder.setCnt(gbzAddDto.getCount()); |
| | | gbzOrder.setMemberId(loginUser.getId()); |
| | | gbzOrder.setSymbol(CoinTypeEnum.XCT.name()); |
| | | gbzOrder.setSymbol(CoinTypeEnum.XCC.name()); |
| | | gbzOrder.setStatus(1); |
| | | |
| | | gbzOrderDao.insert(gbzOrder); |
| | | |
| | | memberWalletCoinDao.updateBlockBalance(wallet.getId(), amount.negate(), BigDecimal.ZERO, 0); |
| | | redisUtils.set("xct_coin_total", Integer.parseInt(total) - gbzAddDto.getCount()); |
| | | redisUtils.set("xcc_coin_total", Integer.parseInt(total) - gbzAddDto.getCount()); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(loginUser.getId(), "购买BEA", amount, "USDT", 1, 1); |
| | | return Result.ok("购买成功"); |
| | | } |
| | |
| | | @GetMapping(value = "/findPrice") |
| | | public Result findPrice() { |
| | | PriceVo priceVo = new PriceVo(); |
| | | String newPriceStr = redisUtils.getString("xct_order_new_price"); |
| | | String newPriceStr = redisUtils.getString("xcc_order_new_price"); |
| | | priceVo.setNewPrice(StrUtil.isNotBlank(newPriceStr) ? new BigDecimal(newPriceStr) : AppContants.DEFAULT_PRICE); |
| | | |
| | | String status = redisUtils.getString("xct_order_status"); |
| | | String status = redisUtils.getString("xcc_order_status"); |
| | | priceVo.setStatus(StrUtil.isNotBlank(status) ? Integer.parseInt(status) : 2); |
| | | |
| | | |
| | | String remain = redisUtils.getString("xct_coin_total"); |
| | | String remain = redisUtils.getString("xcc_coin_total"); |
| | | priceVo.setRemainCnt(280000); |
| | | |
| | | BigDecimal totalAmount = gbzOrderDao.selectOrderTotalAmount(LoginUserUtils.getAppLoginUser().getId()); |
| | |
| | | @ApiOperation(value = "提取到资产") |
| | | @PostMapping(value = "/changeWallet") |
| | | public Result changeWallet() { |
| | | String status = redisUtils.getString("xct_order_status"); |
| | | String status = redisUtils.getString("xcc_order_status"); |
| | | if (!"1".equals(status)) { |
| | | return Result.fail("暂无法划转"); |
| | | } |
| | |
| | | } |
| | | |
| | | MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum |
| | | .XCT.name()); |
| | | .XCC.name()); |
| | | memberWalletCoinDao.updateBlockBalance(wallet.getId(), totalAmount, BigDecimal.ZERO, 0); |
| | | |
| | | gbzOrderDao.updateStatus(member.getId()); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取BEA到资产", totalAmount, "XCT", 1, 1); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取BEA到资产", totalAmount, "XCC", 1, 1); |
| | | return Result.ok("提取成功"); |
| | | } |
| | | } |
| | |
| | | @SubmitRepeat
|
| | | public Result submitSalesWalletCoinOrder(@RequestBody @Valid SubmitSalesWalletCoinOrderDto submitSalesWalletCoinOrderDto) {
|
| | | log.debug("买卖单参数[{}]", JSONObject.toJSONString(submitSalesWalletCoinOrderDto));
|
| | | String status = redisUtils.getString("xct_start");
|
| | | String status = redisUtils.getString("xcc_start");
|
| | | if ("1".equals(status)) {
|
| | | return Result.fail("暂未开放");
|
| | | }
|
| | |
| | | } |
| | | Long memberId = memberCoinAddress.getMemberId(); |
| | | // 查询钱包 并更新 |
| | | MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | if (walletCoinEntity == null) { |
| | | // 创建一个钱包 |
| | | // 创建这个钱包 |
| | |
| | | |
| | | memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), balance, BigDecimal.ZERO, 0); |
| | | |
| | | String orderNo = insertCoinCharge(address, memberId, balance, CoinTypeEnum.XCT.name(), "", BigDecimal.ZERO, null); |
| | | String orderNo = insertCoinCharge(address, memberId, balance, CoinTypeEnum.XCC.name(), "", BigDecimal.ZERO, null); |
| | | // 插入财务记录 |
| | | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", balance, CoinTypeEnum.XCT.name(), 1, 1); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", balance, CoinTypeEnum.XCC.name(), 1, 1); |
| | | |
| | | try { |
| | | ThreadPoolUtils.sendDingTalk(5); |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | if (StrUtil.isNotBlank(member.getPhone())) { |
| | | String amount = balance.toPlainString() + "XCT"; |
| | | String amount = balance.toPlainString() + "XCC"; |
| | | Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); |
| | | } else { |
| | | SubMailSend.sendRechargeMail(member.getEmail(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo); |
| | |
| | |
|
| | | @Override
|
| | | public Result findAllWalletCoinOrder() {
|
| | | List<OrderCoinsDealEntity> orderCoinsDealEntities = orderCoinDealDao.selectAllCoinDealsOrderBySymbol(CoinTypeEnum.XCT.toString());
|
| | | List<OrderCoinsDealEntity> orderCoinsDealEntities = orderCoinDealDao.selectAllCoinDealsOrderBySymbol(CoinTypeEnum.XCC.toString());
|
| | | return Result.ok(orderCoinsDealEntities);
|
| | | }
|
| | |
|
| | |
| | | //1:金币兑换1代币 2:1代币兑换金币 |
| | | if(type == 1){ |
| | | MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | if(balance.compareTo(memberAccountGold.getAvailableBalance()) > 0){ |
| | | return Result.fail("金币不足"); |
| | | } |
| | |
| | | cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange); |
| | | }else if(type == 2){ |
| | | MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | if(balance.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){ |
| | | return Result.fail("代币不足"); |
| | | } |
| | |
| | | public Result getAccountAvaBanlace() { |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); |
| | | MemberWalletCoinEntity memberWalletCoinEntityXCT = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntityXCC = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntityUSDT = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name()); |
| | | AccountAvaBanlaceVo accountAvaBanlaceVo = new AccountAvaBanlaceVo(); |
| | | // accountAvaBanlaceVo.setMemberId(memberId); |
| | | accountAvaBanlaceVo.setGoldAvailableBalance(memberAccountGold.getAvailableBalance() == null?BigDecimal.ZERO:memberAccountGold.getAvailableBalance()); |
| | | accountAvaBanlaceVo.setCoinAvailableBalance(memberWalletCoinEntityXCT.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityXCT.getAvailableBalance()); |
| | | accountAvaBanlaceVo.setCoinAvailableBalance(memberWalletCoinEntityXCC.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityXCC.getAvailableBalance()); |
| | | accountAvaBanlaceVo.setUsdtAvailableBalance(memberWalletCoinEntityUSDT.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityUSDT.getAvailableBalance()); |
| | | return Result.ok(accountAvaBanlaceVo); |
| | | } |
| | |
| | | |
| | | public class SymbolsConstats { |
| | | public final static List<String> EXCHANGE_SYMBOLS = new ArrayList<>(); |
| | | public final static String ROC = "XCT"; |
| | | public final static String ROC = "XCC"; |
| | | static { |
| | | EXCHANGE_SYMBOLS.add("XCT"); |
| | | EXCHANGE_SYMBOLS.add("XCC"); |
| | | } |
| | | } |
| | |
| | | kLine.setLow(kLine.getClose()); |
| | | kLine.setHigh(kLine.getClose()); |
| | | kLine.setVolume(BigDecimal.ZERO); |
| | | redisUtils.set("XCT/USDT",kLine); |
| | | redisUtils.set("XCC/USDT",kLine); |
| | | } |
| | | } |
| | | |
| | |
| | | @RabbitListener(queues = RabbitMqConfig.QUEUE_TRADE_PLATE) |
| | | public void tradePlate(String content) { |
| | | //log.info("--发送盘口消息--"); |
| | | tradePlateSendWebSocket.sendMessagePlate("XCT/USDT",content,null); |
| | | tradePlateSendWebSocket.sendMessagePlate("XCC/USDT",content,null); |
| | | } |
| | | |
| | | /** |
| | |
| | | return "EOS/USDT"; |
| | | case "etcusdt": |
| | | return "ETC/USDT"; |
| | | case "xctusdt": |
| | | return "XCT/USDT"; |
| | | case "xccusdt": |
| | | return "XCC/USDT"; |
| | | default: |
| | | return null; |
| | | } |
| | |
| | | switch (symbol) { |
| | | case "BTC/USDT": |
| | | return "btcusdt"; |
| | | case "XCT/USDT": |
| | | return "xctusdt"; |
| | | case "XCC/USDT": |
| | | return "xccusdt"; |
| | | default: |
| | | return null; |
| | | } |
| | |
| | | return "EOS_NEW_PRICE"; |
| | | case "ETC/USDT": |
| | | return "ETC_NEW_PRICE"; |
| | | case "XCT/USDT": |
| | | case "XCC/USDT": |
| | | return "BEA_NEW_PRICE"; |
| | | default: |
| | | return null; |
| | |
| | | // 发送订阅消息 |
| | | String nekk = factory.getTrader(SymbolsConstats.ROC).sendTradePlateMessage(); |
| | | SubResultModel subResultModel = new SubResultModel(); |
| | | subResultModel.setId("xctusdt"); |
| | | subResultModel.setId("xccusdt"); |
| | | subResultModel.setSubbed(sub); |
| | | synchronized (session) { |
| | | try { |
| | |
| | | String key = "KINE_{}_{}"; |
| | | // 币币k线数据 |
| | | //key = StrUtil.format(key, symbol, period); |
| | | key = StrUtil.format(key, "XCT/USDT", period); |
| | | key = StrUtil.format(key, "XCC/USDT", period); |
| | | RedisUtils bean = SpringContextHolder.getBean(RedisUtils.class); |
| | | Object o = bean.get(key); |
| | | List<CandlestickModel> candlestickModels = new ArrayList<>(); |
| | |
| | | <configuration> |
| | | <contextName>logback</contextName> |
| | | <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 --> |
| | | <property name="log.path" value="XCT/logs" /> |
| | | <property name="log.path" value="XCC/logs" /> |
| | | <!-- <springProperty scope="context" name="log.path" source="logging.file.path"/>--> |
| | | |
| | | <!-- 彩色日志 --> |
| | |
| | | //1:金币兑换1代币 2:1代币兑换金币 |
| | | if(type == 1){ |
| | | MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | if(balance.compareTo(memberAccountGold.getAvailableBalance()) > 0){ |
| | | // return Result.fail("金币不足"); |
| | | } |
| | |
| | | cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange); |
| | | }else if(type == 2){ |
| | | MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); |
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); |
| | | if(balance.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){ |
| | | // return Result.fail("代币不足"); |
| | | } |