Merge remote-tracking branch 'origin/whole' into whole
1 files added
27 files modified
| | |
| | | CONTENTFROMWALLETCOIN("0002","由币币账户转入"),
|
| | |
|
| | | CONTENTTOWALLETCOIN("0003","转出至币币账户"),
|
| | | CONTENTFROMCONTRACT("0004","由合约账户转入"),
|
| | | CONTENTFROMCONTRACT("0004","合约账户转入"),
|
| | |
|
| | | CONTENTFROMAGENT("0005","由代理账户转入"),
|
| | | CONTENTFROMAGENT("0005","代理账户转入"),
|
| | |
|
| | | WALLETCOINCODE("USDT", "USDT"),
|
| | |
|
New file |
| | |
| | | package com.xcong.excoin.common.enumerates; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 币种小数点 |
| | | */ |
| | | @Getter |
| | | public enum SymbolsPlacesEnum { |
| | | |
| | | BTC("BTC/USDT", 2) |
| | | ,ETH("ETH/USDT", 2) |
| | | ,LTC("LTC/USDT", 2) |
| | | ,BCH("BCH/USDT", 2) |
| | | ,EOS("EOS/USDT", 4) |
| | | ,XRP("XRP/USDT", 5) |
| | | ,ETC("ETC/USDT", 4); |
| | | |
| | | private String symbol; |
| | | |
| | | private Integer places; |
| | | |
| | | private SymbolsPlacesEnum(String symbol, Integer places) { |
| | | this.symbol = symbol; |
| | | this.places = places; |
| | | } |
| | | |
| | | public static Integer getValueByName(String symbol) { |
| | | Integer places = 0; |
| | | for (SymbolsPlacesEnum symbolsPlacesEnum : values()) { |
| | | if (symbol.equals(symbolsPlacesEnum.getSymbol())){ |
| | | places = symbolsPlacesEnum.getPlaces(); |
| | | break; |
| | | } |
| | | } |
| | | return places; |
| | | } |
| | | } |
| | |
| | | boolean isDebug = applicationProperties.isDebug(); |
| | | if (!isDebug) { |
| | | long currentTime = System.currentTimeMillis(); |
| | | return currentTime - time <= 10000; |
| | | return currentTime - time <= 30000; |
| | | } |
| | | return true; |
| | | } |
| | |
| | | }
|
| | | break;
|
| | | case "EOS":
|
| | | address = "biyicteos123";
|
| | | address = "hibitdeposit";
|
| | | map.put("address", address);
|
| | | map.put("lable", uuid);
|
| | | break;
|
| | | case "XRP":
|
| | | address = "biyicteos123";
|
| | | address = "rKMGEyjXErL2dx9ck5QXFJVH8onSfHF5gn";
|
| | | map.put("address", address);
|
| | | map.put("lable", uuid);
|
| | | break;
|
| | |
| | | private int status;
|
| | |
|
| | | @ApiModelProperty(value = "时间")
|
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
| | | @JsonFormat(pattern = "HH:mm MM/dd", timezone = "GMT+8")
|
| | | private Date updateTime;
|
| | |
|
| | | }
|
| | |
| | | memberAccountMoneyChangeDao.insert(memberAccountRecord);
|
| | |
|
| | | //添加资金划转历史记录
|
| | | memberAccountRecord.setContent("由合约"+symbol+"账户转入");
|
| | | memberAccountRecord.setContent("合约"+symbol+"账户转入");
|
| | | memberAccountRecord.setSymbol(walletCode);
|
| | | memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
|
| | | memberAccountRecord.setAmount(balance);
|
| | |
| | | memberAccountMoneyChangeDao.insert(memberAccountRecord);
|
| | |
|
| | | //添加合约资金划转历史记录
|
| | | memberAccountRecord.setContent("由合约"+symbolOut+"账户转入至合约"+symbolIn+"账户");
|
| | | memberAccountRecord.setContent("合约"+symbolOut+"账户转入至合约"+symbolIn+"账户");
|
| | | memberAccountRecord.setAmount(balance);
|
| | | memberAccountMoneyChangeDao.insert(memberAccountRecord);
|
| | |
|
| | |
| | | @ApiOperation(value = "全仓模式 - 变更仓位类型") |
| | | @GetMapping(value = "/changePositionType") |
| | | public Result changePositionType() { |
| | | return contractHoldOrderService.changePositionType(); |
| | | return Result.fail("无法切换"); |
| | | // return contractHoldOrderService.changePositionType(); |
| | | } |
| | | |
| | | @GetMapping(value = "/findPositionType") |
| | |
| | | @ApiModelProperty(value = "规格") |
| | | private BigDecimal symbolSku; |
| | | |
| | | @ApiModelProperty(value = "涨跌幅") |
| | | private BigDecimal upOrDown; |
| | | |
| | | public BigDecimal getBeUsedBondAmount() { |
| | | return beUsedBondAmount.setScale(4, BigDecimal.ROUND_DOWN); |
| | | } |
| | |
| | | package com.xcong.excoin.modules.contract.parameter.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.xcong.excoin.common.enumerates.SymbolsPlacesEnum; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @ApiModelProperty("倍率杠杆") |
| | | private int leverRatio; |
| | | |
| | | @ApiModelProperty("剩余张数") |
| | | private int symbolCntSale; |
| | | |
| | | public String getOpeningPrice() { |
| | | return openingPrice == null ? "" : openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return openingPrice == null ? "" : openingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public String getOpeningFeeAmount() { |
| | |
| | | } |
| | | |
| | | public String getForceClosingPrice() { |
| | | return forceClosingPrice == null ? "" : forceClosingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return forceClosingPrice == null ? "" : forceClosingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public void setOpeningFeeAmount(BigDecimal openingFeeAmount, BigDecimal feeSpread) { |
| | |
| | | package com.xcong.excoin.modules.contract.parameter.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.xcong.excoin.common.enumerates.SymbolsPlacesEnum; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | private Integer positionType; |
| | | |
| | | public String getOpeningPrice() { |
| | | return openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return openingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public String getBondAmount() { |
| | |
| | | } |
| | | |
| | | public String getForceClosingPrice() { |
| | | return forceClosingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return forceClosingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public String getProfitOrLoss() { |
| | |
| | | package com.xcong.excoin.modules.contract.parameter.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.xcong.excoin.common.enumerates.SymbolsPlacesEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @ApiModelProperty("杠杆") |
| | | private int leverRatio; |
| | | |
| | | @ApiModelProperty("剩余张数") |
| | | private int symbolCntSale; |
| | | |
| | | public String getClosingPrice() { |
| | | return closingPrice == null ? "" : closingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return closingPrice == null ? "" : closingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public String getClosingFeeAmount() { |
| | |
| | | } |
| | | |
| | | public String getOpeningPrice() { |
| | | return openingPrice == null ? "" : openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | return openingPrice == null ? "" : openingPrice.setScale(SymbolsPlacesEnum.getValueByName(this.symbol), BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | | |
| | | public String getOpeningFeeAmount() { |
| | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.web3j.abi.datatypes.Int; |
| | | import org.web3j.abi.datatypes.primitive.Int; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | @ApiModelProperty(value = "合约类型 1-普通 2-跟单") |
| | | private Integer contractType; |
| | | |
| | | @ApiModelProperty(value = "杠杆倍率") |
| | | private Integer leverRatio; |
| | | |
| | | public String getOpeningFeeAmount() { |
| | | return openingFeeAmount == null ? "" : openingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString(); |
| | | } |
| | |
| | | } else { |
| | | walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeConvert.convertContractTypeToCoin(entrustOrderEntity.getSymbol())); |
| | | |
| | | memberWalletContractDao.increaseWalletContractBalanceById(entrustOrderEntity.getEntrustAmount(), null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId()); |
| | | if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE == entrustOrderEntity.getEntrustType() || ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS == entrustOrderEntity.getEntrustType()) { |
| | | memberWalletContractDao.increaseWalletContractBalanceById(entrustOrderEntity.getEntrustAmount(), null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId()); |
| | | } |
| | | } |
| | | |
| | | ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity); |
| | |
| | | import com.xcong.excoin.modules.member.entity.*; |
| | | import com.xcong.excoin.modules.platform.dao.TradeSettingDao; |
| | | import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity; |
| | | import com.xcong.excoin.modules.symbols.parameter.vo.HomeSymbolsVo; |
| | | import com.xcong.excoin.modules.symbols.service.SymbolsService; |
| | | import com.xcong.excoin.rabbit.producer.OrderProducer; |
| | | import com.xcong.excoin.utils.*; |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderModel; |
| | |
| | | private FollowTraderInfoDao followTraderInfoDao; |
| | | @Resource |
| | | private FollowFollowerOrderRelationDao followFollowerOrderRelationDao; |
| | | @Resource |
| | | private SymbolsService symbolsService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | |
| | | // contractMoneyInfoVo.setAvailableBalance(available); |
| | | // } |
| | | |
| | | HomeSymbolsVo symbolReturnData = symbolsService.getSymbolReturnData(symbol); |
| | | |
| | | contractMoneyInfoVo.setBeUsedBondAmount(beUsedBondAmount); |
| | | contractMoneyInfoVo.setFrozenBondAmount(frozenBondAmount); |
| | |
| | | contractMoneyInfoVo.setNewPrice(newPriceSymbol); |
| | | contractMoneyInfoVo.setSymbolSku(cacheSettingUtils.getSymbolSku(symbol)); |
| | | contractMoneyInfoVo.setLeverRate(rateEntity.getLevelRateUp()); |
| | | contractMoneyInfoVo.setUpOrDown(symbolReturnData.getUpOrDown()); |
| | | return Result.ok(contractMoneyInfoVo); |
| | | } |
| | | |
| | |
| | | contractHoldOrderEntity.setOpeningPrice(entrustPrice); |
| | | contractHoldOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_LIMIT); |
| | | contractHoldOrderEntity.setOperateNo(1); |
| | | contractHoldOrderEntity.setSymbolCntSale(contractHoldOrderEntity.getSymbolCnt()); |
| | | contractHoldOrderService.save(contractHoldOrderEntity); |
| | | |
| | | // 需要一个历史插入 |
| | |
| | | } |
| | | |
| | | holdOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_LIMIT); |
| | | holdOrderEntity.setSymbolCntSale(holdOrderEntity.getSymbolCnt()); |
| | | holdOrderEntity.setSymbolCntSale(entrustOrder.getSymbolCnt()); |
| | | holdOrderEntity.setOpeningFeeAmount(openFeePrice); |
| | | holdOrderEntity.setOpeningPrice(entrustOrder.getEntrustPrice()); |
| | | holdOrderEntity.setMarkPrice(entrustOrder.getEntrustPrice()); |
| | |
| | | // 保证金 |
| | | BigDecimal bondAmount = CalculateUtil.getBondAmount(holdOrderEntity.getOpeningPrice(), lotNumber, closeCnt, holdOrderEntity.getLeverRatio()); |
| | | |
| | | BigDecimal rewardRatio = profitOrLoss.divide(bondAmount, 8, BigDecimal.ROUND_DOWN); |
| | | |
| | | log.info("bondAmount:{}", bondAmount); |
| | | // 平仓手续费 TODO 可能需要修复手续费 |
| | | BigDecimal fee = BigDecimal.ZERO; |
| | |
| | | contractOrderEntity.setRewardAmount(profitOrLoss); |
| | | contractOrderEntity.setBondAmount(bondAmount); |
| | | contractOrderEntity.setClosingFeeAmount(fee); |
| | | contractOrderEntity.setRewardRatio(rewardRatio); |
| | | contractOrderDao.insert(contractOrderEntity); |
| | | |
| | | if (holdOrderEntity.getSymbolCntSale() != 0) { |
| | |
| | | log.info("执行平仓委托"); |
| | | |
| | | Long memberId = entrustOrder.getMemberId(); |
| | | int orderType = entrustOrder.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE ? ContractHoldOrderEntity.OPENING_TYPE_MORE : ContractHoldOrderEntity.OPENING_TYPE_LESS; |
| | | int orderType = entrustOrder.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE ? ContractOrderEntity.ORDER_TYPE_CLOSE_MORE : ContractOrderEntity.ORDER_TYPE_CLOSE_LESS; |
| | | String symbol = entrustOrder.getSymbol(); |
| | | |
| | | MemberEntity memberEntity = memberDao.selectById(memberId); |
| | |
| | | member.setCertifyStatus(MemberEntity.CERTIFY_STATUS_UN_SUBMIT); |
| | | member.setIsForce(1); |
| | | member.setIsProfit(0); |
| | | member.setContractPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ALL); |
| | | member.setContractPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ADD); |
| | | memberDao.insert(member); |
| | | |
| | | MemberSettingEntity memberSettingEntity = new MemberSettingEntity(); |
| | | memberSettingEntity.setSpread(BigDecimal.ONE); |
| | | memberSettingEntity.setClosingSpread(BigDecimal.valueOf(5)); |
| | | memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0055)); |
| | | memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0075)); |
| | | memberSettingEntity.setMemberId(member.getId()); |
| | | memberSettingDao.insert(memberSettingEntity); |
| | | |
| | |
| | | |
| | | import com.xcong.excoin.common.response.Result; |
| | | import com.xcong.excoin.modules.symbols.parameter.dto.KlineDetailDto; |
| | | import com.xcong.excoin.modules.symbols.parameter.vo.HomeSymbolsVo; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | |
| | | public Result findKlineDetails(KlineDetailDto klineDetailDto); |
| | | |
| | | public HomeSymbolsVo getSymbolReturnData(String symbol); |
| | | |
| | | } |
| | |
| | | return Result.ok(homeSymbolsVo); |
| | | } |
| | | |
| | | @Override |
| | | public HomeSymbolsVo getSymbolReturnData(String symbol) { |
| | | PlatformCnyUsdtExchangeEntity cnyUsdtExchange = platformCnyUsdtExchangeDao.getCNYAndUSDTOne(); |
| | | // 获取当日k线数据 |
| | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(500); |
| | | CalculateUtil.getForceSetPriceForWhole(symbol, memberEntity); |
| | | } catch (Exception e) { |
| | | log.error("全仓模式预估强平价", e); |
| | |
| | | @Slf4j |
| | | public class DingTalkUtils { |
| | | |
| | | private static final String SECRET = "SECc0b73559742b950f07eabbd050c406a6abb3b67d112d3735289e90f58884c543"; |
| | | private static final String SECRET = "SEC6b1c402a4fa857e7c5e9e6d4d4afd1296a520893af68e063c7a7f005b4ae2a34"; |
| | | |
| | | public static void sendActionCard(int type) { |
| | | log.info("send dingtalk"); |
| | | String url = "https://oapi.dingtalk.com/robot/send?access_token=161d5e5b60ae5d6b4c80f2a9c35f9f212961a7c7154aa7e94b99503eca3886b0"; |
| | | String url = "https://oapi.dingtalk.com/robot/send?access_token=acc3ae94c91b06372b8465ba3fc079fc9bf382fbf8aee10fb4307ab978c1f5f7"; |
| | | Long timestamp = System.currentTimeMillis(); |
| | | try { |
| | | String sign = generateSign(timestamp); |
| | |
| | | } |
| | | |
| | | public static boolean sendRechargeMsg(String phone, String time, String orderNo) { |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,如有疑问请联系客服,订单编号为{}"; |
| | | String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,订单编号为{}"; |
| | | String content = StrUtil.format(msg, time, orderNo); |
| | | log.info("短信发送:{}", content); |
| | | return request(phone, content, "充值"); |
| | | } |
| | | |
| | |
| | | ## redis配置 |
| | | redis: |
| | | ## Redis数据库索引(默认为0) |
| | | database: 2 |
| | | database: 1 |
| | | ## Redis服务器地址 |
| | | host: 47.114.114.219 |
| | | host: 114.55.92.106 |
| | | ## Redis服务器连接端口 |
| | | port: 6379 |
| | | ## Redis服务器连接密码(默认为空) |
| | | password: biyi123 |
| | | password: hibit123 |
| | | jedis: |
| | | pool: |
| | | ## 连接池最大连接数(使用负值表示没有限制) |
| | |
| | | ## redis配置 |
| | | redis: |
| | | ## Redis数据库索引(默认为0) |
| | | database: 2 |
| | | database: 1 |
| | | ## Redis服务器地址 |
| | | host: 47.114.114.219 |
| | | host: 114.55.92.106 |
| | | ## Redis服务器连接端口 |
| | | port: 6379 |
| | | ## Redis服务器连接密码(默认为空) |
| | | password: biyi123 |
| | | password: hibit123 |
| | | jedis: |
| | | pool: |
| | | ## 连接池最大连接数(使用负值表示没有限制) |
| | |
| | | ## redis配置 |
| | | redis: |
| | | ## Redis数据库索引(默认为0) |
| | | database: 2 |
| | | database: 1 |
| | | ## Redis服务器地址 |
| | | host: 47.114.114.219 |
| | | host: 114.55.92.106 |
| | | ## Redis服务器连接端口 |
| | | port: 6379 |
| | | ## Redis服务器连接密码(默认为空) |
| | | password: biyi123 |
| | | password: hibit123 |
| | | jedis: |
| | | pool: |
| | | ## 连接池最大连接数(使用负值表示没有限制) |
| | |
| | | ## redis配置 |
| | | redis: |
| | | ## Redis数据库索引(默认为0) |
| | | database: 2 |
| | | database: 1 |
| | | ## Redis服务器地址 |
| | | host: 47.114.114.219 |
| | | host: 114.55.92.106 |
| | | ## Redis服务器连接端口 |
| | | port: 6379 |
| | | ## Redis服务器连接密码(默认为空) |
| | | password: biyi123 |
| | | password: hibit123 |
| | | jedis: |
| | | pool: |
| | | ## 连接池最大连接数(使用负值表示没有限制) |
| | |
| | | profiles: |
| | | active: dev |
| | | datasource: |
| | | # url: jdbc:mysql://rm-bp151tw8er79ig9kb5o.mysql.rds.aliyuncs.com:3306/db_biue?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8 |
| | | # username: ctcoin_data |
| | | # password: ctcoin_123 |
| | | url: jdbc:mysql://120.27.238.55:3306/kss_framework?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8 |
| | | username: ct_test |
| | | password: 123456 |
| | | url: jdbc:mysql://rm-bp151tw8er79ig9kb5o.mysql.rds.aliyuncs.com:3306/db_hibit?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8 |
| | | username: ctcoin_data |
| | | password: ctcoin_123 |
| | | # url: jdbc:mysql://120.27.238.55:3306/kss_framework?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8 |
| | | # username: ct_test |
| | | # password: 123456 |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | druid: |
| | |
| | | */ |
| | | @Test |
| | | public void forceSetPriceTest() { |
| | | MemberEntity memberEntity = memberDao.selectById(5L); |
| | | MemberEntity memberEntity = memberDao.selectById(66L); |
| | | CalculateUtil.getForceSetPriceForWhole("BTC/USDT", memberEntity); |
| | | } |
| | | |