From 04063bcb7b9e9d8e0242c1313f54ccc1b71f0b6e Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 25 Jun 2026 22:46:56 +0800
Subject: [PATCH] fix(gateApi): 调整网格交易参数配置
---
src/main/java/com/xcong/excoin/modules/okxApi/OkxConfig.java | 321 ++----------
src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/MarkPriceOkxChannelHandler.java | 24
src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/AbstractOkxPrivateChannelHandler.java | 28
src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientManager.java | 204 +++++--
src/main/java/com/xcong/excoin/modules/okxApi/Direction.java | 20
/dev/null | 29 -
src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/OrdersOkxChannelHandler.java | 14
src/main/java/com/xcong/excoin/modules/okxApi/OkxProfitRecycleStrategy.java | 548 +++++++++++++++++++++
src/main/java/com/xcong/excoin/ExcoinApplication.java | 20
src/main/java/com/xcong/excoin/modules/okxApi/OkxTradeExecutor.java | 44 +
src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/PositionsOkxChannelHandler.java | 42 -
src/main/resources/application.yml | 115 ----
src/main/java/com/xcong/excoin/modules/okxApi/IOkxStrategy.java | 78 +++
13 files changed, 962 insertions(+), 525 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/ExcoinApplication.java b/src/main/java/com/xcong/excoin/ExcoinApplication.java
index ef41726..c0312f2 100644
--- a/src/main/java/com/xcong/excoin/ExcoinApplication.java
+++ b/src/main/java/com/xcong/excoin/ExcoinApplication.java
@@ -1,23 +1,29 @@
package com.xcong.excoin;
-import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
- * @author helius
+ * OKX 盈利回收策略 — 最小化启动入口。
+ *
+ * <p>关闭不需要的自动配置:DataSource / Redis / RabbitMQ / Security / MyBatis。
*/
@EnableScheduling
-@EnableSwagger2
-@SpringBootApplication
-@MapperScan("com.xcong.excoin.modules.*.dao")
+@SpringBootApplication(exclude = {
+ DataSourceAutoConfiguration.class,
+ RedisAutoConfiguration.class,
+ RabbitAutoConfiguration.class,
+ SecurityAutoConfiguration.class
+})
public class ExcoinApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(ExcoinApplication.class, args);
}
-
}
diff --git a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java b/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
deleted file mode 100644
index a59ba96..0000000
--- a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xcong.excoin.common;
-
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.exception.GlobalException;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.SpringContextHolder;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpRequest;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-
-/**
- * 登陆用户工具类
- *
- * @author wzy
- * @date 2020-05-14
- **/
-@Slf4j
-public class LoginUserUtils {
-
- private static final String ANON = "anonymousUser";
-
- public static MemberEntity getAppLoginUser() {
- if (SecurityContextHolder.getContext().getAuthentication().getPrincipal().equals(ANON)) {
- throw new GlobalException("无法获取登陆信息");
- } else {
- return (MemberEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- }
- }
-
- public static String getAppLoginUserToken() {
- return (String) SecurityContextHolder.getContext().getAuthentication().getCredentials();
- }
-
- public static void resetAppLoginUser(MemberEntity memberEntity) {
- String token = getAppLoginUserToken();
- RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
- String jsonStr = redisUtils.getString(AppContants.PC_LOGIN_PREFIX + token);
- if (StrUtil.isNotBlank(jsonStr)) {
- redisUtils.set(AppContants.PC_LOGIN_PREFIX + token, JSONObject.toJSONString(memberEntity));
- } else {
- redisUtils.set(AppContants.APP_LOGIN_PREFIX + token, JSONObject.toJSONString(memberEntity));
- }
- }
-
- /**
- * mybatis 拦截器专用
- *
- * @return MemberEntity
- */
- public static MemberEntity getUser() {
- if (SecurityContextHolder.getContext().getAuthentication() == null) {
- return null;
- }
-
- if (SecurityContextHolder.getContext().getAuthentication().getPrincipal().equals(ANON)) {
- return null;
- } else {
- return (MemberEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- }
- }
-
- public static boolean isBrowser(HttpServletRequest request) {
- String userAgent = request.getHeader("user-agent");
- if (userAgent.toLowerCase().contains("mobile") || userAgent.contains("CFNetwork") || userAgent.toLowerCase().contains("okhttp")) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/annotations/SubmitRepeat.java b/src/main/java/com/xcong/excoin/common/annotations/SubmitRepeat.java
deleted file mode 100644
index eb41b12..0000000
--- a/src/main/java/com/xcong/excoin/common/annotations/SubmitRepeat.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.common.annotations;
-
-import java.lang.annotation.*;
-
-/**
- *
- * @author helius
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface SubmitRepeat {
-}
diff --git a/src/main/java/com/xcong/excoin/common/annotations/UserAuth.java b/src/main/java/com/xcong/excoin/common/annotations/UserAuth.java
deleted file mode 100644
index 597a6e9..0000000
--- a/src/main/java/com/xcong/excoin/common/annotations/UserAuth.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.xcong.excoin.common.annotations;
-
-import java.lang.annotation.*;
-
-
-/**
- * 自动注入当前登录用户
- *
- * @author wzy
- */
-@Target({ ElementType.PARAMETER, ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface UserAuth {
-}
diff --git a/src/main/java/com/xcong/excoin/common/aop/SubmitRepeatAspect.java b/src/main/java/com/xcong/excoin/common/aop/SubmitRepeatAspect.java
deleted file mode 100644
index 9d00c82..0000000
--- a/src/main/java/com/xcong/excoin/common/aop/SubmitRepeatAspect.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.xcong.excoin.common.aop;
-
-import com.xcong.excoin.common.annotations.SubmitRepeat;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * @author wzy
- * @date 2020-04-16 22:01
- **/
-@Slf4j
-@Aspect
-@Component
-public class SubmitRepeatAspect {
-
- @Resource
- private RedisUtils redisUtil;
-
- private String key;
-
- @Pointcut("@annotation(submitRepeat)")
- public void submitRepeatPointCut(SubmitRepeat submitRepeat) {
-
- }
-
- @Before("submitRepeatPointCut(submitRepeat)")
- public void before(SubmitRepeat submitRepeat) {
- }
-
- @Around("submitRepeatPointCut(submitRepeat)")
- public Object around(ProceedingJoinPoint joinPoint, SubmitRepeat submitRepeat) throws Throwable {
- ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
- HttpServletRequest request = attributes.getRequest();
-
- String token = request.getHeader("token");
- String uri = request.getRequestURI();
- String mId = (String) redisUtil.get(token);
- log.info("#token : {}, uri : {}, mId : {}#", token, uri, mId);
- key = mId + "_" + uri;
- boolean flag = redisUtil.setNotExist(key, "1", 5);
- log.info("#mid : {}, flag : {}#", mId, flag);
- if (flag) {
- Object result = joinPoint.proceed();
- redisUtil.del(key);
- return result;
- } else {
- return Result.fail(MessageSourceUtils.getString("submit_repeat"));
- }
- }
-
- @After("submitRepeatPointCut(submitRepeat)")
- public void after(SubmitRepeat submitRepeat) {
-
- }
-
- @AfterThrowing(throwing = "ex", pointcut = "submitRepeatPointCut(submitRepeat)")
- public void afterThrows(JoinPoint jp, Exception ex, SubmitRepeat submitRepeat) throws Exception {
- log.error("#submit repeat error:#", ex);
- redisUtil.del(key);
- throw new Exception("系统繁忙");
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/contants/AppContants.java b/src/main/java/com/xcong/excoin/common/contants/AppContants.java
deleted file mode 100644
index 40a7065..0000000
--- a/src/main/java/com/xcong/excoin/common/contants/AppContants.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.xcong.excoin.common.contants;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-public class AppContants {
-
- /**
- * 系统用户
- */
- public static final String SYSTEM_USER = "system";
-
-
- /**
- * app用户登陆redis前缀
- */
- public static final String APP_LOGIN_PREFIX = "app_";
-
- public static final String PC_LOGIN_PREFIX = "pc_";
-
- /**
- * token头部
- */
- public static final String TOKEN_HEADER = "Authorization";
-
- /**
- * token start with
- */
- public static final String TOKEN_START_WITH = "Bearer ";
-
- /**
- * 账号类型-手机号
- */
- public static final String ACCOUNT_TYPE_MOBILE = "1";
-
- /**
- * 账号类型-邮箱
- */
- public static final String ACCOUNT_TYPE_EMAIL = "2";
-
- /**
- * 系统推荐人id
- */
- public static final String SYSTEM_REFERER = "rxadr3";
-
- /**
- * 初始化金额
- */
- public static final BigDecimal INIT_MONEY = BigDecimal.ZERO;
-
-
- public static final Integer INIT_SIMULATE_MONEY = 5000;
-
- /**
- * homeSymbols 接口状态值 币币
- */
- public static final int HOME_SYMBOLS_COIN = 1;
-
- /**
- * homeSymbols 接口状态值 合约
- */
- public static final int HOME_SYMBOLS_CONTRACT = 2;
-
- /**
- * 验证码前缀 手机
- */
- public static final String VERIFY_CODE_PREFIX = "CODE_SMS_";
-
- /**
- * 图片后缀
- */
- public static final String UPLOAD_IMAGE_SUFFIX = ".jpg";
-
- public static final String TIME_OUT = "time_out";
-
-}
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/CoinTypeEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/CoinTypeEnum.java
deleted file mode 100644
index 720342a..0000000
--- a/src/main/java/com/xcong/excoin/common/enumerates/CoinTypeEnum.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.xcong.excoin.common.enumerates;
-
-/**
- * 币种枚举数据
- *
- * @author wzy
- */
-public enum CoinTypeEnum {
- USDT, BTC, ETH, LTC, EOS, XRP, BCH, ETC
-}
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
deleted file mode 100644
index e4d58dc..0000000
--- a/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.xcong.excoin.common.enumerates;
-
-public enum MemberWalletCoinEnum {
-
- WALLETCOINUSDT("walletCoinUsdt", "usdt"),
- WALLETCOINCNY("walletCoinCny", "cny"),
-
- WALLETCOINLIST("walletCoinList", "walletList"),
- WALLETAGENT("walletCoin", "wallet"),
-
- WALLETCONTRACT("walletContract", "walletContract"),
-
- CONTENTTOCONTRACT("0001","转出至合约账户"),
- CONTENTFROMWALLETCOIN("0002","由币币账户转入"),
-
- CONTENTTOWALLETCOIN("0003","转出至币币账户"),
- CONTENTFROMCONTRACT("0004","由合约账户转入"),
-
- CONTENTFROMAGENT("0005","由代理账户转入"),
-
- WALLETCOINCODE("USDT", "USDT"),
-
- SUBMITSALESWALLETCOINORDER_SERVICERATE("ServiceRate","0.002"),
-
- //SUBMITSALESWALLETCOINORDER_TYPE_S("买入","1"),
- //SUBMITSALESWALLETCOINORDER_TYPE_B("卖出","2"),
- //SUBMITSALESWALLETCOINORDER_TRADETYPE_S("市价","1"),
- //SUBMITSALESWALLETCOINORDER_TRADETYPE_X("限价","2"),
-
- //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_ONE("委托中","1"),
- //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_TWO("撤单","2"),
- //SUBMITSALESWALLETCOINORDER_ORDERSTATUS_THREE("已成交","3"),
-
-
-
- ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO("isCollect","0"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_YES("isCollect","1"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_SPREAD("spread","spread"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_CLOSINGRATIO("closingRatio","closingRatio"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_MEMBERMONEY("memberMoney","memberMoney"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICE("currentPrice","currentPrice"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_CNYUSDT("cnyUsdt","cnyUsdt"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICECNY("currentPriceCny","currentPriceCny"),
- ENTERTRANSACTIONPAGEOFWALLETCOIN_BUY("buy","1")
-
- ;
-
-
-
-
-
- private String name;
- private String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- private MemberWalletCoinEnum(String name, String value) {
- this.name = name;
- this.value = value;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/OrderClosingTypeEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/OrderClosingTypeEnum.java
deleted file mode 100644
index 3d22b26..0000000
--- a/src/main/java/com/xcong/excoin/common/enumerates/OrderClosingTypeEnum.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.common.enumerates;
-
-import lombok.Getter;
-
-/**
- * 合约历史订单 -- 平仓类型
- *
- * @author wzy
- * @date 2020-06-01
- **/
-@Getter
-public enum OrderClosingTypeEnum {
-
- /**
- * 平多
- */
- CLOSE_MORE(2)
- /**
- * 平空
- */
- , CLOSE_LESS(3)
- /**
- * 爆仓平多
- */
- , BOMB_CLOSE_MORE(4)
- /**
- * 爆仓平空
- */
- , BOMB_CLOSE_LESS(5)
- /**
- * 止盈平多
- */
- , PROFIT_STOP_MORE(6)
- /**
- * 止盈平空
- */
- , PROFIT_STOP_LESS(7)
- /**
- * 止损平多
- */
- , LESS_STOP_MORE(8)
- /**
- * 止损平空
- */
- , LESS_STOP_LESS(9);
-
- /**
- * 平仓类型
- */
- private final int value;
-
- private OrderClosingTypeEnum(int value) {
- this.value = value;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/RabbitPriceTypeEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/RabbitPriceTypeEnum.java
deleted file mode 100644
index b3d568f..0000000
--- a/src/main/java/com/xcong/excoin/common/enumerates/RabbitPriceTypeEnum.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.common.enumerates;
-
-import lombok.Getter;
-
-/**
- * rabbit 价格操作类型枚举
- * 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空
- *
- * @author helius
- */
-@Getter
-public enum RabbitPriceTypeEnum {
-
- /**
- * 委托开多
- */
- ENTRUST_OPEN_MORE(2)
- , ENTRUST_OPEN_LESS(3)
- , CLOSE_MORE_BOMB(6)
- , CLOSE_LESS_BOMB(7)
- , CLOSE_MORE_STOP_PROFIT(9)
- , CLOSE_LESS_STOP_PROFIT(10)
- , CLOSE_MORE_STOP_LESS(11)
- , CLOSE_LESS_STOP_LESS(12);
-
- private int value;
-
- private RabbitPriceTypeEnum(int value) {
- this.value = value;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/SymbolEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/SymbolEnum.java
deleted file mode 100644
index ca590aa..0000000
--- a/src/main/java/com/xcong/excoin/common/enumerates/SymbolEnum.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.common.enumerates;
-
-import lombok.Getter;
-
-/**
- * @author wzy
- */
-@Getter
-public enum SymbolEnum {
-
- BTC("BTC", "BTC/USDT")
- ,ETH("ETH", "ETH/USDT")
- ,LTC("LTC", "LTC/USDT")
- ,BCH("BCH", "BCH/USDT")
- ,EOS("EOS", "EOS/USDT")
- ,XRP("XRP", "XRP/USDT")
- ,ETC("ETC", "ETC/USDT");
-
- private String name;
-
- private String value;
-
- private SymbolEnum(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public static String getNameByValue(String value) {
- String name = "";
- for (SymbolEnum symbolEnum : values()) {
- if (value.equals(symbolEnum.getValue())){
- name = symbolEnum.getName();
- break;
- }
- }
- return name;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/common/exception/GlobalException.java b/src/main/java/com/xcong/excoin/common/exception/GlobalException.java
deleted file mode 100644
index 938cd36..0000000
--- a/src/main/java/com/xcong/excoin/common/exception/GlobalException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.common.exception;
-
-import lombok.Getter;
-
-/**
- * 统一异常处理
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Getter
-public class GlobalException extends RuntimeException {
-
- public GlobalException(String msg) {
- super(msg);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/response/Result.java b/src/main/java/com/xcong/excoin/common/response/Result.java
deleted file mode 100644
index 00064a5..0000000
--- a/src/main/java/com/xcong/excoin/common/response/Result.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.xcong.excoin.common.response;
-
-import com.xcong.excoin.utils.MessageSourceUtils;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * @author wzy
- * @date 2020-04-29 11:27
- **/
-@Data
-@ApiModel(value = "返回基类", description = "基础返回类")
-public class Result implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final int SUCCESS = 0;
-
- private static final String SUCCESS_MSG = MessageSourceUtils.getString("result_success_msg");
-
- private static final int FAIL = -1;
-
- private static final int LOGIN_FAIL = -2;
-
- @ApiModelProperty(value = "状态码", example = "0")
- private int code;
-
- @ApiModelProperty(value = "提示消息")
- private String msg;
-
- @ApiModelProperty(value = "数据对象")
- private Object data;
-
- public static Result ok(String msg) {
- Result result = new Result();
- result.code = SUCCESS;
- result.msg = msg;
- return result;
- }
-
- public static Result ok(String msg, Object data) {
- Result result = new Result();
- result.code = SUCCESS;
- result.msg = msg;
- result.data = data;
- return result;
- }
-
- public static Result ok(Object data) {
- Result result = new Result();
- result.code = SUCCESS;
- result.msg = SUCCESS_MSG;
- result.data = data;
- return result;
- }
-
- public static Result fail(String msg) {
- Result result = new Result();
- result.code = FAIL;
- result.msg = msg;
- return result;
- }
-
- public static Result loginFail(String msg) {
- Result result = new Result();
- result.code = LOGIN_FAIL;
- result.msg = msg;
- return result;
- }
-
- public static Result timeOut(String msg) {
- Result result = new Result();
- result.code = -3;
- result.msg = msg;
- return result;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/response/ResultCode.java b/src/main/java/com/xcong/excoin/common/response/ResultCode.java
deleted file mode 100644
index 9a93765..0000000
--- a/src/main/java/com/xcong/excoin/common/response/ResultCode.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.common.response;
-
-/**
- * 状态码
- * @author wzy
- */
-public enum ResultCode {
- /**
- * 成功
- */
- SUCCESS("1", "成功"),
-
- /**
- * 失败
- */
- FAIL("0", "失败");
-
-
- private String code;
- private String message;
-
- ResultCode(String code, String message) {
- this.code = code;
- this.message = message;
- }
-
- public String code() {
- return this.code;
- }
-
- public String message() {
- return this.message;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java b/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java
deleted file mode 100644
index 79c0ff1..0000000
--- a/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.xcong.excoin.common.system.base;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-04-24 14:58
- **/
-@Data
-public class BaseEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
-
- private String createBy;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createTime;
-
- private String updateBy;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date updateTime;
-
- private Integer version;
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/base/IBaseService.java b/src/main/java/com/xcong/excoin/common/system/base/IBaseService.java
deleted file mode 100644
index f11cae2..0000000
--- a/src/main/java/com/xcong/excoin/common/system/base/IBaseService.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.xcong.excoin.common.system.base;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- * @author wzy
- */
-public interface IBaseService<T> extends IService<T> {
- T findById(Object id);
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java b/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java
deleted file mode 100644
index 0924317..0000000
--- a/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.xcong.excoin.common.system.bean;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-@Getter
-@AllArgsConstructor
-public class LoginUserBean implements UserDetails {
-
- private final MemberEntity memberEntity;
-
- private final List<Long> roles;
-
- private final List<GrantedAuthority> authorities;
-
- @JsonIgnore
- @Override
- public String getPassword() {
- return memberEntity.getPassword();
- }
-
- @JsonIgnore
- @Override
- public String getUsername() {
- return "";
- }
-
- @JsonIgnore
- @Override
- public boolean isAccountNonExpired() {
- return true;
- }
-
- @JsonIgnore
- @Override
- public boolean isAccountNonLocked() {
- return true;
- }
-
- @JsonIgnore
- @Override
- public boolean isCredentialsNonExpired() {
- return true;
- }
-
- @JsonIgnore
- @Override
- public boolean isEnabled() {
- return true;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java b/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java
deleted file mode 100644
index 61639f7..0000000
--- a/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.xcong.excoin.common.system.controller;
-
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.StrUtil;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.dto.Base64UploadDto;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.configurations.properties.AliOssProperties;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.OssUtils;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.SmsUtils;
-import com.xcong.excoin.utils.mail.Sms106Send;
-import com.xcong.excoin.utils.mail.SmsSend;
-import com.xcong.excoin.utils.mail.SubMailSend;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 公共请求类
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Slf4j
-@Api(value = "公共请求类", tags = "公共请求类")
-@RestController
-@RequestMapping(value = "/common")
-public class CommonController {
-
- private static final String SUCCESS = "Success";
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private CommonService commonservice;
-
- @Resource
- private AliOssProperties aliOssProperties;
-
- @ApiOperation(value = "获取验证码接口", notes = "获取验证码通用接口")
- @GetMapping(value = "/verifyCode")
- public Result verifyCode(@ApiParam(name = "account", value = "手机号或邮箱", required = true) @RequestParam(value = "account") String account,
- @ApiParam(name = "type", value = "类型1-手机号2-邮箱", required = true) @RequestParam("type") String type) {
- log.info("#账号:{}, 类型:{}#", account, type);
-
- Integer code = (int) ((Math.random() * 9 + 1) * 100000);
- if (StrUtil.isNotBlank(redisUtils.getString(AppContants.VERIFY_CODE_PREFIX + account))) {
- return Result.fail(MessageSourceUtils.getString("common_verify_code_exist"));
- }
-
- // 发送手机验证码
- if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) {
- boolean result = Sms106Send.sendVerifyCode(account, code.toString(), 2);
- if (result) {
- Map<String, Object> map = new HashMap<>();
- boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120);
- map.put("code", flag);
- return Result.ok(MessageSourceUtils.getString("member_service_0010"), map);
- }
- // 发送邮件验证码
- } else if (AppContants.ACCOUNT_TYPE_EMAIL.equals(type)) {
- boolean flag = SubMailSend.sendMail(account, code.toString());
- if (flag) {
- redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120);
- return Result.ok(MessageSourceUtils.getString("member_service_0010"));
- } else {
- return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
- }
- } else {
- log.info("未定义账号类型");
- return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
- }
- return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
- }
-
- @ApiOperation(value = "验证验证码是否正确", notes = "验证验证码是否正确")
- @GetMapping(value = "/checkVerify")
- public Result checkVerify(@ApiParam(name = "account", value = "账号", required = true) @RequestParam("account") String account,
- @ApiParam(name = "code", value = "验证码", required = true) @RequestParam("code") String code) {
- boolean flag = commonservice.verifyCode(account, code);
- if (flag) {
- return Result.ok(MessageSourceUtils.getString("result_success_msg"));
- }
- return Result.fail(MessageSourceUtils.getString("common_verify_code"));
- }
-
- @ApiOperation(value = "文件上次接口", notes = "文件上传")
- @PostMapping(value = "/uploadFileBase64")
- public Result uploadFileBase64(@RequestBody @Validated Base64UploadDto uploadDto) {
- String imageName = "uploadeFile/image/" + System.currentTimeMillis() + IdUtil.simpleUUID() + AppContants.UPLOAD_IMAGE_SUFFIX;
-
- boolean flag = OssUtils.uploadFileWithBase64(uploadDto.base64Str, imageName);
- if (flag) {
- String url = aliOssProperties.getBucketName() + "/" + imageName;
- return Result.ok(MessageSourceUtils.getString("result_success_msg"), url);
- }
- return Result.fail(MessageSourceUtils.getString("uploadFile_controller_0001"));
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java b/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
deleted file mode 100644
index 4754bb5..0000000
--- a/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.xcong.excoin.common.system.controller;
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.crypto.SecureUtil;
-import cn.hutool.crypto.asymmetric.KeyType;
-import cn.hutool.crypto.asymmetric.RSA;
-import cn.hutool.crypto.asymmetric.Sign;
-import cn.hutool.crypto.asymmetric.SignAlgorithm;
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.annotations.SubmitRepeat;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.bean.LoginUserBean;
-import com.xcong.excoin.common.system.dto.LoginDto;
-import com.xcong.excoin.common.system.dto.RegisterDto;
-import com.xcong.excoin.configurations.properties.ApplicationProperties;
-import com.xcong.excoin.configurations.properties.SecurityProperties;
-import com.xcong.excoin.modules.member.service.MemberService;
-import com.xcong.excoin.utils.RedisUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.core.Authentication;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @Author wzy
- * @Date 2020/5/11
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@Slf4j
-@Api(value = "登陆注册类", tags = "登陆注册类")
-@RestController
-@RequestMapping(value = "/")
-public class LoginController {
-
- @Resource
- private MemberService memberservice;
-
- @Resource
- private ApplicationProperties applicationProperties;
-
- @Resource
- private SecurityProperties securityProperties;
-
- @Resource
- private AuthenticationManagerBuilder authenticationManagerBuilder;
-
- @Resource
- private RedisUtils redisUtils;
-
- @ApiOperation(value = "登陆接口", notes = "登陆接口")
- @PostMapping("/login")
- public Result login(@RequestBody @Validated LoginDto loginDto, HttpServletRequest request) {
- // 将账号密码交给spring security验证,并调用userServiceDetails
- UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(loginDto.getUsername(), SecureUtil.md5(loginDto.getPassword()));
- Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authToken);
-
- // 获取当前验证过后的用户
- LoginUserBean loginUserBean = (LoginUserBean) authentication.getPrincipal();
-
- // 生成UUID作为token
- String token = IdUtil.simpleUUID();
- String redisToken = "";
- String redisMember = "";
- if (LoginUserUtils.isBrowser(request)) {
- redisToken = AppContants.PC_LOGIN_PREFIX + token;
- redisMember = AppContants.PC_LOGIN_PREFIX + loginUserBean.getMemberEntity().getId();
- } else {
- redisToken = AppContants.APP_LOGIN_PREFIX + token;
- redisMember = AppContants.APP_LOGIN_PREFIX + loginUserBean.getMemberEntity().getId();
- }
-
- if (StrUtil.isNotBlank(redisUtils.getString(redisMember))) {
- if (redisMember.contains(AppContants.APP_LOGIN_PREFIX)) {
- redisUtils.del(AppContants.APP_LOGIN_PREFIX + redisUtils.getString(redisMember));
- } else {
- redisUtils.del(AppContants.PC_LOGIN_PREFIX + redisUtils.getString(redisMember));
- }
- }
- redisUtils.set(redisToken, JSONObject.toJSONString(loginUserBean.getMemberEntity()), applicationProperties.getRedisExpire());
- redisUtils.set(redisMember, token);
- Map<String, Object> authInfo = new HashMap<>();
- // 开启debug模式,则将加密后的token返回
- if (applicationProperties.isDebug()) {
- authInfo.put("token", token);
- authInfo.put("rsaToken", AppContants.TOKEN_START_WITH + generateAsaToken(token));
- authInfo.put("user", loginUserBean);
- } else {
- authInfo.put("token", token);
- authInfo.put("user", loginUserBean);
- }
- return Result.ok("success", authInfo);
- }
-
- public String generateAsaToken(String token) {
- RSA rsa = new RSA(null, securityProperties.getPublicKey());
- return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey);
- }
-
- @SubmitRepeat
- @ApiOperation(value = "app注册接口", notes = "app注册接口,验证码必须输入可默认为123456")
- @PostMapping(value = "/register")
- public Result register(@RequestBody @Validated RegisterDto registerDto) {
- return memberservice.register(registerDto);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/dto/Base64UploadDto.java b/src/main/java/com/xcong/excoin/common/system/dto/Base64UploadDto.java
deleted file mode 100644
index c4fa5f0..0000000
--- a/src/main/java/com/xcong/excoin/common/system/dto/Base64UploadDto.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.common.system.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
-
-/**
- * @author wzy
- * @date 2020-05-29
- **/
-@Data
-@ApiModel(value = "Base64UploadDto", description = "base64文件上传参数类")
-public class Base64UploadDto {
-
- @NotBlank
- @ApiModelProperty(value = "base64字符串")
- public String base64Str;
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/dto/LoginDto.java b/src/main/java/com/xcong/excoin/common/system/dto/LoginDto.java
deleted file mode 100644
index 1721f62..0000000
--- a/src/main/java/com/xcong/excoin/common/system/dto/LoginDto.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.common.system.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-@Data
-@ApiModel(value = "登陆接口接收类", description = "登陆接口接收类")
-public class LoginDto {
-
-
- @ApiModelProperty(value = "用户名", example = "11111")
- @NotBlank(message = "用户名或密码错误")
- private String username;
-
- @ApiModelProperty(value = "密码", example = "123456")
- @NotBlank(message = "用户名或密码错误")
- private String password;
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java b/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java
deleted file mode 100644
index 188904d..0000000
--- a/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.common.system.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.hibernate.validator.constraints.Length;
-
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-
-/**
- * 注册用户接收类
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@ApiModel(value = "注册接口参数类", description = "注册接口参数类")
-public class RegisterDto {
-
- @ApiModelProperty(value = "账号", example = "13412341234")
- @NotBlank(message = "账号不能为空")
- private String account;
-
- @ApiModelProperty(value = "密码", example = "123456")
- @NotBlank(message = "密码不能为空")
- private String password;
-
- @ApiModelProperty(value = "账号类型 1-手机 2-邮箱", example = "1")
- @NotNull(message = "账号类型不能为空")
- private Integer type;
-
- @ApiModelProperty(value = "验证码", example = "123456")
- @NotBlank(message = "验证码不能为空")
- private String code;
-
- @ApiModelProperty(value = "推荐人id", example = "rxadr3")
- private String refererId;
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/mapper/CandlestickMapper.java b/src/main/java/com/xcong/excoin/common/system/mapper/CandlestickMapper.java
deleted file mode 100644
index 4e6fca1..0000000
--- a/src/main/java/com/xcong/excoin/common/system/mapper/CandlestickMapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.common.system.mapper;
-
-import com.huobi.client.model.Candlestick;
-import com.xcong.excoin.modules.symbols.parameter.vo.KlineDataVo;
-import com.xcong.excoin.utils.api.response.KlineReturn;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.factory.Mappers;
-
-/**
- * @author wzy
- * @date 2020-05-29
- **/
-@Mapper
-public abstract class CandlestickMapper {
- public static final CandlestickMapper INSTANCE = Mappers.getMapper(CandlestickMapper.class);
-
- @Mapping(source = "timestamp", target = "time")
- public abstract KlineDataVo toKlineDataVo(Candlestick candlestick);
-
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/service/CommonService.java b/src/main/java/com/xcong/excoin/common/system/service/CommonService.java
deleted file mode 100644
index 444fc77..0000000
--- a/src/main/java/com/xcong/excoin/common/system/service/CommonService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.xcong.excoin.common.system.service;
-
-
-/**
- * @author helius
- */
-public interface CommonService {
-
- public boolean verifyCode(String account, String code);
-
- public String generateOrderNo(Long mid);
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java b/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java
deleted file mode 100644
index d08afa0..0000000
--- a/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.common.system.service;
-
-import cn.hutool.crypto.SecureUtil;
-import cn.hutool.crypto.asymmetric.Sign;
-import cn.hutool.crypto.asymmetric.SignAlgorithm;
-import com.xcong.excoin.common.exception.GlobalException;
-import com.xcong.excoin.common.system.bean.LoginUserBean;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @Author wzy
- * @Date 2020/5/11
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@Slf4j
-@Service("userDetailsService")
-public class UserDetailsServiceImpl implements UserDetailsService {
-
- @Resource
- private MemberDao memberDao;
-
- @Override
- public LoginUserBean loadUserByUsername(String username) throws UsernameNotFoundException {
- log.info("#登陆账号:{}#", username);
- List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
-// GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_ADMIN");
-// grantedAuthorities.add(grantedAuthority);
-
- MemberEntity memberEntity = memberDao.selectMemberInfoByAccount(username);
- if (memberEntity != null) {
- memberEntity.setPassword(new BCryptPasswordEncoder().encode(memberEntity.getPassword()));
- } else {
- throw new UsernameNotFoundException("");
- }
-
- if (MemberEntity.ACCOUNT_STATUS_DISABLED == memberEntity.getAccountStatus()) {
- throw new GlobalException(MessageSourceUtils.getString("member_service_0092"));
- }
-
- return new LoginUserBean(memberEntity, null, null);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/common/system/service/impl/CommonServiceImpl.java b/src/main/java/com/xcong/excoin/common/system/service/impl/CommonServiceImpl.java
deleted file mode 100644
index 265b41a..0000000
--- a/src/main/java/com/xcong/excoin/common/system/service/impl/CommonServiceImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.xcong.excoin.common.system.service.impl;
-
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.core.util.StrUtil;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.utils.RedisUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-05-29
- **/
-@Slf4j
-@Service
-public class CommonServiceImpl implements CommonService {
-
- @Resource
- private RedisUtils redisUtils;
-
- @Override
- public boolean verifyCode(String account, String code) {
- String cacheCode = redisUtils.getString(AppContants.VERIFY_CODE_PREFIX + account);
- if (StrUtil.isBlank(cacheCode)) {
- return false;
- }
- if (code.equals(cacheCode)) {
- redisUtils.del(AppContants.VERIFY_CODE_PREFIX + account);
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public String generateOrderNo(Long mid) {
- StringBuilder orderNo = new StringBuilder();
- String date = DateUtil.format(new Date(), "yyyyMMdd");
- orderNo.append(date);
- orderNo.append(mid);
- orderNo.append(RandomUtil.randomNumbers(2));
-
- Object countObj = redisUtils.get(date);
- if (countObj == null) {
- countObj = 0;
- }
- int count = (int) countObj;
- count++;
- redisUtils.set(date, count, 24 * 60 * 60);
-
- int size = 4;
- for (int i = 0; i < size - String.valueOf(count).length(); i++) {
- orderNo.append("0");
- }
- orderNo.append(count);
- return orderNo.toString();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java b/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java
deleted file mode 100644
index 99efc56..0000000
--- a/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.xcong.excoin.common.exception.GlobalException;
-import com.xcong.excoin.common.response.Result;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.dao.DuplicateKeyException;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.validation.FieldError;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-import javax.validation.ValidationException;
-
-/**
- * @author wzy
- * @date 2020-05-08 15:40
- **/
-@RestControllerAdvice
-@Slf4j
-public class GlobalExceptionHandler {
-
- /**
- * 方法参数校验
- *
- * @param e
- * @return
- */
- @ExceptionHandler(value = {MethodArgumentNotValidException.class})
- public Result handleException(MethodArgumentNotValidException e) {
- log.error(e.getMessage());
- FieldError fieldError = e.getBindingResult().getFieldError();
- if (fieldError != null) {
- return Result.fail(fieldError.getDefaultMessage());
- } else {
- return Result.fail("参数校验失败");
- }
- }
-
-
- @ExceptionHandler(value = {ValidationException.class})
- public Result handleException(ValidationException e) {
- log.error(e.getMessage(), e);
- return null;
- }
-
- @ExceptionHandler(value = {DuplicateKeyException.class})
- public Result handleException(DuplicateKeyException e) {
- log.error(e.getMessage(), e);
- return null;
- }
-
-
- /**
- * spring security 账户密码验证异常
- *
- * @param e
- * @return
- */
- @ExceptionHandler(value = { BadCredentialsException.class })
- public Result handleException(BadCredentialsException e) {
- log.error(e.getMessage(), e);
- return Result.fail("用户名或密码错误");
- }
-
- @ExceptionHandler(value = {GlobalException.class})
- public Result handleException(GlobalException e) {
- return Result.fail(e.getMessage());
- }
-
- @ExceptionHandler(value = {Exception.class})
- public Result handleException(Exception e) {
- log.error(e.getMessage(), e);
- return Result.fail("系统异常");
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/MybatisPlusConfig.java b/src/main/java/com/xcong/excoin/configurations/MybatisPlusConfig.java
deleted file mode 100644
index 6f48e95..0000000
--- a/src/main/java/com/xcong/excoin/configurations/MybatisPlusConfig.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author wzy
- * @date 2020-04-29 11:17
- **/
-@Configuration
-public class MybatisPlusConfig {
-
- /**
- * 分页插件
- *
- * @return
- */
- @Bean
- public PaginationInterceptor paginationInterceptor(){
- return new PaginationInterceptor();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
deleted file mode 100644
index 0a791bf..0000000
--- a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
+++ /dev/null
@@ -1,289 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.xcong.excoin.configurations.properties.CustomRabbitProperties;
-import org.springframework.amqp.core.Binding;
-import org.springframework.amqp.core.BindingBuilder;
-import org.springframework.amqp.core.DirectExchange;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Scope;
-
-import javax.annotation.Resource;
-
-/**
- * @author wzy
- * @date 2020-05-25
- **/
-@Configuration
-public class RabbitMqConfig {
-
- public static final String EXCHANGE_ONE = "biue-exchange-one";
-
- public static final String QUEUE_TEST = "test-queue";
-
- public static final String ROUTING_KEY_TEST = "test-routingKey";
-
- public static final String EXCHANGE_A = "biue-exchange-A";
-
-
- // 开多止盈队列
- public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO_NEW";
- // 开空止盈队列
- public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO_NEW";
- // 开多止损队列
- public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS_NEW";
- // 开空止损队列
- public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS_NEW";
-
- // 限价委托
- public static final String QUEUE_LIMIT = "QUEUE_LIMIT_NEW";
-
- // 爆仓队列
- public static final String QUEUE_COINOUT = "QUEUE_COINOUT_NEW";
-
- //价格操作
- public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE_NEW";
-
- // 平仓队列
- public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE_NEW";
-
-
- // 开多止盈路由键
- public static final String ROUTINGKEY_MOREPRO = "ROUTINGKEY_MOREPRO";
- // 开空止盈路由
- public static final String ROUTINGKEY_LESSPRO = "ROUTINGKEY_LESSPRO";
- // 开多止损路由
- public static final String ROUTINGKEY_MORELOSS = "ROUTINGKEY_MORELOSS";
- // 开空止损路由
- public static final String ROUTINGKEY_LESSLOSS = "ROUTINGKEY_LESSLOSS";
- // 限价委托
- public static final String ROUTINGKEY_LIMIT = "ROUTINGKEY_LIMIT";
-
- // 爆仓路由
- public static final String ROUTINGKEY_COINOUT = "ROUTINGKEY_COINOUT";
-
-
- // 价格操作
- public static final String ROUTINGKEY_PRICEOPERATE = "ROUTINGKEY_PRICEOPERATE";
- // 平仓路由
- public static final String ROUTINGKEY_CLOSETRADE = "ROUTINGKEY_CLOSETRADE";
-
- @Resource
- private ConnectionFactory connectionFactory;
-
-// @Bean
-// public ConnectionFactory connectionFactory() {
-// CachingConnectionFactory connectionFactory = new CachingConnectionFactory(customRabbitProperties.getHost(), customRabbitProperties.getPort());
-// connectionFactory.setUsername(customRabbitProperties.getUsername());
-// connectionFactory.setPassword(customRabbitProperties.getPassword());
-// connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
-// return connectionFactory;
-// }
-
- @Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public RabbitTemplate rabbitTemplate() {
- return new RabbitTemplate(connectionFactory);
- }
-
- @Bean
- public DirectExchange defaultExchange() {
- return new DirectExchange(EXCHANGE_ONE);
- }
-
- @Bean
- public Queue testQueue() {
- return new Queue(QUEUE_TEST, true);
- }
-
- @Bean
- public Binding binding() {
- return BindingBuilder.bind(testQueue()).to(defaultExchange()).with(ROUTING_KEY_TEST);
- }
-
-
- /**
- * 交换器A 可以继续添加交换器B C
- *
- * @return
- */
- @Bean
- public DirectExchange orderExchange() {
- return new DirectExchange(EXCHANGE_A);
- }
-
-
- /**
- * 开多止盈队列
- *
- * @return
- */
- @Bean
- public Queue queueMorePro() {
- // 定义一个名称为QUEUE_A,持久化的队列
- return new Queue(QUEUE_MOREPRO, true);
- }
-
- /**
- * 开空止盈队列
- *
- * @return
- */
- @Bean
- public Queue queueLessPro() {
- // 定义一个名称为QUEUE_A,持久化的队列
- return new Queue(QUEUE_LESSPRO, true);
- }
-
- /**
- * 开多止损
- *
- * @return
- */
- @Bean
- public Queue queueMoreLoss() {
- // 定义一个名称为QUEUE_A,持久化的队列
- return new Queue(QUEUE_MORELOSS, true);
- }
-
- /**
- * 开空止损
- *
- * @return
- */
- @Bean
- public Queue queueLessLoss() {
- // 定义一个名称为QUEUE_A,持久化的队列
- return new Queue(QUEUE_LESSLOSS, true);
- }
-
- /**
- * 限价委托
- *
- * @return
- */
- @Bean
- public Queue queueLimit() {
- return new Queue(QUEUE_LIMIT, true);
- }
-
-
- /**
- * 爆仓
- *
- * @return
- */
- @Bean
- public Queue queueCoinout() {
- return new Queue(QUEUE_COINOUT, true);
- }
-
- /**
- * 价格操作
- *
- * @return
- */
- @Bean
- public Queue queuePriceoperate() {
- return new Queue(QUEUE_PRICEOPERATE, true);
- }
-
- /**
- * 价格操作
- *
- * @return
- */
- @Bean
- public Queue queueCloseTrade() {
- return new Queue(QUEUE_CLOSETRADE, true);
- }
-
-
- /**
- * 开多止盈
- *
- * @return
- */
- @Bean
- public Binding bindingMroPro() {
- return BindingBuilder.bind(queueMorePro()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_MOREPRO);
- }
-
- /**
- * 开空止盈
- *
- * @return
- */
- @Bean
- public Binding bindingLessPro() {
- return BindingBuilder.bind(queueLessPro()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LESSPRO);
- }
-
- /**
- * 开多止损
- *
- * @return
- */
- @Bean
- public Binding bindingMroLoss() {
- return BindingBuilder.bind(queueMoreLoss()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_MORELOSS);
- }
-
- /**
- * 开空止损
- *
- * @return
- */
- @Bean
- public Binding bindingLessLoss() {
- return BindingBuilder.bind(queueLessLoss()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LESSLOSS);
- }
-
-
- /**
- * 委托
- *
- * @return
- */
- @Bean
- public Binding bindingLimit() {
- return BindingBuilder.bind(queueLimit()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LIMIT);
- }
-
-
- /**
- * 爆仓
- *
- * @return
- */
- @Bean
- public Binding bindingCoinout() {
- return BindingBuilder.bind(queueCoinout()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_COINOUT);
- }
-
-
- /**
- * 价格操作
- *
- * @return
- */
- @Bean
- public Binding bindingPriceoperate() {
- return BindingBuilder.bind(queuePriceoperate()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_PRICEOPERATE);
- }
-
- /**
- * 平仓绑定
- *
- * @return
- */
- @Bean
- public Binding bindingCloseTrade() {
- return BindingBuilder.bind(queueCloseTrade()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_CLOSETRADE);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/RedisConfig.java b/src/main/java/com/xcong/excoin/configurations/RedisConfig.java
deleted file mode 100644
index a9a61fa..0000000
--- a/src/main/java/com/xcong/excoin/configurations/RedisConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-/**
- * @Author wzy
- * @Date 2020/5/10
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@EnableCaching
-@Configuration
-public class RedisConfig {
-
- @Bean
- @SuppressWarnings("all")
- public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
- RedisTemplate<String, Object> template = new RedisTemplate<>();
- template.setConnectionFactory(factory);
- Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
- ObjectMapper om = new ObjectMapper();
- om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
- om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
- jackson2JsonRedisSerializer.setObjectMapper(om);
- StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
- // key采用String的序列化方式
- template.setKeySerializer(stringRedisSerializer);
- // hash的key也采用String的序列化方式
- template.setHashKeySerializer(stringRedisSerializer);
- // value序列化方式采用jackson
- template.setValueSerializer(jackson2JsonRedisSerializer);
- // hash的value序列化方式采用jackson
- template.setHashValueSerializer(jackson2JsonRedisSerializer);
- template.afterPropertiesSet();
- return template;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/SwaggerConfig.java b/src/main/java/com/xcong/excoin/configurations/SwaggerConfig.java
deleted file mode 100644
index 1b79633..0000000
--- a/src/main/java/com/xcong/excoin/configurations/SwaggerConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import io.swagger.annotations.Api;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.ParameterBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.schema.ModelRef;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Parameter;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @Author wzy
- * @Date 2020/5/11
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@Configuration
-@EnableSwagger2
-public class SwaggerConfig {
-
- @Bean
- public Docket createRestApi(){
- // 添加请求参数,我们这里把token作为请求头部参数传入后端
- ParameterBuilder parameterBuilder = new ParameterBuilder();
- List<Parameter> parameters = new ArrayList<Parameter>();
- parameterBuilder.name("Authorization").description("令牌").modelRef(new ModelRef("string")).parameterType("header")
- .required(false).build();
- parameters.add(parameterBuilder.build());
- return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
- .paths(PathSelectors.any()).build().globalOperationParameters(parameters).ignoredParameterTypes(MemberEntity.class);
- }
-
- private ApiInfo apiInfo(){
- return new ApiInfoBuilder()
- .title("ExCoin")
- .description("This is a restful api document of ExCoin.")
- .version("1.0")
- .build();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java b/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
deleted file mode 100644
index 06994e0..0000000
--- a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.xcong.excoin.configurations;
-
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
-import com.xcong.excoin.configurations.properties.AliOssProperties;
-import com.xcong.excoin.configurations.security.UserAuthenticationArgumentResolver;
-import com.xcong.excoin.utils.SpringContextHolder;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.SpringBootConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-04-27 11:54
- **/
-@SpringBootConfiguration
-@Slf4j
-public class WebMvcConfig implements WebMvcConfigurer {
-
- @Resource
- private AliOssProperties aliOssProperties;
-
-
- @Override
- public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
- resolvers.add(new UserAuthenticationArgumentResolver());
- }
-
- /**
- * 设置cors跨域支持
- *
- * @param registry
- */
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
- .allowCredentials(true).maxAge(3600);
- }
-
- @Bean
- public OSS ossClient() {
- return new OSSClientBuilder().build(aliOssProperties.getEndPoint(), aliOssProperties.getAccessKeyId(), aliOssProperties.getAccessKeySecret());
- }
-
-// @Bean
-// public SpringContextHolder springContextHolder() {
-// return new SpringContextHolder();
-// }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/i18n/CustomLocaleResolver.java b/src/main/java/com/xcong/excoin/configurations/i18n/CustomLocaleResolver.java
deleted file mode 100644
index 30324c9..0000000
--- a/src/main/java/com/xcong/excoin/configurations/i18n/CustomLocaleResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.xcong.excoin.configurations.i18n;
-
-import cn.hutool.core.util.StrUtil;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.LocaleResolver;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Locale;
-
-/**
- * @author wzy
- * @date 2020-04-30 14:56
- **/
-@Configuration
-public class CustomLocaleResolver implements LocaleResolver {
-
- @Override
- public Locale resolveLocale(HttpServletRequest httpServletRequest) {
- String lang = httpServletRequest.getHeader("lang");
- if(StrUtil.isBlank(lang)) {
- return new Locale("zh", "CN");
- } else {
- String[] splite = lang.split("_");
- return new Locale(splite[0], splite[1]);
- }
- }
-
- @Override
- public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
-
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/i18n/LocaleResolverConfig.java b/src/main/java/com/xcong/excoin/configurations/i18n/LocaleResolverConfig.java
deleted file mode 100644
index df80884..0000000
--- a/src/main/java/com/xcong/excoin/configurations/i18n/LocaleResolverConfig.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.configurations.i18n;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.LocaleResolver;
-
-
-/**
- * @author wzy
- * @date 2020-04-27 11:55
- **/
-@Configuration
-public class LocaleResolverConfig {
-
- @Bean
- public LocaleResolver localeResolver() {
- return new CustomLocaleResolver();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
deleted file mode 100644
index 5e69b7a..0000000
--- a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.xcong.excoin.configurations.interceptor;
-
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.executor.Executor;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlCommandType;
-import org.apache.ibatis.plugin.*;
-import org.apache.ibatis.session.defaults.DefaultSqlSession;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * mybatis拦截器,自动注入创建人、创建时间、修改人、修改时间
- *
- * @author wzy
- * @date 2020-05-13
- **/
-@Slf4j
-@Component
-@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
-public class MybatisInterceptor implements Interceptor {
- @Override
- public Object intercept(Invocation invocation) throws Throwable {
- MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
- SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
-
- Object parameter = invocation.getArgs()[1];
- if (parameter == null) {
- return invocation.proceed();
- }
-
- if (SqlCommandType.INSERT == sqlCommandType) {
- if (parameter instanceof DefaultSqlSession.StrictMap) {
- Map map = (Map) parameter;
- List list = (List) map.get("list");
- for (Object o : list) {
- injectForInsert(o);
- }
- } else {
- injectForInsert(parameter);
- }
- }
-
- if (SqlCommandType.UPDATE == sqlCommandType) {
- if (parameter instanceof DefaultSqlSession.StrictMap) {
- Map map = (Map) parameter;
- List list = (List) map.get("list");
- for (Object o : list) {
- injectForUpdate(o);
- }
- } else {
- injectForUpdate(parameter);
- }
- }
-
- return invocation.proceed();
- }
-
- @Override
- public Object plugin(Object o) {
- return Plugin.wrap(o, this);
- }
-
- @Override
- public void setProperties(Properties properties) {
-
- }
-
- public void injectForInsert(Object o) {
- MemberEntity member = LoginUserUtils.getUser();
- if (o instanceof BaseEntity) {
- BaseEntity baseEntity = (BaseEntity) o;
- if (member != null) {
- String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
- baseEntity.setCreateBy(by);
- baseEntity.setUpdateBy(by);
- } else {
- baseEntity.setCreateBy(AppContants.SYSTEM_USER);
- baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
- }
- baseEntity.setCreateTime(new Date());
- baseEntity.setUpdateTime(new Date());
- }
- }
-
- public void injectForUpdate(Object o) {
- MemberEntity member = LoginUserUtils.getUser();
- if (o instanceof BaseEntity) {
- BaseEntity baseEntity = (BaseEntity) o;
- if (member != null) {
- String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
- baseEntity.setUpdateBy(by);
- } else {
- baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
- }
- baseEntity.setUpdateTime(new Date());
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/AliOssProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/AliOssProperties.java
deleted file mode 100644
index 117f13c..0000000
--- a/src/main/java/com/xcong/excoin/configurations/properties/AliOssProperties.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.xcong.excoin.configurations.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author wzy
- * @date 2020-05-29
- **/
-@Data
-@Configuration
-@ConfigurationProperties(prefix = "aliyun.oss")
-public class AliOssProperties {
- private String endPoint;
-
- private String bucketName;
-
- private String accessKeyId;
-
- private String accessKeySecret;
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java
deleted file mode 100644
index 9e877ec..0000000
--- a/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.configurations.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * 应用配置
- *
- * @author wzy
- * @date 2020-05-12
- **/
-@Data
-@Configuration
-@ConfigurationProperties(prefix = "app")
-public class ApplicationProperties {
- private boolean debug;
-
- private Long redisExpire;
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java
deleted file mode 100644
index 47ddc4c..0000000
--- a/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.configurations.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author wzy
- * @date 2020-05-25
- **/
-@Data
-@Configuration
-@ConfigurationProperties(prefix = "custom.rabbitmq")
-public class CustomRabbitProperties {
- private String host;
- private int port;
- private String username;
- private String password;
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/SecurityProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/SecurityProperties.java
deleted file mode 100644
index abf0d06..0000000
--- a/src/main/java/com/xcong/excoin/configurations/properties/SecurityProperties.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.configurations.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author wzy
- * @date 2020-05-13
- **/
-@Data
-@Configuration
-@ConfigurationProperties(prefix = "rsa")
-public class SecurityProperties {
-
- private String privateKey;
-
- private String publicKey;
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java b/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java
deleted file mode 100644
index 34f840f..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.xcong.excoin.common.response.Result;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.access.AccessDeniedException;
-import org.springframework.security.web.access.AccessDeniedHandler;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-@Slf4j
-public class CustomAccessDeniedHandler implements AccessDeniedHandler {
- @Override
- public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
- Result result = Result.loginFail("Forbidden");
- httpServletResponse.getWriter().write(new ObjectMapper().writeValueAsString(result));
- httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
deleted file mode 100644
index 98b1cdd..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.response.Result;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.web.AuthenticationEntryPoint;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
-
- @Override
- public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
- String timeOut = response.getHeader("TimeOut");
- if (AppContants.TIME_OUT.equals(timeOut)) {
- Result result = Result.timeOut("Time Out");
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application/json; charset=utf-8");
- response.getWriter().write(new ObjectMapper().writeValueAsString(result));
- response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT);
- } else {
- Result result = Result.loginFail("Unauthorized");
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application/json; charset=utf-8");
- response.getWriter().write(new ObjectMapper().writeValueAsString(result));
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/TokenConfigurer.java b/src/main/java/com/xcong/excoin/configurations/security/TokenConfigurer.java
deleted file mode 100644
index a998762..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/TokenConfigurer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import lombok.RequiredArgsConstructor;
-import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.web.DefaultSecurityFilterChain;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-@RequiredArgsConstructor
-public class TokenConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
-
- @Override
- public void configure(HttpSecurity http) {
- TokenFilter customFilter = new TokenFilter();
- http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java b/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
deleted file mode 100644
index 362eb8b..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.crypto.asymmetric.KeyType;
-import cn.hutool.crypto.asymmetric.RSA;
-import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.exception.GlobalException;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.bean.LoginUserBean;
-import com.xcong.excoin.configurations.properties.ApplicationProperties;
-import com.xcong.excoin.configurations.properties.SecurityProperties;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.SpringContextHolder;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.util.StringUtils;
-import org.springframework.web.filter.GenericFilterBean;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * @author wzy
- * @date 2020-05-12
- **/
-@Slf4j
-public class TokenFilter extends GenericFilterBean {
-
- private final ApplicationProperties applicationProperties = SpringContextHolder.getBean(ApplicationProperties.class);
-
- private final SecurityProperties securityProperties = SpringContextHolder.getBean(SecurityProperties.class);
-
- private final RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
-
- @Override
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest) servletRequest;
- HttpServletResponse response = (HttpServletResponse) servletResponse;
- String token = resolveToken(request);
-
- if (!AppContants.TIME_OUT.equals(token)) {
- if (StrUtil.isNotBlank(token)) {
- String redisKey = "";
- // 根据user-agent判断pc端还是app端
- if (LoginUserUtils.isBrowser(request)) {
- redisKey = AppContants.PC_LOGIN_PREFIX + token;
- } else {
- redisKey = AppContants.APP_LOGIN_PREFIX + token;
- }
-
- String loginStr = (String) redisUtils.get(redisKey);
- if (StrUtil.isNotBlank(loginStr)) {
- MemberEntity loginUser = JSONObject.parseObject(loginStr, MemberEntity.class);
- Authentication authentication = new UsernamePasswordAuthenticationToken(loginUser, token, new ArrayList<>());
- SecurityContextHolder.getContext().setAuthentication(authentication);
- redisUtils.expire(redisKey, 36000);
- } else {
- log.info("token无法查询:{}", token);
- SecurityContextHolder.clearContext();
- }
- } else {
-// log.info("token为空:{}", request.getRequestURI());
- SecurityContextHolder.clearContext();
- }
- } else {
- response.setHeader("TimeOut", AppContants.TIME_OUT);
- SecurityContextHolder.clearContext();
- }
- filterChain.doFilter(servletRequest, servletResponse);
- }
-
- /**
- * 解析前端传来的token,先去掉Bearer,在rsa解密得到token_time,返回token,并判断time与当前是否在5s内
- *
- * @param request
- * @return
- */
- private String resolveToken(HttpServletRequest request) {
- try {
- String bearerToken = request.getHeader(AppContants.TOKEN_HEADER);
- if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(AppContants.TOKEN_START_WITH)) {
- // 去掉令牌前缀
- String rsaToken = bearerToken.replace(AppContants.TOKEN_START_WITH, "");
- RSA rsa = new RSA(securityProperties.getPrivateKey(), null);
- String[] tokens = StrUtil.split(rsa.decryptStr(rsaToken, KeyType.PrivateKey), "_");
-
- if (verifyTokenExpired(Long.parseLong(tokens[1]))) {
- return tokens[0];
- } else {
-// log.info("前面token为{}", tokens[0]);
-// log.info("时间为:{}, 当前时间为:{}", tokens[1], System.currentTimeMillis());
- return AppContants.TIME_OUT;
- }
- }
-// log.info("bearerToken---->{}", bearerToken);
- } catch (Exception e) {
- log.error("#解析token异常#", e);
- return null;
- }
- return null;
- }
-
- private Boolean verifyTokenExpired(Long time) {
- boolean isDebug = applicationProperties.isDebug();
- if (!isDebug) {
- long currentTime = System.currentTimeMillis();
- return currentTime - time <= 10000;
- }
- return true;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/UserAuthenticationArgumentResolver.java b/src/main/java/com/xcong/excoin/configurations/security/UserAuthenticationArgumentResolver.java
deleted file mode 100644
index 5dee717..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/UserAuthenticationArgumentResolver.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import com.xcong.excoin.common.annotations.UserAuth;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import org.springframework.core.MethodParameter;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.web.bind.support.WebDataBinderFactory;
-import org.springframework.web.context.request.NativeWebRequest;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.method.support.ModelAndViewContainer;
-
-/**
- * 自动注入登陆用户
- *
- * @author wzy
- * @date 2020-05-13
- **/
-public class UserAuthenticationArgumentResolver implements HandlerMethodArgumentResolver {
-
- @Override
- public boolean supportsParameter(MethodParameter parameter) {
- return parameter.getParameterAnnotation(UserAuth.class) != null && parameter.getParameterType().equals(MemberEntity.class);
- }
-
- @Override
- public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null) {
- return null;
- }
-
- MemberEntity auth = null;
- if (authentication.getPrincipal() != null) {
- auth = (MemberEntity) authentication.getPrincipal();
- }
- return auth;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java b/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java
deleted file mode 100644
index dfe6523..0000000
--- a/src/main/java/com/xcong/excoin/configurations/security/WebSecurityConfig.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.xcong.excoin.configurations.security;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.web.AuthenticationEntryPoint;
-import org.springframework.security.web.access.AccessDeniedHandler;
-
-import javax.annotation.Resource;
-
-/**
- * @author wzy
- * @date 2020-05-11
- **/
-@Slf4j
-@Configuration
-@EnableWebSecurity
-@EnableGlobalMethodSecurity(prePostEnabled = true)
-public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
-
- @Resource
- private UserDetailsService userDetailsService;
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.httpBasic().and().
- cors().and().csrf().disable()
- .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint())
- .and()
- .authorizeRequests()
- .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
- .antMatchers("/login").permitAll()
- .antMatchers("/register").permitAll()
- .antMatchers("/swagger**/**").permitAll()
- .antMatchers("/webjars/**").permitAll()
- .antMatchers("/v2/**").permitAll()
- .antMatchers("/api/symbols/**").permitAll()
- .antMatchers("/common/**").permitAll()
- .antMatchers("/api/exchange/**").permitAll()
- .antMatchers("/api/member/getMemberAccountInfo").permitAll()
- .antMatchers("/api/member/memberForgetPwd").permitAll()
- .antMatchers("/api/member/memberCoinInfoList").permitAll()
- .antMatchers("/api/member/getPcVersionInfo").permitAll()
- .antMatchers("/api/member/getAppVersionInfo").permitAll()
- .antMatchers("/api/orderCoin/searchSymbolResultList").permitAll()
- .antMatchers("/api/orderCoin/findCollect").permitAll()
- .anyRequest().authenticated()
- .and().apply(securityConfiguereAdapter());
- }
-
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
- }
-
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Bean
- public AccessDeniedHandler accessDeniedHandler() {
- return new CustomAccessDeniedHandler();
- }
-
- @Bean
- public AuthenticationEntryPoint authenticationEntryPoint() {
- return new CustomAuthenticationEntryPoint();
- }
-
- public TokenConfigurer securityConfiguereAdapter() {
- return new TokenConfigurer();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/controller/BlockController.java b/src/main/java/com/xcong/excoin/modules/blackchain/controller/BlockController.java
deleted file mode 100644
index e024e8d..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/controller/BlockController.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.modules.blackchain.controller;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.blackchain.service.BlockSerive;
-import com.xcong.excoin.utils.RedisUtils;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@Api(value = "链上钱包接口", tags = "链上钱包接口")
-@RestController
-@RequestMapping(value = "/api/block")
-public class BlockController {
-
-
-
- @Autowired
- RedisUtils redisUtils;
- @Autowired
- BlockSerive blockSerive;
- /**
- * BTC
- * @param token
- * @return
- */
- @ApiOperation(value = "链上生成钱包地址接口", notes = "链上生成钱包地址接口")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/findBlockAddress")
- public Result findBlockAddress(String symbol) {
- return blockSerive.findBlockAddress(symbol);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/model/EosResult.java b/src/main/java/com/xcong/excoin/modules/blackchain/model/EosResult.java
deleted file mode 100644
index ca0bd19..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/model/EosResult.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.blackchain.model;
-
-import lombok.Data;
-
-/**
- * 数据样例
- * EosResult(quantity=2.0000 EOS, memo=aa, from=okbtothemoon, to=biueeostoken, accountActionSeq=2)
- */
-@Data
-public class EosResult {
- /**
- * 转账数量
- */
- private String quantity;
-
- /**
- * 转账标记
- */
- private String memo;
- private String from;
- private String to;
-
- /**
- * 这笔转账对应于这个账户的序号
- */
- private Integer accountActionSeq;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransResult.java b/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransResult.java
deleted file mode 100644
index a9bf035..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransResult.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.xcong.excoin.modules.blackchain.model;
-
-import java.util.List;
-
-// https://github.com/ripple/rippled-historical-database#get-account-transaction-history
-public class XrpTransResult {
- private String result; //success
- private Integer count; //
- private String marker;//
-
- //transactions
- List<XrpTransactions> transactions;
-
- public String getResult() {
- return result;
- }
-
- public void setResult(String result) {
- this.result = result;
- }
-
- public Integer getCount() {
- return count;
- }
-
- public void setCount(Integer count) {
- this.count = count;
- }
-
- public String getMarker() {
- return marker;
- }
-
- public void setMarker(String marker) {
- this.marker = marker;
- }
-
- public List<XrpTransactions> getTransactions() {
- return transactions;
- }
-
- public void setTransactions(List<XrpTransactions> transactions) {
- this.transactions = transactions;
- }
-
-
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransactions.java b/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransactions.java
deleted file mode 100644
index f69f00f..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTransactions.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.xcong.excoin.modules.blackchain.model;
-
-public class XrpTransactions {
-
- private String hash;
- private Integer ledger_index;
- private String date;//2019-10-28T15:01:01+00:00
- private XrpTx tx;
-
- public String getHash() {
- return hash;
- }
- public void setHash(String hash) {
- this.hash = hash;
- }
- public Integer getLedger_index() {
- return ledger_index;
- }
- public void setLedger_index(Integer ledger_index) {
- this.ledger_index = ledger_index;
- }
- public String getDate() {
- return date;
- }
- public void setDate(String date) {
- this.date = date;
- }
- public XrpTx getTx() {
- return tx;
- }
- public void setTx(XrpTx tx) {
- this.tx = tx;
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTx.java b/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTx.java
deleted file mode 100644
index 9b7a883..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/model/XrpTx.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.xcong.excoin.modules.blackchain.model;
-
-import lombok.Data;
-
-@Data
-public class XrpTx {
- private String transactionType;
- private Integer flags;
- private Integer sequence;
- private Integer destinationTag; // 对应的用户标签
- private Integer amount; // 金额 除以1000000 一百万
- private Integer fee; // 手续费
- private String account; // 转账人
- private String destination; // 收款人(收款人是系统账户 说明是转入)
-
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/BchService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/BchService.java
deleted file mode 100644
index eb142df..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/BchService.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-
-
-public class BchService {
-
-
- private static BchService service = null;
- private final static String RESULT = "result";
- private final static String METHOD_SEND_TO_ADDRESS = "sendtoaddress";
- private final static String METHOD_GET_TRANSACTION = "gettransaction";
- private final static String METHOD_LIST_TRANSACTIONS = "listtransactions";
- private final static String METHOD_GET_BLOCK_COUNT = "getblockcount";
- private final static String METHOD_NEW_ADDRESS = "getnewaddress";
- private final static String METHOD_GET_BALANCE = "getbalance";
- private final static String METHOD_GET_BALANCE_ADDRESS = "getreceivedbyaddress";
- private final static String METHOD_WALLET_PASSPHRASE = "walletpassphrase";
- private final static String METHOD_WALLET_LOCK = "walletlock";
-
- private String url = "http://121.40.86.163:1882";
- private String username = "biyi";
- private String password = "biyi12345";
-
- public static BchService getInstance() {
- if (service != null) {
- return service;
- }
- return new BchService();
- }
-
- private BchService() {
- }
-
- /**
- * 创建BTC钱包 每个账户对应一个地址 方便后续操作
- * @param mId 账户
- * @return
- */
- public static Map<String, String> createWallet(String mId) {
- BchService btcService = getInstance();
- // 创建钱包地址
- String address = btcService.getAddress(mId);
- // 私钥
- String privateKey = btcService.dumpprivkey(address);
- Map<String, String> result = new HashMap<String,String>();
- result.put("address", address);
- result.put("privateKey", privateKey);
- return result;
- }
- public String getAddress(String label) {
- try {
- JSONObject json = doRequest(METHOD_NEW_ADDRESS,label);
- if (isError(json)) {
- return "";
- }
- return json.getString(RESULT);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private JSONObject doRequest(String method, Object... params) {
- JSONObject param = new JSONObject();
- param.put("id", System.currentTimeMillis() + "");
- param.put("jsonrpc", "2.0");
- param.put("method", method);
- if (params != null) {
- param.put("params", params);
- }
- String creb = Base64.encodeBase64String((username + ":" + password).getBytes());
- Map<String, String> headers = new HashMap<>(2);
- headers.put("Authorization", "Basic " + creb);
- return JSON.parseObject(HttpUtil.jsonPost(url, headers, param.toJSONString()));
- }
-
- private boolean isError(JSONObject json) {
- if (json == null || (StringUtils.isNotEmpty(json.getString("error")) && json.get("error") != "null")) {
- return true;
- }
- return false;
- }
-
- public String dumpprivkey(String address) {
- try {
- JSONObject obj = doRequest("dumpprivkey", address);
- System.out.println(obj);
- if (!isError(obj)) {
- return obj.getString(RESULT);
- } else {
- return null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 查询给定地址的总收款额(只计算接受的)
- * @param address
- * @return
- */
- public BigDecimal getBalance(String address) {
- JSONObject json = doRequest(METHOD_GET_BALANCE_ADDRESS,address,3);
- if (!isError(json)) {
- return new BigDecimal(json.getString(RESULT));
- } else {
- return null;
- }
- }
-
- public String METHOD_GET_BLOCK_COUNT() {
- JSONObject json = doRequest(METHOD_GET_BLOCK_COUNT);
- if (!isError(json)) {
- return json.getString(RESULT);
- } else {
- return null;
- }
- }
- public static void main(String[] args) {
- BchService ser = new BchService();
- //ser.getBalance("36RiLqCrnFfBoyUUHpGvEotXiMRtrJG8dp");
- //System.out.println(ser.METHOD_GET_BLOCK_COUNT());
- System.out.println(ser.getBalance("36RiLqCrnFfBoyUUHpGvEotXiMRtrJG8dp"));
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/BigDecimalUtil.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/BigDecimalUtil.java
deleted file mode 100644
index 3043a0f..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/BigDecimalUtil.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.DecimalFormat;
-
-/**
- * 数据计算工具类
- *
- * @author cloud cloud
- * @create 2017/10/11
- **/
-public class BigDecimalUtil {
-
-
- /**
- * 基本单位
- */
- private static final BigDecimal UNIT = new BigDecimal(100000000);
-
- /**
- * 对double数据进行取精度.
- * @param value double数据.
- * @param scale 精度位数(保留的小数位数).
- * @param roundingMode 精度取值方式.
- * @return 精度计算后的数据.
- */
- public static double round(double value, int scale,
- int roundingMode) {
- BigDecimal bd = new BigDecimal(value);
- bd = bd.setScale(scale, roundingMode);
- double d = bd.doubleValue();
- bd = null;
- return d;
- }
-
- /**
- * 获取四位小数的字符串,小数位不够补充0
- * @param value
- * @return X.0000
- */
- public static String getFourString(double value){
- DecimalFormat df = new DecimalFormat("0.0000");
- return df.format(value);
- }
-
-
- /**
- * double 相加
- * @param d1
- * @param d2
- * @return
- */
- public static double sum(Double d1,Double d2){
- BigDecimal bd1 = new BigDecimal(d1.toString());
- BigDecimal bd2 = new BigDecimal(d2.toString());
- return bd1.add(bd2).doubleValue();
- }
-
- public static double sum(String a,String b){
- BigDecimal pa = new BigDecimal(a);
- BigDecimal pb = new BigDecimal(b);
- return pa.add(pb).doubleValue();
- }
-
-
- /**
- * double 相减
- * @param d1
- * @param d2
- * @return
- */
- public static double sub(double d1,double d2){
- BigDecimal bd1 = new BigDecimal(Double.toString(d1));
- BigDecimal bd2 = new BigDecimal(Double.toString(d2));
- return bd1.subtract(bd2).setScale(6,BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
- /**
- * double 乘法
- * @param d1
- * @param d2
- * @return
- */
- public static double mul(double d1,double d2){
- BigDecimal bd1 = new BigDecimal(Double.toString(d1));
- BigDecimal bd2 = new BigDecimal(Double.toString(d2));
- return bd1.multiply(bd2).setScale(6,BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
-
- /**
- * double 除法
- * @param d1
- * @param d2
- * @param scale 四舍五入 小数点位数
- * @return
- */
- public static double div(double d1,double d2,int scale){
- // 当然在此之前,你要判断分母是否为0,
- // 为0你可以根据实际需求做相应的处理
-
- BigDecimal bd1 = new BigDecimal(Double.toString(d1));
- BigDecimal bd2 = new BigDecimal(Double.toString(d2));
- return bd1.divide
- (bd2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
- /**
- * 长整数相乘
- * @param pa
- * @param pb
- * @return
- */
- public static long longMul(long pa,long pb){
- BigDecimal b1 = new BigDecimal(pa);
- BigDecimal b2 = new BigDecimal(pb);
- return b1.multiply(b2).longValue();
- }
-
- public static long longMul(long pa ,Double rate){
- BigDecimal b1 = new BigDecimal(pa);
- BigDecimal b2 = new BigDecimal(rate.toString());
- b2 = b2.setScale(6,BigDecimal.ROUND_HALF_UP);
- return b1.multiply(b2).longValue();
- }
-
- public static long longMul(long pa ,String rate){
- BigDecimal b1 = new BigDecimal(pa);
- BigDecimal b2 = new BigDecimal(rate);
- return b1.multiply(b2).longValue();
- }
-
- /**
- * 长整数相减
- * @param pa
- * @param pb
- * @return
- */
- public static long longSub(long pa,long pb){
- BigDecimal b1 = new BigDecimal(pa);
- BigDecimal b2 = new BigDecimal(pb);
- return b1.subtract(b2).longValue();
- }
-
- /**
- * 长整数相加
- * @param pa
- * @param pb
- * @return
- */
- public static long longAdd(long pa,long pb){
- BigDecimal b1 = new BigDecimal(pa);
- BigDecimal b2 = new BigDecimal(pb);
- return b1.add(b2).longValue();
- }
-
- /**
- * 入参转化
- * @param value
- * @return
- */
- public static long inputConvert(Double value){
- BigDecimal input = new BigDecimal(value.toString());
- return input.multiply(UNIT).longValue();
- }
-
- /**
- * 输出转化
- * @param value
- * @return
- */
- public static double outputConvert(long value){
- BigDecimal output = new BigDecimal(value);
- return output.divide(UNIT,6, RoundingMode.DOWN).doubleValue();
- }
-
- public static void main(String[] args) {
- long res = longMul(100000000,0.000009999999);
- System.out.println(res);
-
- }
-
- public static long sum(Long d1,String d2){
- BigDecimal bd1 = new BigDecimal(d1.toString());
- BigDecimal bd2 = new BigDecimal(d2);
- return bd1.add(bd2).longValue();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/BlockSerive.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/BlockSerive.java
deleted file mode 100644
index 4784320..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/BlockSerive.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import com.xcong.excoin.common.response.Result;
-
-public interface BlockSerive {
-
- Result findBlockAddress(String symbol);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/BtcService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/BtcService.java
deleted file mode 100644
index b8a4c84..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/BtcService.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-
-
-public class BtcService {
-
-
- private static BtcService service = null;
- private final static String RESULT = "result";
- private final static String METHOD_SEND_TO_ADDRESS = "sendtoaddress";
- private final static String METHOD_GET_TRANSACTION = "gettransaction";
- private final static String METHOD_LIST_TRANSACTIONS = "listtransactions";
- private final static String METHOD_GET_BLOCK_COUNT = "getblockcount";
- private final static String METHOD_NEW_ADDRESS = "getnewaddress";
- private final static String METHOD_GET_BALANCE = "getbalance";
- private final static String METHOD_GET_BALANCE_ADDRESS = "getreceivedbyaddress";
- private final static String METHOD_WALLET_PASSPHRASE = "walletpassphrase";
- private final static String METHOD_WALLET_LOCK = "walletlock";
-
- private String url = "http://120.55.86.146:1880";
- private String username = "biyi";
- private String password = "biyi1234";
-
- public static BtcService getInstance() {
- if (service != null) {
- return service;
- }
- return new BtcService();
- }
-
- private BtcService() {
- }
-
- /**
- * 创建BTC钱包 每个账户对应一个地址 方便后续操作
- * @param mId 账户
- * @return
- */
- public static Map<String, String> createWallet(String mId) {
- BtcService btcService = getInstance();
- // 创建钱包地址
- String address = btcService.getAddress(mId);
- // 私钥
- String privateKey = btcService.dumpprivkey(address);
- Map<String, String> result = new HashMap<String,String>();
- result.put("address", address);
- result.put("privateKey", privateKey);
- return result;
- }
- public String getAddress(String label) {
- try {
- JSONObject json = doRequest(METHOD_NEW_ADDRESS,label);
- if (isError(json)) {
- return "";
- }
- return json.getString(RESULT);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private JSONObject doRequest(String method, Object... params) {
- JSONObject param = new JSONObject();
- param.put("id", System.currentTimeMillis() + "");
- param.put("jsonrpc", "2.0");
- param.put("method", method);
- if (params != null) {
- param.put("params", params);
- }
- String creb = Base64.encodeBase64String((username + ":" + password).getBytes());
- Map<String, String> headers = new HashMap<>(2);
- headers.put("Authorization", "Basic " + creb);
- return JSON.parseObject(HttpUtil.jsonPost(url, headers, param.toJSONString()));
- }
-
- private boolean isError(JSONObject json) {
- if (json == null || (StringUtils.isNotEmpty(json.getString("error")) && json.get("error") != "null")) {
- return true;
- }
- return false;
- }
-
- public String dumpprivkey(String address) {
- try {
- JSONObject obj = doRequest("dumpprivkey", address);
- System.out.println(obj);
- if (!isError(obj)) {
- return obj.getString(RESULT);
- } else {
- return null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 查询给定地址的总收款额(只计算接受的)
- * @param address
- * @return
- */
- public BigDecimal getBalance(String address) {
- JSONObject json = doRequest(METHOD_GET_BALANCE_ADDRESS,address,3);
- if (!isError(json)) {
- return new BigDecimal(json.getString(RESULT));
- } else {
- return null;
- }
- }
-
- public String METHOD_GET_BLOCK_COUNT() {
- JSONObject json = doRequest(METHOD_GET_BLOCK_COUNT);
- if (!isError(json)) {
- return json.getString(RESULT);
- } else {
- return null;
- }
- }
- public static void main(String[] args) {
- BtcService ser = new BtcService();
- //ser.getBalance("36RiLqCrnFfBoyUUHpGvEotXiMRtrJG8dp");
- //System.out.println(ser.METHOD_GET_BLOCK_COUNT());
- System.out.println(ser.getBalance("36RiLqCrnFfBoyUUHpGvEotXiMRtrJG8dp"));
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/DateUtil.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/DateUtil.java
deleted file mode 100644
index d8217db..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/DateUtil.java
+++ /dev/null
@@ -1,1369 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.lang.StringUtils;
-public class DateUtil {
-
- public DateUtil() {
-
- }
- /**
- * 测试用
- * @param args
- * @throws ParseException
- */
- public static void main(String[] args) throws ParseException {
-// long time = System.currentTimeMillis()+7200000;
-// Date a = new Date(time);
-// long space = dateSpaceHours(new Date(), a);
-// System.out.println(space);
-// System.out.println(DateUtil.dateToString(DateUtil.getStringToDate(DateUtil.getSQLDateYMD())));
-
-// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-// Date date= DateUtil.addDays(new Date(), -1);
-// System.out.println(date);
-// System.out.println(DateUtil.dateToString(date));
-// System.out.println(simpleDateFormat.format(date));
-// System.out.println(DateUtil.getStringToDate(dateToStringYMD(date),"yyyy-MM-dd"));
-// System.out.println(DateUtil.getStringToDate(null));
- //for(int i=0;i<10;i++){
- //System.out.println(getSQLDateYMD());
- //}
- //System.out.println(dateDiff("2013-06-08 12:25:23","2013-07-08 12:25:23"));
- // System.out.println(currentTimeDiff2("2013-12-08"));
- // System.out.println(compare_date("2013-07-08 12:25:23", "2013-07-08 12:23:23"));
- //System.out.println(fomatDate("2013-10-16 9:27:34"));
- //System.out.println(System.currentTimeMillis());
- //System.out.println(getTenTimestamp());
- //System.out.println(getSixRandom());
- // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //获取当前时间
- // Date time = Calendar.getInstance().getTime();
-
- // System.out.println(simpleDateFormat.format(datePlusOrMinus("2013-10-16 9:27:34",2)));
-
- // System.out.println(dateToString(datePlusOrMinus(getSQLDate(), 2)));
-
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- // String strDate1 = "2012-3-15";
- // String strDate2 = "2013-5-13";
- // Date date1=sdf.parse(strDate1);
- // Date date2=sdf.parse(strDate2);
- // //
- // // System.out.println(getMonths(date2,date1));
- // System.out.println(daysBetween(date2, date1));
- // System.out.println(fomatDate("2014-04"));
- // System.out.println(fomatDate("2014-05"));
- // System.out.println(Double.parseDouble(fomatDate("2014-05")) > Double.parseDouble(fomatDate("2014-04")));
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- // String date1 = "2014-04";
- // String date2 = "2015-08";
- // Date start = sdf.parse(date1);
- // Date end = sdf.parse(date2);
- //
- //
- // System.out.println("###start:==" + start);
- // System.out.println("###end:==" + end);
-
- // System.out.println("月份="+myTimeStr(9615000));
- // System.out.println(fomatDateToNumber("2014-07-28 14:12:14"));
- //System.out.println(compareDate("2014-08-13","2014-08-12"));
- // System.out.println(getNineRandom());
- // System.out.println("222="+dateDiffStr("2014-06-11 00:00:00","2014-06-25 23:59:59"));
-// System.out.println("getUTCTimeStr()=="+DateUtil.currentTimeDiffToHour("2015-01-22 18:12:59"));
- //System.out.println(DateUtil.dateDiff("2015-09-02 09:55:14",DateUtil.dateToString(new Date())));
- System.out.println(DateUtil.currentTimeDiff("2018-07-11 18:00:00"));
- }
-
- /**
- * 计算今天的剩余秒数
- * @return
- */
- public static int getTodaySeconds(){
- Calendar cal = Calendar.getInstance();
- long start = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis());
- cal.add(Calendar.DAY_OF_YEAR, 1);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- long end = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis());
- return (int) (end - start);
- }
-
- /**
- * 获取当前分钟
- * @return
- */
- public static Integer getNowDateMin(){
- Calendar c1 = Calendar.getInstance();
- c1.setTime(new Date());
- return c1.get(Calendar.MINUTE);
- }
- /**
- * 获取当前day
- * @return
- */
- public static Integer getNowDateDay(){
- Calendar c1 = Calendar.getInstance();
- c1.setTime(new Date());
- return c1.get(Calendar.DATE);
- }
-
- /**
- * 获取当前秒
- * @return
- */
- public static Integer getNowDateSecond(){
- Calendar c1 = Calendar.getInstance();
- c1.setTime(new Date());
- return c1.get(Calendar.SECOND);
- }
- /**
- * 返回两个日期之间相差天数---只比较天数
- * @param fDate
- * @param oDate
- * @return
- */
- public static int daysOfTwo(Date fDate, Date oDate) {
-
- Calendar aCalendar = Calendar.getInstance();
-
- aCalendar.setTime(fDate);
-
- int day1 = aCalendar.get(Calendar.DAY_OF_YEAR);
-
- aCalendar.setTime(oDate);
-
- int day2 = aCalendar.get(Calendar.DAY_OF_YEAR);
-
- return Math.abs(day2 - day1);
-
- }
-
- /**
- * 把日期格式转换为字符串格式HH:mm:ss
- * @param date
- * @return
- */
- public static String dateToStringHMS (Date date){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
- return simpleDateFormat.format(date);
- }
- /**
- * 把日期格式转换为字符串格式HH:mm
- * @param date
- * @return
- */
- public static String dateToStringHM (Date date){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
- return simpleDateFormat.format(date);
- }
- /**
- * 把日期格式转换为字符串格式HHmm
- * @param date
- * @return
- */
- public static int dateToIntHM (Date date){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HHmm");
- return Integer.parseInt(simpleDateFormat.format(date));
- }
- /**
- * 指定格式日期往后加多少分钟
- * @param format
- * @param StrDate
- * @param min
- * @return
- */
- @SuppressWarnings("static-access")
- public static String addMin(String format,String StrDate,int min){
- Calendar cal = Calendar.getInstance();
- SimpleDateFormat sFmt = new SimpleDateFormat(format);
- cal.setTime(sFmt.parse( (StrDate), new ParsePosition(0)));
-
- if (min != 0) {
- cal.add(cal.MINUTE,min);
- }
- return sFmt.format(cal.getTime());
- }
- /**
- * 指定格式日期往后加多少分钟
- * @param date
- * @param min
- * @return
- */
- public static Date addMin(Date date,int min){
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- if (min != 0) {
- cal.add(Calendar.MINUTE,min);
- }
- return cal.getTime();
- }
- /**
- * HH:mm:ss上加秒
- * @param date
- * @param seconds
- * @return
- */
- public static String addSecond(Date date, int seconds) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- calendar.add(Calendar.SECOND, seconds);
- date =calendar.getTime();
- return dateToStringHMS(date);
- }
-
- /**
- * 产生2位
- */
- public static String getThreeRandom(){
- int random1 = (int) (Math.random() * 900 + 100);
- String random = String.valueOf(random1);
- return random;
- }
-
- /**
- * 把日期格式转换为字符串格式yyyy-MM-dd
- * @param
- * @return
- */
- public static String dateToStringYMD (){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- return simpleDateFormat.format(new Date());
- }
- /**
- * 把日期格式转换为字符串格式yyyy-MM-dd
- * @param
- * @return
- */
- public static String dateToStringYMD (Date data){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- return simpleDateFormat.format(data);
- }
-
- /**
- * String类型时间转为Timestamp,str与format必须格式一致
- *
- * @param str
- * @param
- * @return
- */
- public static Timestamp str2Timestamp(String str) {
- Timestamp ts = null;
- try {
- if (null != str && !"".equals(str)) {
- DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
- ts = new Timestamp(sdf.parse(str).getTime());
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- return ts;
- }
-
- /**
- * Date类型时间转为String格式,format为需要返回的格式
- *
- * @param
- * @param
- * @return
- */
- public static String timeStamp2Str(Date dateTime) {
- /*SimpleDateFormat oldFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date();
- try {
- date = oldFormat.parse(dateTime);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }*/
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
- return sdf.format(dateTime);
- }
-
- /**
- * 获取一个月的天数
- * @param year
- * @param month
- * @return
- */
- public static int dateToString (String year,String month){
- Calendar c= Calendar.getInstance();
- c.set(Calendar.YEAR, Integer.parseInt(year));
- c.set(Calendar.MONTH, Integer.parseInt(month)+1);
- return c.getActualMaximum(Calendar.DAY_OF_MONTH);
- }
-
- /**
- * 把日期格式转换为字符串格式
- * @param date
- * @return
- */
- public static String dateToString (Date date){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- return simpleDateFormat.format(date);
- }
- /**
- * 把日期格式转换为字符串格式
- * @param date
- * @return
- */
- public static String dateToString (Date date,String dateFormat){
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
- return simpleDateFormat.format(date);
- }
-
- /**
- * 把日期格式转换为YYMMDDHHMMSS格式
- * @param
- * @return
- */
- public static String dateToNumber (String time){
- SimpleDateFormat oldFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat newFormat = new SimpleDateFormat("yyMMddHHmmss");
- Date date = new Date();
- try {
- date = oldFormat.parse(time);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return newFormat.format(date);
- }
-
- /**
- * 根据有效期格式化时间
- * @param type 1每年 2 每月 3 每天 4 每小时 5 每分钟
- * @param time yyMMddHHmmss
- * @return
- */
- public static String termvalidityFormat(int type,String time){
- String retime = null;
- try {
-
- if(type == 1){
- retime = "00"+time.substring(2, time.length());
- }else if(type == 2){
- retime = "0000"+time.substring(4, time.length());
- }else if(type == 3){
- retime = "000000"+time.substring(6, time.length());
- }else if(type == 4){
- retime = "00000000"+time.substring(8, time.length());
- }else if(type == 5){
- retime = "0000000000"+time.substring(10, time.length());
- }else {
- retime = time;
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return retime;
-
- }
-
- /**
- * 把原始字符串扩展成自定的长度
- * @param oriStr 原始字符串
- * @param fillChar 要填充的字符
- * @param setLength 要扩展成的长度
- * @param preFill 前扩充还是后扩充 true-在前面填充,false-后面填充
- * @return
- */
- public static String fixStringToSetLength(String oriStr, String fillChar, int setLength, boolean preFill) {
- if(oriStr == null || fillChar.equals("")) {
- return oriStr;
- }
-
- int oriLength = oriStr.length();
- StringBuilder sb = null;
- if(preFill == true) {
- sb = new StringBuilder();
- for(int i = oriLength; i < setLength; i++) {
- sb.append(fillChar);
- }
- sb.append(oriStr);
- } else {
- sb = new StringBuilder(oriStr);
- for(int i = oriLength; i < setLength; i++) {
- sb.append(fillChar);
- }
- }
-
- return sb.toString();
- }
-
-
-
- //日期往后加多少个月,多少天,多少年
- @SuppressWarnings("static-access")
- public static String addMonth(String format,String StrDate,int year,int month,int day){
-
- Calendar cal = Calendar.getInstance();
- SimpleDateFormat sFmt = new SimpleDateFormat(format);
- cal.setTime(sFmt.parse( (StrDate), new ParsePosition(0)));
-
- if (day != 0) {
- cal.add(cal.DATE,day);
- }
- if (month != 0) {
- cal.add(cal.MONTH, month);
- }
- if (year != 0) {
- cal.add(cal.YEAR, year);
- }
- return sFmt.format(cal.getTime());
- }
-
- /**
- * 在当前时间增加或减少N个小時
- * @param
- * @param month
- * @return
- */
- public static Date addHour(int hour){
- Calendar cal = Calendar.getInstance();
- cal.add( Calendar.HOUR, hour);
- return cal.getTime();
- }
-
- /**
- * 在当前时间增加或减少N个月
- * @param
- * @param month
- * @return
- */
- public static Date addMonth(int month){
- Calendar cal = Calendar.getInstance();
- cal.add( Calendar.MONTH, month);
- return cal.getTime();
- }
-
- /**
- * 增加days天
- * @param date
- * @param days
- * @return
- */
- public static Date addDays(Date date ,int days){
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- cal.add(Calendar.DAY_OF_MONTH, days);
- return cal.getTime();
- }
- /**
- * 判断两个时间字符串之差
- * @param date1
- * @param date2
- * @return 毫秒数
- */
- public static Long dateDiff(String date1,String date2) {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- return df.parse(date1).getTime() - df.parse(date2).getTime();
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 判断两个指定格式时间字符串之差
- * @param format
- * @param date1
- * @param date2
- * @return 毫秒数
- */
- public static Long dateDiff(String format,String date1,String date2) {
- DateFormat df = new SimpleDateFormat(format);
- try {
- return df.parse(date1).getTime() - df.parse(date2).getTime();
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 计算时间差,相差多少天、小时、分、秒
- * @param stime
- * @param etime
- * @return
- */
- public static String dateDiffStr(String stime,String etime){
- String diff = "";
- try {
- SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- java.util.Date begin=dfs.parse(stime);
- java.util.Date end = dfs.parse(etime);
- long between=(end.getTime()-begin.getTime())/1000;//除以1000是为了转换成秒
- long day1=between/(24*3600);
- long hour1=between%(24*3600)/3600;
- long minute1=between%3600/60;
- long second1=between%60;
- System.out.println(""+day1+"天"+hour1+"小时"+minute1+"分"+second1+"秒");
- if(day1>0){
- diff = ""+day1+"天"+hour1+"小时"+minute1+"分"+second1+"秒";
- return diff;
- }
-
- if(hour1>0){
- diff = ""+hour1+"小时"+minute1+"分"+second1+"秒";
- return diff;
- }
-
- if(minute1>0){
- diff = ""+minute1+"分"+second1+"秒";
- return diff;
- }
-
- if(second1>=0){
- diff = ""+second1+"秒";
- return diff;
- }
-
- return diff;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return diff;
-
- }
-
- /**
- * 和当前时间差
- * @param date
- * @return 当前时间 - date 毫秒数
- */
- public static Long currentTimeDiff(String date) {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- return System.currentTimeMillis() - df.parse(date).getTime();
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
- /**
- * 和当前时间差
- * @param date
- * @return 当前时间 - date 返回相差小时
- */
- public static int currentTimeDiffToHour(String date) {
- if(date == null || date.equals("")){
- return 25;
- }
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Long longss = System.currentTimeMillis() - df.parse(date).getTime();
- int hour = Integer.parseInt(longss/(1000*3600)+"");
- return hour;
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return 25;
- }
-
- /**
- * 和当前时间差 分钟
- * @param date
- * @return 当前时间 - 返回分钟
- */
- public static int currentTimeDiffToMin(String date) {
- if(date == null || date.equals("")){
- return 25;
- }
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Long longss = System.currentTimeMillis() - df.parse(date).getTime();
- int hour = Integer.parseInt(longss/(1000*60)+"");
- return hour;
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return 0;
- }
- /**
- * 和当前时间差(不需要时分秒)
- * @param date
- * @return 当前时间 - date
- *
- * */
- public static Long currentTimeDiff2(String date) {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- try {
- return System.currentTimeMillis() - df.parse(date).getTime();
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
-
- /**
- * 日期比较
- * @param DATE1
- * @param DATE2
- * @return DATE1 > DATE2 返回1
- */
- public static int compare_date(String DATE1, String DATE2) {
-
-
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date dt1 = df.parse(DATE1);
- Date dt2 = df.parse(DATE2);
- if (dt1.getTime() > dt2.getTime()) {
- return 1;
- } else if (dt1.getTime() < dt2.getTime()) {
- return -1;
- } else {
- return 0;
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- return 0;
- }
-
-
- /**
- * 日期比较
- * @param DATE1
- * @param DATE2
- * @return DATE1 > DATE2 返回1
- */
- public static int compareDate(String DATE1, String DATE2) {
-
- if(DATE1 == null || DATE1.equals("")){
- return -1;
- }
- if(DATE2 == null || DATE2.equals("")){
- return 1;
- }
- if(DATE1.equals(DATE2)){
- return 0;
- }
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- try {
- Date dt1 = df.parse(DATE1);
- Date dt2 = df.parse(DATE2);
- if (dt1.getTime() > dt2.getTime()) {
- return 1;
- } else if (dt1.getTime() < dt2.getTime()) {
- return -1;
- } else {
- return 0;
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- return 0;
- }
-
-
- /**
- * 日期比较
- * @param DATE1
- * @param DATE2
- * @return DATE1 > DATE2 返回1
- */
- public static int compareDate(String DATE1, String DATE2,String formate) {
-
- if(DATE1 == null || DATE1.equals("")){
- return -1;
- }
- if(DATE2 == null || DATE2.equals("")){
- return 1;
- }
- if(DATE1.equals(DATE2)){
- return 0;
- }
- DateFormat df = new SimpleDateFormat(formate);
- try {
- Date dt1 = df.parse(DATE1);
- Date dt2 = df.parse(DATE2);
- if (dt1.getTime() > dt2.getTime()) {
- return 1;
- } else if (dt1.getTime() < dt2.getTime()) {
- return -1;
- } else {
- return 0;
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- return 0;
- }
-
-
- /**
- * 将日期yyyy-MM-dd HH:mm:ss 格式化为 yyyyMMddHHmmss
- * @param date
- * @return
- */
- public static String fomatDate(String date){
- String dateStr = null;
- if(date == null || "".equals(date)){
- dateStr = "";
- }else{
- try {
- dateStr = date.replaceAll(":", "").replaceAll("-", "").replaceAll(" ", "");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- return dateStr;
- }
-
- /**
- * 获取插入数据库格式的时间
- * @return
- */
- public static String getSQLDate() {
- String systemdate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
- .format(Calendar.getInstance().getTime()); // 获取系统当前时间
- return systemdate;
- }
-
- /**
- * 字符串转日期 yyyy-MM-dd HH:mm:ss
- * @param date
- * @return
- */
- public static Date getStringToDate(String date){
- if (StringUtils.isEmpty(date)) {
- return null;
- }
- Date date2 = new Date();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- date2 = simpleDateFormat.parse(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return date2;
- }
- /**
- * 字符串转日期 yyyy-MM-dd HH:mm:ss
- * @param date
- * @return
- */
- public static Date getStringToDate(String date,String format){
- Date date2 = new Date();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
- try {
- date2 = simpleDateFormat.parse(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return date2;
- }
-
- /**
- * 获取插入数据库格式的时间yyyy-MM-dd
- * @return
- */
- public static String getSQLDateYMD() {
- String systemdate = new SimpleDateFormat("yyyy-MM-dd")
- .format(Calendar.getInstance().getTime()); // 获取系统当前时间
- return systemdate;
- }
-
- public static Integer getSQLDateMonth() {
- String systemdate = new SimpleDateFormat("MM")
- .format(Calendar.getInstance().getTime()); // 获取系统当前时间
- return Integer.parseInt(systemdate);
- }
-
- /**
- * 对月份进行加减
- * @param i
- * @return
- * @throws ParseException
- */
- public static Date datePlusOrMinus(String systime ,Integer i) throws ParseException{
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date systDate =df.parse(systime);
- GregorianCalendar gc =new GregorianCalendar();
- gc.setTime(systDate);
- gc.add(2,i);
- return gc.getTime();
- }
-
- /**
- * 得到月日时分秒10位时间戳字符串
- */
- public static String getTenTimestamp() {
- String systemdate = new SimpleDateFormat("MMddHHmmss").format(Calendar.getInstance().getTime());
- return systemdate;
- }
-
-
- /**
- * 得到年月日
- */
- public static String getDateTime() {
- SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
- String systemdate = sdf.format(Calendar.getInstance().getTime());
- return systemdate.substring(0, systemdate.length());
- }
-
- /**
- * 得到16位时间戳字符串,前面14位年月日时分秒,第15位毫秒,第16位随机数
- */
- public static String getUniqueTimestamp() {
- SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmssSSS");
- String systemdate = sdf.format(Calendar.getInstance().getTime());
- return systemdate.substring(0, systemdate.length()-2)+getOneRandom();
- }
-
- /**
- * 产生6位随机数
- */
- public static String getSixRandom(){
- int random1 = (int) (Math.random() * 900000 + 100000);
- String random = String.valueOf(random1);
- return random;
- }
-
- /**
- * 产生4位随机数
- */
- public static String getFourRandom(){
- int random1 = (int) (Math.random() * 9000 + 1000);
- String random = String.valueOf(random1);
- return random;
- }
- /**
- * 产生2位随机数
- */
- public static String getTwoRandom(){
- int random1 = (int) (Math.random() * 90 + 10);
- String random = String.valueOf(random1);
- return random;
- }
- /**
- * 产生1位随机数
- */
- public static String getOneRandom(){
- int random1 = (int) (Math.random() * 9 + 1);
- String random = String.valueOf(random1);
- return random;
- }
-
- /**
- * 产生2位小于60的随机数
- */
- public static String getTwoRandomSixth(){
- int random1 = (int) (Math.random() * 90 + 10);
- String random = String.valueOf(random1);
- return random;
- }
- /**
- * 产生-10——10之间的数字
- * @return
- */
- public static Integer randomZF(){
- int a=(int)(Math.random()*2+1);
- //System.out.println(a);
- int aa=(int)(Math.pow(-1, a));
- //System.out.println(aa);
- int aaa=(int)(Math.random()*10+1);
- int num=aa*aaa;
- //System.out.println(num);
- return num;
- }
-
- /**
- * 计算两个日期之间相差的月数
- *
- * @param date1
- * @param date2
- * @return
- */
- public static int getMonths(Date date1, Date date2) {
- int iMonth = 0;
- int flag = 0;
- try {
- Calendar objCalendarDate1 = Calendar.getInstance();
- objCalendarDate1.setTime(date1);
-
- Calendar objCalendarDate2 = Calendar.getInstance();
- objCalendarDate2.setTime(date2);
-
- if (objCalendarDate2.equals(objCalendarDate1))
- return 0;
- if (objCalendarDate1.after(objCalendarDate2)) {
- Calendar temp = objCalendarDate1;
- objCalendarDate1 = objCalendarDate2;
- objCalendarDate2 = temp;
- }
- if (objCalendarDate2.get(Calendar.DAY_OF_MONTH) < objCalendarDate1
- .get(Calendar.DAY_OF_MONTH))
- flag = 1;
-
- if (objCalendarDate2.get(Calendar.YEAR) > objCalendarDate1
- .get(Calendar.YEAR))
- iMonth = ((objCalendarDate2.get(Calendar.YEAR) - objCalendarDate1
- .get(Calendar.YEAR))
- * 12 + objCalendarDate2.get(Calendar.MONTH) - flag)
- - objCalendarDate1.get(Calendar.MONTH);
- else
- iMonth = objCalendarDate2.get(Calendar.MONTH)
- - objCalendarDate1.get(Calendar.MONTH) - flag;
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return iMonth;
- }
-
- /**
- * 计算两个日期之间相差的天数
- *
- * @param date1
- * @param date2
- * @return
- */
- public static final int daysBetween(Date date1, Date date2) {
-
- java.util.Calendar time1 = java.util.Calendar.getInstance();
- java.util.Calendar time2 = java.util.Calendar.getInstance();
- time1.setTime(date1);
- time2.setTime(date2);
- int days = 0;
- if(time1.getTime().getTime() >= time2.getTime().getTime()){
- days = ((int) (time1.getTime().getTime() / 1000) - (int) (time2.getTime().getTime() / 1000)) / 3600 / 24;
- }else{
- days = ((int) (time2.getTime().getTime() / 1000) - (int) (time1.getTime().getTime() / 1000)) / 3600 / 24;
- }
- return days;
- }
-
- /**
- * 计算两个日期之间相差秒
- *
- * @param sdate1
- * @param sdate2
- * @return
- */
- public static final int secBetween(String sdate1, String sdate2) {
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date1 = null;
- try {
- date1 = df.parse(sdate1);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Date date2 = null;
- try {
- date2 = df.parse(sdate2);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- java.util.Calendar time1 = java.util.Calendar.getInstance();
- java.util.Calendar time2 = java.util.Calendar.getInstance();
- time1.setTime(date1);
- time2.setTime(date2);
-
- int sec = 0;
- if(time1.getTime().getTime() >= time2.getTime().getTime()){
- sec = ((int) (time1.getTime().getTime() / 1000) - (int) (time2.getTime().getTime() / 1000));
- }else{
- sec = ((int) (time2.getTime().getTime() / 1000) - (int) (time1.getTime().getTime() / 1000));
- }
- return sec;
- }
-
- /**
- *
- * @param date1 <String>
- * @param date2 <String>
- * @return int
- * @throws ParseException
- */
- public static int getMonthSpace(String date1, String date2)
- throws ParseException {
-
- int result = 0;
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-
- Calendar c1 = Calendar.getInstance();
- Calendar c2 = Calendar.getInstance();
-
- c1.setTime(sdf.parse(date1));
- c2.setTime(sdf.parse(date2));
-
- result = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
-
- return result == 0 ? 1 : Math.abs(result);
-
- }
-
- /**
- * 根据毫秒数计算时分秒
- * @param timeMillis
- * @return
- */
- public static String myTimeStr(long timeMillis) {
- int timezone = 8;
- long totalSeconds = timeMillis / 1000;
- totalSeconds += 60 * 60 * timezone;
- int second = (int)(totalSeconds % 60);// 秒
- long totalMinutes = totalSeconds / 60;
- int minute = (int)(totalMinutes % 60);// 分
- long totalHours = totalMinutes / 60;
- int hour = (int)(totalHours % 24);// 时
- int totalDays = (int)(totalHours / 24);
-
- int _year = 1970;
-
- int year = _year + totalDays / 366;
- int month = 1;
- int day = 1;
-
- int diffDays;
- boolean leapYear;
- while (true) {
- int diff = (year - _year) * 365;
- diff += (year - 1) / 4 - (_year - 1) / 4;
- diff -= ((year - 1) / 100 - (_year - 1) / 100);
- diff += (year - 1) / 400 - (_year - 1) / 400;
-
- diffDays = totalDays - diff;
-
- leapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
- if (!leapYear && diffDays < 365 || leapYear && diffDays < 366) {
- break;
- } else {
- year++;
- }
- }
-
- int[] monthDays;
- if (diffDays >= 59 && leapYear) {
- monthDays = new int[]{-1,0,31,60,91,121,152,182,213, 244, 274, 305, 335 };
- } else {
- monthDays = new int[]{-1,0,31,59,90,120,151,181,212, 243, 273, 304, 334 };
- }
- for (int i = monthDays.length - 1; i >= 1; i--) {
- if (diffDays >= monthDays[i]) {
- month = i;
- day = diffDays - monthDays[i] + 1;
- break;
- }
- }
-
- return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
-
- }
- /**
- * 根据秒数计算小时
- * @param
- * @return
- */
- public static String secondToHour(String second) {
- if(second == null || "".equals(second) || "null".equals(second)){
- return null;
- }
- Double sec = Double.parseDouble(second);
- Double hour = sec/3600;
- DecimalFormat df=new DecimalFormat("0.0");
- return df.format(hour).toString();
- }
- /**
- * 根据秒数计算分钟
- * @param
- * @return
- */
- public static String secondToMinute(String second) {
- if(second == null || "".equals(second) || "null".equals(second)){
- return null;
- }
- Double sec = Double.parseDouble(second);
- Double minute = sec/60;
- DecimalFormat df=new DecimalFormat("0.0");
- return df.format(minute).toString();
- }
- /**
- * 根据小时数计算秒
- * @param
- * @return
- */
- public static String hourToSecond(String hour) {
- if(hour == null || "".equals(hour) || "null".equals(hour)){
- return null;
- }
- DecimalFormat df=new DecimalFormat("0");
- return df.format(Double.parseDouble(hour)*3600).toString();
- }
- /**
- * 根据分钟计算秒
- * @param
- * @return
- */
- public static String MinuteToSecond(String minute) {
- if(minute == null || "".equals(minute) || "null".equals(minute)){
- return null;
- }
- DecimalFormat df=new DecimalFormat("0");
- return df.format(Double.parseDouble(minute)*60).toString();
- }
-
- /**
- * 将日期yyyy-MM-dd HH:mm:ss 格式化为 yyMMddHHmmss
- * @param date
- * @return
- */
- public static String fomatDateToNumber(String date){
- String dateStr = null;
- if(date == null || "".equals(date)){
- dateStr = "";
- }else{
- try {
- dateStr = date.replaceAll(":", "").replaceAll("-", "").replaceAll(" ", "");
- dateStr = dateStr.substring(2);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- return dateStr;
- }
-
- /**
- * 把YYMMDDHHMMSS格式转换为date格式
- * @param
- * @return
- */
- public static String numberToDate (String number){
- SimpleDateFormat oldFormat = new SimpleDateFormat("yyMMddHHmmss");
- SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date();
- try {
- date = oldFormat.parse(number);
- } catch (ParseException e) {
- e.printStackTrace();
- return null;
- }
- return newFormat.format(date);
- }
-
- /**
- * 产生8位HHmmss
- */
- public static String getEightRandom(){
- String systemdate = new SimpleDateFormat("HHmmss")
- .format(Calendar.getInstance().getTime()); // 获取系统当前时间
- int random1 = (int) (Math.random() * 90 + 10);
- String random = String.valueOf(random1);
- return systemdate + random;
- }
-
- /**
- * 时间戳转换成时间
- * @param time
- * @return
- */
- public static String TimeStampToDateTime(long time){
- String datetime = null;
- try {
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- datetime = sdf.format(new Date(time*1000));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return datetime;
- }
-
-
- /**
- * 时间转成时间戳 毫秒
- * @param datetime
- * @return
- */
- public static long DateTimeToTimeStampSS(String datetime){
- try {
- SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- Date date=simpleDateFormat.parse(datetime);
- long timeStemp = date.getTime();
- return timeStemp;
- } catch (Exception e) {
- e.printStackTrace();
- return 0L ;
- }
-
- }
-
- /**
- * 时间转成时间戳 秒
- * @param datetime
- * @return
- */
- public static long DateTimeToTimeStampS(String datetime){
- try {
- SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- Date date=simpleDateFormat.parse(datetime);
- long timeStemp = date.getTime()/1000;
- return timeStemp;
- } catch (Exception e) {
- e.printStackTrace();
- return System.currentTimeMillis()/1000 ;
- }
-
- }
-
- /**
- * 转成时间戳
- * @param datetime
- * @return
- */
- public static long NumberTimeToTimeStamp(String datetime){
- try {
- SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyMMddHHmmss");
- Date date=simpleDateFormat.parse(datetime);
- long timeStemp = date.getTime()/1000;
- return timeStemp;
- } catch (Exception e) {
- e.printStackTrace();
- return System.currentTimeMillis()/1000 ;
- }
-
- }
-
- /**
- * 得到UTC时间,类型为字符串,格式为"yyyy-MM-dd HH:mm"<br />
- * 如果获取失败,返回null
- * @return
- */
- public static String getUTCTimeStr() {
- SimpleDateFormat foo = new SimpleDateFormat("yyyy-MM-dd hh:mm");
- System.out.println("foo:"+foo.format(new Date()));
-
- Calendar gc = GregorianCalendar.getInstance();
- System.out.println("gc.getTime():"+gc.getTime());
- System.out.println("gc.getTimeInMillis():"+new Date(gc.getTimeInMillis()));
-
- //当前系统默认时区的时间:
- Calendar calendar=new GregorianCalendar();
- System.out.print("时区:"+calendar.getTimeZone().getID()+" ");
- System.out.println("时间:"+calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE));
- //美国洛杉矶时区
- TimeZone tz=TimeZone.getTimeZone("America/Los_Angeles");
- //时区转换
- calendar.setTimeZone(tz);
- System.out.print("时区:"+calendar.getTimeZone().getID()+" ");
- System.out.println("时间:"+calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE));
-
- //1、取得本地时间:
- java.util.Calendar cal = java.util.Calendar.getInstance();
-
- //2、取得时间偏移量:
- int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);
-
- //3、取得夏令时差:
- int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);
-
- //4、从本地时间里扣除这些差量,即可以取得UTC时间:
- cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));
-
- //之后调用cal.get(int x)或cal.getTimeInMillis()方法所取得的时间即是UTC标准时间。
- System.out.println("UTC:"+new Date(cal.getTimeInMillis()));
-
- Calendar calendar1 = Calendar.getInstance();
- TimeZone tztz = TimeZone.getTimeZone("GMT");
- calendar1.setTimeZone(tztz);
- System.out.println(calendar.getTime());
- System.out.println("9999:"+calendar.getTimeInMillis()/1000);
-
- System.out.println("utc1="+System.currentTimeMillis()/1000);
- System.out.println("utc="+new Date().getTime()/1000);
-
-
- System.out.println(TimeStampToDateTime(1421724351));
- System.out.println("=="+DateTimeToTimeStampS("2015-01-20 11:35:06"));
- System.out.println(TimeStampToDateTime(DateTimeToTimeStampS("2015-01-20 11:35:06")));
- return null;
- }
-
- /**
- * 获得指定日期的前/后n天,小时
- *
- * @param specifiedDay
- * @return
- */
- public static String getSpecifiedDayAbove(String specifiedDay,int n,int h) {
- Calendar c = Calendar.getInstance();
- Date date = null;
- try {
- date = new SimpleDateFormat("yy-MM-dd HH:mm:ss").parse(specifiedDay);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- c.setTime(date);
- int day = c.get(Calendar.DATE);
- c.set(Calendar.DATE, day + n);
- int hour = c.get(Calendar.HOUR);
- c.set(Calendar.HOUR,hour + h);
-
- String dayAfter = new SimpleDateFormat("yy-MM-dd HH:mm:ss")
- .format(c.getTime());
- return dayAfter;
- }
-
- /**
- * 两个时间的小时差
- * @param st
- * @param ed
- * @return
- */
- public static long dateSpaceHours(Date st,Date ed){
- return (long) Math.ceil((ed.getTime() - st.getTime())/3600000.0);
- }
-
- public static String formatDate(Date date, String format) throws ParseException {
- DateFormat df = new SimpleDateFormat(format);
- df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
- return df.format(date);
- }
- public static Date parseDate(String date, String format) {
- DateFormat df = new SimpleDateFormat(format);
- df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
- try {
- return df.parse(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return null;
- }
-}
-
-
-
-
-
-
-
-
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/EosService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/EosService.java
deleted file mode 100644
index 4aad013..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/EosService.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.modules.blackchain.model.EosResult;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class EosService {
- // 正式网络 https://api-v2.eosasia.one https://proxy.eosnode.tools
- // 测试网络 https://api-kylin.eosasia.one
- // "eosqxyx11111", "5JJB2oiCXwASK9fumjyTgbtHcwDVedVRaZda1kBhFuQcmjnrDWB"
- //private final static String account = "huobideposit";
- public final static String ACCOUNT = "biueeostoken";
- // private String account;
- private final static String EOS_NAME = "EOS";
- public static final String K_mnemonic = "mnemonic";
- public static final String K_privateKey = "privateKey";
- public static final String K_publicKey = "publicKey";
- private static final String EOS_TOKEN = "eosio.token";
- private static final String ACTION_TRANSFER = "transfer";
-
-
- public static void main(String[] args) throws Exception {
-
- List<EosResult> actions = getActions(0, 3);
- for(EosResult eosResult:actions){
- System.out.println(eosResult.toString());
- String quantity = eosResult.getQuantity();
- String amountStr = quantity.split("")[0];
- System.out.println(quantity);
- System.out.println(new BigDecimal(amountStr));
- }
- }
-
-
- /**
- *
- * @param pos 从第几条开始(包括pos)
- * @param offset 查询条数
- * @return
- */
- public static List<EosResult> getActions(int pos, int offset) {
- JSONObject param = new JSONObject();
- param.put("account_name", ACCOUNT);
- param.put("pos", pos);
- param.put("offset", offset);
- Map<String, String> header = new HashMap<String, String>();
- header.put("content-type", "application/json");
- String res = HttpUtil.post("https://api.eosflare.io/v1/eosflare/get_actions", null, param.toJSONString(), header);
- System.out.println(res);
- List<EosResult> results = new ArrayList<>();
- try {
-
- JSONObject jsonObject = JSONObject.parseObject(res);
- JSONArray actions = jsonObject.getJSONArray("actions");
- if (actions != null && actions.size() > 0) {
- int size = actions.size();
- EosResult eosResult = null;
- for (int i = 0; i < size; i++) {
- JSONObject jsonObject1 = actions.getJSONObject(i);
- // 当前交易序号
- Object account_action_seq = jsonObject1.get("account_action_seq");
- JSONObject action_trace = jsonObject1.getJSONObject("action_trace");
- JSONObject act = action_trace.getJSONObject("act");
- Object account = act.get("account");
- if (!EOS_TOKEN.equals(account)) {
- continue;
- }
- eosResult = JSONObject.parseObject(act.getString("data"), EosResult.class);
- eosResult.setAccountActionSeq((Integer) account_action_seq);
- results.add(eosResult);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return results;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
deleted file mode 100644
index 5638359..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
+++ /dev/null
@@ -1,283 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.io.File;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import org.web3j.abi.FunctionEncoder;
-import org.web3j.abi.FunctionReturnDecoder;
-import org.web3j.abi.TypeReference;
-import org.web3j.abi.datatypes.Address;
-import org.web3j.abi.datatypes.Function;
-import org.web3j.abi.datatypes.Type;
-import org.web3j.abi.datatypes.generated.Uint256;
-import org.web3j.crypto.Credentials;
-import org.web3j.crypto.RawTransaction;
-import org.web3j.crypto.TransactionEncoder;
-import org.web3j.crypto.WalletUtils;
-import org.web3j.protocol.Web3j;
-import org.web3j.protocol.admin.Admin;
-import org.web3j.protocol.core.DefaultBlockParameterName;
-import org.web3j.protocol.core.Request;
-import org.web3j.protocol.core.methods.request.Transaction;
-import org.web3j.protocol.core.methods.response.*;
-import org.web3j.protocol.http.HttpService;
-import org.web3j.utils.Convert;
-import org.web3j.utils.Numeric;
-import org.web3j.utils.Convert.Unit;
-
-/**
- * ETH类,使用Web3j 下面为使用教程
- * https://kauri.io/article/925d923e12c543da9a0a3e617be963b4/manage-an-ethereum-account-with-java-and-web3js
- *
- * @author Administrator
- *
- */
-
-public class EthService {
-
- private static String ethWalletPath = "/home/javaweb/webresource/eth";
- // private static String ethWalletPath="E://";
- private Web3j web3j;
- // private Admin admin;
- // private Parity parity;
- /**
- * 服务器地址
- */
- //private static final String ETH_UTL = "https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321";
- private static final String ETH_UTL = "http://120.55.86.146:8545";
-
- public EthService() {
- try {
- HttpService service = new HttpService(ETH_UTL);
- web3j = Web3j.build(service);
- // parity = Parity.build(service);
- // admin = Admin.build(service);
- } catch (Exception e) {
- System.out.println("liangjieshibao");
- // logger.error("==============虚拟币-以太坊链接获取失败!");
- e.printStackTrace();
- }
- }
-
- /**
- * 查询ETH余额
- *
- * @param address
- * @return
- */
- public static BigDecimal getEthBlance(String address) {
- Web3j web3 = Web3j.build(new HttpService(ETH_UTL));
- EthGetBalance balanceWei;
- try {
- balanceWei = web3.ethGetBalance(address, DefaultBlockParameterName.LATEST).send();
- if (balanceWei.getResult() == null) {
- return null;
- }
- BigDecimal balanceInEther = Convert.fromWei(balanceWei.getBalance().toString(), Unit.ETHER);
- return balanceInEther;
- } catch (Exception e) {
- System.out.println("ETH查询失败:" + address);
- e.printStackTrace();
- }
- return null;
-
- }
-
- /**
- * 创建ETH钱包
- *
- * @return
- */
- public static Map<String, String> createEth() {
- Map<String, String> wallet = new HashMap<String, String>();
- try {
- String walletPassword = "secr3t";
- // 文件路径
- String walletDirectory = ethWalletPath;
-
- String walletName = WalletUtils.generateNewWalletFile(walletPassword, new File(walletDirectory));
- System.out.println("wallet location: " + walletDirectory + "/" + walletName);
- Credentials credentials = WalletUtils.loadCredentials(walletPassword, walletDirectory + "/" + walletName);
- String accountAddress = credentials.getAddress();
- String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16);
- // 钱包地址
- wallet.put("address", accountAddress);
- // 钱包私钥
- wallet.put("privateKey", privateKey);
- // 产生的钱包文件地址
- wallet.put("walletLocation", walletDirectory + "/" + walletName);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return wallet;
- }
-
- public boolean checkTransferResult(String hash) {
- // 0xa3e6a0ccc3aac30d866a86ca9c0477dd58b7b061787ba40b16c3844803273816 交易hash
- Request<?, EthGetTransactionReceipt> ethGetTransactionReceiptRequest = web3j.ethGetTransactionReceipt(hash);
- EthGetTransactionReceipt send = null;
- try {
- send = ethGetTransactionReceiptRequest.send();
- if(send!=null){
- TransactionReceipt result = send.getResult();
- if(result!=null){
- String status = result.getStatus();
- System.out.println(status);//0x1
- if("0x1".equals(status)){
- return true;
- }else{
- return false;
- }
- }
-
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- }
- return false;
- }
-
- public static void main(String[] args) throws IOException {
- HttpService service = new HttpService(ETH_UTL);
- Web3j build = Web3j.build(service);
- //Request<?, EthTransaction> ethTransactionRequest = build.ethGetTransactionByHash("0xa3e6a0ccc3aac30d866a86ca9c0477dd58b7b061787ba40b16c3844803273816");
- Request<?, EthGetTransactionReceipt> ethGetTransactionReceiptRequest = build.ethGetTransactionReceipt("0xa3e6a0ccc3aac30d866a86ca9c0477dd58b7b061787ba40b16c3844803273816");
- EthGetTransactionReceipt send = ethGetTransactionReceiptRequest.send();
- String status = send.getResult().getStatus();
- System.out.println(status);//0x1
-// EthTransaction send = ethTransactionRequest.send();
-// String input = send.getResult().getInput();
-// System.out.println(input);
- }
-
- /**
- *
- * 方法描述:获取代币余额
- *
- * @param fromAddress
- * @param
- * @param
- * @return long
- */
- public BigDecimal tokenGetBalance(String fromAddress) {
- try {
- // 合约地址
- String contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
- int decimal = 6;
- String methodName = "balanceOf";
- List<Type> inputParameters = new ArrayList<>();
- List<TypeReference<?>> outputParameters = new ArrayList<>();
- Address address = new Address(fromAddress);
- inputParameters.add(address);
- TypeReference<Uint256> typeReference = new TypeReference<Uint256>() {
- };
- outputParameters.add(typeReference);
- Function function = new Function(methodName, inputParameters, outputParameters);
- String data = FunctionEncoder.encode(function);
- Transaction transaction = Transaction.createEthCallTransaction(fromAddress, contractAddress, data);
-
- EthCall ethCall;
- BigInteger balanceValue = BigInteger.ZERO;
- try {
- ethCall = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).send();
- List<Type> results = FunctionReturnDecoder.decode(ethCall.getValue(), function.getOutputParameters());
- balanceValue = (BigInteger) results.get(0).getValue();
- } catch (IOException e) {
- e.printStackTrace();
- }
- double res = BigDecimalUtil.div(new BigDecimal(balanceValue).doubleValue(), Math.pow(10, decimal), 8);
- if (res > 0) {
- return new BigDecimal(res);
- }
- } catch (Exception e) {
- // logger.error("==============以太坊代币链接获取失败!");
- e.printStackTrace();
- }
- return BigDecimal.ZERO;
- }
-
- // USDT
- public String tokenSend(String privateKey, String fromAddress, String toAddress, String amount)
- throws InterruptedException, ExecutionException {
- // Web3j web3j = Web3j.build(new
- // HttpService("https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321"));
- String contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
- Credentials credentials = Credentials.create(privateKey);
-
- EthGetTransactionCount ethGetTransactionCount = web3j
- .ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST).sendAsync().get();
-
- BigInteger nonce = ethGetTransactionCount.getTransactionCount();
-
- Function function = new Function("transfer",
- Arrays.asList(new Address(toAddress), new Uint256(new BigInteger(amount))),
- Arrays.asList(new TypeReference<Type>() {
- }));
-
- String encodedFunction = FunctionEncoder.encode(function);
-
- RawTransaction rawTransaction = RawTransaction.createTransaction(nonce,
- Convert.toWei("70", Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快
- Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);//里程上限
- // 10*80000/1000000000=0.0008 手续费
-
- byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
- String hexValue = Numeric.toHexString(signedMessage);
-
- // log.debug("transfer hexValue:" + hexValue);
-
- EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
-
-
- if (ethSendTransaction.hasError()) {
- // log.info("transfer error:", ethSendTransaction.getError().getMessage());
- return "";
- } else {
- String transactionHash = ethSendTransaction.getTransactionHash();
- // log.info("Transfer transactionHash:" + transactionHash);
- return transactionHash;
- }
- }
-
- public String ethSend(String privateKey, String fromAddress, String toAddress, String amount)
- throws InterruptedException, ExecutionException {
- // Web3j web3j = Web3j.build(new
- // HttpService("https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321"));
-
- Credentials credentials = Credentials.create(privateKey);
-
- EthGetTransactionCount ethGetTransactionCount = web3j
- .ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST).sendAsync().get();
-
- BigInteger nonce = ethGetTransactionCount.getTransactionCount();
- BigInteger value = Convert.toWei(amount, Convert.Unit.ETHER).toBigInteger();
- RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce,
- Convert.toWei("50", Convert.Unit.GWEI).toBigInteger(),
- Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), toAddress, value);
- byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
- String hexValue = Numeric.toHexString(signedMessage);
-
- EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
- if (ethSendTransaction.hasError()) {
- // log.info("transfer error:", ethSendTransaction.getError().getMessage());
- return "";
- } else {
- String transactionHash = ethSendTransaction.getTransactionHash();
- // log.info("Transfer transactionHash:" + transactionHash);
- return transactionHash;
- }
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/HttpUtil.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/HttpUtil.java
deleted file mode 100644
index a146fe4..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/HttpUtil.java
+++ /dev/null
@@ -1,281 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-/**
- * @author: DengJiong
- * @date: 2018-05-09 18:43
- * @description:
- */
-
-import org.apache.commons.lang3.StringUtils;
-
-import javax.net.ssl.*;
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * http 工具类
- *
- * @author cloud cloud
- * @create 2017/10/18
- **/
-public class HttpUtil {
-
- private static final String CHARSET = "UTF-8";
- private static final String HTTP_POST = "POST";
- private static final String HTTP_GET = "GET";
-
- private static final String HTTP_PUT = "PUT";
-
- /**
- * Send GET request
- */
- public static String get(String url, Map<String, String> queryParas, Map<String, String> headers) {
- HttpURLConnection conn = null;
- try {
- conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), HTTP_GET, headers);
- conn.connect();
- return readResponseString(conn);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- finally {
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
- public static String get(String url, Map<String, String> queryParas) {
- return get(url, queryParas, null);
- }
-
- public static String get(String url) {
- return get(url, null, null);
- }
-
- public static String jsonGet(String url,Map<String,String> params){
- Map<String,String> headers = new HashMap<>();
- headers.put("Content-Type","application/json");
- return get(url,params,headers);
- }
-
-
- /**
- * Send POST request
- */
- public static String post(String url, Map<String, String> queryParas, String data, Map<String, String> headers) {
- HttpURLConnection conn = null;
- try {
- conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), HTTP_POST, headers);
- conn.connect();
- OutputStream out = conn.getOutputStream();
- out.write(data.getBytes(CHARSET));
- out.flush();
- out.close();
- return readResponseString(conn);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- finally {
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
- public static String post(String url, Map<String, String> queryParas, String data) {
- return post(url, queryParas, data, null);
- }
-
- public static String post(String url, String data, Map<String, String> headers) {
- return post(url, null, data, headers);
- }
-
- public static String post(String url, String data) {
- return post(url, null, data, null);
- }
-
- public static String jsonPost(String url,String data){
- Map<String,String> headers = new HashMap<>();
- headers.put("Content-Type","application/json");
- return post(url,null,data,headers);
- }
-
- public static String jsonPost(String url,Map<String,String>headers,String data){
- if(headers == null){
- headers = new HashMap<>();
- }
- headers.put("Content-Type","application/json");
- return post(url,null,data,headers);
- }
-
- /**
- * Send POST request
- */
- public static String put(String url, Map<String, String> queryParas, String data, Map<String, String> headers) {
- HttpURLConnection conn = null;
- try {
- conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), HTTP_PUT, headers);
- conn.connect();
- OutputStream out = conn.getOutputStream();
- out.write(data.getBytes(CHARSET));
- out.flush();
- out.close();
- return readResponseString(conn);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- finally {
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
-
-
- public static String jsonPut(String url,String data){
- Map<String,String> headers = new HashMap<>();
- headers.put("Content-Type","application/json");
- return put(url,null,data,headers);
- }
-
-
- /**
- * https 域名校验
- */
- private static class TrustAnyHostnameVerifier implements HostnameVerifier {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- }
-
- /**
- * https 证书管理
- */
- private static class TrustAnyTrustManager implements X509TrustManager {
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
- @Override
- public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- }
- @Override
- public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- }
- }
-
- private static SSLSocketFactory initSSLSocketFactory() {
- try {
- TrustManager[] tm = {new TrustAnyTrustManager()};
- SSLContext sslContext = SSLContext.getInstance("TLS", "SunJSSE");
- sslContext.init(null, tm, new java.security.SecureRandom());
- return sslContext.getSocketFactory();
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private static final SSLSocketFactory sslSocketFactory = initSSLSocketFactory();
- private static final TrustAnyHostnameVerifier trustAnyHostnameVerifier = new TrustAnyHostnameVerifier();
-
- private static HttpURLConnection getHttpConnection(String url, String method, Map<String, String> headers) throws Exception {
- URL _url = new URL(url);
- HttpURLConnection conn = (HttpURLConnection)_url.openConnection();
- if (conn instanceof HttpsURLConnection) {
- ((HttpsURLConnection)conn).setSSLSocketFactory(sslSocketFactory);
- ((HttpsURLConnection)conn).setHostnameVerifier(trustAnyHostnameVerifier);
- }
- conn.setRequestMethod(method);
- conn.setDoOutput(true);
- conn.setDoInput(true);
- conn.setConnectTimeout(30000);
- conn.setReadTimeout(30000);
- conn.setUseCaches(false); // Post 请求不能使用缓存
- if(headers != null){
- String contentType = headers.get("Content-Type");
- if(StringUtils.isNotEmpty(contentType)){
- conn.setRequestProperty("Content-Type",contentType);
- }else{
- conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
- }
- }
- conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36");
- if (headers != null && !headers.isEmpty())
- for (Map.Entry<String, String> entry : headers.entrySet())
- conn.setRequestProperty(entry.getKey(), entry.getValue());
-
- return conn;
- }
-
- private static String readResponseString(HttpURLConnection conn) {
- StringBuilder sb = new StringBuilder();
- InputStream inputStream = null;
- try {
- inputStream = conn.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, CHARSET));
- String line = null;
- while ((line = reader.readLine()) != null){
- sb.append(line).append("\n");
- }
- return sb.toString();
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- /**
- * Build queryString of the url
- */
- private static String buildUrlWithQueryString(String url, Map<String, String> queryParas) {
- if (queryParas == null || queryParas.isEmpty())
- return url;
-
- StringBuilder sb = new StringBuilder(url);
- boolean isFirst;
- if (url.indexOf("?") == -1) {
- isFirst = true;
- sb.append("?");
- }
- else {
- isFirst = false;
- }
-
- for (Map.Entry<String, String> entry : queryParas.entrySet()) {
- if (isFirst) isFirst = false;
- else sb.append("&");
-
- String key = entry.getKey();
- String value = entry.getValue();
- if (!StringUtils.isEmpty(value)){
- try {value = URLEncoder.encode(value, CHARSET);} catch (UnsupportedEncodingException e) {throw new RuntimeException(e);}
- sb.append(key).append("=").append(value);
- }
- }
- return sb.toString();
- }
-}
-
-
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java
deleted file mode 100644
index 87d9239..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service.Impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.blackchain.service.BlockSerive;
-import com.xcong.excoin.modules.blackchain.service.BtcService;
-import com.xcong.excoin.modules.blackchain.service.EthService;
-import com.xcong.excoin.modules.blackchain.service.LtcService;
-import com.xcong.excoin.modules.blackchain.service.UsdtService;
-import com.xcong.excoin.modules.blackchain.service.XrpService;
-import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
-
-@Slf4j
-@Service
-public class BlockSeriveImpl implements BlockSerive {
-
- @Resource
- RedisUtils redisUtil;
- @Resource
- MemberDao memberDao;
- @Resource
- MemberCoinAddressDao memberMapper;
-
- @Override
- public Result findBlockAddress(String symbol) {
- //获取用户ID
- String mId = LoginUserUtils.getAppLoginUser().getId().toString();
- MemberEntity member = memberDao.selectById(mId);
- if (member == null) {
- return Result.fail(MessageSourceUtils.getString("member_service_0003"));
- }
- String lable = "ERC20";
- Result result = new Result();
- try {
- Map<String, String> map = new HashMap<String, String>();
- MemberCoinAddressEntity memberCoinAddress = new MemberCoinAddressEntity();
-
- if ("USDT".equals(symbol)) {
- memberCoinAddress = memberMapper.selectBlockAddressWithTag(Long.parseLong(mId), symbol, lable);
- } else {
- memberCoinAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), symbol);
- }
- log.info("--->{}", memberCoinAddress);
- if (memberCoinAddress != null) {
- map.put("address", memberCoinAddress.getAddress());
- map.put("lable", memberCoinAddress.getLabel());
- result.setData(map);
- result.setCode(0);
- } else {
- String address = "";
- String key = "";
- String uuid = member.getInviteId();
- switch (symbol) {
- case "BTC":
- Map<String, String> btcMap = UsdtService.createWallet(mId);
- address = btcMap.get("address");
- key = btcMap.get("privateKey");
- map.put("address", address);
- break;
- case "ETH":
- Map<String, String> ethMap = EthService.createEth();
- address = ethMap.get("address");
- key = ethMap.get("privateKey");
- map.put("address", address);
- break;
- case "BCH":
- MemberCoinAddressEntity btcAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), "BTC");
- if (btcAddress != null) {
- address = btcAddress.getAddress();
- key = btcAddress.getPrivateKey();
- map.put("address", address);
- } else {
- Map<String, String> bchMap = BtcService.createWallet(mId);
- address = bchMap.get("address");
- key = bchMap.get("privateKey");
- map.put("address", address);
-
- MemberCoinAddressEntity coinAddress = new MemberCoinAddressEntity();
- coinAddress.setAddress(address);
- coinAddress.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_YES);
- coinAddress.setMemberId(Long.parseLong(mId));
- coinAddress.setPrivateKey(key);
- coinAddress.setSymbol("BTC");
- coinAddress.setLabel(uuid);
- memberMapper.insert(coinAddress);
- }
- break;
- case "EOS":
- address = "biyicteos123";
- map.put("address", address);
- map.put("lable", uuid);
- break;
- case "XRP":
- address = "biyicteos123";
- map.put("address", address);
- map.put("lable", uuid);
- break;
- case "LTC":
- Map<String, String> ltcMap = LtcService.createWallet(mId);
- address = ltcMap.get("address");
- key = ltcMap.get("privateKey");
- map.put("address", address);
- break;
- case "ETC":
- MemberCoinAddressEntity ethAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), "ETH");
- if (ethAddress != null) {
- address = ethAddress.getAddress();
- key = ethAddress.getPrivateKey();
- map.put("address", address);
- } else {
- Map<String, String> etcMap = EthService.createEth();
- address = etcMap.get("address");
- key = etcMap.get("privateKey");
- map.put("address", address);
-
- MemberCoinAddressEntity coinAddress = new MemberCoinAddressEntity();
- coinAddress.setAddress(address);
- coinAddress.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_YES);
- coinAddress.setMemberId(Long.parseLong(mId));
- coinAddress.setPrivateKey(key);
- coinAddress.setSymbol("ETH");
- coinAddress.setLabel(uuid);
- memberMapper.insert(coinAddress);
- }
-
- break;
- case "USDT":
- if ("OMNI".equals(lable)) {
- MemberCoinAddressEntity btcAddress2 = memberMapper.selectBlockAddress(Long.parseLong(mId), "BTC");
- if (btcAddress2 != null) {
- address = btcAddress2.getAddress();
- key = btcAddress2.getPrivateKey();
- map.put("address", address);
- } else {
- //如果BTC地址不存在,创建一个BTC地址
- Map<String, String> usdtMap = UsdtService.createWallet(mId);
- address = usdtMap.get("address");
- key = usdtMap.get("privateKey");
- map.put("address", address);
-
- MemberCoinAddressEntity coinAddress = new MemberCoinAddressEntity();
- coinAddress.setAddress(address);
- coinAddress.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_YES);
- coinAddress.setMemberId(Long.parseLong(mId));
- coinAddress.setPrivateKey(key);
- coinAddress.setSymbol("BTC");
- coinAddress.setLabel(uuid);
- memberMapper.insert(coinAddress);
- }
-
- } else {
- MemberCoinAddressEntity ethAddress2 = memberMapper.selectBlockAddress(Long.parseLong(mId), "ETH");
- if (ethAddress2 != null) {
- address = ethAddress2.getAddress();
- key = ethAddress2.getPrivateKey();
- map.put("address", address);
- } else {
- Map<String, String> usdtMap = EthService.createEth();
- address = usdtMap.get("address");
- key = usdtMap.get("privateKey");
- map.put("address", address);
-
- MemberCoinAddressEntity coinAddress = new MemberCoinAddressEntity();
- coinAddress.setAddress(address);
- coinAddress.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_YES);
- coinAddress.setMemberId(Long.parseLong(mId));
- coinAddress.setPrivateKey(key);
- coinAddress.setSymbol("ETH");
- coinAddress.setLabel(uuid);
- memberMapper.insert(coinAddress);
- }
- }
- break;
- default:
- break;
- }
- MemberCoinAddressEntity coinAddress = new MemberCoinAddressEntity();
- coinAddress.setAddress(address);
- coinAddress.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_YES);
- coinAddress.setMemberId(Long.parseLong(mId));
- coinAddress.setPrivateKey(key);
- coinAddress.setSymbol(symbol);
- coinAddress.setLabel(uuid);
- if (symbol.equals("USDT")) {
- coinAddress.setTag(lable);
- }
-
- memberMapper.insert(coinAddress);
- result.setData(map);
- result.setCode(0);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/LtcService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/LtcService.java
deleted file mode 100644
index 9acd8a1..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/LtcService.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-
-
-public class LtcService {
-
- private static LtcService service = null;
- private final static String RESULT = "result";
- private final static String METHOD_SEND_TO_ADDRESS = "sendtoaddress";
- private final static String METHOD_GET_TRANSACTION = "gettransaction";
- private final static String METHOD_LIST_TRANSACTIONS = "listtransactions";
- private final static String METHOD_GET_BLOCK_COUNT = "getblockcount";
- private final static String METHOD_NEW_ADDRESS = "getnewaddress";
- private final static String METHOD_GET_BALANCE = "getbalance";
- private final static String METHOD_WALLET_PASSPHRASE = "walletpassphrase";
- private final static String METHOD_WALLET_LOCK = "walletlock";
- private final static String METHOD_GET_BALANCE_ADDRESS = "getreceivedbyaddress";
-
- private String url = "http://121.40.86.163:1888";
- private String username = "biyiltc";
- private String password = "biyiltc";
-
- public static LtcService getInstance() {
- if (service != null) {
- return service;
- }
- return new LtcService();
- }
-
- private LtcService() {
- }
-
- /**
- * 创建BTC钱包 每个账户对应一个地址 方便后续操作
- * @param mId 账户
- * @return
- */
- public static Map<String, String> createWallet(String mId) {
- LtcService btcService = getInstance();
- // 创建钱包地址
- String address = btcService.getAddress(mId);
- // 私钥
- String privateKey = btcService.dumpprivkey(address);
- Map<String, String> result = new HashMap<String,String>();
- result.put("address", address);
- result.put("privateKey", privateKey);
- return result;
- }
- public String getAddress(String label) {
- try {
- JSONObject json = doRequest(METHOD_NEW_ADDRESS,label);
- //JSONObject json = doRequest(METHOD_NEW_ADDRESS);
- if (isError(json)) {
- return "";
- }
- return json.getString(RESULT);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private JSONObject doRequest(String method, Object... params) {
- JSONObject param = new JSONObject();
- param.put("id", System.currentTimeMillis() + "");
- param.put("jsonrpc", "2.0");
- param.put("method", method);
- if (params != null) {
- param.put("params", params);
- }
- String creb = Base64.encodeBase64String((username + ":" + password).getBytes());
- Map<String, String> headers = new HashMap<>(2);
- headers.put("Authorization", "Basic " + creb);
- return JSON.parseObject(HttpUtil.jsonPost(url, headers, param.toJSONString()));
- }
-
- private boolean isError(JSONObject json) {
- if (json == null || (StringUtils.isNotEmpty(json.getString("error")) && json.get("error") != "null")) {
- return true;
- }
- return false;
- }
-
- public String dumpprivkey(String address) {
- try {
- JSONObject obj = doRequest("dumpprivkey", address);
- //System.out.println(obj);
- if (!isError(obj)) {
- return obj.getString(RESULT);
- } else {
- return null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 查询给定地址的总收款额(只计算接受的)
- * @param address
- * @return
- */
- public BigDecimal getBalance(String address) {
- JSONObject json = doRequest(METHOD_GET_BALANCE_ADDRESS,address,3);
- if (!isError(json)) {
- return new BigDecimal(json.getString(RESULT));
- } else {
- return null;
- }
- }
-
- public static void main(String[] args) {
- BigDecimal s = LtcService.getInstance().getBalance("MS6UBteTkQYbbBg5xEPWUQ1PPG7zkxY368");
- System.out.println(s);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
deleted file mode 100644
index b3aea54..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.StrUtil;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao;
-import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
-import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity;
-import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-/**
- * @author wzy
- * @date 2020-07-03
- **/
-@Slf4j
-@Component
-public class UsdtEthService {
-
- private static final BigDecimal LIMIT = new BigDecimal("50");
- private static final BigDecimal LIMIT_ETH = new BigDecimal("0.2");
- private static final BigDecimal FEE = new BigDecimal("0.005");
- private static final BigDecimal ETH_TR_FEE = new BigDecimal("0.0032");
-
- public static String ETH_FEE = "0.005";
-
- public static final String TOTAL_ADDRESS = "0x067b4bE5d7B05560AE539Fc8f10597D854ae056D";
- public static final String TOTAL_PRIVATE = "1fb7288c8c88c37d6f79e9617822bffc8d3635bf2d808c5f6afdee9bb326e49c";
-
- @Resource
- private MemberCoinChargeDao memberCoinChargeDao;
- @Resource
- private MemberCoinAddressDao memberCoinAddressDao;
- @Resource
- private MemberWalletCoinDao memberWalletCoinDao;
-
- public void pool() throws ExecutionException, InterruptedException {
- List<MemberCoinChargeEntity> list = memberCoinChargeDao.selectAllBySymbolAndTag(CoinTypeEnum.USDT.name(), "ERC20", 1);
- if (CollUtil.isNotEmpty(list)) {
- EthService ethService = new EthService();
-
- for (MemberCoinChargeEntity coinCharge : list) {
- // 首先根据每个地址查询其是否有ETH 如果没有就充值ETH并设置1 表示初始状态 status=2(待充值)3:表示已提过
- String address = coinCharge.getAddress();
- Long memberId = coinCharge.getMemberId();
- BigDecimal lastAmount = coinCharge.getLastAmount();
- if (lastAmount == null || lastAmount.compareTo(LIMIT) < 0) {
- continue;
- }
-
- BigDecimal usdt = ethService.tokenGetBalance(address);
- log.info("地址:{}, 金额:{}", address, usdt);
- if (usdt != null && usdt.compareTo(LIMIT) > 0) {
- usdt = usdt.subtract(new BigDecimal("0.01"));
-
- // 查询eth是否足够
- BigDecimal eth = EthService.getEthBlance(address);
- log.info("地址:{}, ETH:{}", address, eth);
- if (eth != null && eth.compareTo(FEE) >= 0) {
- MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectBlockAddressWithTag(memberId, CoinTypeEnum.USDT.name(), "ERC20");
- if (memberCoinAddressEntity == null) {
- continue;
- }
-
- String privateKey = memberCoinAddressEntity.getPrivateKey();
-
- usdt = usdt.multiply(new BigDecimal("1000000"));
- String usdtStr = usdt.toPlainString();
- if (usdtStr.contains(".")) {
- usdtStr = usdtStr.substring(0, usdtStr.lastIndexOf("."));
- }
-
- String hash = ethService.tokenSend(privateKey, address, TOTAL_ADDRESS, usdtStr);
- log.info("归集:{}", hash);
- if (StrUtil.isNotBlank(hash)) {
- // 归集成功更新状态 先保存本次的hash值,待交易成功后再更新
- coinCharge.setHash(hash);
- memberCoinChargeDao.updateById(coinCharge);
- }
- } else {
- String hash = ethService.ethSend(TOTAL_PRIVATE, TOTAL_ADDRESS, address, ETH_FEE);
- log.info("转手续费:{}", hash);
- }
- }
- }
- }
- }
-
-
- public void ethPool() throws ExecutionException, InterruptedException {
- List<MemberCoinChargeEntity> list = memberCoinChargeDao.selectAllBySymbolAndTag(CoinTypeEnum.ETH.name(), null, 1);
- if (CollUtil.isNotEmpty(list)) {
- EthService ethService = new EthService();
- for (MemberCoinChargeEntity coinCharge : list) {
- String address = coinCharge.getAddress();
- Long memberId = coinCharge.getMemberId();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.ETH.name());
- if (walletCoin == null) {
- continue;
- }
-
- BigDecimal earlyBalance = walletCoin.getEarlyBalance();
-
- if (earlyBalance == null || earlyBalance.compareTo(LIMIT_ETH) < 0) {
- continue;
- }
-
- BigDecimal eth = EthService.getEthBlance(address);
- if (eth != null && eth.compareTo(LIMIT_ETH) >= 0) {
- MemberCoinAddressEntity coinAddress = memberCoinAddressDao.selectBlockAddressWithTag(memberId, CoinTypeEnum.ETH.name(), null);
- String privateKey = coinAddress.getPrivateKey();
-
- BigDecimal tr = eth.subtract(ETH_TR_FEE);
- String hash = ethService.ethSend(privateKey, address, TOTAL_ADDRESS, tr.toPlainString());
- if (StrUtil.isNotBlank(hash)) {
- coinCharge.setHash(hash);
- coinCharge.setLastAmount(new BigDecimal("0.0001"));
- coinCharge.setStatus(3);
- memberCoinChargeDao.updateById(coinCharge);
- }
- }
- }
- }
- }
-
- /**
- * 定时查询该归集转账交易是否成功
- */
- public void usdtEthPoolCheck() {
- // 首先查询需要确认的交易
- List<MemberCoinChargeEntity> list = memberCoinChargeDao.selectAllBySymbolAndTag(CoinTypeEnum.USDT.name(), "ERC20", null);
- EthService ethService = new EthService();
-
- if (CollectionUtils.isNotEmpty(list)) {
- for (MemberCoinChargeEntity appeal : list) {
- String hash = appeal.getHash();
- boolean b = ethService.checkTransferResult(hash);
- if (b) {
- appeal.setStatus(3);
- appeal.setLastAmount(new BigDecimal("0.0001"));
-
- // 表示这笔归集转账已经成功
- // 更新状态
- memberCoinChargeDao.updateById(appeal);
- }
- }
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtService.java
deleted file mode 100644
index bfb5074..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtService.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-
-public class UsdtService {
-// public static void main(String[] args) throws IOException {
-// ECKey key = new ECKey();
-// //logger.info("We created a new key:\n" + key);
-// // TEST 网络
-// NetworkParameters params = MainNetParams.get();
-// Address addressFromKey = key.toAddress(params);
-// System.out.println("Public Address generated: " + addressFromKey);
-// //logger.info("Public Address generated: " + addressFromKey);
-// String privateKey = key.getPrivateKeyEncoded(params).toString();
-// System.out.println("Private key is: " + privateKey);
-// //logger.info("Private key is: " + privateKey);
-// //logger.info("Private Hex key is: " + key.getPrivateKeyAsHex());
-// Wallet wallet = new Wallet(TestNet3Params.get());
-// File walletFile = new File("D//:test.wallet");
-// wallet.importKey(key);
-// wallet.saveToFile(walletFile);
-// }
-
- private static UsdtService service = null;
- private final static String RESULT = "result";
- private final static String METHOD_SEND_TO_ADDRESS = "sendtoaddress";
- private final static String METHOD_GET_TRANSACTION = "gettransaction";
- private final static String METHOD_LIST_TRANSACTIONS = "listtransactions";
- private final static String METHOD_GET_BLOCK_COUNT = "getblockcount";
- private final static String METHOD_NEW_ADDRESS = "getnewaddress";
- private final static String METHOD_GET_BALANCE = "getbalance";
- private final static String METHOD_GET_BALANCE_ADDRESS = "getreceivedbyaddress";
- private final static String METHOD_WALLET_PASSPHRASE = "walletpassphrase";
- private final static String METHOD_WALLET_LOCK = "walletlock";
-
- private String url = "http://120.55.86.146:1880";
- private String username = "biyi";
- private String password = "biyi1234";
-
- public static UsdtService getInstance() {
- if (service != null) {
- return service;
- }
- return new UsdtService();
- }
-
- private UsdtService() {
- }
-
- /**
- * 创建BTC钱包 每个账户对应一个地址 方便后续操作
- *
- * @param mId 账户
- * @return
- */
- public static Map<String, String> createWallet(String mId) {
- UsdtService btcService = getInstance();
- // 创建钱包地址
- String address = btcService.getAddress(mId);
- // 私钥
- String privateKey = btcService.dumpprivkey(address);
- Map<String, String> result = new HashMap<String, String>();
- result.put("address", address);
- result.put("privateKey", privateKey);
- return result;
- }
-
- public String getAddress(String label) {
- try {
- JSONObject json = doRequest(METHOD_NEW_ADDRESS, label);
- if (isError(json)) {
- return "";
- }
- return json.getString(RESULT);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private JSONObject doRequest(String method, Object... params) {
- JSONObject param = new JSONObject();
- param.put("id", System.currentTimeMillis() + "");
- param.put("jsonrpc", "2.0");
- param.put("method", method);
- if (params != null) {
- param.put("params", params);
- }
- String creb = Base64.encodeBase64String((username + ":" + password).getBytes());
- Map<String, String> headers = new HashMap<>(2);
- headers.put("Authorization", "Basic " + creb);
- return JSON.parseObject(HttpUtil.jsonPost(url, headers, param.toJSONString()));
- }
-
- private boolean isError(JSONObject json) {
- if (json == null || (StringUtils.isNotEmpty(json.getString("error")) && json.get("error") != "null")) {
- return true;
- }
- return false;
- }
-
- public String dumpprivkey(String address) {
- try {
- JSONObject obj = doRequest("dumpprivkey", address);
- System.out.println(obj);
- if (!isError(obj)) {
- return obj.getString(RESULT);
- } else {
- return null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 查询给定地址的总收款额(只计算接受的)
- *
- * @param address
- * @return
- */
- public BigDecimal getBalance(String address) {
- try {
- JSONObject json = doRequest("omni_getbalance", address, 31);
- if (!isError(json)) {
- return new BigDecimal(json.getJSONObject(RESULT).get("balance").toString());
- } else {
- return null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("BTC-USDT查询余额失败");
- return null;
- }
-
- }
-
- public String METHOD_GET_BLOCK_COUNT() {
- JSONObject json = doRequest(METHOD_GET_BLOCK_COUNT);
- if (!isError(json)) {
- return json.getString(RESULT);
- } else {
- return null;
- }
- }
-
-
-
-
-
- public static void main(String[] args) {
-
- System.out.println(UsdtService.getInstance().getBalance("1PLCr8A2z7YLEtoPLJdzzqpfb3Ym87UCtt"));
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/XrpService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/XrpService.java
deleted file mode 100644
index 781eee7..0000000
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/XrpService.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.xcong.excoin.modules.blackchain.service;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.text.MessageFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.ripple.core.coretypes.AccountID;
-import com.ripple.core.coretypes.Amount;
-import com.ripple.core.coretypes.uint.UInt32;
-import com.ripple.core.types.known.tx.signed.SignedTransaction;
-import com.ripple.core.types.known.tx.txns.Payment;
-import com.xcong.excoin.modules.blackchain.model.XrpTransResult;
-
-public class XrpService {
-
- /**
- * 平台钱包地址
- */
- public final static String ACCOUNT="rKMGEyjXErL2dx9ck5QXFJVH8onSfHF5gn";
- /**
- * 官方接口地址
- */
- private static String getUrl = "https://data.ripple.com";
- private String postUrl = "https://s1.ripple.com:51234";
-
- /**
- * 结果类型
- */
- private final static String TES_SUCCESS = "tesSUCCESS";
-
-
-
-
-
- /**
- * start YYYY-MM-DDThh:mm:ssZ String - Timestamp Start time of query range. The default is the
- * earliest date available.
- * end String - Timestamp End time of query range. The
- * default is the current date.
- * min_sequence String Minimum sequence number to
- * query.
- * max_sequence String Max sequence number to query.
- * type String Restrict results to a specified transaction type.
- * result String Restrict results to a specified transaction result.
- * binary Boolean Return results in binary format.
- * descending Boolean If true, return results in reverse chronological order.The default is false.
- * limit Integer Maximum results per page. The default is 20. Cannot be more than 1,000.
- * marker String Pagination key from previously
- * returned response.
- *
- * https://github.com/ripple/rippled-historical-database
- * 接口文档:https://xrpl.org/data-api.html#get-account
- */
- public static XrpTransResult getTransactions(Date start) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- String startTime = dateFormat.format(start);
- String url ="https://data.ripple.com/v2/accounts/"+ACCOUNT+"/transactions?type=Payment&result=tesSUCCESS&limit=100&start="+startTime;
- // 十分钟查一次 每次100条
- String result = HttpUtil.get(url);
- try {
- JSONObject json = JSONObject.parseObject(result);
- XrpTransResult res = json.toJavaObject(XrpTransResult.class);
- return res;
- }catch(Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
deleted file mode 100644
index 64df9f2..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package com.xcong.excoin.modules.coin.controller;
-
-import java.math.BigDecimal;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAgentIntoInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
-
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
-import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceDto;
-import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceFromAgentDto;
-import com.xcong.excoin.modules.coin.service.CoinService;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@Api(value = "会员资产接口", tags = "会员资产接口")
-@RestController
-@RequestMapping(value = "/api/walletCoin")
-public class CoinController {
-
- @Resource
- private CoinService coinService;
-
- /**
- * 获取我的总资产
- * @return
- */
- @ApiOperation(value = "获取我的总资产", notes = "获取我的总资产")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = AllWalletCoinVo.class)})
- @GetMapping(value = "/getAllWalletCoin")
- public Result getAllWalletCoin() {
- return coinService.getAllWalletCoin();
- }
- /**
- * 获取我的币币资产信息
- * @return
- */
- @ApiOperation(value = "获取我的币币账户信息", notes = "获取我的币币账户信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletCoinVo.class)})
- @GetMapping(value = "/getWalletCoin")
- public Result getWalletCoin() {
- return coinService.getWalletCoin();
- }
-
- /**
- * 获取币币账户某个币种信息
- * @return
- */
- @ApiOperation(value="获取币币账户某个币种信息", notes="获取币币账户某个币种信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletCoinInfoVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/getWalletCoinBySymbol")
- public Result getWalletCoinBySymbol(String symbol) {
- return coinService.getWalletCoinBySymbol(symbol);
- }
-
- /**
- * --todo
- * 获取我的合约资产信息
- * @return
- */
- @ApiOperation(value="获取我的合约账户信息", notes="获取我的合约账户信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletContractInfoVo.class)})
- @GetMapping(value="/getWalletContractById")
- public Result getWalletContractById() {
- return coinService.getWalletContractById();
- }
-
- /**
- * 查询合约账户里面的可用资产余额
- * @return
- */
- @ApiOperation(value="查询合约账户里面的可用资产余额", notes="查询合约账户里面的可用资产余额")
- @GetMapping(value="/findWalletContractBySymbol")
- public Result findWalletContractBySymbol() {
- return coinService.findWalletContractBySymbol();
- }
-
- /**
- * 查询币币账户里面的可用资产余额
- * @return
- */
- @ApiOperation(value="查询币币账户里面的可用资产余额", notes="查询币币账户里面的可用资产余额")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value="/findWalletCoinBySymbol")
- public Result findWalletCoinBysymbol(String symbol) {
- return coinService.findWalletCoinBySymbol(symbol);
- }
-
- /**
- * 查询代理账户里面的资产余额
- * @return
- */
- @ApiOperation(value="查询代理账户信息", notes="查询代理账户信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletAgentInfoVo.class)})
- @GetMapping(value="/findWalletAgentBySymbol")
- public Result findWalletAgentBySymbol() {
- return coinService.findWalletAgentBySymbol();
- }
-
- /**
- * 获取币币资产交易记录
- * @return
- */
- @ApiOperation(value="获取币币资产交易记录", notes="获取币币资产交易记录")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeInfoVo.class)})
- @PostMapping(value="/getWalletCoinRecords")
- public Result getWalletCoinRecords(@RequestBody @Valid RecordsPageDto recordsPageDto) {
- return coinService.getWalletCoinRecords(recordsPageDto);
- }
-
- /**
- * 获取合约资产交易记录
- * @return
- */
- @ApiOperation(value="获取合约资产交易记录", notes="获取合约资产交易记录")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeInfoVo.class)})
- @PostMapping(value="/getWalletContractRecords")
- public Result getWalletContractRecords(@RequestBody @Valid RecordsPageDto recordsPageDto) {
- return coinService.getWalletContractRecords(recordsPageDto);
- }
-
- /**
- * 获取代理资产交易记录
- * @return
- */
- @ApiOperation(value="获取代理资产交易记录", notes="获取代理资产交易记录")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeInfoVo.class)})
- @PostMapping(value="/getWalletAgentRecords")
- public Result getWalletAgentRecords(@RequestBody @Valid RecordsPageDto recordsPageDto) {
- return coinService.getWalletAgentRecords(recordsPageDto);
- }
-
- /**
- * 获取代理资产佣金入账
- * @return
- */
- @ApiOperation(value="获取代理资产佣金入账", notes="获取代理资产佣金入账")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAgentIntoInfoVo.class)})
- @PostMapping(value="/getWalletAgentIntoRecords")
- public Result getWalletAgentIntoRecords(@RequestBody @Valid RecordsPageDto recordsPageDto) {
- return coinService.getWalletAgentIntoRecords(recordsPageDto);
- }
-
- /**
- * 币币账户USDT划转到合约账户
- * @return
- */
- @ApiOperation(value="币币账户USDT划转到合约账户", notes="币币账户USDT划转到合约账户")
- @PostMapping(value="/coinWalletTransferToContract")
- public Result coinWalletTransferToContract(@RequestBody @Valid TransferOfBalanceDto transferOfBalanceDto) {
- BigDecimal balance = transferOfBalanceDto.getBalance();
- String symbol = transferOfBalanceDto.getSymbol();
- return coinService.coinWalletTransferToContract(balance,symbol);
- }
-
- /**
- * 合约账户划转到币币USDT账户
- * @return
- */
- @ApiOperation(value="合约账户划转到币币USDT账户", notes="合约账户划转到币币USDT账户")
- @PostMapping(value="/contractTransferToWalletCoin")
- public Result contractTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceDto transferOfBalanceDto) {
- BigDecimal balance = transferOfBalanceDto.getBalance();
- String symbol = transferOfBalanceDto.getSymbol();
- return coinService.contractTransferToWalletCoin(balance,symbol);
- }
-
- /**
- * 代理账户划转到USDT账户
- * @return
- */
- @ApiOperation(value="代理账户划转到合约或币币USDT账户", notes="代理账户划转到合约或币币USDT账户")
- @PostMapping(value="/agentTransferToWalletCoin")
- public Result agentTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceFromAgentDto transferOfBalanceFromAgentDto) {
- BigDecimal balance = transferOfBalanceFromAgentDto.getBalance();
- Integer transfertype = transferOfBalanceFromAgentDto.getTransfertype();
- return coinService.agentTransferToWalletCoin(balance,transfertype);
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
deleted file mode 100644
index f9f4ece..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package com.xcong.excoin.modules.coin.controller;
-
-import java.math.BigDecimal;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.parameter.dto.CancelEntrustWalletCoinOrderDto;
-import com.xcong.excoin.modules.coin.parameter.dto.FindAllWalletCoinOrderDto;
-import com.xcong.excoin.modules.coin.parameter.dto.FindCollectDto;
-import com.xcong.excoin.modules.coin.parameter.dto.SubmitSalesWalletCoinOrderDto;
-import com.xcong.excoin.modules.coin.parameter.vo.FindCollectListVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinListVo;
-import com.xcong.excoin.modules.coin.parameter.vo.TransactionPageOfWalletCoinVo;
-import com.xcong.excoin.modules.coin.service.OrderCoinService;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@Api(value = "币币交易接口", tags = "币币交易接口")
-@RestController
-@RequestMapping(value = "/api/orderCoin")
-public class OrderCoinController {
-
- @Resource
- OrderCoinService orderCoinService;
-
- /**
- * 进入交易页面
- * @return
- */
- @ApiOperation(value = "进入交易页面", notes = "进入交易页面")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = TransactionPageOfWalletCoinVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/enterTransactionPageOfWalletCoin")
- public Result enterTransactionPageOfWalletCoin(String symbol) {
- return orderCoinService.enterTransactionPageOfWalletCoin(symbol);
- }
-
- /**
- * 提交买卖订单
- * @return
- */
- @ApiOperation(value = "提交买卖订单", notes = "提交买卖订单")
- @PostMapping(value="/submitSalesWalletCoinOrder")
- public Result submitSalesWalletCoinOrder(@RequestBody @Valid SubmitSalesWalletCoinOrderDto submitSalesWalletCoinOrderDto) {
- String symbol = submitSalesWalletCoinOrderDto.getSymbol();
- Integer type = submitSalesWalletCoinOrderDto.getType();
- Integer tradeType = submitSalesWalletCoinOrderDto.getTradeType();
- BigDecimal price = submitSalesWalletCoinOrderDto.getPrice();
- BigDecimal amount = submitSalesWalletCoinOrderDto.getAmount();
- return orderCoinService.submitSalesWalletCoinOrder(symbol,type,tradeType,price,amount);
- }
-
- /**
- * 获取委托单数据
- * @return
- */
- @ApiOperation(value = "获取委托单数据", notes = "获取委托单数据")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinListVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query"),
- @ApiImplicitParam(name = "status", value = "状态 1:委托中2:撤单3:已成交", required = true, dataType = "int", paramType="query")
- })
- @GetMapping(value = "/getEntrustWalletCoinOrder")
- public Result getEntrustWalletCoinOrder(String symbol,Integer status) {
- return orderCoinService.getEntrustWalletCoinOrder(symbol,status);
- }
-
- /**
- * 撤销委托订单
- * @return
- */
- @ApiOperation(value = "撤销委托订单", notes = "撤销委托订单")
- @PostMapping(value="/cancelEntrustWalletCoinOrder")
- public Result cancelEntrustWalletCoinOrder(@RequestBody @Valid CancelEntrustWalletCoinOrderDto cancelEntrustWalletCoinOrderDto) {
- String orderId = cancelEntrustWalletCoinOrderDto.getOrderId();
- return orderCoinService.cancelEntrustWalletCoinOrder(orderId);
- }
-
- /**
- * 获取币币交易历史订单信息
- * @return
- */
- @ApiOperation(value = "获取币币交易历史订单信息", notes = "获取币币交易历史订单信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealVo.class)})
- @PostMapping(value="/findAllWalletCoinOrder")
- public Result findAllWalletCoinOrder(@RequestBody @Validated FindAllWalletCoinOrderDto findAllWalletCoinOrderDto) {
- return orderCoinService.findAllWalletCoinOrder(findAllWalletCoinOrderDto);
- }
-
- /**
- * 获取一条币币交易历史订单信息
- * @return
- */
- @ApiOperation(value = "获取一条币币交易历史订单信息", notes = "获取一条币币交易历史订单信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType="query")
- })
- @GetMapping(value = "/findWalletCoinOrder")
- public Result findWalletCoinOrder(Long orderId) {
- return orderCoinService.findWalletCoinOrder(orderId);
- }
-
- /**
- * 币币自选|取消自选
- * @return
- */
- @ApiOperation(value = "币币自选|取消自选", notes = "币币自选|取消自选")
- @PostMapping(value="/findCollect")
- public Result findCollect(@RequestBody @Valid FindCollectDto findCollectDto) {
- String symbol = findCollectDto.getSymbol();
- Integer type = findCollectDto.getType();
- return orderCoinService.findCollect(symbol,type);
- }
-
- /**
- * 币币是否自选
- * @return
- */
- @ApiOperation(value = "币币是否自选", notes = "币币是否自选")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberSelectSymbolsVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/checkIsCollect")
- public Result checkIsCollect(String symbol) {
- return orderCoinService.checkIsCollect(symbol);
- }
-
- /**
- * 已自选的币种
- * @return
- */
- @ApiOperation(value = "已自选的币种", notes = "已自选的币种")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = FindCollectListVo.class)})
- @GetMapping(value = "/findCollectList")
- public Result findCollectList() {
- return orderCoinService.findCollectList();
- }
-
- /**
- * 币种搜索
- * @return
- */
- @ApiOperation(value = "币种搜索", notes = "币种搜索")
- @GetMapping(value = "/searchSymbolResultList")
- public Result searchSymbolResultList() {
- return orderCoinService.searchSymbolResultList();
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountFlowEntityDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountFlowEntityDao.java
deleted file mode 100644
index 64af089..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountFlowEntityDao.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.xcong.excoin.modules.coin.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
-
-public interface MemberAccountFlowEntityDao extends BaseMapper<MemberAccountFlowEntity>{
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java
deleted file mode 100644
index 2319534..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.xcong.excoin.modules.coin.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-
-public interface MemberAccountMoneyChangeDao extends BaseMapper<MemberAccountMoneyChange>{
-
- List<MemberAccountMoneyChange> selectWalletCoinRecordsByMemIdTypeSymbol(Long memberId);
-
- List<MemberAccountMoneyChange> selectWalletContractRecordsByMemIdTypeSymbol(@Param("symbol")String symbol, @Param("memberId")Long memberId);
-
- List<MemberAccountMoneyChange> selectWalletAgentRecordByMemIdTypeSymbol(@Param("symbol")String symbol, @Param("memberId")Long memberId);
-
- List<MemberAccountMoneyChange> selectWalletAgentIntoRecordsByMemIdTypeSymbol(@Param("memberId")Long memberId);
-
- IPage<MemberAccountMoneyChange> selectWalletCoinRecordsInPage(Page<OrderCoinsDealEntity> page,
- @Param("record") MemberAccountMoneyChange memberAccountMoneyChange);
-
- IPage<MemberAccountMoneyChange> selectWalletContractRecordsInPage(Page<OrderCoinsDealEntity> page,
- @Param("record") MemberAccountMoneyChange memberAccountMoneyChange);
-
- IPage<MemberAccountMoneyChange> selectWalletAgentRecordsInPage(Page<OrderCoinsDealEntity> page,
- @Param("record") MemberAccountMoneyChange memberAccountMoneyChange);
-
- IPage<MemberAccountMoneyChange> selectWalletAgentIntoRecordsByMemIdTypeSymbol(Page<OrderCoinsDealEntity> page,
- @Param("record")MemberAccountMoneyChange memberAccountMoneyChange);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberSelectSymbolsDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberSelectSymbolsDao.java
deleted file mode 100644
index 4bd7721..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberSelectSymbolsDao.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity;
-
-public interface MemberSelectSymbolsDao extends BaseMapper<MemberSelectSymbolsEntity>{
-
- List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol(@Param("memberId")Long memberId,@Param("symbol")String symbol);
-
- List<MemberSelectSymbolsEntity> selectSymbolByMemId(@Param("memberId")Long memberId);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
deleted file mode 100644
index ab900b8..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.coin.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-
-public interface OrderCoinDealDao extends BaseMapper<OrderCoinsDealEntity>{
-
- List<OrderCoinsDealEntity> selectAllWalletCoinOrder(@Param("memberId")Long memberId);
-
- List<OrderCoinsDealEntity> selectAllWalletCoinOrderBySymbol(@Param("memberId")Long memberId,@Param("symbol")String symbol);
-
- OrderCoinsDealEntity selectWalletCoinOrder(@Param("memberId")Long memberId,@Param("orderId")Long orderId);
-
- IPage<OrderCoinsDealEntity> findAllWalletCoinOrderInPage(Page<OrderCoinsDealEntity> page,
- @Param("record") OrderCoinsDealEntity orderCoinsDealEntity);
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinsDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinsDao.java
deleted file mode 100644
index beed401..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinsDao.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.modules.coin.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
-
-public interface OrderCoinsDao extends BaseMapper<OrderCoinsEntity>{
-
- long getOrderCountByToday(@Param("now")String now,@Param("tomorrow") String tomorrow);
-
- List<OrderCoinsEntity> findCoinOrderListByMemberIdAndSysmbol(@Param("memberId")Long memberId,@Param("symbol")String symbol,@Param("status")int status);
-
- OrderCoinsEntity findWalletCoinOrderByOrderNo(@Param("orderNo")String orderNo);
-
- List<OrderCoinsEntity> selectAllEntrustingCoinOrderList();
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountFlowEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountFlowEntity.java
deleted file mode 100644
index 396540b..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountFlowEntity.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.xcong.excoin.modules.coin.entity;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-/**
- * 会员账户流水情况
- */
-@Data
-@TableName("member_account_flow")
-public class MemberAccountFlowEntity extends BaseEntity {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 会员ID
- */
- private Long memberId;
-
- /**
- * 价格
- */
- private BigDecimal price;
-
- /**
- * 用户余额
- */
- private BigDecimal balance;
-
- /**
- * 来源
- */
- private String source;
-
- public static final String SOURCE_BUY = "币币买入";
- public static final String SOURCE_SALE = "币币卖出";
- public static final String SOURCE_CANCEL = "撤销币币委托单";
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 备注
- */
- private String remark;
- public static final String REMARK_BUY = "买入";
- public static final String REMARK_SALE = "卖出";
- public static final String REMARK_CANCEL = "撤销";
- public static final String REMARK_RETURNBALANCE = "返回金额:";
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java b/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java
deleted file mode 100644
index 35f5d7a..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.xcong.excoin.modules.coin.entity;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-@Data
-@TableName("member_account_money_change")
-public class MemberAccountMoneyChange extends BaseEntity {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 类型【1:币币资产2:合约资产3:代理资产】
- */
- public static final Integer TYPE_WALLET_COIN = 1;
- public static final Integer TYPE_WALLET_CONTRACT = 2;
- public static final Integer TYPE_WALLET_AGENT = 3;
- /**
- * 状态【0:待审核 1:成功2:失败】
- */
- public static final Integer STATUS_WAIT_INTEGER = 0;
- public static final Integer STATUS_SUCCESS_INTEGER = 1;
- public static final Integer STATUS_FAIL_INTEGER = 2;
-
- private Long memberId;
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 金额
- */
- private BigDecimal amount;
- /**
- * 记录内容
- */
- private String content;
- /**
- * 类型【1:币币资产2:合约资产3:代理资产】
- */
- private int type;
- /**
- * 状态【0:待审核 1:成功2:失败】
- */
- private int status;
- /**
- * 提币ID
- */
- private Long withdrawId;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java
deleted file mode 100644
index de6f514..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.xcong.excoin.modules.coin.entity;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-/**
- * 币币订单成交表
- */
-@Data
-@TableName("coins_order_deal")
-public class OrderCoinsDealEntity extends BaseEntity{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * 会员ID
- */
- private Long memberId;
- /**
- * 订单主表ID
- */
- private Long orderId;
- /**
- * 订单编号
- */
- private String orderNo;
- /**
- * 订单类型 1、买入2、卖出
- */
- private Integer orderType;
- public static final Integer ORDERTYPE_BUY = 1;
- public static final Integer ORDERTYPE_SELL = 2;
- /**
- * 交易类型 1:市价2:限价
- */
- private Integer tradeType;
- public static final Integer TRADETYPE_MARKETPRICE = 1;
- public static final Integer TRADETYPE_FIXEDPRICE = 2;
-
- /**
- * 状态 2:撤单3:已成交
- */
- private Integer orderStatus;
- public static final Integer ORDERSTATUS_CANCEL = 2;
- public static final Integer ORDERSTATUS_DONE = 3;
- /**
- * 币种
- */
- private String symbol;
- /**
- * 数量
- */
- private BigDecimal symbolCnt;
- /**
- * 委托价
- */
- private BigDecimal entrustPrice;
- /**
- * 成交价
- */
- private BigDecimal dealPrice;
- /**
- * 成交金额
- */
- private BigDecimal dealAmount;
- /**
- * 手续费
- */
- private BigDecimal feeAmount;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java
deleted file mode 100644
index 54cadd8..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.xcong.excoin.modules.coin.entity;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-/**
- * 币币订单表
- */
-@Data
-@TableName("coins_order")
-public class OrderCoinsEntity extends BaseEntity{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 会员ID
- */
- private Long memberId;
- /**
- * 订单编号
- */
- private String orderNo;
- /**
- * 订单类型 1、买入2、卖出
- */
- private Integer orderType;
- public static final Integer ORDERTYPE_BUY = 1;
- public static final Integer ORDERTYPE_SELL = 2;
-
- /**
- * 币种
- */
- private String symbol;
- /**
- * 市场价
- */
- private BigDecimal markPrice;
- /**
- * 委托量
- */
- private BigDecimal entrustCnt;
- /**
- * 委托价
- */
- private BigDecimal entrustPrice;
- /**
- * 成交量
- */
- private BigDecimal dealCnt;
- /**
- * 成交价
- */
- private BigDecimal dealPrice;
- /**
- * 成交金额
- */
- private BigDecimal dealAmount;
- /**
- * 状态 1:委托中2:撤单3:已成交
- */
- private Integer orderStatus;
- public static final Integer ORDERSTATUS_DODING = 1;
- public static final Integer ORDERSTATUS_CANCEL = 2;
- public static final Integer ORDERSTATUS_DONE = 3;
-
- /**
- * 交易类型 1:市价2:限价
- */
- private Integer tradeType;
- public static final Integer TRADETYPE_MARKETPRICE = 1;
- public static final Integer TRADETYPE_FIXEDPRICE = 2;
-
- /**
- * 手续费
- */
- private BigDecimal feeAmount;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/mapper/MemberAccountMoneyChangeMapper.java b/src/main/java/com/xcong/excoin/modules/coin/mapper/MemberAccountMoneyChangeMapper.java
deleted file mode 100644
index 6ff5422..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/mapper/MemberAccountMoneyChangeMapper.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.coin.mapper;
-
-import java.util.List;
-
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
-
-@Mapper
-public abstract class MemberAccountMoneyChangeMapper {
-
- public static final MemberAccountMoneyChangeMapper INSTANCE = Mappers.getMapper(MemberAccountMoneyChangeMapper.class);
-
- public abstract MemberAccountMoneyChangeInfoVo entityToVoOrder(MemberAccountMoneyChange memberAccountMoneyChange);
-
- public abstract List<MemberAccountMoneyChangeInfoVo> orderEntitiesToOrderListVo(List<MemberAccountMoneyChange> memberAccountMoneyChanges);
-
- public abstract Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo(IPage<MemberAccountMoneyChange> memberAccountMoneyChanges);
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderCoinsDealMapper.java b/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderCoinsDealMapper.java
deleted file mode 100644
index e2375b2..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderCoinsDealMapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.modules.coin.mapper;
-
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.factory.Mappers;
-
-/**
- * @author wzy
- * @date 2020-07-01
- **/
-@Mapper
-public abstract class OrderCoinsDealMapper {
-
- public static final OrderCoinsDealMapper INSTANCE = Mappers.getMapper(OrderCoinsDealMapper.class);
-
- @Mapping(target = "symbolCnt", source = "entrustCnt")
- public abstract OrderCoinsDealEntity orderToOrderDeal(OrderCoinsEntity orderCoinsEntity);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinDealMapper.java b/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinDealMapper.java
deleted file mode 100644
index ddd13a3..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinDealMapper.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.coin.mapper;
-
-import java.util.List;
-
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo;
-
-@Mapper
-public abstract class OrderWalletCoinDealMapper {
-
- public static final OrderWalletCoinDealMapper INSTANCE = Mappers.getMapper(OrderWalletCoinDealMapper.class);
-
- public abstract OrderWalletCoinDealVo entityToVoOrder(OrderCoinsDealEntity orderCoinsDealEntity);
-
- public abstract List<OrderWalletCoinDealVo> orderEntitiesToOrderListVo(List<OrderCoinsDealEntity> orderEntities);
-
- public abstract Page<OrderWalletCoinDealVo> pageEntityToPageVo(IPage<OrderCoinsDealEntity> orderCoins);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinMapper.java b/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinMapper.java
deleted file mode 100644
index 742896f..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/mapper/OrderWalletCoinMapper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.mapper;
-
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo;
-
-@Mapper
-public abstract class OrderWalletCoinMapper {
-
- public static final OrderWalletCoinMapper INSTANCE = Mappers.getMapper(OrderWalletCoinMapper.class);
-
- public abstract OrderWalletCoinVo entityToVo(OrderCoinsEntity orderCoinsEntity);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/CancelEntrustWalletCoinOrderDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/CancelEntrustWalletCoinOrderDto.java
deleted file mode 100644
index 19ff619..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/CancelEntrustWalletCoinOrderDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "CancelEntrustWalletCoinOrderDto", description = "撤销委托订单")
-public class CancelEntrustWalletCoinOrderDto {
-
- @NotNull(message = "订单ID不能为空")
- @ApiModelProperty(value = "订单ID", example = "100")
- private String orderId;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindAllWalletCoinOrderDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindAllWalletCoinOrderDto.java
deleted file mode 100644
index 7990a5d..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindAllWalletCoinOrderDto.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "FindAllWalletCoinOrderDto", description = "获取币币交易历史订单信息参数接受类")
-public class FindAllWalletCoinOrderDto {
-
- @NotNull
- @Min(1)
- @ApiModelProperty(value = "第几页", example = "1")
- private int pageNum;
-
- @NotNull
- @ApiModelProperty(value = "每页数量", example = "10")
- private int pageSize;
-
- @NotNull
- @ApiModelProperty(value = "币种", example = "BTC")
- private String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindCollectDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindCollectDto.java
deleted file mode 100644
index 5367b10..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/FindCollectDto.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "FindCollectDto", description = "币币自选|取消自选参数接收类")
-public class FindCollectDto {
-
- @NotNull(message = "币种")
- @ApiModelProperty(value = "币种", example = "BTC")
- private String symbol;
-
- @NotNull(message = "币币自选")
- @ApiModelProperty(value = "自选标识1:选中0:未选中", example = "1")
- private Integer type;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
deleted file mode 100644
index 2a54cf0..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "InOrderCoinDto", description = "进入交易页面参数接收类")
-public class InOrderCoinDto {
-
- @NotNull(message = "划转金额不能为空")
- @ApiModelProperty(value = "划转金额", example = "100")
- private BigDecimal balance;
-
- @NotNull(message = "币种不能为空")
- @ApiModelProperty(value = "币种", example = "USDT")
- private String symbol;
-
- @NotNull(message = "账户类型不能为空")
- @ApiModelProperty(value = "账户类型", example = "1")
- private Integer transfertype;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/RecordsPageDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/RecordsPageDto.java
deleted file mode 100644
index c1e9fdd..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/RecordsPageDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "RecordsPageDto", description = "资产交易记录参数接受类")
-public class RecordsPageDto {
-
- @NotNull
- @Min(1)
- @ApiModelProperty(value = "第几页", example = "1")
- private int pageNum;
-
- @NotNull
- @ApiModelProperty(value = "每页数量", example = "10")
- private int pageSize;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
deleted file mode 100644
index b15186a..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "SubmitSalesWalletCoinOrderDto", description = "提交买卖订单参数接收类")
-public class SubmitSalesWalletCoinOrderDto {
-
-
- @NotNull(message = "币种不能为空")
- @ApiModelProperty(value = "币种", example = "BTC")
- private String symbol;
-
- @NotNull(message = "交易类型不能为空")
- @ApiModelProperty(value = "买入卖出类型买入:1,卖出:2", example = "1")
- private Integer type;
-
- @NotNull(message = "交易方式不能为空")
- @ApiModelProperty(value = "市价:1,限价:2", example = "1")
- private Integer tradeType;
-
- @Min(0)
- @NotNull(message = "数量不能为空")
- @ApiModelProperty(value = "数量", example = "100")
- private BigDecimal amount;
-
- @NotNull(message = "建仓价不能为空")
- @ApiModelProperty(value = "建仓价", example = "20.0000")
- private BigDecimal price;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java
deleted file mode 100644
index e1f9967..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "TransferOfBalanceDto", description = "资金划转参数接收类")
-public class TransferOfBalanceDto {
-
- @NotNull(message = "划转金额不能为空")
- @ApiModelProperty(value = "划转金额", example = "100")
- private BigDecimal balance;
-
- @NotNull(message = "币种不能为空")
- @ApiModelProperty(value = "币种", example = "USDT")
- private String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java
deleted file mode 100644
index bd7f8d4..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-@Data
-@ApiModel(value = "TransferOfBalanceFromAgentDto", description = "资金划转参数接收类")
-public class TransferOfBalanceFromAgentDto {
-
- @NotNull(message = "划转金额不能为空")
- @ApiModelProperty(value = "划转金额", example = "100")
- private BigDecimal balance;
-
- @NotNull(message = "币种不能为空")
- @ApiModelProperty(value = "币种", example = "USDT")
- private String symbol;
-
- @NotNull(message = "账户类型不能为空")
- @ApiModelProperty(value = "转账类型1:转币币,2:转合约", example = "1")
- private Integer transfertype;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/AllWalletCoinVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/AllWalletCoinVo.java
deleted file mode 100644
index d1e4ae2..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/AllWalletCoinVo.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "AllWalletCoinVo", description = "信息返回")
-public class AllWalletCoinVo {
-
- @ApiModelProperty(value = "账户总USDT")
- private BigDecimal totalUsdt;
-
- @ApiModelProperty(value = "账户总RMB")
- private BigDecimal totalCny;
-
- @ApiModelProperty(value = "币币USDT")
- private BigDecimal walletUsdt;
-
- @ApiModelProperty(value = "合约USDT")
- private BigDecimal contractUsdt;
-
- @ApiModelProperty(value = "代理USDT")
- private BigDecimal agentUsdt;
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/FindCollectListVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/FindCollectListVo.java
deleted file mode 100644
index 2d68aad..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/FindCollectListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "FindCollectListVo", description = "币币是否自选返回")
-public class FindCollectListVo {
-
- @ApiModelProperty(value = "币币自选")
- private List<MemberSelectSymbolsVo> memberSelectSymbolsVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java
deleted file mode 100644
index 69306a0..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAccountMoneyChangeInfoVo", description = "资产交易记录详情信息返回")
-public class MemberAccountMoneyChangeInfoVo {
-
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
- /**
- * 金额
- */
- @ApiModelProperty(value = "金额")
- private BigDecimal amount;
- /**
- * 记录内容
- */
- @ApiModelProperty(value = "记录内容")
- private String content;
- /**
- * 类型【1:币币资产2:合约资产3:代理资产】
- */
- @ApiModelProperty(value = "类型【1:币币资产2:合约资产3:代理资产】")
- private int type;
- /**
- * 状态【0:待审核 1:成功2:失败】
- */
- @ApiModelProperty(value = "状态【0:待审核 1:成功2:失败】")
- private int status;
-
- @ApiModelProperty(value = "时间")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date updateTime;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java
deleted file mode 100644
index c1de610..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAccountMoneyChangeVo", description = "资产交易记录信息返回")
-public class MemberAccountMoneyChangeVo {
-
- @ApiModelProperty(value = "资产交易记录详情信息")
- private List<MemberAccountMoneyChangeInfoVo> memberAccountMoneyChangeInfoVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAgentIntoInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAgentIntoInfoVo.java
deleted file mode 100644
index ed7ecbb..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAgentIntoInfoVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAgentIntoInfoVo", description = "佣金入账记录信息返回")
-public class MemberAgentIntoInfoVo {
-
- @ApiModelProperty(value = "资产交易记录详情信息")
- private List<MemberAccountMoneyChangeInfoVo> memberAccountMoneyChangeInfoVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberSelectSymbolsVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberSelectSymbolsVo.java
deleted file mode 100644
index d5cc0e2..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberSelectSymbolsVo.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberSelectSymbolsVo", description = "币币是否自选返回")
-public class MemberSelectSymbolsVo {
- /**
- * 会员ID
- */
- @ApiModelProperty(value = "是否自选1:选中0:未选中")
- private Integer isCollect;
- public static final Integer ISCOLLECT_YES = 1;
- public static final Integer ISCOLLECT_NO = 0;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java
deleted file mode 100644
index 5961d16..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberWalletAgentInfoVo", description = "代理账户信息返回")
-public class MemberWalletAgentInfoVo {
-
- /**
- * 总金额
- */
- @ApiModelProperty(value = "总金额")
- private BigDecimal totalBalance;
-
- /**
- * 总人民币金额
- */
- @ApiModelProperty(value = "总人民币金额")
- private BigDecimal totalRMBBalance;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
deleted file mode 100644
index 2098c61..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class MemberWalletCoinInfoVo {
-
- /**
- * 用户Id
- */
- @ApiModelProperty(value = "用户Id")
- private Long memberId;
-
- /**
- * 钱包标识
- */
- @ApiModelProperty(value = "币种名称")
- private String walletCode;
-
- /**
- * 可用余额
- */
- @ApiModelProperty(value = "可用余额")
- private BigDecimal availableBalance;
-
- /**
- * 总金额
- */
- @ApiModelProperty(value = "总金额")
- private BigDecimal totalBalance;
-
- /**
- * 冻结金额
- */
- @ApiModelProperty(value = "冻结金额")
- private BigDecimal frozenBalance;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java
deleted file mode 100644
index ad0580e..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * @author xy
- */
-@Data
-@ApiModel(value = "MemberWalletCoinVo", description = "币币账户信息返回")
-public class MemberWalletCoinVo {
-
- private static final long serialVersionUID = 1L;
-
- @ApiModelProperty(value = "账户总USDT")
- private BigDecimal totalUsdt;
-
- @ApiModelProperty(value = "账户总RMB")
- private BigDecimal totalCny;
-
- @ApiModelProperty(value = "币种详情")
- private List<MemberWalletCoinInfoVo> memberWalletCoinInfoVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java
deleted file mode 100644
index 89bcb7a..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberWalletContractInfoVo", description = "合约账户信息返回")
-public class MemberWalletContractInfoVo {
-
- /**
- * 用户Id
- */
- @ApiModelProperty(value = "用户Id")
- private Long memberId;
-
- /**
- * 可用余额
- */
- @ApiModelProperty(value = "可用余额")
- private BigDecimal availableBalance;
-
- /**
- * 总金额
- */
- @ApiModelProperty(value = "总金额")
- private BigDecimal totalBalance;
-
- /**
- * 总人民币金额
- */
- @ApiModelProperty(value = "总人民币金额")
- private BigDecimal totalRMBBalance;
-
- /**
- * 冻结金额
- */
- @ApiModelProperty(value = "冻结金额")
- private BigDecimal frozenBalance;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealListVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealListVo.java
deleted file mode 100644
index da1059f..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "OrderWalletCoinDealListVo", description = "币币交易历史订单信息返回")
-public class OrderWalletCoinDealListVo {
-
- @ApiModelProperty(value = "历史订单详情")
- private List<OrderWalletCoinDealVo> orderWalletCoinDealVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealVo.java
deleted file mode 100644
index 0b5d4a7..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealVo.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "OrderWalletCoinDealVo", description = "历史订单详情")
-public class OrderWalletCoinDealVo {
- /**
- * 会员ID
- */
- @ApiModelProperty(value = "会员ID")
- private Long memberId;
- /**
- * 订单主表ID
- */
- @ApiModelProperty(value = "订单主表ID")
- private Long orderId;
- /**
- * 订单编号
- */
- @ApiModelProperty(value = "订单编号")
- private String orderNo;
- /**
- * 订单类型 1、买入2、卖出
- */
- @ApiModelProperty(value = "订单类型 1、买入2、卖出")
- private Integer orderType;
- /**
- * 交易类型 1:市价2:限价
- */
- @ApiModelProperty(value = "交易类型 1:市价2:限价")
- private Integer tradeType;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
- /**
- * 数量
- */
- @ApiModelProperty(value = "数量")
- private BigDecimal symbolCnt;
- /**
- * 委托价
- */
- @ApiModelProperty(value = "委托价")
- private BigDecimal entrustPrice;
- /**
- * 成交价
- */
- @ApiModelProperty(value = "成交价")
- private BigDecimal dealPrice;
- /**
- * 成交金额
- */
- @ApiModelProperty(value = "成交金额")
- private BigDecimal dealAmount;
- /**
- * 状态 2:撤单3:已成交
- */
- @ApiModelProperty(value = "状态 2:撤单3:已成交")
- private Integer orderStatus;
-
- /**
- * 手续费
- */
- @ApiModelProperty(value = "手续费")
- private BigDecimal feeAmount;
-
- @ApiModelProperty(value = "时间")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date updateTime;
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinListVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinListVo.java
deleted file mode 100644
index f85f3ee..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "OrderWalletCoinListVo", description = "委托单返回")
-public class OrderWalletCoinListVo {
-
- @ApiModelProperty(value = "委托单")
- private List<OrderWalletCoinVo> orderWalletCoinVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinVo.java
deleted file mode 100644
index 8a6f509..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinVo.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "OrderWalletCoinVo", description = "订单详情")
-public class OrderWalletCoinVo {
- /**
- * 订单ID
- */
- @ApiModelProperty(value = "ID")
- private Long id;
- /**
- * 订单编号
- */
- @ApiModelProperty(value = "订单编号")
- private String orderNo;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
-
- /**
- * 订单类型 1、买入2、卖出
- */
- @ApiModelProperty(value = "订单类型")
- private Integer orderType;
- /**
- * 市场价
- */
- @ApiModelProperty(value = "市场价")
- private BigDecimal markPrice;
- /**
- * 委托量
- */
- @ApiModelProperty(value = "委托量")
- private BigDecimal entrustCnt;
- /**
- * 委托价
- */
- @ApiModelProperty(value = "委托价")
- private BigDecimal entrustPrice;
- /**
- * 成交量
- */
- @ApiModelProperty(value = "成交量")
- private BigDecimal dealCnt;
- /**
- * 成交价
- */
- @ApiModelProperty(value = "成交价")
- private BigDecimal dealPrice;
- /**
- * 成交金额
- */
- @ApiModelProperty(value = "成交金额")
- private BigDecimal dealAmount;
- /**
- * 手续费
- */
- @ApiModelProperty(value = "手续费")
- private BigDecimal feeAmount;
-
- @ApiModelProperty(value = "时间")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date updateTime;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/TransactionPageOfWalletCoinVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/TransactionPageOfWalletCoinVo.java
deleted file mode 100644
index ec1ceb3..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/TransactionPageOfWalletCoinVo.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.xcong.excoin.modules.coin.parameter.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "TransactionPageOfWalletCoinVo", description = "进入交易页面返回")
-public class TransactionPageOfWalletCoinVo {
- /**
- * 是否自选
- */
- @ApiModelProperty(value = "是否自选")
- private Integer isCollect;
- public static final Integer ISCOLLECT_YES = 1;
- public static final Integer ISCOLLECT_NO = 0;
- /**
- * 点差
- */
- @ApiModelProperty(value = "点差")
- private BigDecimal spread;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
- /**
- * 买入卖出类型
- */
- @ApiModelProperty(value = "买入卖出类型")
- private String type;
- /**
- * 手续费
- */
- @ApiModelProperty(value = "手续费率")
- private BigDecimal feeRatio;
- /**
- * 用户可用金额
- */
- @ApiModelProperty(value = "买入用户可用金额")
- private BigDecimal availableBalanceBuy;
-
- /**
- * 用户可用金额
- */
- @ApiModelProperty(value = "卖出用户可用金额")
- private BigDecimal availableBalanceSell;
- /**
- * 当前价
- */
- @ApiModelProperty(value = "当前价")
- private BigDecimal currentPrice;
- /**
- * 比例
- */
- @ApiModelProperty(value = "比例")
- private BigDecimal cnyUsdt;
- /**
- * 换算成人民币之后的价格
- */
- @ApiModelProperty(value = "换算成人民币之后的价格")
- private BigDecimal currentPriceCny;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/BlockCoinService.java b/src/main/java/com/xcong/excoin/modules/coin/service/BlockCoinService.java
deleted file mode 100644
index e617f0a..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/BlockCoinService.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.coin.service;
-
-public interface BlockCoinService {
-
- public void updateEthUsdt();
-
- public void updateEth();
-
- public void updateBtcUsdt();
-
- public void updateBtc();
-
- public void updateEos();
-
- public void updateXrp();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java b/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java
deleted file mode 100644
index 58cdd57..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.xcong.excoin.modules.coin.service;
-
-import java.math.BigDecimal;
-
-import javax.validation.Valid;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-
-public interface CoinService extends IService<MemberWalletCoinEntity>{
-
- public Result getWalletCoin();
-
- public Result getWalletContractById();
-
- public Result coinWalletTransferToContract(BigDecimal balance, String symbol);
-
- public Result contractTransferToWalletCoin(BigDecimal balance, String symbol);
-
- public Result findWalletContractBySymbol();
-
- public Result findWalletCoinBySymbol(String symbol);
-
- public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype);
-
- public Result findWalletAgentBySymbol();
-
- public Result getWalletCoinBySymbol(String symbol);
-
- public Result getWalletAgentIntoRecords(@Valid RecordsPageDto recordsPageDto);
-
- public Result getWalletCoinRecords(@Valid RecordsPageDto recordsPageDto);
-
- public Result getWalletContractRecords(@Valid RecordsPageDto recordsPageDto);
-
- public Result getWalletAgentRecords(@Valid RecordsPageDto recordsPageDto);
-
- public Result getAllWalletCoin();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java b/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
deleted file mode 100644
index a8f2914..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.xcong.excoin.modules.coin.service;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
-import com.xcong.excoin.modules.coin.parameter.dto.FindAllWalletCoinOrderDto;
-
-public interface OrderCoinService extends IService<OrderCoinsEntity>{
-
- public String generateSimpleSerialno(String userId);
-
- Result enterTransactionPageOfWalletCoin(String symbol);
-
- Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
- BigDecimal amount);
-
- public Result getEntrustWalletCoinOrder(String symbol, Integer status);
-
- public Result cancelEntrustWalletCoinOrder(String orderId);
-
- public Result findAllWalletCoinOrder(FindAllWalletCoinOrderDto findAllWalletCoinOrderDto);
-
- public Result findWalletCoinOrder(Long orderId);
-
- public Result findCollect(String symbol, Integer type);
-
- public Result checkIsCollect(String symbol);
-
- public Result findCollectList();
-
- public Result searchSymbolResultList();
-
- public void dealEntrustCoinOrder();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
deleted file mode 100644
index a0ef93b..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
+++ /dev/null
@@ -1,431 +0,0 @@
-package com.xcong.excoin.modules.coin.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DatePattern;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.StrUtil;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.modules.blackchain.model.EosResult;
-import com.xcong.excoin.modules.blackchain.model.XrpTransResult;
-import com.xcong.excoin.modules.blackchain.model.XrpTransactions;
-import com.xcong.excoin.modules.blackchain.model.XrpTx;
-import com.xcong.excoin.modules.blackchain.service.*;
-import com.xcong.excoin.modules.coin.service.BlockCoinService;
-import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao;
-import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
-import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity;
-import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.utils.LogRecordUtils;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.ThreadPoolUtils;
-import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
-import com.xcong.excoin.utils.mail.Sms106Send;
-import com.xcong.excoin.utils.mail.SubMailSend;
-import lombok.extern.slf4j.Slf4j;
-import lombok.val;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-07-02
- **/
-@Slf4j
-@Service
-public class BlockCoinServiceImpl implements BlockCoinService {
-
- @Resource
- private MemberCoinAddressDao memberCoinAddressDao;
- @Resource
- private MemberDao memberDao;
- @Resource
- private MemberCoinChargeDao memberCoinChargeDao;
- @Resource
- private MemberWalletCoinDao memberWalletCoinDao;
-
- @Resource
- private RedisUtils redisUtils;
-
- private final static String EOS_SEQ_KEY="eos_seq_key";
-
- private final static String xrp_update_key = "xrp_update_key";
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void updateEthUsdt() {
- List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.USDT.name(), "ERC20");
- if (CollUtil.isNotEmpty(list)) {
- EthService ethService = new EthService();
- for (MemberCoinAddressEntity addressEntity : list) {
- String address = addressEntity.getAddress();
- Long memberId = addressEntity.getMemberId();
-
- if (StrUtil.isBlank(address)) {
- continue;
- }
-
- BigDecimal balance = ethService.tokenGetBalance(address);
- if (balance != null && balance.compareTo(new BigDecimal("0.1")) > 0) {
- balance = balance.setScale(8, RoundingMode.CEILING);
-
- BigDecimal early = BigDecimal.ZERO;
- MemberCoinChargeEntity chargeEntity = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.USDT.name(), "ERC20");
- if (chargeEntity != null) {
- BigDecimal lastAmount = chargeEntity.getLastAmount();
- if (lastAmount != null) {
- early = lastAmount;
- }
- }
-
- MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
- if (walletCoinEntity == null) {
- continue;
- }
-
- if (balance.compareTo(early) > 0) {
- BigDecimal newBalance = balance.subtract(early);
- memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), newBalance, balance, 0);
-
- String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "ERC20", balance);
- // 插入财务记录
- LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.USDT.name(), 1, 1);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- String amount = newBalance.toPlainString() + "USDT-ERC20";
- 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);
- }
- }
- }
- }
- }
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void updateEth() {
- List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.ETH.name());
- if (CollUtil.isNotEmpty(list)) {
- for (MemberCoinAddressEntity coinAddressEntity : list) {
- String address = coinAddressEntity.getAddress();
- Long memberId = coinAddressEntity.getMemberId();
-
- BigDecimal balance = EthService.getEthBlance(address);
- if (balance != null && new BigDecimal("0.01").compareTo(balance) < 0) {
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.ETH.name());
-
- if (walletCoin == null) {
- continue;
- }
-
- BigDecimal early = BigDecimal.ZERO;
- MemberCoinChargeEntity coinChargeEntity = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.ETH.name(), null);
- if (coinChargeEntity != null) {
- BigDecimal lastAmount = coinChargeEntity.getLastAmount();
- if (lastAmount != null) {
- early = lastAmount;
- }
- }
-
- balance = balance.setScale(8, RoundingMode.CEILING);
- if (balance.compareTo(early) > 0) {
- log.info("#ETH更新:{},{},{}#", memberId, balance, early);
-
- BigDecimal newBalance = balance.subtract(early);
- memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
- String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.ETH.name(), null, balance);
-
- // 插入财务记录
- LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.ETH.name(), 1, 1);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- String amount = newBalance.toPlainString() + "ETH";
- 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);
- }
- }
- }
- }
- }
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void updateBtcUsdt() {
- List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.USDT.name(), "OMNI");
- if (CollUtil.isNotEmpty(list)) {
- UsdtService usdtService = UsdtService.getInstance();
-
- for (MemberCoinAddressEntity coinAddressEntity : list) {
- String address = coinAddressEntity.getAddress();
- Long memberId = coinAddressEntity.getMemberId();
-
- BigDecimal balance = usdtService.getBalance(address);
- if (balance != null && balance.compareTo(new BigDecimal("0.1")) > 0) {
- MemberCoinChargeEntity memberCoinChargeEntity = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.USDT.name(), "OMNI");
- BigDecimal early = BigDecimal.ZERO;
- if (memberCoinChargeEntity != null) {
- BigDecimal lastAmount = memberCoinChargeEntity.getLastAmount();
- if (lastAmount != null) {
- early = lastAmount;
- }
- }
-
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
- if (walletCoin == null) {
- continue;
- }
-
- if (balance.compareTo(early) > 0) {
- BigDecimal newBalance = balance.subtract(early);
-
- memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
- String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "OMNI", balance);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- String amount = newBalance.toPlainString() + "USDT-OMNI";
- 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);
- }
- }
- }
- }
- }
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void updateBtc() {
- List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.BTC.name());
- if (CollUtil.isNotEmpty(list)) {
- BtcService btcService = BtcService.getInstance();
- for (MemberCoinAddressEntity coinAddressEntity : list) {
- String address = coinAddressEntity.getAddress();
- Long memberId = coinAddressEntity.getMemberId();
-
- BigDecimal balance = btcService.getBalance(address);
-
- if (balance != null && balance.compareTo(new BigDecimal("0.00012")) > 0) {
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.BTC.name());
- if (walletCoin == null) {
- continue;
- }
-
- BigDecimal early = BigDecimal.ZERO;
- MemberCoinChargeEntity coinCharge = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.BTC.name(), null);
- if (coinCharge != null) {
- BigDecimal lastAmount = coinCharge.getLastAmount();
- if (lastAmount != null) {
- early = lastAmount;
- }
- }
-
- if (balance.compareTo(early) > 0) {
- log.info("#btc同步:{}, {}, {}#", memberId, balance, early);
- BigDecimal newBalance = balance.subtract(early);
- memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
-
- String orderNo = insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.BTC.name(), null, balance);
- LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.BTC.name(), 1, 1);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- String amount = newBalance.toPlainString() + "BTC";
- 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 void updateEos() {
- // 获取上次读取的序号
- int pos= 0;
- //每次获取的条数
- int offset = 10;
-
- String eosSeq = redisUtils.getString(EOS_SEQ_KEY);
- if(StringUtils.isNotBlank(eosSeq)){
- pos = Integer.valueOf(eosSeq);
- }
- // 记录最大的seq
- int seq = pos;
- List<EosResult> actions = EosService.getActions(pos, offset);
- if(CollectionUtils.isNotEmpty(actions)){
- for(EosResult eosResult:actions){
- String to = eosResult.getTo();
- Integer accountActionSeq = eosResult.getAccountActionSeq();
- if(accountActionSeq>seq){
- seq = accountActionSeq;
- }
- if(!EosService.ACCOUNT.equals(to)){
- // 判断是否是收款
- continue;
- }
- // 处理收款
- String quantity = eosResult.getQuantity();
- String memo = eosResult.getMemo();
- if(StringUtils.isBlank(memo)){
- // 没有标记的跳过
- continue;
- }
- if(StringUtils.isNotBlank(quantity)){
- // 转账额
- String amountStr = quantity.split("")[0];
- BigDecimal amount = new BigDecimal(amountStr);
- List<MemberCoinAddressEntity> memberCoinAddress = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.EOS.name(), memo);
- if(CollectionUtils.isNotEmpty(memberCoinAddress)){
- MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddress.get(0);
- // 用户ID
- Long memberId = memberCoinAddressEntity.getMemberId();
- MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.EOS.name());
- if(memberCoinAddressEntity!=null){
- memberWalletCoinDao.updateBlockBalance(memberWalletCoinEntity.getId(),amount,BigDecimal.ZERO,0);
- // 添加冲币记录
- String orderNo = insertCoinCharge(EosService.ACCOUNT,memberId,amount,CoinTypeEnum.EOS.name(),memo,BigDecimal.ZERO);
- LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", amount, CoinTypeEnum.EOS.name(), 1, 1);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- //String amountEos = amountStr + "EOS";
- 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);
- }
- }
- }
- }
- }
- }
- // 最后更新seq 即下次查询的起始位置 在本次最大的基础上加一
- if(seq>0 && seq>pos){
- redisUtils.set(EOS_SEQ_KEY,seq+1);
- }
- }
-
- public void updateXrp() {
- // 首先去查redis上的上次同步时间
- Object lastUpdateTime = redisUtils.get(xrp_update_key);
- SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");
- Date start =null;
- if(lastUpdateTime==null) {
- // 没有 说明是第一次同步 此时从第一天开始同步2020 0716开始
- try {
- start = format.parse("2020-07-16 12:00:00");
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }else {
- // 有上次时间
- try {
- start = format.parse(lastUpdateTime.toString());
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
-
- // 去查询上次同步时间后的所有记录
- XrpTransResult result = XrpService.getTransactions(start);
- // 写入本次更新时间
- String updateTime = format.format(new Date());
- redisUtils.set(xrp_update_key, updateTime);
- // 判断有无
- List<XrpTransactions> list = result.getTransactions();
- if(CollectionUtils.isNotEmpty(list)) {
- // 不为空 说明有转入记录
- for(XrpTransactions item:list) {
- XrpTx data = item.getTx();
- Integer amountOld = data.getAmount();
- // 除以1000000
- BigDecimal amount = new BigDecimal(amountOld).divide(new BigDecimal(1000000));
- Integer memoInt = data.getDestinationTag();
- // 没有标签直接返回
- if(memoInt==null){
- continue;
- }
- String memo = memoInt.toString();
- String destination = data.getDestination();
- // 判断收款人是不是系统账号
- if(!XrpService.ACCOUNT.equals(destination)){
- continue;
- }
- List<MemberCoinAddressEntity> memberCoinAddress = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.XRP.name(), memo);
- if(CollectionUtils.isNotEmpty(memberCoinAddress)){
- MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddress.get(0);
- // 用户ID
- Long memberId = memberCoinAddressEntity.getMemberId();
- MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XRP.name());
- if(memberCoinAddressEntity!=null){
- memberWalletCoinDao.updateBlockBalance(memberWalletCoinEntity.getId(),amount,BigDecimal.ZERO,0);
- // 添加冲币记录
- String orderNo = insertCoinCharge(XrpService.ACCOUNT,memberId,amount,CoinTypeEnum.XRP.name(),memo,BigDecimal.ZERO);
- LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", amount, CoinTypeEnum.XRP.name(), 1, 1);
-
- ThreadPoolUtils.sendDingTalk(5);
- MemberEntity member = memberDao.selectById(memberId);
- if (StrUtil.isNotBlank(member.getPhone())) {
- //String amountEos = amount + "XRP";
- 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);
- }
- }
- }
-
- }
- }
-
- }
-
- private String generateNo() {
- // 生成订单号
- Long timestamp = System.currentTimeMillis();
- // 随机数
- int random = (int) (Math.random() * 10);
- return String.valueOf(timestamp).substring(2) + random;
- }
-
- public String insertCoinCharge(String address, Long memberId, BigDecimal newBalance, String symbol, String tag, BigDecimal lastAmount) {
- MemberCoinChargeEntity memberCoinChargeEntity = new MemberCoinChargeEntity();
- memberCoinChargeEntity.setAddress(address);
- memberCoinChargeEntity.setMemberId(memberId);
- memberCoinChargeEntity.setAmount(newBalance);
- memberCoinChargeEntity.setSymbol(symbol);
- memberCoinChargeEntity.setTag(tag);
- memberCoinChargeEntity.setStatus(1);
- memberCoinChargeEntity.setLastAmount(lastAmount);
- String orderNo = generateNo();
- memberCoinChargeEntity.setOrderCode(orderNo);
- memberCoinChargeDao.insert(memberCoinChargeEntity);
- return orderNo;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
deleted file mode 100644
index e7ddaae..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
+++ /dev/null
@@ -1,577 +0,0 @@
-package com.xcong.excoin.modules.coin.service.impl;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
-import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-import com.xcong.excoin.modules.coin.mapper.MemberAccountMoneyChangeMapper;
-import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
-import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAgentIntoInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
-import com.xcong.excoin.modules.coin.service.CoinService;
-import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
-import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-
-@Service
-public class CoinServiceImpl extends ServiceImpl<MemberWalletCoinDao, MemberWalletCoinEntity> implements CoinService {
-
- //@Resource
- //SymbolsService symbolsService;
- @Resource
- PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao;
- @Resource
- MemberWalletCoinDao memberWalletCoinDao;
- @Resource
- MemberWalletContractDao memberWalletContractDao;
- @Resource
- MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
- @Resource
- MemberWalletAgentDao memberWalletAgentDao;
- @Resource
- RedisUtils redisUtils;
-
-
- @Override
- public Result getWalletCoin() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-
- BigDecimal totalUsdts = BigDecimal.ZERO;
- if (!StrUtil.isEmpty(memberId.toString())) {
-
- List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
- List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
-
- if (CollUtil.isNotEmpty(memberWalletCoinlist)) {
- for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
- MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
- memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
- memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
- memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
- }
- }
-
- if (CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) {
- for (MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) {
- if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
- BigDecimal totalUsdt = BigDecimal.ZERO;
- totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
- totalUsdts = totalUsdts.add(totalUsdt);
- BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
- walletCoin.setTotalBalance(totalCny);
- } else {
- BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
- // 获取最新价
- BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
- BigDecimal totalUsdt = BigDecimal.ZERO;
- //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(walletCoin.getWalletCode()+"/USDT");
- totalUsdt = totalUsdt.add(amount.multiply(closePrice));
- totalUsdts = totalUsdts.add(totalUsdt);
- walletCoin.setTotalBalance(totalUsdt.multiply(cnyUsdt));
- }
- }
- }
- MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
- memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist);
- return Result.ok(memberWalletCoinVo);
- } else {
- List<MemberWalletCoinInfoVo> memberWalletCoinlist = new ArrayList<MemberWalletCoinInfoVo>();
- MemberWalletCoinInfoVo coin = new MemberWalletCoinInfoVo();
- coin.setAvailableBalance(BigDecimal.ZERO);
- coin.setTotalBalance(BigDecimal.ZERO);
- coin.setFrozenBalance(BigDecimal.ZERO);
- coin.setWalletCode(CoinTypeEnum.BTC.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.ETH.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.LTC.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.BCH.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.USDT.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.EOS.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.XRP.toString());
- memberWalletCoinlist.add(coin);
- coin.setWalletCode(CoinTypeEnum.ETC.toString());
- memberWalletCoinlist.add(coin);
-
- MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
- memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinlist);
- return Result.ok(memberWalletCoinVo);
- }
- }
-
- @Override
- public Result getWalletCoinBySymbol(String symbol) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
- MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
- memberWalletCoinInfoVo.setFrozenBalance(walletCoin.getFrozenBalance());
- memberWalletCoinInfoVo.setAvailableBalance(walletCoin.getAvailableBalance());
- memberWalletCoinInfoVo.setMemberId(memberId);
- memberWalletCoinInfoVo.setWalletCode(symbol);
- if (!StrUtil.isEmpty(memberId.toString())) {
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
- BigDecimal total = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
-
- if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
- memberWalletCoinInfoVo.setTotalBalance(total.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-
- } else {
- BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol+"/USDT")));
- //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(wallet.getCode()+"/USDT");
- memberWalletCoinInfoVo.setTotalBalance(total.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- }
- }
- return Result.ok(memberWalletCoinInfoVo);
- }
-
- @Override
- public Result getWalletContractById() {
-
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- if (ObjectUtil.isEmpty(walletContract)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0001"));
- }
-
- MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
- memberWalletContractInfoVo.setFrozenBalance(walletContract.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletContractInfoVo.setAvailableBalance(walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletContractInfoVo.setTotalBalance(walletContract.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletContractInfoVo.setTotalRMBBalance(walletContract.getTotalBalance().multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-
- return Result.ok(memberWalletContractInfoVo);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Result coinWalletTransferToContract(BigDecimal balance, String symbol) {
- if (balance.compareTo(BigDecimal.ZERO) <= 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0004"));
- }
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- if (!StrUtil.isEmpty(memberId.toString())) {
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
- BigDecimal available = walletCoin.getAvailableBalance();
- // 扣币
- BigDecimal total = available.subtract(balance);
- if (total.compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0005"));
- }
- BigDecimal subtract = walletCoin.getTotalBalance().subtract(balance);
- walletCoin.setAvailableBalance(total);
- walletCoin.setTotalBalance(subtract);
- int updateWalletCoinById = memberWalletCoinDao.updateById(walletCoin);
- if (updateWalletCoinById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0096"));
- }
- // 加币
- // 查询合约账户
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- BigDecimal availableBalance = walletContract.getAvailableBalance();
- BigDecimal add = availableBalance.add(balance);
- walletContract.setAvailableBalance(add);
- BigDecimal totalBalance = walletContract.getTotalBalance();
- BigDecimal totalBigDecimal = totalBalance.add(balance);
- walletContract.setTotalBalance(totalBigDecimal);
- int updateWalletContractById = memberWalletContractDao.updateById(walletContract);
- if (updateWalletContractById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0096"));
- }
- //添加币币资金划转历史记录
- MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
- memberAccountRecord.setMemberId(memberId);
- memberAccountRecord.setAmount(balance.negate());
- memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
- memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
-
- //添加合约资金划转历史记录
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMWALLETCOIN.getValue());
- memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
- memberAccountRecord.setAmount(balance);
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
- }
- return Result.ok(MessageSourceUtils.getString("member_service_0006"));
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Result contractTransferToWalletCoin(BigDecimal balance, String symbol) {
- if (balance.compareTo(BigDecimal.ZERO) <= 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0004"));
- }
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- BigDecimal availableBalance = walletContract.getAvailableBalance();
- // 扣币
- BigDecimal availableSubtract = availableBalance.subtract(balance);
- if (availableSubtract.compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0007"));
- }
- BigDecimal totalBalance = walletContract.getTotalBalance();
- BigDecimal totalSubtract = totalBalance.subtract(balance);
-
- walletContract.setAvailableBalance(availableSubtract);
- walletContract.setTotalBalance(totalSubtract);
- int updateWalletCoinById = memberWalletContractDao.updateById(walletContract);
- if (updateWalletCoinById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0096"));
- }
- // 加币
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
- BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
- BigDecimal CoinAvailableBalance = walletCoinAvailableBalance.add(balance);
- BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
- BigDecimal CoinTotalBalance = walletCoinTotalBalance.add(balance);
-
- walletCoin.setAvailableBalance(CoinAvailableBalance);
- walletCoin.setTotalBalance(CoinTotalBalance);
- int updateById = memberWalletCoinDao.updateById(walletCoin);
- if (updateById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0096"));
- }
-
- //添加资金划转历史记录
- MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
- memberAccountRecord.setMemberId(memberId);
- memberAccountRecord.setAmount(balance.negate());
- memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
- memberAccountRecord.setSymbol(walletCode);
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
-
- //添加资金划转历史记录
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMCONTRACT.getValue());
- memberAccountRecord.setSymbol(walletCode);
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
- memberAccountRecord.setAmount(balance);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
- return Result.ok(MessageSourceUtils.getString("member_service_0006"));
- }
-
- @Override
- public Result findWalletContractBySymbol() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- BigDecimal availableBalance = walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
- return Result.ok(availableBalance);
- }
-
- @Override
- public Result findWalletCoinBySymbol(String symbol) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
- BigDecimal availableBalance = walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
- return Result.ok(availableBalance);
- }
-
- @Override
- public Result getWalletCoinRecords(RecordsPageDto recordsPageDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
- MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
- memberAccountMoneyChange.setMemberId(memberId);
- IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletCoinRecordsInPage(page, memberAccountMoneyChange);
- Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
-
- return Result.ok(pageEntityToPageVo);
- }
-
- @Override
- public Result getWalletContractRecords(RecordsPageDto recordsPageDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
- MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
- memberAccountMoneyChange.setMemberId(memberId);
- IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletContractRecordsInPage(page, memberAccountMoneyChange);
- Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
- return Result.ok(pageEntityToPageVo);
- }
-
- @Override
- public Result getWalletAgentRecords(RecordsPageDto recordsPageDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
- MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
- memberAccountMoneyChange.setMemberId(memberId);
- IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentRecordsInPage(page, memberAccountMoneyChange);
- Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
-
- return Result.ok(pageEntityToPageVo);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype) {
- if (balance.compareTo(BigDecimal.ZERO) <= 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0004"));
- }
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- // 扣币
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
- BigDecimal availableBalance = walletAgent.getAvailableBalance();
- BigDecimal totalBalance = walletAgent.getTotalBalance();
-
- BigDecimal available = availableBalance.subtract(balance);
- if (available.compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0008"));
- }
- BigDecimal total = totalBalance.subtract(balance);
- if (total.compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0008"));
- }
-
- walletAgent.setAvailableBalance(available);
- walletAgent.setTotalBalance(total);
-
- int i = memberWalletAgentDao.updateById(walletAgent);
- if (i < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0095"));
- }
- //添加资金划转历史记录
- MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
- //代理账户转币币
- if (MemberAccountMoneyChange.TYPE_WALLET_COIN.equals(transfertype)) {
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
- BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
- BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
-
- walletCoin.setAvailableBalance(walletCoinAvailableBalance.add(balance));
- walletCoin.setTotalBalance(walletCoinTotalBalance.add(balance));
-
- int updateById = memberWalletCoinDao.updateById(walletCoin);
- if (updateById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0095"));
- }
- //添加资金划转历史记录
- memberAccountRecord.setMemberId(memberId);
- memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
- memberAccountRecord.setSymbol(walletCode);
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
- memberAccountRecord.setAmount(balance);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
-
- } else if (MemberAccountMoneyChange.TYPE_WALLET_CONTRACT.equals(transfertype)) {
- //代理账户转合约
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- BigDecimal walletContractAvailableBalance = walletContract.getAvailableBalance();
- BigDecimal walletContractTotalBalance = walletContract.getTotalBalance();
-
- walletContract.setAvailableBalance(walletContractAvailableBalance.add(balance));
- walletContract.setTotalBalance(walletContractTotalBalance.add(balance));
-
- int updateById = memberWalletContractDao.updateById(walletContract);
- if (updateById < 1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0095"));
- }
-
- //添加资金划转历史记录
- memberAccountRecord.setMemberId(memberId);
- memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
- memberAccountRecord.setSymbol(walletCode);
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
- memberAccountRecord.setAmount(balance);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
- memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
- }
- memberAccountRecord.setAmount(balance.negate());
- memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
- memberAccountMoneyChangeDao.insert(memberAccountRecord);
-
- return Result.ok(MessageSourceUtils.getString("member_service_0006"));
- }
-
- @Override
- public Result findWalletAgentBySymbol() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-
- MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
- BigDecimal availableBalance = walletAgent.getAvailableBalance();
-
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
- BigDecimal multiply = availableBalance.multiply(cnyUsdt);
-
- MemberWalletAgentInfoVo memberWalletAgentInfoVo = new MemberWalletAgentInfoVo();
- memberWalletAgentInfoVo.setTotalBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletAgentInfoVo.setTotalRMBBalance(multiply.setScale(4, BigDecimal.ROUND_DOWN));
- return Result.ok(memberWalletAgentInfoVo);
- }
-
- @Override
- public Result getWalletAgentIntoRecords(RecordsPageDto recordsPageDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
- MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
- memberAccountMoneyChange.setMemberId(memberId);
- IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(page, memberAccountMoneyChange);
- List<MemberAccountMoneyChange> contractRecordList = list.getRecords();
- List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
- if(CollUtil.isNotEmpty(contractRecordList)) {
- if (ObjectUtil.isNotNull(contractRecordList)) {
- for (MemberAccountMoneyChange memberAccountMoneyChanges : contractRecordList) {
- MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
- memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChanges.getAmount());
- memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChanges.getContent());
- memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChanges.getStatus());
- memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChanges.getSymbol());
- memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChanges.getType());
- memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
- arrayList.add(memberAccountMoneyChangeInfoVo);
- }
- }
- }
- Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = new Page<>();
- pageEntityToPageVo.setRecords(arrayList);
-
- return Result.ok(pageEntityToPageVo);
- }
-
- @Override
- public Result getAllWalletCoin() {
- //获取【币币】
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
- AllWalletCoinVo allWalletCoinVo = new AllWalletCoinVo();
-
- BigDecimal totalUsdts = BigDecimal.ZERO;
- if (!StrUtil.isEmpty(memberId.toString())) {
-
- List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
- List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
-
- if (CollUtil.isNotEmpty(memberWalletCoinlist)) {
- for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
- MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
- memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
- memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
- memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
- }
- }
-
- if (CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) {
- for (MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) {
- if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
- BigDecimal totalUsdt = BigDecimal.ZERO;
- totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
- totalUsdts = totalUsdts.add(totalUsdt);
- } else {
- BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
- // 获取最新价
- BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
- BigDecimal totalUsdt = BigDecimal.ZERO;
- totalUsdt = totalUsdt.add(amount.multiply(closePrice));
- totalUsdts = totalUsdts.add(totalUsdt);
- }
- }
- }
- }
- allWalletCoinVo.setWalletUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
- //获取【合约】
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
- if (ObjectUtil.isEmpty(walletContract)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0001"));
- }
- allWalletCoinVo.setContractUsdt(walletContract.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
- totalUsdts = totalUsdts.add(walletContract.getTotalBalance());
- //获取【代理】
- MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
- BigDecimal availableBalance = walletAgent.getAvailableBalance();
- allWalletCoinVo.setAgentUsdt(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
- totalUsdts = totalUsdts.add(availableBalance);
-
- allWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
- allWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- return Result.ok(allWalletCoinVo);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
deleted file mode 100644
index c96299f..0000000
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
+++ /dev/null
@@ -1,641 +0,0 @@
-package com.xcong.excoin.modules.coin.service.impl;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import com.xcong.excoin.modules.coin.mapper.OrderCoinsDealMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao;
-import com.xcong.excoin.modules.coin.dao.MemberSelectSymbolsDao;
-import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao;
-import com.xcong.excoin.modules.coin.dao.OrderCoinsDao;
-import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
-import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
-import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinDealMapper;
-import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinMapper;
-import com.xcong.excoin.modules.coin.parameter.dto.FindAllWalletCoinOrderDto;
-import com.xcong.excoin.modules.coin.parameter.vo.FindCollectListVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinListVo;
-import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo;
-import com.xcong.excoin.modules.coin.parameter.vo.TransactionPageOfWalletCoinVo;
-import com.xcong.excoin.modules.coin.service.OrderCoinService;
-import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
-import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao;
-import com.xcong.excoin.modules.platform.dao.TradeSettingDao;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.core.util.StrUtil;
-
-@Service
-public class OrderCoinServiceImpl extends ServiceImpl<OrderCoinsDao, OrderCoinsEntity> implements OrderCoinService {
-
- @Resource
- TradeSettingDao platformTradeSettingDao;
- @Resource
- MemberWalletCoinDao memberWalletCoinDao;
- @Resource
- MemberSelectSymbolsDao memberSelectSymbolsDao;
- @Resource
- PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao;
- @Resource
- OrderCoinsDao orderCoinsDao;
- @Resource
- OrderCoinDealDao orderCoinDealDao;
- @Resource
- MemberAccountFlowEntityDao memberAccountFlowEntityDao;
- @Resource
- RedisUtils redisUtils;
- @Resource
- PlatformSymbolsCoinDao platformSymbolsCoinDao;
-
- @Override
- public String generateSimpleSerialno(String userId) {
- StringBuilder sb = new StringBuilder();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
- Date now = new Date();
- sb.append(sd.format(now));
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(now);
- calendar.add(calendar.DATE, 1);
- Date nextDate = calendar.getTime();
- if (StrUtil.isNotEmpty(userId)) {
- sb.append(userId);
- }
- sb.append(RandomUtil.randomInt(2));
- long count = orderCoinsDao.getOrderCountByToday(sdf.format(now), sdf.format(nextDate));
- count++;
- int size = 4;
- for (int i = 0; i < size - String.valueOf(count).length(); i++) {
- sb.append("0");
- }
- sb.append(count);
- return sb.toString();
- }
-
- @Override
- public Result enterTransactionPageOfWalletCoin(String symbol) {
- if (StrUtil.isBlank(symbol)) {
- return Result.fail(MessageSourceUtils.getString("order_service_0001"));
- }
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- //获取该币种的币币账户信息
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
-
- PlatformTradeSettingEntity tradeSetting = platformTradeSettingDao.findTradeSetting();
- if (ObjectUtil.isEmpty(tradeSetting)) {
- return Result.fail(MessageSourceUtils.getString("order_service_0003"));
- }
- //获取USDT的币币账户信息
- MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId,
- MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-
- BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
-
- List<MemberSelectSymbolsEntity> memSymbols = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol);
-
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
- BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
- TransactionPageOfWalletCoinVo transactionPageOfWalletCoinVo = new TransactionPageOfWalletCoinVo();
- //是否自选
- if (CollUtil.isEmpty(memSymbols)) {
- transactionPageOfWalletCoinVo.setIsCollect(TransactionPageOfWalletCoinVo.ISCOLLECT_NO);
- } else {
- transactionPageOfWalletCoinVo.setIsCollect(TransactionPageOfWalletCoinVo.ISCOLLECT_YES);
- }
- if (ObjectUtil.isEmpty(walletCoin))
- return Result.fail(MessageSourceUtils.getString("order_service_0003"));
- // 点差
- transactionPageOfWalletCoinVo.setSpread(tradeSetting.getSpread().setScale(4, BigDecimal.ROUND_DOWN));
- // 手续费用率
- transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getCoinFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
- // 用户可用金额
- transactionPageOfWalletCoinVo.setAvailableBalanceBuy(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- transactionPageOfWalletCoinVo.setAvailableBalanceSell(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- //当前价
- transactionPageOfWalletCoinVo.setCurrentPrice(closePrice.setScale(4, BigDecimal.ROUND_DOWN));
- //比例
- transactionPageOfWalletCoinVo.setCnyUsdt(cnyUsdt.setScale(4, BigDecimal.ROUND_DOWN));
- //换算成人民币的币种价格
- transactionPageOfWalletCoinVo.setCurrentPriceCny(cnyUsdt.multiply(closePrice).setScale(4, BigDecimal.ROUND_DOWN));
-
- transactionPageOfWalletCoinVo.setSymbol(symbol);
- return Result.ok(transactionPageOfWalletCoinVo);
- }
-
- @Override
- @Transactional
- public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price, BigDecimal amount) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- BigDecimal nowPriceinBigDecimal = price;
- //查询当前价
- BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
-
- // 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
- symbol = symbol.toUpperCase();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
- if (ObjectUtil.isEmpty(walletCoin)) {
- return Result.fail(MessageSourceUtils.getString("order_service_0003"));
- }
- // 查询交易设置
- PlatformTradeSettingEntity tradeSetting = platformTradeSettingDao.findTradeSetting();
- if (ObjectUtil.isEmpty(tradeSetting)) {
- return Result.fail(MessageSourceUtils.getString("order_service_0009"));
- }
- // 手续费用(手续费=建仓价X数量X手续费率)
- BigDecimal closingPrice = price.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
- //总费用 = 成交价*数量+手续费
- BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice);
- BigDecimal totalPayPricCoin = nowPrice.multiply(amount).add(closingPrice);
-
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
- //买入,所需总费用跟用户USDT金额进行比较
- BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance();
- if (totalPayPrice.compareTo(availableBalance) > 0 || totalPayPricCoin.compareTo(availableBalance) > 0) {
- return Result.fail(MessageSourceUtils.getString("order_service_0010"));
- }
- } else {
- //卖出,所需总费用跟用户所对应的币种金额进行比较
- BigDecimal availableBalance = walletCoin.getAvailableBalance();
- if (amount.compareTo(availableBalance) > 0) {
- return Result.fail(MessageSourceUtils.getString("order_service_0010"));
- }
- }
-
- // 创建订单
- OrderCoinsEntity order = new OrderCoinsEntity();
- if ((OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(1) && price.compareTo(nowPrice) < 0)
- || (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(2) && price.compareTo(nowPrice) > 0)) {
- // 如果是限价交易直接插入主表数据
- order.setMemberId(memberId);
- order.setOrderNo(generateSimpleSerialno(memberId.toString()));
- order.setOrderType(type);
- order.setSymbol(symbol);
- order.setMarkPrice(nowPrice);
- order.setEntrustCnt(amount);
- order.setEntrustPrice(price);
- order.setDealCnt(amount);
- order.setDealPrice(price);
- order.setDealAmount(totalPayPrice);
- order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DODING);
- order.setTradeType(tradeType);
- order.setFeeAmount(closingPrice);
- orderCoinsDao.insert(order);
-
- //更新用户钱包信息
- //冻结相应的资产
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
- //如果是买入,所对应的币种增加,USDT账户减少金额
- BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice);
- BigDecimal frozenBalance = walletCoinUsdt.getFrozenBalance().add(totalPayPrice);
- walletCoinUsdt.setAvailableBalance(availableBalance);
- walletCoinUsdt.setFrozenBalance(frozenBalance);
- memberWalletCoinDao.updateById(walletCoinUsdt);
- } else {
- //如果是卖出,币种减少,USDT增加
- BigDecimal availableBalance = walletCoin.getAvailableBalance().subtract(amount);
- BigDecimal frozenBalance = walletCoin.getFrozenBalance().add(amount);
- walletCoin.setAvailableBalance(availableBalance);
- walletCoin.setFrozenBalance(frozenBalance);
- memberWalletCoinDao.updateById(walletCoin);
- }
- } else {
- //如果是市价交易,主表和附表都需要插入数据
- order.setMemberId(memberId);
- order.setOrderNo(generateSimpleSerialno(memberId.toString()));
- order.setOrderType(type);
- order.setSymbol(symbol);
- order.setMarkPrice(nowPrice);
- order.setEntrustCnt(amount);
- order.setEntrustPrice(price);
- order.setDealCnt(amount);
- if ((OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(1) && price.compareTo(nowPrice) >= 0)
- || (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(2) && price.compareTo(nowPrice) <= 0)) {
- // 手续费用(手续费=建仓价X数量X手续费率)
- closingPrice = nowPrice.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
- //总费用 = 成交价*数量+手续费
- totalPayPrice = nowPrice.multiply(amount).add(closingPrice);
- price = nowPrice;
- }
- order.setDealPrice(nowPrice);
- order.setDealAmount(totalPayPrice);
- order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE);
- order.setTradeType(tradeType);
- order.setFeeAmount(closingPrice);
- orderCoinsDao.insert(order);
-
- OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
- detail.setMemberId(memberId);
- detail.setOrderId(order.getId());
- detail.setOrderNo(order.getOrderNo());
- detail.setOrderType(type);
- detail.setTradeType(tradeType);
- detail.setSymbol(symbol);
- detail.setSymbolCnt(amount);
- detail.setEntrustPrice(nowPriceinBigDecimal);
- detail.setDealPrice(nowPrice);
- detail.setDealAmount(totalPayPrice);
- detail.setFeeAmount(closingPrice);
- detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
- orderCoinDealDao.insert(detail);
-
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
- //如果是买入,所对应的币种增加,USDT账户减少金额
- // 更新用户的可用金额
- walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(amount));
- memberWalletCoinDao.updateById(walletCoin);
-
- walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice));
- memberWalletCoinDao.updateById(walletCoinUsdt);
- } else {
- //如果是卖出,币种减少,USDT增加
- walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().subtract(amount));
- memberWalletCoinDao.updateById(walletCoin);
-
- BigDecimal subtract = totalPayPrice.subtract(closingPrice).subtract(closingPrice);
- walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(subtract));
- memberWalletCoinDao.updateById(walletCoinUsdt);
- }
- }
- // 流水记录
- MemberAccountFlowEntity record = new MemberAccountFlowEntity();
- record.setMemberId(memberId);
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
- record.setPrice(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
- record.setSource(MemberAccountFlowEntity.SOURCE_BUY + symbol);
- record.setRemark(MemberAccountFlowEntity.REMARK_BUY + symbol + ":" + amount);
- } else {
- record.setPrice(totalPayPrice.negate().setScale(4, BigDecimal.ROUND_DOWN));
- record.setSource(MemberAccountFlowEntity.SOURCE_SALE + symbol);
- record.setRemark(MemberAccountFlowEntity.REMARK_SALE + symbol + ":" + amount);
- }
- record.setSymbol(symbol);
- record.setBalance(walletCoinUsdt.getAvailableBalance());
-
- memberAccountFlowEntityDao.insert(record);
-
- return Result.ok(MessageSourceUtils.getString("order_service_0011"));
- }
-
- @Override
- public Result getEntrustWalletCoinOrder(String symbol, Integer status) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- OrderWalletCoinListVo orderWalletCoinListVo = new OrderWalletCoinListVo();
-
- List<OrderWalletCoinVo> arrayList = new ArrayList<>();
- List<OrderCoinsEntity> findCoinOrderListByMemberIdAndSysmbol = orderCoinsDao.findCoinOrderListByMemberIdAndSysmbol(memberId, symbol, status);
- if (CollUtil.isNotEmpty(findCoinOrderListByMemberIdAndSysmbol)) {
- for (OrderCoinsEntity orderCoinsEntity : findCoinOrderListByMemberIdAndSysmbol) {
- OrderWalletCoinVo entityToVo = OrderWalletCoinMapper.INSTANCE.entityToVo(orderCoinsEntity);
- entityToVo.setFeeAmount(entityToVo.getFeeAmount()== null
- ? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setMarkPrice(entityToVo.getMarkPrice()== null
- ? BigDecimal.ZERO : entityToVo.getMarkPrice().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setEntrustCnt(entityToVo.getEntrustCnt()== null
- ? BigDecimal.ZERO : entityToVo.getEntrustCnt().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setEntrustPrice(entityToVo.getEntrustPrice()== null
- ? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setDealCnt(entityToVo.getDealCnt()== null
- ? BigDecimal.ZERO : entityToVo.getDealCnt().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setDealPrice(entityToVo.getDealPrice()== null
- ? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
- entityToVo.setDealAmount(entityToVo.getDealAmount()== null
- ? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
- arrayList.add(entityToVo);
- }
- }
- orderWalletCoinListVo.setOrderWalletCoinVo(arrayList);
- return Result.ok(arrayList);
- }
-
- @Override
- @Transactional
- public Result cancelEntrustWalletCoinOrder(String orderId) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- OrderCoinsEntity orderCoinsEntity = orderCoinsDao.selectById(orderId);
- if (ObjectUtil.isNotEmpty(orderCoinsEntity) && orderCoinsEntity.getMemberId() == memberId) {
- if (orderCoinsEntity.getOrderStatus() == OrderCoinsEntity.ORDERSTATUS_CANCEL) {
- return Result.fail(MessageSourceUtils.getString("order_service_0012"));
- }
- orderCoinsEntity.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_CANCEL);
- orderCoinsDao.updateById(orderCoinsEntity);
-
- String symbol = orderCoinsEntity.getSymbol();
-
- OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
- detail.setMemberId(memberId);
- detail.setOrderId(orderCoinsEntity.getId());
- detail.setOrderNo(generateSimpleSerialno(memberId.toString()));
- detail.setOrderType(orderCoinsEntity.getOrderType());
- detail.setTradeType(orderCoinsEntity.getTradeType());
- detail.setSymbol(symbol);
- detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_CANCEL);
- detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt());
- detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice());
- detail.setDealPrice(orderCoinsEntity.getDealPrice());
- detail.setDealAmount(orderCoinsEntity.getDealAmount());
- detail.setFeeAmount(orderCoinsEntity.getFeeAmount());
- orderCoinDealDao.insert(detail);
-
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
- //如果是限价买入,撤单将USDT账户冻结金额返回
- String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
-
- if (ObjectUtil.isNotEmpty(walletCoin)) {
- //手续费 = 开仓价*数量*手续费率
- //返还金额=开仓价*未成交数量+手续费
- BigDecimal returnBalance = orderCoinsEntity.getDealAmount();
-
- walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance));
- walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance));
- memberWalletCoinDao.updateById(walletCoin);
- // 流水记录
- MemberAccountFlowEntity record = new MemberAccountFlowEntity();
- record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL);
- record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL + symbol + MemberAccountFlowEntity.REMARK_RETURNBALANCE + returnBalance);
- record.setBalance(walletCoin.getAvailableBalance());
- record.setMemberId(memberId);
- record.setSymbol(symbol);
- record.setPrice(returnBalance);
- memberAccountFlowEntityDao.insert(record);
- return Result.ok(MessageSourceUtils.getString("order_service_0013"));
- }
- } else {
- //如果是限价卖出,撤单将对应的钱包冻结金额返回
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
- if (ObjectUtil.isNotEmpty(walletCoin)) {
-
- BigDecimal returnBalance = orderCoinsEntity.getEntrustCnt();
- walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance));
- walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance));
- memberWalletCoinDao.updateById(walletCoin);
- // 流水记录
- MemberAccountFlowEntity record = new MemberAccountFlowEntity();
- record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL);
- record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL + symbol + MemberAccountFlowEntity.REMARK_RETURNBALANCE + returnBalance);
- record.setBalance(walletCoin.getAvailableBalance());
- record.setMemberId(memberId);
- record.setSymbol(symbol);
- record.setPrice(walletCoin.getFrozenBalance());
- memberAccountFlowEntityDao.insert(record);
- return Result.ok(MessageSourceUtils.getString("order_service_0013"));
- }
- }
- }
- return Result.fail(MessageSourceUtils.getString("order_service_0043"));
- }
-
- @Override
- public Result findAllWalletCoinOrder(FindAllWalletCoinOrderDto findAllWalletCoinOrderDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
- Page<OrderCoinsDealEntity> page = new Page<>(findAllWalletCoinOrderDto.getPageNum(), findAllWalletCoinOrderDto.getPageSize());
- OrderCoinsDealEntity orderCoinsDealEntity = new OrderCoinsDealEntity();
- orderCoinsDealEntity.setMemberId(memberId);
- orderCoinsDealEntity.setSymbol(findAllWalletCoinOrderDto.getSymbol());
- IPage<OrderCoinsDealEntity> list = orderCoinDealDao.findAllWalletCoinOrderInPage(page, orderCoinsDealEntity);
- Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list);
- List<OrderWalletCoinDealVo> records = pageEntityToPageVo.getRecords();
- if(CollUtil.isNotEmpty(records)) {
- for(OrderWalletCoinDealVo orderWalletCoinDealVo : records) {
- orderWalletCoinDealVo.setFeeAmount(orderWalletCoinDealVo.getFeeAmount() == null
- ? BigDecimal.ZERO : orderWalletCoinDealVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
-
- orderWalletCoinDealVo.setDealAmount(orderWalletCoinDealVo.getDealAmount() == null
- ? BigDecimal.ZERO : orderWalletCoinDealVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-
- orderWalletCoinDealVo.setSymbolCnt(orderWalletCoinDealVo.getSymbolCnt() == null
- ? BigDecimal.ZERO : orderWalletCoinDealVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN));
-
- orderWalletCoinDealVo.setEntrustPrice(orderWalletCoinDealVo.getEntrustPrice() == null
- ? BigDecimal.ZERO : orderWalletCoinDealVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-
- orderWalletCoinDealVo.setDealPrice(orderWalletCoinDealVo.getDealPrice() == null
- ? BigDecimal.ZERO : orderWalletCoinDealVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
- }
- }
-
-
- return Result.ok(pageEntityToPageVo);
- }
-
- @Override
- public Result findWalletCoinOrder(Long orderId) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- OrderCoinsDealEntity selectWalletCoinOrder = orderCoinDealDao.selectWalletCoinOrder(orderId, memberId);
- OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(selectWalletCoinOrder);
- if(ObjectUtil.isNotEmpty(entityToVo)) {
- entityToVo.setFeeAmount(entityToVo.getFeeAmount() == null
- ? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
-
- entityToVo.setDealAmount(entityToVo.getDealAmount() == null
- ? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-
- entityToVo.setSymbolCnt(entityToVo.getSymbolCnt() == null
- ? BigDecimal.ZERO : entityToVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN));
-
- entityToVo.setEntrustPrice(entityToVo.getEntrustPrice() == null
- ? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-
- entityToVo.setDealPrice(entityToVo.getDealPrice() == null
- ? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
- }
- return Result.ok(entityToVo);
- }
-
- @Override
- public Result findCollect(String symbol, Integer type) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- if (type == 1) {
- //添加自选
- MemberSelectSymbolsEntity symbols = new MemberSelectSymbolsEntity();
- symbols.setMemberId(memberId);
- symbols.setSymbol(symbol);
- memberSelectSymbolsDao.insert(symbols);
- return Result.ok(MessageSourceUtils.getString("order_service_0015"));
- } else {
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("symbol", symbol);
- columnMap.put("member_id", memberId);
- memberSelectSymbolsDao.deleteByMap(columnMap);
- ;
- return Result.ok(MessageSourceUtils.getString("order_service_0016"));
- }
- }
-
- @Override
- public Result checkIsCollect(String symbol) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
- List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol);
-
- if (CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) {
- memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES);
- } else {
- memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO);
- }
- memberSelectSymbolsVo.setSymbol(symbol);
- return Result.ok(memberSelectSymbolsVo);
- }
-
- @Override
- public Result findCollectList() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- List<MemberSelectSymbolsEntity> selectByMap = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
-
- FindCollectListVo findCollectListVo = new FindCollectListVo();
- List<MemberSelectSymbolsVo> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectByMap) {
- MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
- memberSelectSymbolsVo.setSymbol(memberSelectSymbolsEntity.getSymbol());
- arrayList.add(memberSelectSymbolsVo);
- }
- }
- findCollectListVo.setMemberSelectSymbolsVo(arrayList);
-
- return Result.ok(findCollectListVo);
- }
-
- @Override
- public Result searchSymbolResultList() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- FindCollectListVo findCollectListVo = new FindCollectListVo();
- List<MemberSelectSymbolsVo> list = new ArrayList<>();
-
- Map<String, Object> columnMap = new HashMap<>();
- List<PlatformSymbolsCoinEntity> selectByMap = platformSymbolsCoinDao.selectByMap(columnMap);
-
- List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
- for (PlatformSymbolsCoinEntity platformSymbolsCoinEntity : selectByMap) {
- MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
- memberSelectSymbolsVo.setSymbol(platformSymbolsCoinEntity.getName());
- if (CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) {
- for (MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectSymbolByMemIdAndSymbol) {
- if (platformSymbolsCoinEntity.getName().equals(memberSelectSymbolsEntity.getSymbol())) {
- memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES);
- }
- }
- } else {
- memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO);
- }
- list.add(memberSelectSymbolsVo);
- }
- findCollectListVo.setMemberSelectSymbolsVo(list);
- return Result.ok(findCollectListVo);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void dealEntrustCoinOrder() {
- List<OrderCoinsEntity> list = orderCoinsDao.selectAllEntrustingCoinOrderList();
- if (CollUtil.isNotEmpty(list)) {
- for (OrderCoinsEntity orderCoinsEntity : list) {
- BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(orderCoinsEntity.getSymbol() + "/USDT")));
- // 下单时市场价
- BigDecimal markPrice = orderCoinsEntity.getMarkPrice();
- // 委托价
- BigDecimal entrustPrice = orderCoinsEntity.getEntrustPrice();
-
- //如果当时委托价小于市价
- if (entrustPrice.compareTo(markPrice) < 0) {
- if (nowPrice.compareTo(entrustPrice) > 0) {
- continue;
- }
- } else {
- //委托价大于市价
- if (nowPrice.compareTo(entrustPrice) < 0) {
- continue;
- }
- }
-
- BigDecimal fee = entrustPrice.multiply(orderCoinsEntity.getEntrustCnt()).multiply(new BigDecimal("0.002")).setScale(8, BigDecimal.ROUND_HALF_UP);
-
- BigDecimal dealAmount = entrustPrice.multiply(orderCoinsEntity.getEntrustCnt());
-
- OrderCoinsDealEntity orderCoinsDealEntity = OrderCoinsDealMapper.INSTANCE.orderToOrderDeal(orderCoinsEntity);
- orderCoinsDealEntity.setDealAmount(dealAmount);
- orderCoinsDealEntity.setDealPrice(entrustPrice);
- orderCoinsDealEntity.setFeeAmount(fee);
- orderCoinsDealEntity.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
- orderCoinsDealEntity.setId(null);
- orderCoinDealDao.insert(orderCoinsDealEntity);
-
- orderCoinsDao.deleteById(orderCoinsEntity.getId());
-
- MemberWalletCoinEntity walletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(orderCoinsEntity.getMemberId(), orderCoinsEntity.getSymbol());
- MemberWalletCoinEntity usdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(orderCoinsEntity.getMemberId(), "USDT");
-
- BigDecimal frozen = BigDecimal.ZERO;
- BigDecimal total = BigDecimal.ZERO;
- // 买入
- if (OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
- BigDecimal newCoins = walletCoinEntity.getAvailableBalance().add(orderCoinsEntity.getEntrustCnt());
- BigDecimal newCoinTotal = walletCoinEntity.getTotalBalance().add(orderCoinsEntity.getEntrustCnt());
- walletCoinEntity.setAvailableBalance(newCoins);
- walletCoinEntity.setTotalBalance(newCoinTotal);
- memberWalletCoinDao.updateById(walletCoinEntity);
-
- frozen = usdt.getFrozenBalance().subtract(dealAmount.add(fee));
- total = usdt.getTotalBalance().subtract(dealAmount.add(fee));
- usdt.setFrozenBalance(frozen);
- usdt.setTotalBalance(total);
- memberWalletCoinDao.updateById(usdt);
- } else {
- walletCoinEntity.setFrozenBalance(walletCoinEntity.getFrozenBalance().subtract(orderCoinsEntity.getEntrustCnt()));
- walletCoinEntity.setTotalBalance(walletCoinEntity.getTotalBalance().subtract(orderCoinsEntity.getEntrustCnt()));
- memberWalletCoinDao.updateById(walletCoinEntity);
-
- usdt.setAvailableBalance(usdt.getAvailableBalance().add(dealAmount.add(fee)));
- usdt.setTotalBalance(usdt.getTotalBalance().add(dealAmount.add(fee)));
- memberWalletCoinDao.updateById(usdt);
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractEntrustOrderController.java b/src/main/java/com/xcong/excoin/modules/contract/controller/ContractEntrustOrderController.java
deleted file mode 100644
index 7d1430b..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractEntrustOrderController.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.xcong.excoin.modules.contract.controller;
-
-import cn.hutool.core.util.StrUtil;
-import com.xcong.excoin.common.enumerates.SymbolEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitEntrustDto;
-import com.xcong.excoin.modules.contract.parameter.vo.ContractEntrustVo;
-import com.xcong.excoin.modules.contract.service.ContractEntrustOrderService;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.TypeJudgeUtils;
-import com.xcong.excoin.utils.api.response.Symbol;
-import io.swagger.annotations.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-
-/**
- * 合约委托订单controller
- *
- * @author wzy
- * @date 2020-05-27
- **/
-@Slf4j
-@Api(value = "ContractEntrustOrderController", tags = "合约委托订单接口类")
-@RestController
-@RequestMapping(value = "/api/contractEntrust")
-public class ContractEntrustOrderController {
-
- @Resource
- private ContractEntrustOrderService contractEntrustOrderService;
-
- @ApiOperation(value = "合约提交委托订单", notes = "提交委托订单")
- @PostMapping(value = "/submitEntrustOrder")
- public Result submitEntrustOrder(@RequestBody @Validated SubmitEntrustDto submitEntrustDto) {
- if (StrUtil.isBlank(SymbolEnum.getNameByValue(submitEntrustDto.getSymbol()))) {
- return Result.fail(MessageSourceUtils.getString("illegal_symbol"));
- }
-
- if (!TypeJudgeUtils.entrustType(submitEntrustDto.getEntrustType())) {
- return Result.fail(MessageSourceUtils.getString("illegal_type"));
- }
-
- return contractEntrustOrderService.addContractEntrustOrder(submitEntrustDto);
- }
-
- @ApiOperation(value = "获取当前委托单列表", notes = "获取当前委托单列表")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = ContractEntrustVo.class)
- })
- @GetMapping(value = "/findCurrentEntrustOrderList")
- public Result findCurrentEntrustOrderList(@ApiParam(name = "symbol", value = "币种", example = "BTC/USDT") @RequestParam(value = "symbol", required = false) String symbol) {
- return contractEntrustOrderService.findEntrustOrderList(symbol);
- }
-
-
- @ApiOperation(value = "撤销委托单", notes = "撤销委托单")
- @GetMapping(value = "/cancelEntrustOrder")
- public Result cancelEntrustOrder(@ApiParam(name = "id", value = "委托单ID", required = true, example = "1") @RequestParam("id") Long id) {
- return contractEntrustOrderService.cancelEntrustOrder(id);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractHoldOrderController.java b/src/main/java/com/xcong/excoin/modules/contract/controller/ContractHoldOrderController.java
deleted file mode 100644
index 71fafda..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractHoldOrderController.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.contract.controller;
-
-import io.swagger.annotations.Api;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Slf4j
-@Api(value = "ContractHoldOrderController", tags = "合约持仓订单接口类")
-@RestController
-@RequestMapping(value = "/api/contractHold")
-public class ContractHoldOrderController {
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java b/src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java
deleted file mode 100644
index 0be9cc1..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.xcong.excoin.modules.contract.controller;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.parameter.dto.*;
-import com.xcong.excoin.modules.contract.parameter.vo.ContractMoneyInfoVo;
-import com.xcong.excoin.modules.contract.parameter.vo.HoldOrderListVo;
-import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
-import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
-import com.xcong.excoin.modules.contract.service.ContractOrderService;
-import com.xcong.excoin.rabbit.producer.OrderProducer;
-import io.swagger.annotations.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Slf4j
-@Api(value = "ContractOrderController", tags = "合约订单接口类")
-@RestController
-@RequestMapping(value = "/api/contractOrder")
-public class ContractOrderController {
-
- @Resource
- private ContractHoldOrderService contractHoldOrderService;
-
- @Resource
- private ContractOrderService contractOrderService;
-
- @ApiOperation(value = "市价提交合约订单")
- @PostMapping(value = "/submitOrder")
- public Result submitOrder(@RequestBody SubmitOrderDto submitOrderDto) {
- return contractHoldOrderService.submitOrder(submitOrderDto);
- }
-
- @ApiOperation(value = "查询当前持仓订单列表 -- 轮询")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = HoldOrderListVo.class)
- })
- @GetMapping(value = "/findHoldOrderList")
- public Result findHoldOrderList(@ApiParam(name = "symbol", value = "币种", example = "BTC/USDT") @RequestParam(value = "symbol", required = false) String symbol) {
- return contractHoldOrderService.findHoldOrderList(symbol);
- }
-
- @ApiOperation(value = "根据Id查询持仓订单详情")
- @GetMapping(value = "/findHoldOrderDetail")
- public Result findHoldOrderDetail(@ApiParam(name = "id", value = "持仓ID", required = true, example = "1") @RequestParam(value = "id") Long id) {
- return contractHoldOrderService.findHoldOrderDetailById(id);
- }
-
- @ApiOperation(value = "根据Id平仓")
- @GetMapping(value = "/closingOrder")
- public Result closingOrder(@ApiParam(name = "id", value = "持仓ID", required = true, example = "1") @RequestParam(value = "id") Long id) {
- return contractHoldOrderService.cancelHoldOrder(id);
- }
-
- @ApiOperation(value = "一键平仓")
- @PostMapping(value = "/oneKeyClosing")
- public Result oneKeyClosing(@RequestBody SymbolDto symbolDto) {
- return contractHoldOrderService.cancelHoldOrderBatch(symbolDto);
- }
-
- @ApiOperation(value = "设置止盈止损")
- @PostMapping(value = "/setTargetProfitOrLoss")
- public Result setTargetProfitOrLoss(@RequestBody @Validated ProfitOrLessDto profitOrLessDto) {
- return contractHoldOrderService.setTargetProfitOrLess(profitOrLessDto);
- }
-
- @ApiOperation(value = "调整保证金")
- @PostMapping(value = "/changeBond")
- public Result changeBond(@RequestBody @Validated ChangeBondDto changeBondDto) {
- return contractHoldOrderService.changeBond(changeBondDto);
- }
-
- @ApiOperation(value = "分页查询历史订单列表")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = OrderListVo.class)
- })
- @PostMapping(value = "/findHistoryOrderList")
- public Result findHistoryOrderList(@RequestBody @Validated OrderListDto orderListDto) {
- return contractHoldOrderService.findOrderList(orderListDto);
- }
-
- @ApiOperation(value = "获取合约页面资产信息")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = ContractMoneyInfoVo.class)
- })
- @GetMapping(value = "/findContractMoneyInfo")
- public Result findContractMoneyInfo(@ApiParam(name = "symbol", value = "币种", required = true, example = "BTC/USDT") @RequestParam(value = "symbol") String symbol) {
- return contractHoldOrderService.findContractMoneyInfo(symbol);
- }
-
- @ApiOperation(value = "调整杠杆")
- @PostMapping(value = "/changeLeverRate")
- public Result changeLeverRate(@RequestBody @Validated ChangeLeverRateDto changeLeverRateDto) {
- return contractHoldOrderService.changeLeverRate(changeLeverRateDto);
- }
-
- @ApiOperation(value = "查询历史委托订单详情")
- @GetMapping(value = "/findOrderDetailById")
- public Result findOrderDetailById(@ApiParam(name = "id", value = "订单id", required = true, example = "1") @RequestParam(value = "id") Long id) {
- return contractHoldOrderService.findOrderDetailById(id);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractEntrustOrderDao.java b/src/main/java/com/xcong/excoin/modules/contract/dao/ContractEntrustOrderDao.java
deleted file mode 100644
index 3f07e27..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractEntrustOrderDao.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.contract.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface ContractEntrustOrderDao extends BaseMapper<ContractEntrustOrderEntity> {
-
- public ContractEntrustOrderEntity selectEntrustOrderByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);
-
- public List<ContractEntrustOrderEntity> selectEntrustOrderListByMemberId(@Param("memberId") Long memberId);
-
- public List<ContractEntrustOrderEntity> selectEntrustOrderListByMemberIdAndSymbol(@Param("memberId") Long memberId, @Param("symbol") String symbol);
-
- public List<ContractEntrustOrderEntity> selectEntrustOrderListByIds(@Param("list") List<Long> list);
-
- public List<ContractEntrustOrderEntity> selectAllEntrustOrder();
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractHoldOrderDao.java b/src/main/java/com/xcong/excoin/modules/contract/dao/ContractHoldOrderDao.java
deleted file mode 100644
index dd1f6ac..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractHoldOrderDao.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.modules.contract.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface ContractHoldOrderDao extends BaseMapper<ContractHoldOrderEntity> {
- /**
- * 根据ids更新所有订单的平仓状态
- *
- * @param list
- * @return
- */
- int updateContractHoldOrderCanNotClosingByIds(@Param("list") List<OrderModel> list, @Param("batchNo") String batchNo);
-
- /**
- * 根据批次号查询次仓订单
- *
- * @param batchNo
- * @return
- */
- List<ContractHoldOrderEntity> selectContractHoldOrderByBatchNo(@Param("batchNo") String batchNo);
-
- /**
- * 更新该订单为可平仓状态
- *
- * @param id
- */
- public void updateOrderIsCanClosingAndBatchNoById(@Param("id") Long id);
-
- public List<ContractHoldOrderEntity> selectHoldOrderListByMemberId(@Param("memberId") Long memberId);
-
- public List<ContractHoldOrderEntity> selectHoldOrderListByMemberIdAndSymbol(@Param("memberId") Long memberId, @Param("symbol") String symbol);
-
- public ContractHoldOrderEntity selectHoldOrderByMemberIdAndId(@Param("memberId") Long memberId, @Param("id") Long id);
-
- public int updateHoldOrderIsCanClosingById(@Param("isCanClosing") int isCanClosing, @Param("id") Long id);
-
- public List<ContractHoldOrderEntity> selectAllHoldOrder();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java b/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
deleted file mode 100644
index aaea6dc..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.modules.contract.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.OrderListDto;
-import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * @author helius
- */
-public interface ContractOrderDao extends BaseMapper<ContractOrderEntity> {
-
- public IPage<ContractOrderEntity> selectContractOrderInPage(Page<ContractOrderEntity> page, @Param("record") ContractOrderEntity contractOrderEntity);
-
- public ContractOrderEntity selectOrderDetailByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractEntrustOrderEntity.java b/src/main/java/com/xcong/excoin/modules/contract/entity/ContractEntrustOrderEntity.java
deleted file mode 100644
index ee1067b..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractEntrustOrderEntity.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.xcong.excoin.modules.contract.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Data
-@TableName("contract_entrust_order")
-public class ContractEntrustOrderEntity extends BaseEntity {
-
- public static final int ENTRUST_TYPE_OPEN_MORE = 1;
-
- public static final int ENTRUST_TYPE_OPEN_LESS = 2;
-
- public static final int ENTRUST_TYPE_CLOSE_MORE = 3;
-
- public static final int ENTRUST_TYPE_CLOSE_LESS = 4;
-
- /**
- * 逐仓
- */
- public static final int POSITION_TYPE_ADD = 1;
-
- /**
- * 全仓
- */
- public static final int POSITION_TYPE_ALL = 2;
-
-
- /**
- * 会员ID
- */
- private Long memberId;
-
- /**
- * 订单编号
- */
- private String orderNo;
-
- /**
- * 仓位类型 1逐仓2全仓
- */
- private int positionType;
-
- /**
- * 委托类型 1开多,2开空,3平多,4平空
- */
- private int entrustType;
-
- /**
- * 委托价格
- */
- private BigDecimal entrustPrice;
-
- /**
- * 委托金额
- */
- private BigDecimal entrustAmount;
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 数量
- */
- private int symbolCnt;
-
- /**
- * 币种规格
- */
- private BigDecimal symbolSku;
-
- /**
- * 杠杆倍率
- */
- private int leverRatio;
-
- /**
- * 保证金
- */
- private BigDecimal bondAmount;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractHoldOrderEntity.java b/src/main/java/com/xcong/excoin/modules/contract/entity/ContractHoldOrderEntity.java
deleted file mode 100644
index 7da4069..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractHoldOrderEntity.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package com.xcong.excoin.modules.contract.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * 合约持仓订单表
- *
- * @author wzy
- * @date 2020-05-27
- **/
-@Data
-@TableName("contract_hold_order")
-public class ContractHoldOrderEntity extends BaseEntity {
-
- /**
- * 是否可平仓 1-是
- */
- public static final int ORDER_CAN_CLOSING_Y = 1;
- /**
- * 是否可平仓 0-否
- */
- public static final int ORDER_CAN_CLOSING_N = 0;
-
- /**
- * 开多
- */
- public static final int OPENING_TYPE_MORE = 1;
-
- /**
- * 开空
- */
- public static final int OPENING_TYPE_LESS = 2;
-
- /**
- * 交易类型 市价
- */
- public static final int TRADE_TYPE_MARK = 1;
-
- /**
- * 交易类型 限价
- */
- public static final int TRADE_TYPE_LIMIT = 2;
-
- /**
- * 会员Id
- */
- private Long memberId;
-
- /**
- * 订单编号
- */
- private String orderNo;
-
- /**
- * 仓位类型 1-逐仓 2-全仓
- */
- private int positionType;
-
- /**
- * 交易类型 1-市价 2-限价
- */
- private int tradeType;
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 手数
- */
- private int symbolCnt;
-
- /**
- * 可平张数(仅全仓模式)
- */
- private int symbolCntSale;
-
- /**
- * 币种规格
- */
- private BigDecimal symbolSku;
-
- /**
- * 开仓价
- */
- private BigDecimal openingPrice;
-
- /**
- * 开仓类型 1-开多 2-开空
- */
- private int openingType;
-
- /**
- * 开仓手续费
- */
- private BigDecimal openingFeeAmount;
-
- /**
- * 保证金
- */
- private BigDecimal bondAmount;
-
- /**
- * 杠杆倍率
- */
- private int leverRatio;
-
- /**
- * 市场价
- */
- private BigDecimal markPrice;
-
- /**
- * 止损价
- */
- private BigDecimal stopLossPrice;
-
- /**
- * 止盈价
- */
- private BigDecimal stopProfitPrice;
-
- /**
- * 预付款金额
- */
- private BigDecimal prePaymentAmount;
-
- /**
- * 预估强平价
- */
- private BigDecimal forceClosingPrice;
-
- private int operateNo;
-
- /**
- * 是否可平仓 0-否 1-是
- */
- private int isCanClosing;
-
- /**
- * 批次号 队列平仓时使用,避免重复
- */
- public String batchNo;
-
- /**
- * 持仓费
- */
- private BigDecimal holdAmount;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractOrderEntity.java b/src/main/java/com/xcong/excoin/modules/contract/entity/ContractOrderEntity.java
deleted file mode 100644
index 9a82765..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/entity/ContractOrderEntity.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package com.xcong.excoin.modules.contract.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * 合约订单历史表
- *
- * @author wzy
- * @date 2020-05-27
- **/
-@Data
-@TableName("contract_order")
-public class ContractOrderEntity extends BaseEntity {
-
- /**
- * 交易类型 市价
- */
- public static final int TRADE_TYPE_MARK_PRICE = 1;
-
- /**
- * 交易类型 限价
- */
- public static final int TRADE_TYPE_LIMIT_PRICE = 2;
-
- /**
- * 订单状态 撤单
- */
- public static final int ORDER_STATUS_CANCEL = 2;
-
- /**
- * 订单状态 成交
- */
- public static final int ORDER_STATUS_SUCCESS = 1;
-
- /**
- * 订单类型 开多
- */
- public static final int ORDER_TYPE_OPEN_MORE = 1;
-
- /**
- * 订单类型 开空
- */
- public static final int ORDER_TYPE_OPEN_LESS = 2;
-
- /**
- * 订单类型 平多
- */
- public static final int ORDER_TYPE_CLOSE_MORE = 3;
-
- /**
- * 订单类型 平空
- */
- public static final int ORDER_TYPE_CLOSE_LESS = 4;
-
-
- /**
- * 会员Id
- */
- private Long memberId;
-
- /**
- * 订单编号
- */
- private String orderNo;
-
- /**
- * 仓位类型 1-逐仓 2-全仓
- */
- private int positionType;
-
- /**
- * 交易类型 1-市价 2-限价
- */
- private int tradeType;
-
- /**
- * 订单类型 - 1开多,2开空,3平多,4平空
- */
- private int orderType;
-
- /**
- * 订单状态 - 1成交 2撤单
- */
- private int orderStatus = 1;
-
- /**
- * 委托开仓价
- */
- private BigDecimal entrustOpeningPrice;
-
- /**
- * 委托时间
- */
- private Date entrustTime;
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 手数
- */
- private int symbolCnt;
-
- /**
- * 币种规格
- */
- private BigDecimal symbolSku;
-
- /**
- * 平仓价
- */
- private BigDecimal closingPrice;
-
- /**
- * 平仓手续费
- */
- private BigDecimal closingFeeAmount;
-
- /**
- * 平仓时间
- */
- private Date closingTime;
-
- /**
- * 平仓类型 2平多3平空4爆仓平多5爆仓平空6止盈平多7止盈平空8止损平多9止损平空
- */
- private int closingType;
-
- /**
- * 杠杆倍率
- */
- private int leverRatio;
-
- /**
- * 止损价
- */
- private BigDecimal stopLossPrice;
-
- /**
- * 止盈价
- */
- private BigDecimal stopProfitPrice;
-
- /**
- * 盈亏金额
- */
- private BigDecimal rewardAmount;
-
- /**
- * 盈亏比例
- */
- private BigDecimal rewardRatio;
-
- /**
- * 开仓价
- */
- private BigDecimal openingPrice;
-
- /**
- * 开仓手续费
- */
- private BigDecimal openingFeeAmount;
-
- private Date openingTime;
-
- /**
- * 预付款金额
- */
- private BigDecimal prePaymentAmount;
-
- /**
- * 保证金
- */
- private BigDecimal bondAmount;
-
- /**
- * 市场价
- */
- private BigDecimal markPrice;
-
- /**
- * 预估强平价
- */
- private BigDecimal forceClosingPrice;
-
- /**
- * 持仓费
- */
- private BigDecimal holdAmount;
-
- private int operateNo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractEntrustOrderEntityMapper.java b/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractEntrustOrderEntityMapper.java
deleted file mode 100644
index a80d1ef..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractEntrustOrderEntityMapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.modules.contract.mapper;
-
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitEntrustDto;
-import com.xcong.excoin.modules.contract.parameter.vo.ContractEntrustVo;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.factory.Mappers;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-28
- **/
-@Mapper
-public abstract class ContractEntrustOrderEntityMapper {
- public static final ContractEntrustOrderEntityMapper INSTANCE = Mappers.getMapper(ContractEntrustOrderEntityMapper.class);
-
- public abstract ContractEntrustOrderEntity submitEntrustDtoToEntity(SubmitEntrustDto dto);
-
- @Mapping(source = "entrustPrice", target = "entrustOpeningPrice")
- @Mapping(source = "createTime", target = "entrustTime")
- @Mapping(source = "entrustAmount", target = "prePaymentAmount")
- @Mapping(source = "entrustType", target = "orderType")
- public abstract ContractOrderEntity entrustOrderToOrder(ContractEntrustOrderEntity orderEntity);
-
- @Mapping(source = "createTime", target = "entrustTime")
- @Mapping(source = "entrustType", target = "type")
- public abstract ContractEntrustVo entityToContractEntrustVo(ContractEntrustOrderEntity orderEntity);
-
- public abstract List<ContractEntrustVo> entityListToVoList(List<ContractEntrustOrderEntity> list);
-
- @Mapping(source = "entrustAmount", target = "prePaymentAmount")
- public abstract ContractHoldOrderEntity entrustOrderToHoldOrder(ContractEntrustOrderEntity entrustOrderEntity);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractHoldOrderEntityMapper.java b/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractHoldOrderEntityMapper.java
deleted file mode 100644
index b2ad5e4..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractHoldOrderEntityMapper.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.xcong.excoin.modules.contract.mapper;
-
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.vo.HoldOrderDetailVo;
-import com.xcong.excoin.modules.contract.parameter.vo.HoldOrderListVo;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.factory.Mappers;
-
-/**
- * @author wzy
- * @date 2020-05-31
- **/
-@Mapper
-public abstract class ContractHoldOrderEntityMapper {
- public static final ContractHoldOrderEntityMapper INSTANCE = Mappers.getMapper(ContractHoldOrderEntityMapper.class);
-
- @Mapping(target = "orderType", source = "openingType")
- @Mapping(target = "openingTime", source = "createTime")
- public abstract ContractOrderEntity holdOrderToOrder(ContractHoldOrderEntity holdOrderEntity);
-
- public abstract HoldOrderListVo holdOrderToDto(ContractHoldOrderEntity holdOrderEntity);
-
- @Mapping(target = "openingTime", source = "createTime")
- public abstract HoldOrderDetailVo holdOrderToOrderDetailVo(ContractHoldOrderEntity holdOrderEntity);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java b/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java
deleted file mode 100644
index b2e3ee2..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.contract.mapper;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.vo.OrderDetailVo;
-import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-06-05
- **/
-@Mapper
-public abstract class ContractOrderEntityMapper {
- public static final ContractOrderEntityMapper INSTANCE = Mappers.getMapper(ContractOrderEntityMapper.class);
-
- public abstract OrderListVo orderEntityToOrderListVo(ContractOrderEntity orderEntity);
-
- public abstract List<OrderListVo> orderEntitiesToOrderListVo(List<ContractOrderEntity> orderEntities);
-
- public abstract Page<OrderListVo> pageEntityToPageVo(IPage<ContractOrderEntity> orderEntityIPage);
-
- public abstract OrderDetailVo entityToDetailVo(ContractOrderEntity orderEntity);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeBondDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeBondDto.java
deleted file mode 100644
index cbac1d1..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeBondDto.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-06-02
- **/
-@Data
-@ApiModel(value = "ChangeBondDto", description = "调整保证金接口接受参数类")
-public class ChangeBondDto {
-
- public static final int TYPE_ADD = 1;
-
- public static final int TYPE_REDUCE = 2;
-
- @NotNull
- @ApiModelProperty(value = "订单ID", example = "1")
- private Long id;
-
- @NotNull
- @ApiModelProperty(value = "类型 1-增加2-减少", example = "1")
- private Integer type;
-
- @NotNull
- @Min(0)
- @ApiModelProperty(value = "金额", example = "90.00")
- private BigDecimal amount;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeLeverRateDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeLeverRateDto.java
deleted file mode 100644
index 4ba4265..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ChangeLeverRateDto.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * @Author wzy
- * @Date 2020/6/5
- **/
-@Data
-@ApiModel(value = "ChangeLeverRateDto", description = "调整杠杆接口接收参数类")
-public class ChangeLeverRateDto {
-
- @NotNull
- @ApiModelProperty(value = "杠杆", example = "100")
- private int leverRate;
-
- @NotNull
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/OrderListDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/OrderListDto.java
deleted file mode 100644
index d194891..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/OrderListDto.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-/**
- * @Author wzy
- * @Date 2020/6/5
- **/
-@Data
-@ApiModel(value = "OrderListDto", description = "历史委托订单列表接口参数接受类")
-public class OrderListDto {
-
- @NotNull
- @Min(1)
- @ApiModelProperty(value = "第几页", example = "1")
- private int pageNum;
-
- @NotNull
- @ApiModelProperty(value = "每页数量", example = "10")
- private int pageSize;
-
- @NotNull
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ProfitOrLessDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ProfitOrLessDto.java
deleted file mode 100644
index ea0e60f..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/ProfitOrLessDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.DecimalMin;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-06-02
- **/
-@Data
-@ApiModel(value = "ProfitOrLessDto", description = "设置止盈止损接口参数类")
-public class ProfitOrLessDto {
-
- @NotNull
- @ApiModelProperty(value = "订单ID", example = "1")
- private Long id;
-
- @ApiModelProperty(value = "止盈价", example = "9000.00")
- private BigDecimal stopProfitPrice;
-
- @ApiModelProperty(value = "止损价", example = "9000.00")
- private BigDecimal stopLessPrice;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitEntrustDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitEntrustDto.java
deleted file mode 100644
index bf588cb..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitEntrustDto.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Data
-@ApiModel(value = "SubmitEntrustDto", description = "提交委托订单接口接受类")
-public class SubmitEntrustDto {
-
- @NotNull()
- @Min(1)
- @ApiModelProperty(value = "委托价", example = "9000.00")
- private BigDecimal entrustPrice;
-
- @NotNull
- @ApiModelProperty(value = "委托类型 1开多 2开空 3平多 4平空", example = "1")
- private int entrustType;
-
- @NotBlank
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-
- @NotNull
- @Min(1)
- @ApiModelProperty(value = "币种数量", example = "1")
- private int symbolCnt;
-
- @NotNull
- @ApiModelProperty(value = "杠杆倍率", example = "100")
- private int leverRatio;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitOrderDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitOrderDto.java
deleted file mode 100644
index 2a6c692..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SubmitOrderDto.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-
-/**
- * @author wzy
- * @date 2020-05-31
- **/
-@Data
-@ApiModel(value = "SubmitOrderDto", description = "提交订单接口接受类")
-public class SubmitOrderDto {
-
- @NotNull
- @ApiModelProperty(value = "订单类型 1开多 2开空", example = "1")
- private int orderType;
-
- @NotBlank
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-
- @NotNull
- @Min(1)
- @ApiModelProperty(value = "币种数量", example = "1")
- private int symbolCnt;
-
- @NotNull
- @ApiModelProperty(value = "杠杆倍率", example = "100")
- private int leverRatio;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SymbolDto.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SymbolDto.java
deleted file mode 100644
index 4319d46..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/dto/SymbolDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * @author wzy
- * @date 2020-06-03
- **/
-@Data
-@ApiModel(value = "SymbolDto", description = "币种dto")
-public class SymbolDto {
-
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java
deleted file mode 100644
index 1203690..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-05-29
- **/
-@Data
-@ApiModel(value = "ContractEntrustVo", description = "合约委托")
-public class ContractEntrustVo {
-
- @ApiModelProperty(value = "委托单ID")
- private Long id;
-
- @ApiModelProperty(value = "委托价")
- private BigDecimal entrustPrice;
-
- @ApiModelProperty(value = "委托数量")
- private int symbolCnt;
-
- @ApiModelProperty(value = "保证金")
- private BigDecimal bondAmount;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone="GMT+8")
- @ApiModelProperty(value = "委托时间")
- private Date entrustTime;
-
- @ApiModelProperty(value = "委托类型 1-开多 2-开空")
- private int type;
-
- public String getBondAmount() {
- return bondAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractMoneyInfoVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractMoneyInfoVo.java
deleted file mode 100644
index 8ae1d67..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractMoneyInfoVo.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @Author wzy
- * @Date 2020/6/2
- **/
-@Data
-@ApiModel(value = "ContractMoneyInfoVo", description = "合约资产信息接口返回参数类")
-public class ContractMoneyInfoVo {
-
- @ApiModelProperty(value = "占用保证金")
- private BigDecimal beUsedBondAmount;
-
- @ApiModelProperty(value = "冻结保证金")
- private BigDecimal frozenBondAmount;
-
- @ApiModelProperty(value = "手续费率")
- private BigDecimal feeRatio;
-
- @ApiModelProperty(value = "权益")
- private BigDecimal equity;
-
- @ApiModelProperty(value = "合约杠杆")
- private Integer leverRate;
-
- @ApiModelProperty(value = "倍率")
- private BigDecimal leverAgeRatio;
-
- @ApiModelProperty(value = "可用余额")
- private BigDecimal availableBalance;
-
- @ApiModelProperty(value = "最新价")
- private BigDecimal newPrice;
-
- @ApiModelProperty(value = "规格")
- private BigDecimal symbolSku;
-
- public BigDecimal getBeUsedBondAmount() {
- return beUsedBondAmount.setScale(4, BigDecimal.ROUND_DOWN);
- }
-
- public BigDecimal getFrozenBondAmount() {
- return frozenBondAmount.setScale(4, BigDecimal.ROUND_DOWN);
- }
-
- public BigDecimal getEquity() {
- return equity.setScale(4, BigDecimal.ROUND_DOWN);
- }
-
- public BigDecimal getAvailableBalance() {
- return availableBalance.setScale(4, BigDecimal.ROUND_DOWN);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderDetailVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderDetailVo.java
deleted file mode 100644
index 66f370b..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderDetailVo.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-06-01
- **/
-@Data
-@ApiModel(value = "HoldOrderDetailVo", description = "获取持仓订单详情接口返回类")
-public class HoldOrderDetailVo {
-
- @ApiModelProperty("订单编号")
- private String orderNo;
-
- @ApiModelProperty("交易类型 1-市价2-限价")
- private int tradeType;
-
- @ApiModelProperty("币种")
- private String symbol;
-
- @ApiModelProperty("张数")
- private int symbolCnt;
-
- @ApiModelProperty("规格")
- private BigDecimal symbolSku;
-
- @ApiModelProperty("开仓价")
- private BigDecimal openingPrice;
-
- @ApiModelProperty("开仓类型 1-开多 2-开空")
- private int openingType;
-
- @ApiModelProperty("开仓手续费")
- private BigDecimal openingFeeAmount;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- @ApiModelProperty("开仓时间")
- private Date openingTime;
-
- @ApiModelProperty("保证金")
- private BigDecimal bondAmount;
-
- @ApiModelProperty("持仓费")
- private BigDecimal holdAmount;
-
- @ApiModelProperty("预估强平价")
- private BigDecimal forceClosingPrice;
-
- @ApiModelProperty("止损价")
- private BigDecimal stopLossPrice;
-
- @ApiModelProperty("止盈价")
- private BigDecimal stopProfitPrice;
-
- @ApiModelProperty("倍率杠杆")
- private int leverRatio;
-
- public String getOpeningPrice() {
- return openingPrice == null ? "" : openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getOpeningFeeAmount() {
- return openingFeeAmount == null ? "" : openingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getBondAmount() {
- return bondAmount == null ? "" : bondAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getHoldAmount() {
- return holdAmount == null ? "" : holdAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getForceClosingPrice() {
- return forceClosingPrice == null ? "" : forceClosingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public void setOpeningFeeAmount(BigDecimal openingFeeAmount, BigDecimal feeSpread) {
- this.openingFeeAmount = openingFeeAmount == null ? openingFeeAmount : openingFeeAmount.multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderListVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderListVo.java
deleted file mode 100644
index e06bff3..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/HoldOrderListVo.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-06-01
- **/
-@Data
-@ApiModel(value = "HoldOrderListVo", description = "获取当前持仓列表接口返回数据类")
-public class HoldOrderListVo {
-
- @ApiModelProperty(value = "订单ID", example = "1")
- private Long id;
-
- @ApiModelProperty(value = "开仓均价", example = "9000.00")
- private BigDecimal openingPrice;
-
- @ApiModelProperty(value = "止损")
- private BigDecimal stopLossPrice;
-
- @ApiModelProperty(value = "止盈")
- private BigDecimal stopProfitPrice;
-
- @ApiModelProperty(value = "保证金")
- private BigDecimal bondAmount;
-
- @ApiModelProperty(value = "强平价")
- private BigDecimal forceClosingPrice;
-
- @ApiModelProperty(value = "杠杆倍率")
- private int leverRatio;
-
- @ApiModelProperty(value = "订单类型 1-开多 2-开空")
- private int openingType;
-
- @ApiModelProperty(value = "币种")
- private String symbol;
-
- @ApiModelProperty(value = "张数")
- private int symbolCnt;
-
- @ApiModelProperty(value = "回报率")
- private BigDecimal returnRate;
-
- @ApiModelProperty(value = "盈亏")
- private BigDecimal profitOrLoss;
-
- @ApiModelProperty(value = "可增加的最大保证金")
- private BigDecimal canAddMaxBond;
-
- @ApiModelProperty(value = "可减少最大保证金")
- private BigDecimal canReduceMaxBond;
-
- @ApiModelProperty(value = "开仓时间")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createTime;
-
- @ApiModelProperty(value = "交易类型 1-市价 2-限价")
- private Integer tradeType;
-
- public String getOpeningPrice() {
- return openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getBondAmount() {
- return bondAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getForceClosingPrice() {
- return forceClosingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getProfitOrLoss() {
- return profitOrLoss.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public BigDecimal getCanAddMaxBond() {
- return canAddMaxBond.setScale(4, BigDecimal.ROUND_DOWN);
- }
-
- public BigDecimal getCanReduceMaxBond() {
- return canReduceMaxBond.setScale(4, BigDecimal.ROUND_DOWN);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java
deleted file mode 100644
index 2939331..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-06-05
- **/
-@Data
-@ApiModel(value = "OrderDetailVo", description = "历史委托订单详情接口返回参数类")
-public class OrderDetailVo {
-
- @ApiModelProperty("交易类型 1-市价2-限价")
- private int tradeType;
-
- @ApiModelProperty("订单类型 -1撤单,1开多,2开空,3平多,4平空")
- private int orderType;
-
- @ApiModelProperty("订单编号")
- private String orderNo;
-
- @ApiModelProperty("委托开仓价")
- private BigDecimal entrustOpeningPrice;
-
- @ApiModelProperty("委托时间")
- private Date entrustTime;
-
- @ApiModelProperty("币种")
- private String symbol;
-
- @ApiModelProperty("张数")
- private int symbolCnt;
-
- @ApiModelProperty("平仓价")
- private BigDecimal closingPrice;
-
- @ApiModelProperty("平仓手续费")
- private BigDecimal closingFeeAmount;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- @ApiModelProperty("平仓时间")
- private Date closingTime;
-
- @ApiModelProperty("平仓类型 2平多3平空4爆仓平多5爆仓平空6止盈平多7止盈平空8止损平多9止损平空")
- private int closingType;
-
- @ApiModelProperty("止损价")
- private BigDecimal stopLossPrice;
-
- @ApiModelProperty("止盈价")
- private BigDecimal stopProfitPrice;
-
- @ApiModelProperty("盈亏金额")
- private BigDecimal rewardAmount;
-
- @ApiModelProperty("盈亏比例")
- private BigDecimal rewardRatio;
-
- @ApiModelProperty("开仓价")
- private BigDecimal openingPrice;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- @ApiModelProperty("开仓时间")
- private Date openingTime;
-
- @ApiModelProperty("开仓手续费")
- private BigDecimal openingFeeAmount;
-
- @ApiModelProperty("保证金")
- private BigDecimal bondAmount;
-
- @ApiModelProperty("持仓费")
- private BigDecimal holdAmount;
-
- @ApiModelProperty("杠杆")
- private int leverRatio;
-
- public String getClosingPrice() {
- return closingPrice == null ? "" : closingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getClosingFeeAmount() {
- return closingFeeAmount == null ? "" : closingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getRewardAmount() {
- return rewardAmount == null ? "" : rewardAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getOpeningPrice() {
- return openingPrice == null ? "" : openingPrice.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getOpeningFeeAmount() {
- return openingFeeAmount == null ? "" : openingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getBondAmount() {
- return bondAmount == null ? "" : bondAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getHoldAmount() {
- return holdAmount == null ? "" : holdAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public void setClosingFeeAmount(BigDecimal closingFeeAmount, BigDecimal feeSpread) {
- this.closingFeeAmount = closingFeeAmount == null ? closingFeeAmount : closingFeeAmount.multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN);
- }
-
- public void setOpeningFeeAmount(BigDecimal openingFeeAmount, BigDecimal feeSpread) {
- this.openingFeeAmount = openingFeeAmount == null ? openingFeeAmount : openingFeeAmount.multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderListVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderListVo.java
deleted file mode 100644
index 24701bb..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderListVo.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.xcong.excoin.modules.contract.parameter.vo;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author wzy
- * @date 2020-06-05
- **/
-@Data
-@ApiModel(value = "OrderListVo", description = "历史委托订单接口返回参数类")
-public class OrderListVo {
-
- @ApiModelProperty("订单ID")
- private Long id;
-
- @ApiModelProperty("订单类型 1开多,2开空,3平多,4平空")
- private int orderType;
-
- @ApiModelProperty("订单状态 1成交 2撤单")
- private int orderStatus;
-
- @ApiModelProperty("开仓均价")
- private BigDecimal openingPrice;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- @ApiModelProperty("开仓价")
- private Date openingTime;
-
- @ApiModelProperty("开仓手续费")
- private BigDecimal openingFeeAmount;
-
- @ApiModelProperty("保证金")
- private BigDecimal bondAmount;
-
- @ApiModelProperty("张数")
- private int symbolCnt;
-
- @ApiModelProperty("已实现盈亏")
- private BigDecimal rewardAmount;
-
- @ApiModelProperty("平仓类型 2平多3平空4爆仓平多5爆仓平空6止盈平多7止盈平空8止损平多9止损平空")
- private int closingType;
-
- @ApiModelProperty("平仓手续费")
- private BigDecimal closingFeeAmount;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- @ApiModelProperty("平仓时间")
- private Date closingTime;
-
- @ApiModelProperty("平仓价格")
- private BigDecimal closingPrice;
-
- @ApiModelProperty("强平价")
- private BigDecimal forceClosingPrice;
-
- @ApiModelProperty(value = "交易类型 1-市价 2-限价")
- private Integer tradeType;
-
- public String getOpeningFeeAmount() {
- return openingFeeAmount == null ? "" : openingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
-
- public String getClosingFeeAmount() {
- return closingFeeAmount == null ? "" : closingFeeAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getBondAmount() {
- return bondAmount == null ? "" : bondAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-
- public String getRewardAmount() {
- return rewardAmount == null ? "" : rewardAmount.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/ContractEntrustOrderService.java b/src/main/java/com/xcong/excoin/modules/contract/service/ContractEntrustOrderService.java
deleted file mode 100644
index 2e27705..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/ContractEntrustOrderService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.contract.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitEntrustDto;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface ContractEntrustOrderService extends IService<ContractEntrustOrderEntity> {
-
- public Result addContractEntrustOrder(SubmitEntrustDto submitEntrustDto);
-
- public Result findEntrustOrderList(String symbol);
-
- public Result cancelEntrustOrder(Long id);
-
- public List<ContractEntrustOrderEntity> selectEntrustOrderListByIds( List<Long> list);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java b/src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java
deleted file mode 100644
index eb2d903..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.xcong.excoin.modules.contract.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.*;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface ContractHoldOrderService extends IService<ContractHoldOrderEntity> {
-
- public Result submitOrder(SubmitOrderDto submitOrderDto);
-
- public int updateContractHoldOrderCanNotClosingByIds(List<OrderModel> list, String batchNo);
-
- public List<ContractHoldOrderEntity> selectContractHoldOrderByBatchNo(String batchNo);
-
- public void updateOrderIsCanClosingAndBatchNoById(Long id);
-
- public Result findHoldOrderList(String symbol);
-
- public Result cancelHoldOrder(Long id);
-
- public Result cancelHoldOrderBatch(SymbolDto symbolDto);
-
- public Result setTargetProfitOrLess(ProfitOrLessDto profitOrLessDto);
-
- public Result changeBond(ChangeBondDto changeBondDto);
-
- public Result findContractMoneyInfo(String symbol);
-
- public Result changeLeverRate(ChangeLeverRateDto changeLeverRateDto);
-
- public Result findHoldOrderDetailById(Long id);
-
- public Result findOrderList(OrderListDto orderListDto);
-
- public Result findOrderDetailById(Long id);
-
- public void calHoldOrderHoldFeeAmount();
-
- public void calHoldFeeAmountForBondAmount();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/ContractOrderService.java b/src/main/java/com/xcong/excoin/modules/contract/service/ContractOrderService.java
deleted file mode 100644
index 86cbb33..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/ContractOrderService.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.modules.contract.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitOrderDto;
-
-/**
- * @author helius
- */
-public interface ContractOrderService extends IService<ContractOrderEntity> {
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/RabbitOrderService.java b/src/main/java/com/xcong/excoin/modules/contract/service/RabbitOrderService.java
deleted file mode 100644
index 670735f..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/RabbitOrderService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.xcong.excoin.modules.contract.service;
-
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface RabbitOrderService {
-
- public void cancelHoldOrder(List<Long> ids);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
deleted file mode 100644
index cda4dcf..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package com.xcong.excoin.modules.contract.service.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
-import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao;
-import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.mapper.ContractEntrustOrderEntityMapper;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitEntrustDto;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitOrderDto;
-import com.xcong.excoin.modules.contract.parameter.vo.ContractEntrustVo;
-import com.xcong.excoin.modules.contract.service.ContractEntrustOrderService;
-import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
-import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import com.xcong.excoin.rabbit.producer.OrderProducer;
-import com.xcong.excoin.utils.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Slf4j
-@Service
-public class ContractEntrustOrderServiceImpl extends ServiceImpl<ContractEntrustOrderDao, ContractEntrustOrderEntity> implements ContractEntrustOrderService {
-
- @Resource
- private ContractEntrustOrderDao contractEntrustOrderDao;
-
- @Resource
- private MemberWalletContractDao memberWalletContractDao;
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private CacheSettingUtils cacheSettingUtils;
-
- @Resource
- private ContractOrderDao contractOrderDao;
-
- @Resource
- private CommonService commonService;
-
- @Resource
- private OrderProducer producer;
-
- @Resource
- private ContractHoldOrderService contractHoldOrderService;
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public Result addContractEntrustOrder(SubmitEntrustDto submitEntrustDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(submitEntrustDto.getSymbol())));
-
- // 委托开仓
- if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE || submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS) {
- // 开多委托价不能大于当前价
- if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
- if (submitEntrustDto.getEntrustPrice().compareTo(newPrice) > -1) {
- SubmitOrderDto submitOrderDto = new SubmitOrderDto();
- submitOrderDto.setOrderType(submitEntrustDto.getEntrustType());
- submitOrderDto.setSymbol(submitEntrustDto.getSymbol());
- submitOrderDto.setSymbolCnt(submitEntrustDto.getSymbolCnt());
- submitOrderDto.setLeverRatio(submitEntrustDto.getLeverRatio());
- return contractHoldOrderService.submitOrder(submitOrderDto);
- }
- }
-
- // 开空委托价不能小于当前价
- if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS) {
- if (submitEntrustDto.getEntrustPrice().compareTo(newPrice) < 1) {
- SubmitOrderDto submitOrderDto = new SubmitOrderDto();
- submitOrderDto.setOrderType(submitEntrustDto.getEntrustType());
- submitOrderDto.setSymbol(submitEntrustDto.getSymbol());
- submitOrderDto.setSymbolCnt(submitEntrustDto.getSymbolCnt());
- submitOrderDto.setLeverRatio(submitEntrustDto.getLeverRatio());
- return contractHoldOrderService.submitOrder(submitOrderDto);
- }
- }
-
- MemberWalletContractEntity walletContract = memberWalletContractDao.selectById(memberEntity.getId());
-
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(submitEntrustDto.getSymbol());
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
-
- // 保证金计算 -- 建仓价X规格X手数X(1/杠杆倍率)
- BigDecimal bondAmount = submitEntrustDto.getEntrustPrice().multiply(lotNumber).multiply(new BigDecimal(submitEntrustDto.getSymbolCnt())).multiply((BigDecimal.ONE.divide(BigDecimal.valueOf(submitEntrustDto.getLeverRatio()), 8, BigDecimal.ROUND_DOWN)));
-
- // 开仓手续费 建仓价*规格*手数*手续费率
- BigDecimal openFeePrice = submitEntrustDto.getEntrustPrice().multiply(lotNumber)
- .multiply(new BigDecimal(submitEntrustDto.getSymbolCnt()))
- .multiply(tradeSettingEntity.getFeeRatio().divide(new BigDecimal(100)))
- .setScale(8, BigDecimal.ROUND_DOWN);
- log.info("手续费:{}", openFeePrice);
-
- // 预付款
- BigDecimal entrustTotalAmount = bondAmount.add(openFeePrice).add(openFeePrice);
- log.info("预付款:{}", entrustTotalAmount);
-
- if (entrustTotalAmount.compareTo(walletContract.getAvailableBalance()) > -1) {
- return Result.fail(MessageSourceUtils.getString("member_service_0085"));
- }
-
- ContractEntrustOrderEntityMapper convert = ContractEntrustOrderEntityMapper.INSTANCE;
- ContractEntrustOrderEntity entrustOrderEntity = convert.submitEntrustDtoToEntity(submitEntrustDto);
- entrustOrderEntity.setOrderNo(commonService.generateOrderNo(memberEntity.getId()));
- entrustOrderEntity.setMemberId(memberEntity.getId());
- entrustOrderEntity.setBondAmount(bondAmount.add(openFeePrice));
- entrustOrderEntity.setSymbolSku(lotNumber);
- entrustOrderEntity.setEntrustAmount(entrustTotalAmount);
- // 暂默认逐仓
- entrustOrderEntity.setPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ADD);
-
- int i = contractEntrustOrderDao.insert(entrustOrderEntity);
-
- memberWalletContractDao.increaseWalletContractBalanceById(entrustTotalAmount.negate(), null, entrustOrderEntity.getBondAmount(), walletContract.getId());
- if (i > 0) {
-
- // 发送委托单队列消息
- if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
-
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol());
- } else {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
-
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol());
- }
-
- return Result.ok(MessageSourceUtils.getString("result_success_msg"));
- } else {
- return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
- }
- }
-
- // 委托平仓 (全仓模式)
- if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE || submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_LESS) {
- return Result.fail("功能暂未开放,敬请期待");
- }
-
- return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
- }
-
- @Override
- public Result findEntrustOrderList(String symbol) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- List<ContractEntrustOrderEntity> list = contractEntrustOrderDao.selectEntrustOrderListByMemberIdAndSymbol(memberEntity.getId(), symbol);
- List<ContractEntrustVo> resultList = ContractEntrustOrderEntityMapper.INSTANCE.entityListToVoList(list);
- return Result.ok(resultList);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Result cancelEntrustOrder(Long id) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- // 查询该委托单是否为该用户所有
- ContractEntrustOrderEntity entrustOrderEntity = contractEntrustOrderDao.selectEntrustOrderByIdAndMemberId(id, memberEntity.getId());
- if (entrustOrderEntity == null) {
- return Result.fail(MessageSourceUtils.getString("entrust_order_not_exist"));
- }
-
- MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-
- BigDecimal total = entrustOrderEntity.getEntrustAmount();
- memberWalletContractDao.increaseWalletContractBalanceById(total, null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId());
-
- ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity);
- orderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_MARK_PRICE);
- orderEntity.setOrderStatus(ContractOrderEntity.ORDER_STATUS_CANCEL);
- int i = contractOrderDao.insert(orderEntity);
-
- contractEntrustOrderDao.deleteById(entrustOrderEntity.getId());
-
- // 插入财务流水
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), total, walletContractEntity.getAvailableBalance().add(total), entrustOrderEntity.getSymbol(), "撤销委托单", "撤销委托单");
- if (i > 0) {
- return Result.ok(MessageSourceUtils.getString("cancellation_success"));
- }
- return Result.fail(MessageSourceUtils.getString("cancellation_fail"));
- }
-
- @Override
- public List<ContractEntrustOrderEntity> selectEntrustOrderListByIds(List<Long> list) {
- return contractEntrustOrderDao.selectEntrustOrderListByIds(list);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
deleted file mode 100644
index dcbb704..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
+++ /dev/null
@@ -1,710 +0,0 @@
-package com.xcong.excoin.modules.contract.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import com.alibaba.druid.sql.visitor.functions.If;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao;
-import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
-import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
-import com.xcong.excoin.modules.contract.mapper.ContractOrderEntityMapper;
-import com.xcong.excoin.modules.contract.parameter.dto.*;
-import com.xcong.excoin.modules.contract.parameter.vo.*;
-import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.dao.MemberLevelRateDao;
-import com.xcong.excoin.modules.member.dao.MemberSettingDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
-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.rabbit.producer.OrderProducer;
-import com.xcong.excoin.utils.*;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import jnr.a64asm.Mem;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import sun.rmi.runtime.Log;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Slf4j
-@Service
-public class ContractHoldOrderServiceImpl extends ServiceImpl<ContractHoldOrderDao, ContractHoldOrderEntity> implements ContractHoldOrderService {
-
- @Resource
- private ContractHoldOrderDao contractHoldOrderDao;
-
- @Resource
- private ContractOrderDao contractOrderDao;
-
- @Resource
- private ContractEntrustOrderDao contractEntrustOrderDao;
-
- @Resource
- private CommonService commonService;
-
- @Resource
- private MemberWalletContractDao memberWalletContractDao;
-
- @Resource
- private MemberLevelRateDao memberLevelRateDao;
-
- @Resource
- private CacheSettingUtils cacheSettingUtils;
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private OrderProducer producer;
-
- @Resource
- private MemberDao memberDao;
- @Resource
- private MemberSettingDao memberSettingDao;
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public Result submitOrder(SubmitOrderDto submitOrderDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(submitOrderDto.getSymbol())));
-
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeEnum.USDT.name());
-
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
-
- MemberSettingEntity memberSetting = memberSettingDao.selectMemberSettingByMemberId(memberEntity.getId());
- BigDecimal spread = memberSetting.getSpread();
- // 规格
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(submitOrderDto.getSymbol());
-
- // 开仓价
- BigDecimal openingPrice = BigDecimal.ZERO;
-
- // 开多
- if (submitOrderDto.getOrderType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) {
- // 市场价*(1 + (点差/10000))
- openingPrice = newPrice.multiply(BigDecimal.ONE.add(spread.divide(new BigDecimal(10000)))).setScale(8, BigDecimal.ROUND_DOWN);
-
- // 开空
- } else if (submitOrderDto.getOrderType() == ContractHoldOrderEntity.OPENING_TYPE_LESS) {
- // 市场价*(1 - (点差/10000))
- openingPrice = newPrice.multiply(BigDecimal.ONE.subtract(spread.divide(new BigDecimal(10000)))).setScale(8, BigDecimal.ROUND_DOWN);
- } else {
- return Result.fail("未知类型");
- }
-
- log.info("开仓价:{}", openingPrice);
- // 开仓手续费 建仓价*规格*手数*手续费率
- BigDecimal openFeePrice = openingPrice.multiply(lotNumber)
- .multiply(new BigDecimal(submitOrderDto.getSymbolCnt()))
- .multiply(tradeSettingEntity.getFeeRatio().divide(new BigDecimal(100)))
- .setScale(8, BigDecimal.ROUND_DOWN);
- log.info("开仓手续费:{}", openFeePrice);
-
- // 保证金 建仓价*规格*手数*(1/杠杆倍率)
- BigDecimal bondAmount = openingPrice.multiply(lotNumber).multiply(new BigDecimal(submitOrderDto.getSymbolCnt()))
- .multiply(BigDecimal.ONE.divide(new BigDecimal(submitOrderDto.getLeverRatio())))
- .setScale(8, BigDecimal.ROUND_DOWN);
- log.info("保证金:{}", bondAmount);
-
- // 预付款为 --> 保证金+开仓手续费+平仓手续费 (开仓平仓手续费相同)
- BigDecimal prePaymentAmount = bondAmount.add(openFeePrice).add(openFeePrice);
- log.info("预付款:{}", prePaymentAmount);
-
- if (prePaymentAmount.compareTo(walletContract.getAvailableBalance()) > -1) {
- return Result.fail("可用金额不足");
- }
-
- // 预估强平价
- BigDecimal forceClosingPrice = CalculateUtil.getForceSetPrice(bondAmount, openingPrice, submitOrderDto.getSymbolCnt(), lotNumber, submitOrderDto.getOrderType(), memberEntity);
- log.info("强平价:{}", forceClosingPrice);
-
- ContractHoldOrderEntity holdOrderEntity = new ContractHoldOrderEntity();
- holdOrderEntity.setMemberId(memberEntity.getId());
- holdOrderEntity.setOrderNo(commonService.generateOrderNo(memberEntity.getId()));
- holdOrderEntity.setPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ADD);
- holdOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_MARK);
- holdOrderEntity.setSymbol(submitOrderDto.getSymbol());
- holdOrderEntity.setSymbolCnt(submitOrderDto.getSymbolCnt());
- holdOrderEntity.setSymbolSku(lotNumber);
- holdOrderEntity.setLeverRatio(submitOrderDto.getLeverRatio());
- holdOrderEntity.setForceClosingPrice(forceClosingPrice);
- holdOrderEntity.setOpeningFeeAmount(openFeePrice);
- holdOrderEntity.setOpeningPrice(openingPrice);
- holdOrderEntity.setOpeningType(submitOrderDto.getOrderType());
- holdOrderEntity.setMarkPrice(newPrice);
- holdOrderEntity.setIsCanClosing(ContractHoldOrderEntity.ORDER_CAN_CLOSING_Y);
- holdOrderEntity.setPrePaymentAmount(prePaymentAmount);
- holdOrderEntity.setBondAmount(bondAmount.add(openFeePrice));
- holdOrderEntity.setOperateNo(1);
-
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity);
- contractOrderEntity.setOpeningTime(new Date());
- contractHoldOrderDao.insert(holdOrderEntity);
- int i = contractOrderDao.insert(contractOrderEntity);
-
- if (i > 0) {
- memberWalletContractDao.increaseWalletContractBalanceById(prePaymentAmount.negate(), openFeePrice.negate(), null, walletContract.getId());
-
- // 发送爆仓消息
- sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
-
- // 计算佣金
- ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN);
-
- // 插入财务流水
- if (submitOrderDto.getOrderType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) {
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), prePaymentAmount, walletContract.getAvailableBalance().subtract(prePaymentAmount), submitOrderDto.getSymbol(), "买涨持仓", "买涨:" + submitOrderDto.getSymbol());
- } else {
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), prePaymentAmount, walletContract.getAvailableBalance().subtract(prePaymentAmount), submitOrderDto.getSymbol(), "买跌持仓", "买跌:" + submitOrderDto.getSymbol());
- }
- return Result.ok("提交成功");
- }
- return Result.fail("提交失败");
- }
-
- @Override
- public int updateContractHoldOrderCanNotClosingByIds(List<OrderModel> list, String batchNo) {
- return contractHoldOrderDao.updateContractHoldOrderCanNotClosingByIds(list, batchNo);
- }
-
- @Override
- public List<ContractHoldOrderEntity> selectContractHoldOrderByBatchNo(String batchNo) {
- return contractHoldOrderDao.selectContractHoldOrderByBatchNo(batchNo);
- }
-
- @Override
- public void updateOrderIsCanClosingAndBatchNoById(Long id) {
- contractHoldOrderDao.updateOrderIsCanClosingAndBatchNoById(id);
- }
-
- @Override
- public Result findHoldOrderList(String symbol) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- List<ContractHoldOrderEntity> list = contractHoldOrderDao.selectHoldOrderListByMemberIdAndSymbol(memberEntity.getId(), symbol);
- MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeEnum.USDT.name());
- if (CollUtil.isNotEmpty(list)) {
- BigDecimal totalProfitOrLoss = BigDecimal.ZERO;
- List<HoldOrderListVo> resultList = new ArrayList<>();
- for (ContractHoldOrderEntity holdOrderEntity : list) {
- HoldOrderListVo holdOrderListVo = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToDto(holdOrderEntity);
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(holdOrderEntity.getSymbol());
- // 盈亏
- BigDecimal rewardRatio = BigDecimal.ZERO;
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- // (最新价-开仓价)*规格*张数
- rewardRatio = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- // 开空
- } else {
- // (开仓价-最新价)*规格*张数
- rewardRatio = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- }
-
- if (memberEntity.getIsProfit() == MemberEntity.IS_PROFIT_Y) {
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
- if (rewardRatio.compareTo(BigDecimal.ZERO) > -1) {
- rewardRatio = rewardRatio.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
- } else {
-// rewardRatio = rewardRatio.multiply(BigDecimal.ONE.add(tradeSettingEntity.getProfitParam()));
- }
- }
-
- // 回报率
- BigDecimal returnRate = rewardRatio.divide(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
-
- // 成本价格
- BigDecimal costPrice = holdOrderEntity.getOpeningPrice()
- .multiply(lotNumber)
- .multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()))
- .divide(new BigDecimal(holdOrderEntity.getLeverRatio()), 8, BigDecimal.ROUND_DOWN);
-
- // 可增加最大保证金
-// BigDecimal canAddMaxBond = holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()).subtract(costPrice);
-// if (canAddMaxBond.compareTo(BigDecimal.ZERO) < 0) {
-// canAddMaxBond = BigDecimal.ZERO;
-// }
- BigDecimal canReduceMaxBond = holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getPrePaymentAmount());
-
- if (rewardRatio.compareTo(BigDecimal.ZERO) < 0) {
- canReduceMaxBond = canReduceMaxBond.add(rewardRatio);
- }
-
- if (canReduceMaxBond.compareTo(BigDecimal.ZERO) < 0) {
- canReduceMaxBond = BigDecimal.ZERO;
- }
-
- holdOrderListVo.setCanReduceMaxBond(canReduceMaxBond);
- holdOrderListVo.setCanAddMaxBond(walletContractEntity.getAvailableBalance());
- holdOrderListVo.setReturnRate(returnRate);
- holdOrderListVo.setProfitOrLoss(rewardRatio);
- resultList.add(holdOrderListVo);
- totalProfitOrLoss = totalProfitOrLoss.add(rewardRatio);
- }
-
- Map<String, Object> result = new HashMap<>();
- result.put("hold", resultList);
- result.put("totalProfitOrLoss", totalProfitOrLoss.setScale(4, BigDecimal.ROUND_DOWN).toPlainString());
- return Result.ok(result);
- }
- return Result.ok("success");
- }
-
- @Override
- public Result cancelHoldOrder(Long id) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectHoldOrderByMemberIdAndId(memberEntity.getId(), id);
- if (holdOrderEntity == null) {
- return Result.fail("订单不存在");
- }
-
- if (ContractHoldOrderEntity.ORDER_CAN_CLOSING_N == holdOrderEntity.getIsCanClosing()) {
- return Result.fail("订单暂不可平仓");
- }
-
- contractHoldOrderDao.updateHoldOrderIsCanClosingById(ContractHoldOrderEntity.ORDER_CAN_CLOSING_N, id);
- // 发送平仓消息
- List<Long> ids = new ArrayList<>();
- ids.add(id);
- producer.sendCloseTrade(JSONObject.toJSONString(ids));
-
- return Result.ok("平仓成功");
- }
-
- @Override
- public Result cancelHoldOrderBatch(SymbolDto symbolDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectHoldOrderListByMemberIdAndSymbol(memberEntity.getId(), symbolDto.getSymbol());
- if (CollUtil.isEmpty(holdOrderEntities)) {
- return Result.fail("订单不存在");
- }
-
- List<Long> ids = new ArrayList<>();
- for (ContractHoldOrderEntity holdOrderEntity : holdOrderEntities) {
- contractHoldOrderDao.updateHoldOrderIsCanClosingById(ContractHoldOrderEntity.ORDER_CAN_CLOSING_N, holdOrderEntity.getId());
- ids.add(holdOrderEntity.getId());
- }
- producer.sendCloseTrade(JSONObject.toJSONString(ids));
- return Result.ok("平仓成功");
- }
-
- @Override
- public Result setTargetProfitOrLess(ProfitOrLessDto profitOrLessDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectHoldOrderByMemberIdAndId(memberEntity.getId(), profitOrLessDto.getId());
- if (holdOrderEntity == null) {
- return Result.fail("订单不存在");
- }
-
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
- // 开仓价
- BigDecimal openPrice = holdOrderEntity.getOpeningPrice();
- // 设置的止盈止损价
- BigDecimal stopProfitPrice = profitOrLessDto.getStopProfitPrice();
-
- BigDecimal stopLessPrice = profitOrLessDto.getStopLessPrice();
-
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- if (stopProfitPrice != null) {
- // 当前价大于开仓价
- if (newPrice.compareTo(openPrice) > 0) {
- // 如果止盈价小于当前价
- if (stopProfitPrice.compareTo(newPrice) < 0) {
- return Result.fail("止盈价必须高于当前价");
- }
- } else {
- if (stopProfitPrice.compareTo(openPrice) < 0) {
- return Result.fail("止盈价必须高于开仓价");
- }
- }
- }
-
- if (stopLessPrice != null) {
- if (newPrice.compareTo(openPrice) > 0) {
- if (stopLessPrice.compareTo(openPrice) > 0) {
- return Result.fail("止损价必须低于开仓价");
- }
- } else {
- if (stopLessPrice.compareTo(newPrice) > 0) {
- return Result.fail("止损价必须低于当前价");
- }
- }
- }
- // 开空
- } else {
- if (stopProfitPrice != null) {
- if (newPrice.compareTo(openPrice) > 0) {
- if (stopProfitPrice.compareTo(openPrice) > 0) {
- return Result.fail("止盈价必须低于开仓价");
- }
- } else {
- if (stopProfitPrice.compareTo(newPrice) > 0) {
- return Result.fail("止盈价必须低于当前价");
- }
- }
- }
- if (stopLessPrice != null) {
- if (newPrice.compareTo(openPrice) > 0) {
- if (stopLessPrice.compareTo(newPrice) < 0) {
- return Result.fail("止损价必须高于当前价");
- }
- } else {
- if (stopLessPrice.compareTo(openPrice) < 0) {
- return Result.fail("止损价必须高于开仓价");
- }
- }
- }
- }
-
- holdOrderEntity.setStopProfitPrice(stopProfitPrice);
- holdOrderEntity.setStopLossPrice(stopLessPrice);
-
- int i = contractHoldOrderDao.updateById(holdOrderEntity);
- if (i > 0) {
- OrderModel model = null;
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- // 开多止盈
- if (stopProfitPrice != null) {
- model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 开多止损
- if (stopLessPrice != null) {
- model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- } else {
- // 开空止盈
- if (stopProfitPrice != null) {
- model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 开空止损
- if (stopLessPrice != null) {
- model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- }
- return Result.ok("设置成功");
- }
- return Result.fail("设置失败");
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public Result changeBond(ChangeBondDto changeBondDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectHoldOrderByMemberIdAndId(memberEntity.getId(), changeBondDto.getId());
- if (holdOrderEntity == null) {
- return Result.fail("订单不存在");
- }
-
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeEnum.USDT.name());
-
- // 增加保证金
- if (ChangeBondDto.TYPE_ADD == changeBondDto.getType()) {
- if (changeBondDto.getAmount().compareTo(walletContract.getAvailableBalance()) > 0) {
- return Result.fail("可用余额不足");
- }
- memberWalletContractDao.increaseWalletContractBalanceById(changeBondDto.getAmount().negate(), null, null, walletContract.getId());
- holdOrderEntity.setBondAmount(holdOrderEntity.getBondAmount().add(changeBondDto.getAmount()));
- // 减少保证金
- } else {
- if (holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getPrePaymentAmount()).subtract(changeBondDto.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail("超出保证金最大减少金额");
- }
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
-
- BigDecimal rewardRatio = BigDecimal.ZERO;
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- // (最新价-开仓价)*规格*张数
- rewardRatio = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(holdOrderEntity.getSymbolSku()).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- // 开空
- } else {
- // (开仓价-最新价)*规格*张数
- rewardRatio = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(holdOrderEntity.getSymbolSku()).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- }
-
- if (memberEntity.getIsProfit() == MemberEntity.IS_PROFIT_Y) {
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
- if (rewardRatio.compareTo(BigDecimal.ZERO) > -1) {
- rewardRatio = rewardRatio.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
- }
- }
-
- if (rewardRatio.compareTo(BigDecimal.ZERO) < 0) {
- BigDecimal canReduceMax = holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getPrePaymentAmount()).add(rewardRatio);
- if (canReduceMax.subtract(changeBondDto.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
- return Result.fail("超出保证金最大减少金额");
- }
- }
-
- memberWalletContractDao.increaseWalletContractBalanceById(changeBondDto.getAmount(), null, null, walletContract.getId());
- holdOrderEntity.setBondAmount(holdOrderEntity.getBondAmount().subtract(changeBondDto.getAmount()));
- }
-
- BigDecimal forceClosingPrice = CalculateUtil.getForceSetPrice(holdOrderEntity.getBondAmount(), holdOrderEntity.getOpeningPrice(), holdOrderEntity.getSymbolCnt(), holdOrderEntity.getSymbolSku(), holdOrderEntity.getOpeningType(), memberEntity);
- holdOrderEntity.setForceClosingPrice(forceClosingPrice);
- holdOrderEntity.setOperateNo(holdOrderEntity.getOperateNo() + 1);
-
- int i = contractHoldOrderDao.updateById(holdOrderEntity);
-
- if (i > 0) {
- // 发送爆仓消息
- sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
- return Result.ok("调整成功");
- }
- return Result.fail("调整失败");
- }
-
- @Override
- public Result findContractMoneyInfo(String symbol) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- BigDecimal newPriceSymbol = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol)));
-
- // 当前合约委托单
- List<ContractEntrustOrderEntity> entrustOrderEntities = contractEntrustOrderDao.selectEntrustOrderListByMemberId(memberEntity.getId());
-
- // 当前持仓列表
- List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectHoldOrderListByMemberId(memberEntity.getId());
-
- // 冻结保证金 -- 即委托单中的保证金之和
- BigDecimal frozenBondAmount = BigDecimal.ZERO;
- if (CollUtil.isNotEmpty(entrustOrderEntities)) {
- for (ContractEntrustOrderEntity entrustOrderEntity : entrustOrderEntities) {
- frozenBondAmount = frozenBondAmount.add(entrustOrderEntity.getBondAmount());
- }
- }
-
- // 占用保证金 -- 即持仓单中的保证金之和
- BigDecimal beUsedBondAmount = BigDecimal.ZERO;
- // 总盈利
- BigDecimal totalProfitOrLess = BigDecimal.ZERO;
- if (CollUtil.isNotEmpty(holdOrderEntities)) {
- for (ContractHoldOrderEntity holdOrderEntity : holdOrderEntities) {
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(holdOrderEntity.getSymbol());
- beUsedBondAmount = beUsedBondAmount.add(holdOrderEntity.getBondAmount());
-
- // 单个订单盈利
- BigDecimal profitOrLess = BigDecimal.ZERO;
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- profitOrLess = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt())).multiply(lotNumber);
- // 开空
- } else {
- profitOrLess = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt())).multiply(lotNumber);
- }
-
- if (MemberEntity.IS_PROFIT_Y == memberEntity.getIsProfit()) {
- if (profitOrLess.compareTo(BigDecimal.ZERO) > 0) {
- profitOrLess = profitOrLess.multiply(BigDecimal.ONE.subtract(tradeSetting.getForceParam()));
- } else {
- profitOrLess = profitOrLess.multiply(BigDecimal.ONE.add(tradeSetting.getForceParam()));
- }
- }
-
- totalProfitOrLess = totalProfitOrLess.add(profitOrLess);
- }
- }
-
- MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeEnum.USDT.name());
-
- MemberLevelRateEntity rateEntity = memberLevelRateDao.selectLeverRateByMemberIdAndSymbol(memberEntity.getId(), symbol);
-
- // 权益
- BigDecimal equity = walletContractEntity.getTotalBalance().add(totalProfitOrLess);
-
- ContractMoneyInfoVo contractMoneyInfoVo = new ContractMoneyInfoVo();
- contractMoneyInfoVo.setAvailableBalance(walletContractEntity.getAvailableBalance());
- contractMoneyInfoVo.setBeUsedBondAmount(beUsedBondAmount);
- contractMoneyInfoVo.setFrozenBondAmount(frozenBondAmount);
- contractMoneyInfoVo.setEquity(equity);
- contractMoneyInfoVo.setFeeRatio(tradeSetting.getFeeRatio());
- contractMoneyInfoVo.setLeverAgeRatio(tradeSetting.getLeverageRatio());
- contractMoneyInfoVo.setNewPrice(newPriceSymbol);
- contractMoneyInfoVo.setSymbolSku(cacheSettingUtils.getSymbolSku(symbol));
- contractMoneyInfoVo.setLeverRate(rateEntity.getLevelRateUp());
- return Result.ok(contractMoneyInfoVo);
- }
-
- @Override
- public Result changeLeverRate(ChangeLeverRateDto changeLeverRateDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- MemberLevelRateEntity levelRateEntity = memberLevelRateDao.selectLeverRateByMemberIdAndSymbol(memberEntity.getId(), changeLeverRateDto.getSymbol());
- levelRateEntity.setLevelRateUp(changeLeverRateDto.getLeverRate());
- levelRateEntity.setLevelRateDown(changeLeverRateDto.getLeverRate());
- int i = memberLevelRateDao.updateById(levelRateEntity);
- if (i > 0) {
- return Result.ok("调整成功");
- }
- return Result.fail("调整失败");
- }
-
- @Override
- public Result findHoldOrderDetailById(Long id) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectHoldOrderByMemberIdAndId(memberEntity.getId(), id);
- if (holdOrderEntity == null) {
- return Result.fail("订单不存在");
- }
-
- HoldOrderDetailVo holdOrderDetailVo = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrderDetailVo(holdOrderEntity);
- BigDecimal feeSpread = cacheSettingUtils.getTradeSetting().getFeeSpreadRatio();
-// holdOrderDetailVo.setOpeningFeeAmount(holdOrderDetailVo.getOpeningFeeAmount().multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN));
- holdOrderDetailVo.setOpeningFeeAmount(holdOrderEntity.getOpeningFeeAmount(), feeSpread);
- return Result.ok(holdOrderDetailVo);
- }
-
- @Override
- public Result findOrderList(OrderListDto orderListDto) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- Page<ContractOrderEntity> page = new Page<>(orderListDto.getPageNum(), orderListDto.getPageSize());
- ContractOrderEntity contractOrderEntity = new ContractOrderEntity();
- contractOrderEntity.setMemberId(memberEntity.getId());
- contractOrderEntity.setSymbol(orderListDto.getSymbol());
- IPage<ContractOrderEntity> list = contractOrderDao.selectContractOrderInPage(page, contractOrderEntity);
- Page<OrderListVo> result = ContractOrderEntityMapper.INSTANCE.pageEntityToPageVo(list);
- return Result.ok(result);
- }
-
- @Override
- public Result findOrderDetailById(Long id) {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
- ContractOrderEntity contractOrderEntity = contractOrderDao.selectOrderDetailByIdAndMemberId(id, memberEntity.getId());
- if (contractOrderEntity == null) {
- return Result.fail("订单不存在");
- }
-
- OrderDetailVo orderDetailVo = ContractOrderEntityMapper.INSTANCE.entityToDetailVo(contractOrderEntity);
- BigDecimal feeSpread = cacheSettingUtils.getTradeSetting().getFeeSpreadRatio();
-// orderDetailVo.setClosingFeeAmount(orderDetailVo.getClosingFeeAmount() == null ? orderDetailVo.getClosingFeeAmount() : orderDetailVo.getClosingFeeAmount().multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN));
-// orderDetailVo.setOpeningFeeAmount(orderDetailVo.getOpeningFeeAmount() == null ? orderDetailVo.getOpeningFeeAmount() : orderDetailVo.getOpeningFeeAmount().multiply(feeSpread).setScale(8, BigDecimal.ROUND_DOWN));
- orderDetailVo.setOpeningFeeAmount(contractOrderEntity.getOpeningFeeAmount(), feeSpread);
- orderDetailVo.setClosingFeeAmount(contractOrderEntity.getClosingFeeAmount(), feeSpread);
- return Result.ok(orderDetailVo);
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void calHoldOrderHoldFeeAmount() {
- List<ContractHoldOrderEntity> list = contractHoldOrderDao.selectAllHoldOrder();
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
-
- if (CollUtil.isNotEmpty(list)) {
- for (ContractHoldOrderEntity holdOrderEntity : list) {
- BigDecimal holdAmount = holdOrderEntity.getHoldAmount();
- if (holdAmount == null) {
- holdAmount = BigDecimal.ZERO;
- }
-
- BigDecimal thisTimeHold = holdOrderEntity.getBondAmount().multiply(tradeSettingEntity.getDoingRatio());
- log.info("订单编号:{}, 持仓费:{}", holdOrderEntity.getOrderNo(), thisTimeHold);
- MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(holdOrderEntity.getMemberId(), CoinTypeEnum.USDT.name());
-
- // 判断当前可用余额是否大于目前持仓费,若大于则扣可用余额,若小于则扣保证金中的金额
- if (thisTimeHold.compareTo(walletContractEntity.getAvailableBalance()) < 0) {
- memberWalletContractDao.increaseWalletContractBalanceById(thisTimeHold.negate(), thisTimeHold.negate(), null, walletContractEntity.getId());
-
- holdOrderEntity.setHoldAmount(holdAmount.add(thisTimeHold));
- contractHoldOrderDao.updateById(holdOrderEntity);
- } else {
- BigDecimal available = walletContractEntity.getAvailableBalance();
- BigDecimal lessAmount = thisTimeHold.subtract(available);
- MemberEntity memberEntity = memberDao.selectById(holdOrderEntity.getMemberId());
- memberWalletContractDao.increaseWalletContractBalanceById(available.negate(), available.negate(), null, walletContractEntity.getId());
-
- BigDecimal newBondAmount = holdOrderEntity.getBondAmount().subtract(lessAmount);
-
- BigDecimal newForcePrice = CalculateUtil.getForceSetPrice(newBondAmount.subtract(holdOrderEntity.getOpeningFeeAmount()), holdOrderEntity.getOpeningPrice(), holdOrderEntity.getSymbolCnt(), holdOrderEntity.getSymbolSku(), holdOrderEntity.getOpeningType(), memberEntity);
-
- holdOrderEntity.setHoldAmount(holdAmount.add(thisTimeHold));
- holdOrderEntity.setBondAmount(newBondAmount);
- holdOrderEntity.setForceClosingPrice(newForcePrice);
- holdOrderEntity.setOperateNo(holdOrderEntity.getOperateNo() + 1);
- contractHoldOrderDao.updateById(holdOrderEntity);
-
- // 发送爆仓消息
- sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), newForcePrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
- }
- }
- }
- }
-
- public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo) {
- OrderModel model = null;
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) {
- model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
- // 开空
- } else {
- model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
- }
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void calHoldFeeAmountForBondAmount() {
- List<ContractHoldOrderEntity> list = contractHoldOrderDao.selectAllHoldOrder();
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
-
- if (CollUtil.isNotEmpty(list)) {
- for (ContractHoldOrderEntity holdOrderEntity : list) {
- BigDecimal holdAmount = holdOrderEntity.getHoldAmount();
- if (holdAmount == null) {
- holdAmount = BigDecimal.ZERO;
- }
-
- BigDecimal thisTimeHold = holdOrderEntity.getBondAmount().multiply(tradeSettingEntity.getDoingRatio());
- log.info("订单编号:{}, 持仓费:{}", holdOrderEntity.getOrderNo(), thisTimeHold);
-
- MemberEntity memberEntity = memberDao.selectById(holdOrderEntity.getMemberId());
- BigDecimal subBond = holdOrderEntity.getBondAmount().subtract(thisTimeHold);
-
- BigDecimal newForcePrice = CalculateUtil.getForceSetPrice(subBond.subtract(holdOrderEntity.getOpeningFeeAmount()), holdOrderEntity.getOpeningPrice(), holdOrderEntity.getSymbolCnt(), holdOrderEntity.getSymbolSku(), holdOrderEntity.getOpeningType(), memberEntity);
- holdAmount = holdAmount.add(thisTimeHold);
- holdOrderEntity.setBondAmount(subBond);
- holdOrderEntity.setHoldAmount(holdAmount);
- holdOrderEntity.setForceClosingPrice(newForcePrice);
- holdOrderEntity.setOperateNo(holdOrderEntity.getOperateNo() + 1);
- contractHoldOrderDao.updateById(holdOrderEntity);
-
- // 发送爆仓消息
- sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), newForcePrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
- }
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractOrderServiceImpl.java
deleted file mode 100644
index 9fdc086..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractOrderServiceImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.contract.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.parameter.dto.SubmitOrderDto;
-import com.xcong.excoin.modules.contract.service.ContractOrderService;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.RedisUtils;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-27
- **/
-@Service
-public class ContractOrderServiceImpl extends ServiceImpl<ContractOrderDao, ContractOrderEntity> implements ContractOrderService {
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
deleted file mode 100644
index 93b135e..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
+++ /dev/null
@@ -1,759 +0,0 @@
-package com.xcong.excoin.modules.contract.service.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao;
-import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.mapper.ContractEntrustOrderEntityMapper;
-import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
-import com.xcong.excoin.modules.contract.service.ContractEntrustOrderService;
-import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
-import com.xcong.excoin.modules.contract.service.ContractOrderService;
-import com.xcong.excoin.modules.member.dao.AgentReturnDao;
-import com.xcong.excoin.modules.member.dao.MemberSettingDao;
-import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberSettingEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo;
-import com.xcong.excoin.modules.member.service.MemberService;
-import com.xcong.excoin.modules.member.service.MemberWalletContractService;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import com.xcong.excoin.rabbit.producer.OrderProducer;
-import com.xcong.excoin.utils.CacheSettingUtils;
-import com.xcong.excoin.utils.CalculateUtil;
-import com.xcong.excoin.utils.ThreadPoolUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-
-/**
- * @author helius
- */
-@Slf4j
-@Service
-public class OrderWebsocketServiceImpl {
-
- @Resource
- ContractHoldOrderService contractHoldOrderService;
-
- @Resource
- ContractOrderService contractOrderService;
-
- @Resource
- ContractEntrustOrderService contractEntrustOrderService;
-
- @Resource
- MemberWalletContractService memberWalletContractService;
-
- @Resource
- CacheSettingUtils cacheSettingUtils;
-
- @Resource
- OrderProducer producer;
-
- @Resource
- MemberService memberService;
-
- @Resource
- private AgentReturnDao agentReturnDao;
-
- @Resource
- private MemberAccountFlowEntityDao memberAccountFlowEntityDao;
- @Resource
- private MemberSettingDao memberSettingDao;
-
-
- public void dealOrderFromMq(List<OrderModel> list, Integer type) {
- if (CollectionUtils.isNotEmpty(list)) {
- String batchno = UUID.randomUUID().toString();
- // 更新订单状态
- // 更新为不可平仓状态
- int count = contractHoldOrderService.updateContractHoldOrderCanNotClosingByIds(list, batchno);
- // 查询
- if (count > 0) {
- // 查询
- List<ContractHoldOrderEntity> coinsCoinsOrders = contractHoldOrderService.selectContractHoldOrderByBatchNo(batchno);
- // 根据状态调用不同的方法
- // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空
- // 6在这里是爆仓 包括爆空和暴多
- switch (type) {
- case 6:
- this.dealCoinOut(coinsCoinsOrders, list);
- break;
- case 9:
- this.dealForMoreStopPro(coinsCoinsOrders, list);
- break;
- case 10:
- this.dealForLessStopPro(coinsCoinsOrders, list);
- break;
- case 11:
- this.dealForMoreLoss(coinsCoinsOrders, list);
- break;
- case 12:
- this.dealForLessLoss(coinsCoinsOrders, list);
- break;
- default:
- break;
- }
-
- }
-
-
- }
- }
-
- public void dealForLimitMq(List<OrderModel> list) {
- if (CollectionUtils.isNotEmpty(list)) {
- //查询限价委托的单
- String batchno = UUID.randomUUID().toString();
- List<Long> ids = new ArrayList<>();
- list.forEach(model -> ids.add(model.getOrderId()));
- List<ContractEntrustOrderEntity> contractEntrustOrderEntities = contractEntrustOrderService.selectEntrustOrderListByIds(ids);
-
- if (CollectionUtils.isNotEmpty(contractEntrustOrderEntities)) {
- this.dealLimitBuyOrder(contractEntrustOrderEntities);
- }
-
- }
- }
-
- /**
- * 开多止盈
- */
- @Transactional(rollbackFor = Exception.class)
- public void dealForMoreStopPro(List<ContractHoldOrderEntity> orderList, List<OrderModel> list) {
- if (CollectionUtils.isNotEmpty(orderList)) {
- Map<Long, BigDecimal> modelMap = new HashMap<Long, BigDecimal>();
- for (OrderModel model : list) {
- modelMap.put(model.getOrderId(), new BigDecimal(model.getPrice()));
- }
- for (ContractHoldOrderEntity order : orderList) {
- Long orderId = order.getId();
- System.out.println("开多止盈订单号:" + order.getOrderNo());
- System.out.println("传来的止盈价格:" + modelMap.get(order.getId()));
- if (null != order.getStopProfitPrice()) {
- BigDecimal closePrice = order.getStopProfitPrice();
- BigDecimal queuePrice = modelMap.get(order.getId());
- System.out.println("订单的止盈价格:" + closePrice);
- // 判断 保留七位是为了忽略以为小数 防止不精确导致的不相等
- if (queuePrice.compareTo(closePrice) != 0) {
-
- // 不能止盈
- System.out.println("数据库价格:" + queuePrice.toPlainString() + "--价格不能止盈:" + closePrice);
- //更新数据
- contractHoldOrderService.updateOrderIsCanClosingAndBatchNoById(orderId);
- continue;
- }
- System.out.println("执行操作");
- // 止盈价
- String symbol = order.getSymbol();
- // 本次需要退回的保证金
- BigDecimal prePrice = order.getBondAmount();
- Long memberId = order.getMemberId();
- MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT");
- if (wallet != null) {
- // 历史订单
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(order);
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setId(null);
-
- // 本次平仓数量
- int currentFlat = order.getSymbolCnt();
- BigDecimal symbolSku = cacheSettingUtils.getSymbolSku(order.getSymbol());
- // 盈亏额度= (当前的币种的平仓价-下单时的建仓价)*购买的手数/规格*倍率
- BigDecimal profitLossPrice = (closePrice
- .subtract(order.getOpeningPrice()))
- .multiply(new BigDecimal(currentFlat))
- .multiply(symbolSku).setScale(8, BigDecimal.ROUND_DOWN);
- MemberEntity memberEntity = memberService.getById(memberId);
- MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(memberId);
- log.info("划点前:{}", profitLossPrice);
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_DOWN)));
- log.info("划点后:{}", profitLossPrice);
- if (memberEntity.getIsProfit() == 1) {
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
- } else {
-// profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
- }
- }
- //回报率
- BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN);
- contractOrderEntity.setRewardAmount(profitLossPrice);
- contractOrderEntity.setRewardRatio(returnRate);
- contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
- contractOrderEntity.setClosingPrice(closePrice);
- contractOrderEntity.setClosingType(6);
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
- BigDecimal totalReturn = BigDecimal.ZERO;
- contractOrderService.save(contractOrderEntity);
-
- contractHoldOrderService.removeById(order.getId());
- // 将需要退回的减去手续费
- BigDecimal needReturn = prePrice.add(profitLossPrice);
- //总退回金额=保证金+收益-手续费
- totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
- // 总的是收益-平仓手续费
- BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-
- memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
-
- // 流水记录 TODO 531e
- insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
-
- //返佣
- ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE);
- }
- }
- }
- }
-
- }
-
- /**
- * 开空止盈
- */
- public void dealForLessStopPro(List<ContractHoldOrderEntity> orderList, List<OrderModel> list) {
- //List<CoinsCoinsOrder> orderList = orderMapper.selectOrderByBatchNo(batchno);
- //System.out.println("开空止盈订单batchno:" + batchno);
- if (CollectionUtils.isNotEmpty(orderList)) {
- Map<Long, BigDecimal> modelMap = new HashMap<Long, BigDecimal>();
- for (OrderModel model : list) {
- modelMap.put(model.getOrderId(), new BigDecimal(model.getPrice()));
- }
- for (ContractHoldOrderEntity order : orderList) {
- System.out.println("开空止盈订单号:" + order.getOrderNo());
- System.out.println("传来的止盈价格:" + modelMap.get(order.getId()).toPlainString());
- BigDecimal closePrice = order.getStopProfitPrice();
- Long orderId = order.getId();
- if (null != closePrice) {
-
- // 止盈价
- System.out.println("订单的止盈价格:" + closePrice);
- System.out.println(closePrice.compareTo(modelMap.get(order.getId())));
- BigDecimal queuePrice = modelMap.get(order.getId()).setScale(7, RoundingMode.HALF_UP);
- if (closePrice.compareTo(queuePrice) != 0) {
- System.out.println("数据库价格:" + queuePrice.toPlainString() + "--价格不能开空止盈:" + closePrice);
- contractHoldOrderService.updateOrderIsCanClosingAndBatchNoById(orderId);
- continue;
- }
- System.out.println("执行操作");
- String symbol = order.getSymbol();
- // 本次需要退回的预付款
- BigDecimal prePrice = order.getBondAmount();
- Long memberId = order.getMemberId();
- MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT");
- if (wallet != null) {
- // 历史订单
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(order);
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setId(null);
-
- // 本次平仓数量
- int currentFlat = order.getSymbolCnt();
- BigDecimal symbolSku = cacheSettingUtils.getSymbolSku(order.getSymbol());
- // 盈亏额度= (当前的币种的平仓价-下单时的建仓价)*购买的手数/规格*倍率
- BigDecimal profitLossPrice = (order.getOpeningPrice()
- .subtract(closePrice))
- .multiply(new BigDecimal(currentFlat + ""))
- .multiply(symbolSku).setScale(8, BigDecimal.ROUND_DOWN);
- MemberEntity memberEntity = memberService.getById(memberId);
- MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(memberId);
- log.info("划点前:{}", profitLossPrice);
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_DOWN)));
- log.info("划点后:{}", profitLossPrice);
- if (memberEntity.getIsProfit() == 1) {
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
- } else {
-// profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
- }
- }
- //回报率
- BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN);
- contractOrderEntity.setRewardAmount(profitLossPrice);
- contractOrderEntity.setRewardRatio(returnRate);
- contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
- contractOrderEntity.setClosingPrice(closePrice);
- contractOrderEntity.setClosingType(7);
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
- BigDecimal totalReturn = BigDecimal.ZERO;
- contractOrderService.save(contractOrderEntity);
-
- contractHoldOrderService.removeById(order.getId());
- // 将需要退回的减去手续费
- BigDecimal needReturn = prePrice.add(profitLossPrice);
- //总退回金额=保证金+收益-手续费
- totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
- // 更新钱包
- // 总的是收益-平仓手续费
- BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-
- memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
-
- insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
-
- //返佣
- ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE);
- }
- }
- }
- }
-
- }
-
- /**
- * 开多止损
- *
- * @param
- */
- public void dealForMoreLoss(List<ContractHoldOrderEntity> orderList, List<OrderModel> list) {
- //List<CoinsCoinsOrder> orderList = orderMapper.selectOrderByBatchNo(batchno);
- //System.out.println("开多止损批次号batchno:" + batchno);
- if (CollectionUtils.isNotEmpty(orderList)) {
- Map<Long, BigDecimal> modelMap = new HashMap<Long, BigDecimal>();
- for (OrderModel model : list) {
- modelMap.put(model.getOrderId(), new BigDecimal(model.getPrice()));
- }
- for (ContractHoldOrderEntity order : orderList) {
- System.out.println("开多止损订单号:" + order.getOrderNo());
- Long orderId = order.getId();
- System.out.println("传来的止损价格:" + modelMap.get(orderId));
-
- if (null != order.getStopLossPrice()) {
- // 止损价
- BigDecimal closePrice = order.getStopLossPrice();
- System.out.println("订单止损价格:" + closePrice.toPlainString());
- BigDecimal queuePrice = modelMap.get(orderId);
- if (closePrice.compareTo(queuePrice) != 0) {
- System.out.println("数据库价格:" + queuePrice.toPlainString() + "--价格不能开多止损:" + closePrice);
- contractHoldOrderService.updateOrderIsCanClosingAndBatchNoById(orderId);
- continue;
- }
- System.out.println("执行操作");
- String symbol = order.getSymbol();
- Long memberId = order.getMemberId();
- // 本次需要退回的预付款
- BigDecimal prePrice = order.getBondAmount();
- MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT");
-
- if (wallet != null) {
- // 历史订单
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(order);
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setId(null);
-
- // 本次平仓数量
- int currentFlat = order.getSymbolCnt();
- BigDecimal symbolSku = cacheSettingUtils.getSymbolSku(order.getSymbol());
- // 盈亏额度= (当前的币种的平仓价-下单时的建仓价)*购买的手数/规格*倍率
- BigDecimal profitLossPrice = (closePrice
- .subtract(order.getOpeningPrice()))
- .multiply(new BigDecimal(currentFlat + ""))
- .multiply(symbolSku).setScale(8, BigDecimal.ROUND_DOWN);
- MemberEntity memberEntity = memberService.getById(memberId);
-
- if (memberEntity.getIsProfit() == 1) {
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
- } else {
-// profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
- }
- }
- //回报率
- BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN);
- contractOrderEntity.setRewardAmount(profitLossPrice);
- contractOrderEntity.setRewardRatio(returnRate);
- contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
- contractOrderEntity.setClosingPrice(closePrice);
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
- contractOrderEntity.setClosingType(8);
- BigDecimal totalReturn = BigDecimal.ZERO;
- contractOrderService.save(contractOrderEntity);
-
- contractHoldOrderService.removeById(order.getId());
- // 将需要退回的减去手续费
- BigDecimal needReturn = prePrice.add(profitLossPrice);
- //总退回金额=保证金+收益-手续费
- totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
- // 更新钱包
- // 总的是收益-平仓手续费
- BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-
- memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
-
- insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓");
-
- //返佣
- ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE);
- }
- }
- }
- }
- }
-
- /**
- * 开空止损
- *
- * @param
- */
- public void dealForLessLoss(List<ContractHoldOrderEntity> orderList, List<OrderModel> list) {
- // List<CoinsCoinsOrder> orderList = orderMapper.selectOrderByBatchNo(batchno);
- //System.out.println("开空止损批次号batchno:" + batchno);
- if (CollectionUtils.isNotEmpty(orderList)) {
- Map<Long, BigDecimal> modelMap = new HashMap<Long, BigDecimal>();
- for (OrderModel model : list) {
- modelMap.put(model.getOrderId(), new BigDecimal(model.getPrice()));
- }
- for (ContractHoldOrderEntity order : orderList) {
- Long orderId = order.getId();
- System.out.println("传来的止损价格:" + modelMap.get(orderId).toPlainString());
- System.out.println("开空止损订单号:" + order.getOrderNo());
- if (null != order.getStopLossPrice()) {
- // 止损价
- BigDecimal closePrice = order.getStopLossPrice();
-
- System.out.println("订单止损价格:" + closePrice.toPlainString());
- BigDecimal queuePrice = modelMap.get(orderId);
- if (closePrice.compareTo(queuePrice) != 0) {
- System.out.println("数据库价格:" + queuePrice.toPlainString() + "--价格不能开空止损:" + closePrice);
- contractHoldOrderService.updateOrderIsCanClosingAndBatchNoById(orderId);
- continue;
- }
- System.out.println("执行操作");
- String symbol = order.getSymbol();
- Long memberId = order.getMemberId();
- // 本次需要退回的预付款
- BigDecimal prePrice = order.getBondAmount();
- MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT");
-
- if (wallet != null) {
- // 历史订单
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(order);
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setId(null);
-
- // 本次平仓数量
- int currentFlat = order.getSymbolCnt();
- BigDecimal symbolSku = cacheSettingUtils.getSymbolSku(order.getSymbol());
- // 盈亏额度= (当前的币种的平仓价-下单时的建仓价)*购买的手数/规格*倍率
- BigDecimal profitLossPrice = (order.getOpeningPrice()
- .subtract(closePrice))
- .multiply(new BigDecimal(currentFlat + ""))
- .multiply(symbolSku).setScale(8, BigDecimal.ROUND_DOWN);
- MemberEntity memberEntity = memberService.getById(memberId);
-
- if (memberEntity.getIsProfit() == 1) {
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- if (profitLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.subtract(tradeSetting.getProfitParam()));
- } else {
-// profitLossPrice = profitLossPrice.multiply(BigDecimal.ONE.add(tradeSetting.getProfitParam()));
- }
- }
- //回报率
- BigDecimal returnRate = profitLossPrice.divide((order.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN);
- contractOrderEntity.setRewardAmount(profitLossPrice);
- contractOrderEntity.setRewardRatio(returnRate);
- contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
- contractOrderEntity.setClosingPrice(closePrice);
- contractOrderEntity.setClosingType(9);
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
- BigDecimal totalReturn = BigDecimal.ZERO;
- contractOrderService.save(contractOrderEntity);
-
- contractHoldOrderService.removeById(order.getId());
-
- // 将需要退回的减去手续费
- BigDecimal needReturn = prePrice.add(profitLossPrice);
- //总退回金额=保证金+收益-手续费
- totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
- // 更新钱包
- // 总的是收益-平仓手续费
- BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
- memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
-
- insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓");
-
- //返佣
- ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE);
- }
- }
- }
- }
- }
-
- private void insertAccountFlow(ContractHoldOrderEntity order, MemberWalletContractEntity wallet, BigDecimal profitLossPrice, String source) {
- MemberAccountFlowEntity record = new MemberAccountFlowEntity();
- record.setCreateTime(new Date());
- record.setSource(source);
- record.setRemark(source);
- record.setBalance(wallet.getAvailableBalance());
- record.setMemberId(order.getMemberId());
- record.setSymbol(order.getSymbol());
- record.setPrice(profitLossPrice.add(order.getPrePaymentAmount()));
- memberAccountFlowEntityDao.insert(record);
- }
-
-
- /**
- * 限价委托
- *
- * @param
- */
- public void dealLimitBuyOrder(List<ContractEntrustOrderEntity> orderList) {
- //List<CoinsCoinsOrder> orderList = orderMapper.selectOrderByBatchNo(batchno);
- if (CollectionUtils.isNotEmpty(orderList)) {
- ContractHoldOrderEntity contractHoldOrderEntity = null;
- for (ContractEntrustOrderEntity coinsCoinsOrder : orderList) {
- MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(coinsCoinsOrder.getMemberId(), "USDT");
- if (wallet == null) {
- continue;
- }
-
- // 委托单bean转换为持仓单bean
- contractHoldOrderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToHoldOrder(coinsCoinsOrder);
- contractHoldOrderEntity.setId(null);
- Long memId = coinsCoinsOrder.getMemberId();
- MemberEntity memberEntity = memberService.getById(memId);
- BigDecimal entrustPrice = coinsCoinsOrder.getEntrustPrice();
- int symbolCnt = coinsCoinsOrder.getSymbolCnt();
- int type = coinsCoinsOrder.getEntrustType();
-
- if (type == 1) {
- // 开多
- contractHoldOrderEntity.setOpeningType(ContractHoldOrderEntity.OPENING_TYPE_MORE);
- } else {
- // 开空
- contractHoldOrderEntity.setOpeningType(ContractHoldOrderEntity.OPENING_TYPE_LESS);
- }
-
- //持仓单赋值
- contractHoldOrderEntity.setMemberId(memId);
- contractHoldOrderEntity.setIsCanClosing(ContractHoldOrderEntity.ORDER_CAN_CLOSING_Y);
- contractHoldOrderEntity.setMarkPrice(coinsCoinsOrder.getEntrustPrice());
- contractHoldOrderEntity.setBondAmount(coinsCoinsOrder.getBondAmount());
- // 开仓手续费 建仓价*规格*手数*手续费率
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(coinsCoinsOrder.getSymbol());
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
- BigDecimal openFeePrice = coinsCoinsOrder.getEntrustPrice().multiply(lotNumber)
- .multiply(new BigDecimal(coinsCoinsOrder.getSymbolCnt()))
- .multiply(tradeSettingEntity.getFeeRatio().divide(new BigDecimal(100)))
- .setScale(8, BigDecimal.ROUND_DOWN);
- contractHoldOrderEntity.setOpeningFeeAmount(openFeePrice);
- contractHoldOrderEntity.setVersion(1);
- BigDecimal forceSetPrice = CalculateUtil.getForceSetPrice(coinsCoinsOrder.getBondAmount().subtract(openFeePrice), entrustPrice, symbolCnt, lotNumber, type, memberEntity);
-
- contractHoldOrderEntity.setForceClosingPrice(forceSetPrice);
- contractHoldOrderEntity.setLeverRatio(coinsCoinsOrder.getLeverRatio());
- contractHoldOrderEntity.setOpeningPrice(entrustPrice);
- contractHoldOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_LIMIT);
- contractHoldOrderEntity.setOperateNo(1);
- contractHoldOrderService.save(contractHoldOrderEntity);
-
- // 需要一个历史插入
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(contractHoldOrderEntity);
- contractOrderEntity.setEntrustOpeningPrice(coinsCoinsOrder.getEntrustPrice());
- contractOrderEntity.setEntrustTime(coinsCoinsOrder.getCreateTime());
- contractOrderEntity.setOpeningTime(new Date());
-
- contractOrderEntity.setId(null);
- contractOrderService.save(contractOrderEntity);
- // 发送爆仓的队列
- // 市价
- if (coinsCoinsOrder.getEntrustType() == 1) {
- // 开多
- OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 6, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1);
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- } else {
- // 开空
- OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 7, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1);
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 扣除手续费
- BigDecimal totalBalance = openFeePrice.negate();
- contractEntrustOrderService.removeById(coinsCoinsOrder.getId());
- memberWalletContractService.increaseWalletContractBalanceById(null, totalBalance, coinsCoinsOrder.getBondAmount().negate(), wallet.getId());
-
- //返佣
- ThreadPoolUtils.calReturnMoney(memberEntity.getId(), openFeePrice, contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN);
- }
- }
- }
-
- /**
- * 爆仓
- *
- * @param
- */
- public void dealCoinOut(List<ContractHoldOrderEntity> orderList, List<OrderModel> orderModels) {
- if (CollectionUtils.isNotEmpty(orderList)) {
- Map<Long, Integer> modelMap = new HashMap<Long, Integer>();
- for (OrderModel model : orderModels) {
- modelMap.put(model.getOrderId(), model.getOperateNo());
- }
- for (ContractHoldOrderEntity coinsOrder : orderList) {
- Long orderId = coinsOrder.getId();
- Integer operateNo = coinsOrder.getOperateNo();
- //判断当前订单是否是最新的爆仓价 不相等时直接进入下一个订单
- if (!modelMap.get(orderId).equals(operateNo)) {
- // 将订单更新为可平仓并删除批次号
- contractHoldOrderService.updateOrderIsCanClosingAndBatchNoById(orderId);
- continue;
- }
- boolean isDone = false;
- Long memId = coinsOrder.getMemberId();
- BigDecimal nowPrice = coinsOrder.getForceClosingPrice();
- // 创建订单(加入历史表的订单)
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(coinsOrder);
-
- //查询是否满足爆仓条件
- if (coinsOrder.getOpeningType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) {
- //如果是开多,当前价小于预估强平价即为爆仓
- // 设置平仓类型 // 爆仓平多
- contractOrderEntity.setClosingType(4);
- //更新用户钱包数据
- isDone = true;
- } else {
- //如果是开空,当前价大于预估强平价即为爆仓
- contractOrderEntity.setClosingType(5);
- //更新主表订单状态位为“已平仓”
- isDone = true;
-
- }
- if (isDone) {
- //删除次仓订单
- contractHoldOrderService.removeById(orderId);
- // 订单状态转换
- if (ContractOrderEntity.ORDER_TYPE_OPEN_MORE == contractOrderEntity.getOrderType()) {
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
- } else {
- contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
- }
- //更新主表订单状态位为“已平仓”
- contractOrderEntity.setId(null);
- contractOrderEntity.setClosingPrice(nowPrice);
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setClosingFeeAmount(coinsOrder.getOpeningFeeAmount());
- contractOrderEntity.setRewardAmount(coinsOrder.getBondAmount().subtract(contractOrderEntity.getOpeningFeeAmount()).negate());
- contractOrderService.save(contractOrderEntity);
-
- //更新用户钱包数据
- MemberWalletContractEntity usdt = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memId, "USDT");
-
- // 减去的时候用负数
- BigDecimal totalPrice = coinsOrder.getBondAmount().negate();
- memberWalletContractService.increaseWalletContractBalanceById(null, totalPrice, null, usdt.getId());
- // 流水记录 TODO
- MemberAccountFlowEntity record = new MemberAccountFlowEntity();
- record.setCreateTime(new Date());
- record.setSource("系统自动平仓");
- record.setRemark("系统自动平仓");
- record.setBalance(usdt.getAvailableBalance());
- record.setMemberId(memId);
- record.setSymbol(coinsOrder.getSymbol());
- record.setPrice(coinsOrder.getBondAmount());
- memberAccountFlowEntityDao.insert(record);
- }
- }
- }
- }
-
- public void calYj(Long mid, BigDecimal money, ContractOrderEntity order, int type) {
- PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
- if (money != null) {
- money = money.multiply(tradeSetting.getFeeSpreadRatio());
- }
- MemberEntity member = memberService.getById(mid);
- String[] referenceIds = member.getRefererIds().split(",");
- List<String> ids = Arrays.asList(referenceIds);
-
- if (MemberEntity.ACCOUNT_TYPE_TEST.equals(member.getAccountType())) {
- return;
- }
-
- // 判断该用户是否为代理商
- NeedMoneyMemberVo needMoneyMember = memberService.selectFriendRelationUserByMemberId(mid);
-
- // 查询该用户下所有需要返佣的代理商
- List<NeedMoneyMemberVo> list = memberService.selectAllNeedMoneyMember(ids);
- TreeMap<Integer, NeedMoneyMemberVo> treeMap = new TreeMap<>(new Comparator<Integer>() {
- @Override
- public int compare(Integer o1, Integer o2) {
- return o2.compareTo(o1);
- }
- });
- // 建立层级关系
- for (int i = 0; i < list.size(); i++) {
- treeMap.put(list.get(i).getLevelId(), list.get(i));
- }
-
- // 该用户为代理商则判断is_self字段,判断是否保留其手续费
- // 该用户为代理商则判断is_self字段,判断是否保留其手续费
- if (needMoneyMember != null && needMoneyMember.getFeeIsSelf() == 1) {
- treeMap.put(needMoneyMember.getLevelId(), needMoneyMember);
- }
-
-
- // 存放uid以及对应uid用户的佣金
- Map<String, Map<String, BigDecimal>> map = new HashMap<>();
- Iterator<Map.Entry<Integer, NeedMoneyMemberVo>> it = treeMap.entrySet().iterator();
- BigDecimal lastRate = BigDecimal.ZERO;
- BigDecimal lastYj = BigDecimal.ZERO;
- while (it.hasNext()) {
- Map.Entry<Integer, NeedMoneyMemberVo> entry = it.next();
- NeedMoneyMemberVo member1 = entry.getValue();
- Map<String, BigDecimal> returnValue = new HashMap<>();
- returnValue.put("ratio", member1.getReturnRatio());
- returnValue.put("lastRate", lastRate);
- // 上下级佣金比率相减后乘以手续费 -- 即用户所得佣金
- lastYj = (member1.getReturnRatio().subtract(lastRate)).multiply(money);
- lastRate = member1.getReturnRatio();
- returnValue.put("returnMoney", lastYj);
- map.put(member1.getInviteId(), returnValue);
- }
-
- // 输出对应佣金是否正确
- Iterator<Map.Entry<String, Map<String, BigDecimal>>> it1 = map.entrySet().iterator();
- List<AgentReturnEntity> agentList = new ArrayList<AgentReturnEntity>();
- while (it1.hasNext()) {
- Map.Entry<String, Map<String, BigDecimal>> entry = it1.next();
- // System.out.println(entry.getKey() + "-----" + entry.getValue());
- MemberEntity agentMember = memberService.selectMemberInfoByInviteId(entry.getKey());
- AgentReturnEntity agent = new AgentReturnEntity();
- agent.setMemberId(mid);
- agent.setOrderId(order.getId());
- agent.setOrderNo(order.getOrderNo());
- agent.setRefererId(agentMember.getId());
- agent.setOrderType(order.getOrderType());
- agent.setReturnSymbol(order.getSymbol());
- agent.setIsReturn(0);
- agent.setReturnAmount(entry.getValue().get("returnMoney"));
- agent.setChildReturnRatio(entry.getValue().get("lastRate"));
- agent.setReturnRatio(entry.getValue().get("ratio"));
- agent.setClosingType(order.getClosingType());
- if (type == 1) {//开仓
- agent.setOpeningFeeAmount(order.getOpeningFeeAmount());
- } else if (type == 2) {//平仓
- agent.setClosingFeeAmount(order.getClosingFeeAmount());
- } else {//持仓费
- agent.setHoldingFeeAmount(order.getHoldAmount());
- }
- agent.setInviteId(entry.getKey());
- agentReturnDao.insert(agent);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
deleted file mode 100644
index 1f4e3ed..0000000
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.xcong.excoin.modules.contract.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.common.enumerates.OrderClosingTypeEnum;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
-import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
-import com.xcong.excoin.modules.contract.service.RabbitOrderService;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.dao.MemberSettingDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
-import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberSettingEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import com.xcong.excoin.utils.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-06-01
- **/
-@Slf4j
-@Service
-public class RabbitOrderServiceImpl implements RabbitOrderService {
-
- @Resource
- private MemberDao memberDao;
-
- @Resource
- private OrderWebsocketServiceImpl orderWebsocketService;
-
- @Resource
- private ContractHoldOrderDao contractHoldOrderDao;
-
- @Resource
- private ContractOrderDao contractOrderDao;
-
- @Resource
- private CommonService commonService;
-
- @Resource
- private MemberWalletContractDao memberWalletContractDao;
-
- @Resource
- private CacheSettingUtils cacheSettingUtils;
-
- @Resource
- private RedisUtils redisUtils;
- @Resource
- private MemberSettingDao memberSettingDao;
-
- @Transactional(rollbackFor = Exception.class)
- @Override
- public void cancelHoldOrder(List<Long> ids) {
- if (CollUtil.isNotEmpty(ids)) {
- if (ids.size() == 1) {
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectById(ids.get(0));
- cancelHoldOrderMethod(holdOrderEntity);
- } else {
- List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectBatchIds(ids);
- if (CollUtil.isNotEmpty(holdOrderEntities)) {
- for (ContractHoldOrderEntity holdOrder : holdOrderEntities) {
- cancelHoldOrderMethod(holdOrder);
- }
- }
- }
- }
- }
-
- public void cancelHoldOrderMethod(ContractHoldOrderEntity holdOrderEntity) {
- String symbol = holdOrderEntity.getSymbol();
- // 获取最新价
- BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol)));
-
- MemberEntity memberEntity = memberDao.selectById(holdOrderEntity.getMemberId());
-
- MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(holdOrderEntity.getMemberId(), CoinTypeEnum.USDT.name());
- if (walletContract != null) {
- // 删除持仓表订单
- contractHoldOrderDao.deleteById(holdOrderEntity.getId());
-
- BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(symbol);
- // 盈亏
- BigDecimal profitOrLoss = BigDecimal.ZERO;
- Integer orderType = null;
- Integer closingType = null;
-
- MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(memberEntity.getId());
- // 开多
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
- newPrice = newPrice.multiply(BigDecimal.ONE.subtract(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
- // (最新价-开仓价)*规格*张数
- profitOrLoss = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- orderType = ContractOrderEntity.ORDER_TYPE_CLOSE_MORE;
- closingType = OrderClosingTypeEnum.CLOSE_MORE.getValue();
- // 开空
- } else {
- newPrice = newPrice.multiply(BigDecimal.ONE.add(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
- // (开仓价-最新价)*规格*张数
- profitOrLoss = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
- orderType = ContractOrderEntity.ORDER_TYPE_CLOSE_LESS;
- closingType = OrderClosingTypeEnum.CLOSE_LESS.getValue();
- }
-
- if (memberEntity.getIsProfit() == MemberEntity.IS_PROFIT_Y) {
- PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
- if (profitOrLoss.compareTo(BigDecimal.ZERO) > -1) {
- profitOrLoss = profitOrLoss.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
- } else {
- profitOrLoss = profitOrLoss.multiply(BigDecimal.ONE.add(tradeSettingEntity.getProfitParam()));
- }
- }
-
- // 盈亏比例(回报率)
- BigDecimal rewardRatio = profitOrLoss.divide(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
-
- ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity);
- contractOrderEntity.setId(null);
- contractOrderEntity.setOrderType(orderType);
- contractOrderEntity.setClosingPrice(newPrice);
- contractOrderEntity.setClosingFeeAmount(holdOrderEntity.getOpeningFeeAmount());
- contractOrderEntity.setClosingTime(new Date());
- contractOrderEntity.setClosingType(closingType);
- contractOrderEntity.setRewardAmount(profitOrLoss);
- contractOrderEntity.setRewardRatio(rewardRatio);
- contractOrderDao.insert(contractOrderEntity);
-
- // 计算盈利或亏损后可用金额和总金额应该增加或减少的
- BigDecimal addMoney = holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()).add(profitOrLoss);
- memberWalletContractDao.increaseWalletContractBalanceById(addMoney, profitOrLoss.subtract(contractOrderEntity.getOpeningFeeAmount()), null, walletContract.getId());
-
- // 流水
- LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), addMoney, walletContract.getAvailableBalance().add(addMoney), holdOrderEntity.getSymbol(), "平仓", "平仓");
-
- // 计算佣金
- ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getClosingFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE);
- }
-
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java b/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java
deleted file mode 100644
index ee8cbfb..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.xcong.excoin.modules.home.controller;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.alibaba.druid.util.StringUtils;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
-import com.xcong.excoin.modules.home.service.MemberQuickBuySaleService;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.service.MemberService;
-
-import cn.hutool.crypto.SecureUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-
-@RestController
-@Slf4j
-@RequestMapping(value = "/api/quick")
-@Api(value = "MemberQuickBuySaleController", tags = "USDT快捷买卖类")
-public class MemberQuickBuySaleController {
-
- @Autowired
- MemberQuickBuySaleService memberQuickBuySaleService;
- @Autowired
- MemberService memberService;
-
- @ApiOperation(value = "recharge", notes = "USDT快速充值")
- @RequestMapping(value = "/recharge", method = RequestMethod.POST)
- public Result recharge(@RequestBody @Valid MemberQuickBuySaleDto memberQuickBuySaleDto) {
- log.info("入参----->{}", memberQuickBuySaleDto);
- //获取用户ID
- MemberEntity member = LoginUserUtils.getAppLoginUser();
- log.info("查询到的会员----->{}", member);
- // 验证是否实名认证
- //if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
- // return Result.fail("请先实名认证");
- //}
- String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword();
-
- // 验证支付密码
- String tradePassword = member.getTradePassword();
-
- log.info("入参交易密码{},用户设置的交易密码{}", tradePasswordWeb,tradePassword);
- if (StringUtils.isEmpty(tradePassword)) {
- return Result.fail("请先配置交易密码");
- }
- if (StringUtils.isEmpty(tradePasswordWeb)) {
- return Result.fail("请输入交易密码");
- }
- // 验证交易密码
- if (!tradePassword.equals(SecureUtil.md5(tradePasswordWeb))) {
- return Result.fail("请输入正确的交易密码");
- }
- return memberQuickBuySaleService.recharge(member, memberQuickBuySaleDto);
- }
-
-
- @ApiOperation(value = "commitPay", notes = "USDT充值支付确认")
- @RequestMapping(value = "/commitPay", method = RequestMethod.POST)
- public Result commitPay(@RequestBody @Valid MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto) {
- return memberQuickBuySaleService.commitPay(memberQuickBuySaleCommitDto);
- }
-
- @ApiOperation(value = "selectById", notes = "查询单个买卖记录")
- @GetMapping(value = "/selectById/{id}")
- public Result selectById(@PathVariable(value = "id") Long id) {
- return memberQuickBuySaleService.selectById(id);
- }
-
- @ApiOperation(value = "selectAll", notes = "查询用户所有的买卖记录")
- @GetMapping(value = "/selectAll")
- public Result selectAll(@RequestParam(value = "type") String type) {
- return memberQuickBuySaleService.selectAll(type);
- }
-
- @ApiOperation(value = "cancel", notes = "充值撤销")
- @GetMapping(value = "/cancel")
- public Result cancel(@RequestParam(value = "id") Long id) {
- return memberQuickBuySaleService.cancelRecharge(id);
- }
-
- @ApiOperation(value = "sell", notes = "USDT快速卖出")
- @RequestMapping(value = "/sell", method = RequestMethod.POST)
- public Result sell(@RequestBody @Valid MemberQuickBuySaleDto memberQuickBuySaleDto) {
- // 获取当前登录用户
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberService.getById(memberId);
- if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
- return Result.fail("请先实名认证");
- }
- String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword();
- // 验证支付密码
- String tradePassword = member.getTradePassword();
-
- log.info("入参交易密码{},用户设置的交易密码{}", tradePasswordWeb,tradePassword);
- if (StringUtils.isEmpty(tradePassword)) {
- return Result.fail("请先配置交易密码");
- }
- if (StringUtils.isEmpty(tradePasswordWeb)) {
- return Result.fail("请输入交易密码");
- }
- // 验证交易密码
- if (!tradePassword.equals(SecureUtil.md5(tradePasswordWeb))) {
- return Result.fail("请输入正确的交易密码");
- }
- return memberQuickBuySaleService.sell(member,memberQuickBuySaleDto);
- }
-
- @ApiOperation(value = "cancelSell", notes = "提现撤销")
- @GetMapping(value = "/cancelSell")
- public Result cancelSell(@RequestParam(value = "id") Long id) {
- return memberQuickBuySaleService.cancelSell(id);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java b/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java
deleted file mode 100644
index 9f0f27f..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.xcong.excoin.modules.home.dao;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
-
-public interface MemberQuickBuySaleDao extends BaseMapper<MemberQuickBuySaleEntity> {
-
- MemberQuickBuySaleEntity selectByIdAndMemberId(@Param("memberId")Long memberId,@Param("id")Long id);
-
- int updateQuickBuySaleTimeOut();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java
deleted file mode 100644
index 3d3a550..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.home.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberQuickBuySaleCommitDto", description = "确认快捷买入接收参数")
-public class MemberQuickBuySaleCommitDto {
-
- @NotNull(message = "订单id不能为空")
- @ApiModelProperty(value = "主键",example = "1")
- private Long id;
-
- @NotNull(message = "付款方式不能为空")
- @ApiModelProperty(value = "付款方式 1-支付宝2-微信3-银行卡",example = "1")
- private int paymentType;
-
- @NotNull(message = "收款账号不能为空")
- @ApiModelProperty(value = "收款账号",example = "13000000000")
- private String paymentAccount;
-
- @NotNull(message = "收款人姓名不能为空")
- @ApiModelProperty(value = "收款人姓名",example = "张三")
- private String paymentName;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java
deleted file mode 100644
index 4e48a48..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.home.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "会员快捷买入卖出参数接收类", description = "会员快捷买入卖出参数接收类")
-public class MemberQuickBuySaleDto {
-
- @NotNull(message = "金额不能为空")
- @ApiModelProperty(value = "金额(人民币)",example = "700")
- private BigDecimal amountCny;
-
- @NotNull(message = "金额不能为空")
- @ApiModelProperty(value = "金额(USDT)",example = "100")
- private BigDecimal amountUsdt;
-
- @ApiModelProperty(value = "单价",example = "7")
- private BigDecimal unitPrice;
-
- @NotNull(message = "交易密码不能为空")
- @ApiModelProperty(value = "交易密码",example = "123456")
- private String tradePassword;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java b/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
deleted file mode 100644
index 88ca2bc..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.xcong.excoin.modules.home.entity;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@TableName("member_quick_buy_sale")
-public class MemberQuickBuySaleEntity extends BaseEntity{
- /**
- * 订单状态 1-新建
- */
- public static final Integer CHARGE_STATUS_CREATE = 1;
-
- /**
- * 订单状态 2-已付款
- */
- public static final Integer CHARGE_STATUS_PAID = 2;
-
- /**
- * 订单状态 3-已审核
- */
- public static final Integer CHARGE_STATUS_CHECKED = 3;
-
- /**
- * 订单状态 4-撤单
- */
- public static final Integer CHARGE_STATUS_CANCEL_USER = 4;
-
- /**
- * 订单状态 5-系统取消
- */
- public static final Integer CHARGE_STATUS_CANCEL_SYSTEM = 5;
-
-
- private static final long serialVersionUID = 1L;
- /**
- * 用户Id
- */
- private Long memberId;
- /**
- * 金额(人民币)
- */
- private BigDecimal amountCny;
- /**
- * 金额(USDT)
- */
- private BigDecimal amountUsdt;
- /**
- * 付款方式 1-支付宝2-微信3-银行卡
- */
- private Integer paymentType;
- /**
- * 收款账号
- */
- private String paymentAccount;
- /**
- * 收款人姓名
- */
- private String paymentName;
- /**
- * 支付码
- */
- private String paymentCode;
- /**
- * 单价
- */
- private BigDecimal unitPrice;
- /**
- * 订单状态 1-新建2-已付款3-已审核4-撤单5-系统取消
- */
- private int orderStatus;
- /**
- * 订单编号
- */
- private String orderNo;
- /**
- * 订单类型 B买入 S卖出
- */
- private String orderType;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java b/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java
deleted file mode 100644
index c79e48e..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.home.mapper;
-
-import java.util.List;
-
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
-import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
-import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleDetailVo;
-
-
-@Mapper
-public abstract class MemberQuickBuySaleEntityMapper {
-
- public static final MemberQuickBuySaleEntityMapper INSTANCE = Mappers.getMapper(MemberQuickBuySaleEntityMapper.class);
-
- public abstract MemberQuickBuySaleDetailVo entityToVo(MemberQuickBuySaleEntity memberQuickBuySaleEntity);
-
- public abstract MemberQuickBuySaleEntity dtoToEntity(MemberQuickBuySaleDto dto);
-
- public abstract List<MemberQuickBuySaleDetailVo> entityListToVoList(List<MemberQuickBuySaleEntity> memberQuickBuySaleEntityList);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java b/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java
deleted file mode 100644
index 3256044..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.home.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
-import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-
-public interface MemberQuickBuySaleService extends IService<MemberQuickBuySaleEntity> {
-
- public Result recharge(MemberEntity member,MemberQuickBuySaleDto memberQuickBuySaleDto);
-
- public Result commitPay(MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto);
-
- public Result selectById(Long id);
-
- public Result selectAll(String type);
-
- public Result cancelRecharge(Long id);
-
- public Result sell(MemberEntity member,MemberQuickBuySaleDto memberQuickBuySaleDto);
-
- public Result cancelSell(Long id);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java b/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java
deleted file mode 100644
index fd6273b..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package com.xcong.excoin.modules.home.service.impl;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import com.xcong.excoin.utils.ThreadPoolUtils;
-import com.xcong.excoin.utils.dingtalk.DingTalkType;
-import org.springframework.stereotype.Service;
-
-import com.alibaba.druid.util.StringUtils;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
-import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
-import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
-import com.xcong.excoin.modules.home.mapper.MemberQuickBuySaleEntityMapper;
-import com.xcong.excoin.modules.home.service.MemberQuickBuySaleService;
-import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleDetailVo;
-import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleVo;
-import com.xcong.excoin.modules.member.dao.MemberDao;
-import com.xcong.excoin.modules.member.dao.MemberPaymentMethodDao;
-import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.modules.platform.dao.PlatformPaymentMethodDao;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-
-@Service
-public class MemberQuickBuySaleServiceImpl extends ServiceImpl<MemberQuickBuySaleDao, MemberQuickBuySaleEntity> implements MemberQuickBuySaleService {
-
- @Resource
- MemberDao memberDao;
- @Resource
- MemberQuickBuySaleDao memberQuickBuySaleDao;
- @Resource
- MemberWalletCoinDao memberWalletCoinDao;
- @Resource
- MemberPaymentMethodDao memberPaymentMethodDao;
- @Resource
- PlatformPaymentMethodDao platformPaymentMethodDao;
-
- @Override
- public Result recharge(MemberEntity member, MemberQuickBuySaleDto memberQuickBuySaleDto) {
- // 生成订单号
- Long timestamp = System.currentTimeMillis();
- int random = (int) (Math.random() * 10);
- String chargeNo = String.valueOf(timestamp).substring(2) + random;
- // 插入订单表
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = new MemberQuickBuySaleEntity();
- memberQuickBuySaleEntity.setOrderStatus(1);
- memberQuickBuySaleEntity.setMemberId(member.getId());
- memberQuickBuySaleEntity.setAmountUsdt(memberQuickBuySaleDto.getAmountUsdt());
- memberQuickBuySaleEntity.setAmountCny(memberQuickBuySaleDto.getAmountCny());
- memberQuickBuySaleEntity.setUnitPrice(memberQuickBuySaleDto.getUnitPrice());
- memberQuickBuySaleEntity.setCreateTime(new Date());
- memberQuickBuySaleEntity.setOrderNo(chargeNo);
- memberQuickBuySaleEntity.setOrderType("B");
- // 支付码 ID+四位随机数
- int ran = (int) (Math.random() * 10000000);
- memberQuickBuySaleEntity.setPaymentCode(ran + "");
-
- memberQuickBuySaleDao.insert(memberQuickBuySaleEntity);
- MemberQuickBuySaleVo memberQuickBuySaleVo = new MemberQuickBuySaleVo();
- memberQuickBuySaleVo.setId(memberQuickBuySaleEntity.getId());
- // 返回前台付款方式
- return Result.ok("提交成功", memberQuickBuySaleVo);
- }
-
- @Override
- public Result commitPay(MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto) {
- // 用户提交支付确认 将状态改为付款中
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = new MemberQuickBuySaleEntity();
- memberQuickBuySaleEntity.setId(memberQuickBuySaleCommitDto.getId());
- memberQuickBuySaleEntity.setOrderStatus(2);
- memberQuickBuySaleEntity.setPaymentAccount(memberQuickBuySaleCommitDto.getPaymentAccount());
- memberQuickBuySaleEntity.setPaymentName(memberQuickBuySaleCommitDto.getPaymentName());
-
- memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity);
-
- ThreadPoolUtils.sendDingTalk(1);
- return Result.ok("确认成功");
- }
-
- @Override
- public Result selectById(Long id) {
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectById(id);
- MemberQuickBuySaleDetailVo memberQuickBuySaleDetailVo = MemberQuickBuySaleEntityMapper.INSTANCE.entityToVo(memberQuickBuySaleEntity);
- // 收款信息
- QueryWrapper<PlatformPaymentMethodEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("status", "1");
- List<PlatformPaymentMethodEntity> paymentMethodList = platformPaymentMethodDao.selectList(queryWrapper);
- // 随机一个
- if (CollectionUtils.isEmpty(paymentMethodList)) {
- return Result.fail("收款方式为空");
- }
- memberQuickBuySaleDetailVo.setPlatforPaymentMethodList(paymentMethodList);
- long startTime = memberQuickBuySaleEntity.getCreateTime().getTime();
- long nowTime = new Date().getTime();
- long third = 30 * 60 * 1000;
- memberQuickBuySaleDetailVo.setTimeLeft((third - nowTime + startTime) / 1000);
- return Result.ok(memberQuickBuySaleDetailVo);
- }
-
- @Override
- public Result selectAll(String type) {
- MemberEntity member = LoginUserUtils.getAppLoginUser();
- QueryWrapper<MemberQuickBuySaleEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("member_id", member.getId());
- if (!StringUtils.isEmpty(type)) {
- queryWrapper.eq("order_type", type);
- }
- queryWrapper.orderByDesc("id");
- List<MemberQuickBuySaleEntity> memberQuickBuySaleEntityList = memberQuickBuySaleDao.selectList(queryWrapper);
- List<MemberQuickBuySaleDetailVo> memberQuickBuySaleDetailVoList = MemberQuickBuySaleEntityMapper.INSTANCE.entityListToVoList(memberQuickBuySaleEntityList);
- return Result.ok(memberQuickBuySaleDetailVoList);
- }
-
- @Override
- public Result sell(MemberEntity member, MemberQuickBuySaleDto memberQuickBuySaleDto) {
- // 判断是否存在足够余额
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum.USDT.toString());
- // 判断是否存在足够余额
- if (walletCoin == null) {
- return Result.fail("您当前可用USDT额度不够");
- }
- BigDecimal extractUsdt = memberQuickBuySaleDto.getAmountUsdt();
- if (extractUsdt == null) {
- return Result.fail("请输入提币量");
- }
- // 判断是否足够
- System.out.println("提币数:" + extractUsdt.doubleValue() + " 可用:" + walletCoin.getAvailableBalance());
- if (extractUsdt.compareTo(walletCoin.getAvailableBalance()) == 1) {
- return Result.fail("您当前可用USDT额度不够");
- }
-
- // 判断是否存在收款方式
- List<MemberPaymentMethodEntity> payMentMethodList = memberPaymentMethodDao.selectByMemberId(member.getId());
- if (CollectionUtils.isEmpty(payMentMethodList)) {
- return Result.fail("请配置收款方式");
- }
- // 冻结可用额度
- int i = memberWalletCoinDao.updateFrozenBalance(member.getId(),
- walletCoin.getId(), extractUsdt);
- if (i <= 0) {
- return Result.fail("可用USDT余额不足");
- }
-
- // 生成订单号
- Long timestamp = System.currentTimeMillis();
- int random = (int) (Math.random() * 10);
- String chargeNo = String.valueOf(timestamp).substring(2) + random;
- // 插入订单表
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = new MemberQuickBuySaleEntity();
- memberQuickBuySaleEntity.setOrderStatus(1);
- memberQuickBuySaleEntity.setMemberId(member.getId());
- memberQuickBuySaleEntity.setAmountUsdt(memberQuickBuySaleDto.getAmountUsdt());
- memberQuickBuySaleEntity.setAmountCny(memberQuickBuySaleDto.getAmountCny());
- memberQuickBuySaleEntity.setOrderNo(chargeNo);
- memberQuickBuySaleEntity.setOrderType("S");
- // 支付码 ID+四位随机数
- int ran = (int) (Math.random() * 10000000);
- memberQuickBuySaleEntity.setPaymentCode(ran + "");
-
- memberQuickBuySaleDao.insert(memberQuickBuySaleEntity);
-
- ThreadPoolUtils.sendDingTalk(2);
- return Result.ok("下单成功");
- }
-
- @Override
- public Result cancelRecharge(Long id) {
- // 获取当前登录用户
- MemberEntity member = LoginUserUtils.getAppLoginUser();
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectByIdAndMemberId(member.getId(), id);
- memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_CANCEL_USER);
- memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity);
- return Result.ok("成功");
- }
-
- @Override
- public Result cancelSell(Long id) {
- // 获取当前登录用户
- MemberEntity member = LoginUserUtils.getAppLoginUser();
- MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectByIdAndMemberId(member.getId(), id);
- if (memberQuickBuySaleEntity != null) {
- memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_CANCEL_USER);
- memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity);
-
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum.USDT.toString());
- // 冻结资金返回可用
- int i = memberWalletCoinDao.subFrozenBalance(member.getId(),
- walletCoin.getId(), memberQuickBuySaleEntity.getAmountUsdt());
- if (i < 0) {
- return Result.fail("撤单失败");
- }
- return Result.ok("成功");
- } else {
- return Result.fail("订单不存在");
- }
-
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleDetailVo.java b/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleDetailVo.java
deleted file mode 100644
index db8e91f..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleDetailVo.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.xcong.excoin.modules.home.vo;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-@Data
-@ApiModel(value = "会员快捷买入卖出", description = "会员快捷买入卖出类")
-public class MemberQuickBuySaleDetailVo {
-
- @ApiModelProperty(value = "订单Id")
- private Long id;
- @ApiModelProperty(value = "用户id")
- private Long memberId;
- @ApiModelProperty(value = "金额(人民币)")
- private BigDecimal amountCny;
- @ApiModelProperty(value = "金额(USDT)")
- private BigDecimal amountUsdt;
- @ApiModelProperty(value = "付款方式 1-支付宝2-微信3-银行卡")
- private Integer paymentType;
- @ApiModelProperty(value = "支付码")
- private String paymentCode;
- @ApiModelProperty(value = "单价")
- private BigDecimal unitPrice;
- @ApiModelProperty(value = "订单状态 1-新建2-已付款3-已审核4-撤单5-系统取消")
- private int orderStatus;
- @ApiModelProperty(value = "订单编号")
- private String orderNo;
- @ApiModelProperty(value = "订单类型 B买入 S卖出")
- private String orderType;
- @ApiModelProperty(value = "剩余时间")
- private Long timeLeft;
- @ApiModelProperty(value = "下单时间")
- @JsonFormat(pattern = "MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createTime;
- @ApiModelProperty(value = "平台收款方式")
- private List<PlatformPaymentMethodEntity> platforPaymentMethodList;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java b/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java
deleted file mode 100644
index 6d41454..0000000
--- a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.modules.home.vo;
-
-import java.util.List;
-
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-@Data
-@ApiModel(value = "会员快捷买入卖出", description = "会员快捷买入卖出类")
-public class MemberQuickBuySaleVo {
-
- @ApiModelProperty(value = "订单Id")
- private Long id;
- @ApiModelProperty(value = "剩余时间")
- private Long timeLeft;
- @ApiModelProperty(value = "平台收款方式")
- private List<PlatformPaymentMethodEntity> platforPaymentMethodList;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java b/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
deleted file mode 100644
index c2a3f6e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
+++ /dev/null
@@ -1,365 +0,0 @@
-package com.xcong.excoin.modules.member.controller;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAddCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAuthenticationDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindEmailDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindPhoneDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
-import com.xcong.excoin.modules.member.parameter.vo.AppVersionListVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberAuthenticationInfoVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberAvivableCoinInfoVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberCoinAddressCountListVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberCoinAddressListVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberCoinInfoListVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberInfoVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberPaymethodDetailListVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberPaymethodDetailVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberPersonCenterInfoVo;
-import com.xcong.excoin.modules.member.parameter.vo.MemberSendCodeWayVo;
-import com.xcong.excoin.modules.member.service.MemberService;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 用户类
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Slf4j
-@Api(value = "个人中心接口", tags = "个人中心接口")
-@RestController
-@RequestMapping(value = "/api/member")
-public class MemberController {
-
- @Resource
- MemberService memberService;
-
- /**
- * 获取当前版本号
- */
- @ApiOperation(value="APP端获取当前版本号", notes="获取当前版本号")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = AppVersionListVo.class)})
- @GetMapping(value = "/getAppVersionInfo")
- public Result getAppVersionInfo() {
- return memberService.getAppVersionInfo();
- }
-
-
- /**
- * 获取当前版本号
- */
- @ApiOperation(value="PC端获取当前版本号", notes="获取当前版本号")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = AppVersionListVo.class)})
- @GetMapping(value = "/getPcVersionInfo")
- public Result getPcVersionInfo() {
- return memberService.getPcVersionInfo();
- }
-
-
- /**
- * 获取我的信息
- * @return
- */
- @ApiOperation(value="获取我的信息", notes="获取我的信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberInfoVo.class)})
- @GetMapping(value = "/getMemberInfo")
- public Result getMemberInfo() {
- return memberService.getMemberInfo();
- }
-
- /**
- * 忘记密码
- * @return
- */
- @ApiOperation(value=" 忘记密码", notes=" 忘记密码")
- @PostMapping(value="/memberForgetPwd")
- public Result memberForgetPwd(@RequestBody @Valid MemberForgetPwdDto memberForgetPwdDto) {
- return memberService.memberForgetPwd(memberForgetPwdDto);
- }
-
- /**
- * 验证账户是否存在
- * @return
- */
- @ApiOperation(value="验证账户是否存在", notes="验证账户是否存在")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "account", value = "账号", required = true, dataType = "String", paramType="query"),
- @ApiImplicitParam(name = "type", value = "类型 1:手机号 2:邮箱", required = true, dataType = "int", paramType="query")
- })
- @GetMapping(value = "/getMemberAccountInfo")
- public Result getMemberAccountInfo(String account,int type) {
- return memberService.getMemberAccountInfo(account,type);
- }
-
- /**
- * 修改密码
- * @return
- */
- @ApiOperation(value="修改密码", notes="修改密码")
- @PostMapping(value="/memberUpdatePwd")
- public Result memberUpdatePwd(@RequestBody @Valid MemberUpdatePwdDto memberUpdatePwdDto) {
- //System.out.println("修改密码:");
- return memberService.memberUpdatePwd(memberUpdatePwdDto);
- }
-
- /**
- * 修改资金密码时效性
- * @return
- */
- @ApiOperation(value="修改资金密码时效性", notes="修改资金密码时效性")
- @PostMapping(value="/memberUpdateTradersPwdTime")
- public Result memberUpdateTradersPwdTime(@RequestBody @Valid MemberUpdateTradersPwdTimeDto memberUpdateTradersPwdTimeDto) {
- //System.out.println("修改密码:");
- return memberService.memberUpdateTradersPwdTime(memberUpdateTradersPwdTimeDto);
- }
-
- /**
- * 获取实名认证信息
- * @return
- */
- @ApiOperation(value = "获取实名认证信息", notes = "获取实名认证信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAuthenticationInfoVo.class)})
- @GetMapping(value = "/memberAuthenticationInfo")
- public Result memberAuthenticationInfo() {
- return memberService.memberAuthenticationInfo();
- }
-
- /**
- * 实名认证
- * @return
- */
- @ApiOperation(value="实名认证", notes="实名认证")
- @PostMapping(value="/memberAuthentication")
- public Result memberAuthentication(@RequestBody @Valid MemberAuthenticationDto memberAuthenticationDto) {
- return memberService.memberAuthentication(memberAuthenticationDto);
- }
-
- /**
- * 修改资金密码
- * @return
- */
- @ApiOperation(value="修改资金密码", notes="修改资金密码")
- @PostMapping(value="/memberUpdateTradePwd")
- public Result memberUpdateTradePwd(@RequestBody @Valid MemberUpdateTradePwdDto memberUpdateTradePwdDto) {
- return memberService.memberUpdateTradePwd(memberUpdateTradePwdDto);
- }
-
- /**
- * 用户退出登录
- * @return
- */
- @ApiOperation(value="用户退出登录", notes="用户退出登录")
- @GetMapping(value = "/memberLogout")
- public Result memberLogout() {
- return memberService.memberLogout();
- }
-
- /**
- * 设置交易密码
- * @param code
- * @param password
- * @param token
- * @return
- */
- @ApiOperation(value="设置交易密码", notes="设置交易密码")
- @PostMapping(value="/memberTradersPwd")
- public Result memberTradersPwd(@RequestBody @Valid MemberForgetPwdDto memberForgetPwdDto) {
- return memberService.memberTradersPwd(memberForgetPwdDto);
- }
-
- /**
- * 收款方式
- * @return
- */
- @ApiOperation(value="新增收款方式", notes="新增收款方式")
- @PostMapping(value="/memberAddPaymethod")
- public Result memberAddPaymethod(@RequestBody @Valid MemberPaymethodDto memberPaymethodDto) {
- return memberService.memberAddPaymethod(memberPaymethodDto);
- }
-
- /**
- * 收款方式
- * @return
- */
- @ApiOperation(value="删除收款方式", notes="删除收款方式")
- @PostMapping(value="/memberDelPaymethod")
- public Result memberDelPaymethod(@RequestBody @Valid MemberDelPaymethodDto memberDelPaymethodDto) {
- return memberService.memberDelPaymethod(memberDelPaymethodDto);
- }
-
- /**
- * 收款方式
- * @return
- */
- @ApiOperation(value="一个收款方式的详情", notes="一个收款方式的详情")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberPaymethodDetailVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "long", paramType="query")
- })
- @GetMapping(value = "/memberPaymethodDetail")
- public Result memberPaymethodDetail(long id) {
- return memberService.memberPaymethodDetail(id);
- }
-
- /**
- * 收款方式
- * @return
- */
- @ApiOperation(value="收款方式的列表", notes="收款方式的列表")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberPaymethodDetailListVo.class)})
- @GetMapping(value = "/memberPaymethodDetailList")
- public Result memberPaymethodDetailList() {
- return memberService.memberPaymethodDetailList();
- }
-
- /**
- * 绑定手机号
- * @return
- */
- @ApiOperation(value="绑定手机号", notes="绑定手机号")
- @PostMapping(value="/memberBindPhone")
- public Result memberBindPhone(@RequestBody @Valid MemberBindPhoneDto memberBindPhoneDto) {
- return memberService.memberBindPhone(memberBindPhoneDto);
- }
-
- /**
- * 绑定邮箱
- * @return
- */
- @ApiOperation(value="绑定邮箱", notes="绑定邮箱")
- @PostMapping(value="/memberBindEmail")
- public Result memberBindEmail(@RequestBody @Valid MemberBindEmailDto memberBindEmailDto) {
- return memberService.memberBindEmail(memberBindEmailDto);
- }
-
- /**
- * 获取币种地址
- * @return
- */
- @ApiOperation(value = "获取币种地址数量", notes = "获取币种地址数量")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberCoinAddressCountListVo.class)})
- @GetMapping(value = "/memberCoinAddressCount")
- public Result memberCoinAddressCount() {
- return memberService.memberCoinAddressCount();
- }
-
- /**
- * 获取提币地址
- * @return
- */
- @ApiOperation(value = "获取提币地址列表", notes = "获取提币地址列表")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberCoinAddressListVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/memberCoinAddressList")
- public Result memberCoinAddressList(String symbol) {
- return memberService.memberCoinAddressList(symbol);
- }
-
- /**
- * 添加提币地址
- * @return
- */
- @ApiOperation(value = "添加提币地址", notes = "添加提币地址")
- @PostMapping(value = "/memberAddCoinAddress")
- public Result memberAddCoinAddress(@RequestBody @Valid MemberAddCoinAddressDto memberAddCoinAddressDto) {
- return memberService.memberAddCoinAddress(memberAddCoinAddressDto);
- }
-
- /**
- * 删除提币地址
- * @return
- */
- @ApiOperation(value="删除提币地址", notes="删除提币地址")
- @PostMapping(value="/memberDelCoinAddress")
- public Result memberDelCoinAddress(@RequestBody @Valid MemberDelCoinAddressDto memberDelCoinAddressDto) {
- return memberService.memberDelCoinAddress(memberDelCoinAddressDto);
- }
-
- /**
- * 获取发送验证码途径
- * @return
- */
- @ApiOperation(value = "获取发送验证码途径", notes = "获取发送验证码途径")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberSendCodeWayVo.class)})
- @GetMapping(value = "/memberSendCodeWay")
- public Result memberSendCodeWay() {
- return memberService.memberSendCodeWay();
- }
-
- /**
- * 获取个人中心信息
- * @return
- */
- @ApiOperation(value = "获取个人中心信息", notes = "获取个人中心信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberPersonCenterInfoVo.class)})
- @GetMapping(value = "/memberPersonCenterInfo")
- public Result memberPersonCenterInfo() {
- return memberService.memberPersonCenterInfo();
- }
-
- /**
- * 提币币种信息
- * @return
- */
- @ApiOperation(value = "获取提币币种信息", notes = "获取提币币种信息")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberCoinInfoListVo.class)})
- @GetMapping(value = "/memberCoinInfoList")
- public Result memberCoinInfoList() {
- return memberService.memberCoinInfoList();
- }
-
- /**
- * 提币币种可用资金
- * @param token
- * @param coinVo
- * @return
- */
- @ApiOperation(value = "提币币种可用资金", notes = "提币币种可用资金")
- @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAvivableCoinInfoVo.class)})
- @ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
- })
- @GetMapping(value = "/memberAvivableCoinInfo")
- public Result memberAvivableCoinInfo(String symbol) {
- return memberService.memberAvivableCoinInfo(symbol);
- }
-
- /**
- * 提币申请
- * @param token
- * @param coinVo
- * @return
- */
- @ApiOperation(value="提交提币申请", notes="提交提币申请")
- @PostMapping(value="/memberSubmitCoinApply")
- public Result memberSubmitCoinApply(@RequestBody @Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto) {
- return memberService.memberSubmitCoinApply(memberSubmitCoinApplyDto);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/AgentReturnDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/AgentReturnDao.java
deleted file mode 100644
index d20792d..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/AgentReturnDao.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface AgentReturnDao extends BaseMapper<AgentReturnEntity> {
-
- List<AgentReturnEntity> selectAllNeedMoneyReturn();
-
- int updateAgentReturnStatusByRefererId(@Param("isReturn") int isReturn, @Param("refererId") Long refererId);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/AppVersionDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/AppVersionDao.java
deleted file mode 100644
index d487e27..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/AppVersionDao.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.AppVersionEntity;
-
-public interface AppVersionDao extends BaseMapper<AppVersionEntity> {
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberAuthenticationDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberAuthenticationDao.java
deleted file mode 100644
index 51e3adb..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberAuthenticationDao.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberAuthenticationEntity;
-
-public interface MemberAuthenticationDao extends BaseMapper<MemberAuthenticationEntity> {
-
- int findMemberbyIdCardNoCount(String idCardNo);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinAddressDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinAddressDao.java
deleted file mode 100644
index b9fea92..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinAddressDao.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity;
-
-public interface MemberCoinAddressDao extends BaseMapper<MemberCoinAddressEntity> {
-
- MemberCoinAddressEntity selectAddressByMemberIdAndSymbol(Long memberId, String symbol);
-
- MemberCoinAddressEntity selectBlockAddressWithTag(@Param("memberId") Long memberId, @Param("symbol") String symbol, @Param("tag") String tag);
-
- MemberCoinAddressEntity selectBlockAddress(@Param("memberId") Long memberId, @Param("symbol") String symbol);
-
- List<MemberCoinAddressEntity> selectCoinAddressListByMap(@Param("symbol") String symbol, @Param("memberId") Long memberId);
-
- List<MemberCoinAddressEntity> selectAllBlockAddressBySymbolAndTag(@Param("symbol") String symbol, @Param("tag") String tag);
-
- List<MemberCoinAddressEntity> selectAllBlockAddressBySymbol(@Param("symbol") String symbol);
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinChargeDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinChargeDao.java
deleted file mode 100644
index c35bdb0..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinChargeDao.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-public interface MemberCoinChargeDao extends BaseMapper<MemberCoinChargeEntity> {
-
- public MemberCoinChargeEntity selectNewestChargeRecord(@Param("memberId") Long memberId, @Param("symbol") String symbol, @Param("tag") String tag);
-
- List<MemberCoinChargeEntity> selectAllBySymbolAndTag(@Param("symbol") String symbol, @Param("tag") String tag, @Param("status") Integer status);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinWithdrawDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinWithdrawDao.java
deleted file mode 100644
index 75ce0f4..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinWithdrawDao.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity;
-
-public interface MemberCoinWithdrawDao extends BaseMapper<MemberCoinWithdrawEntity> {
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
deleted file mode 100644
index b7e285a..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author wzy
- */
-public interface MemberDao extends BaseMapper<MemberEntity> {
-
- public MemberEntity selectMemberInfoByAccount(@Param("account") String account);
-
- public MemberEntity selectMemberInfoByInviteId(@Param("inviteId") String inviteId);
-
- public NeedMoneyMemberVo selectFriendRelationUserByMemberId(@Param("memberId") Long memberId);
-
- public List<NeedMoneyMemberVo> selectAllNeedMoneyMember(@Param("list") List<String> list);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberLevelRateDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberLevelRateDao.java
deleted file mode 100644
index bfea23f..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberLevelRateDao.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberLevelRateEntity;
-import org.apache.ibatis.annotations.Param;
-
-public interface MemberLevelRateDao extends BaseMapper<MemberLevelRateEntity> {
-
- public MemberLevelRateEntity selectLeverRateByMemberIdAndSymbol(@Param("memberId") Long memberId, @Param("symbol") String symbol);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberPaymentMethodDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberPaymentMethodDao.java
deleted file mode 100644
index 1aaebf2..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberPaymentMethodDao.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import java.util.List;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity;
-
-public interface MemberPaymentMethodDao extends BaseMapper<MemberPaymentMethodEntity> {
-
- public List<MemberPaymentMethodEntity> selectByMemberId(Long memberId);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberSettingDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberSettingDao.java
deleted file mode 100644
index 620a813..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberSettingDao.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberSettingEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-08-13
- **/
-public interface MemberSettingDao extends BaseMapper<MemberSettingEntity> {
-
- public MemberSettingEntity selectMemberSettingByMemberId(@Param("memberId") Long memberId);
-
- public int batchInsert(@Param("list") List<MemberSettingEntity> list);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java
deleted file mode 100644
index 595a570..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
-
-public interface MemberWalletAgentDao extends BaseMapper<MemberWalletAgentEntity> {
-
- MemberWalletAgentEntity selectWalletAgentBymIdAndCode(@Param("memberId")Long memberId,@Param("walletCode")String walletCode);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java
deleted file mode 100644
index 66a50dc..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-
-/**
- * @author wzy
- */
-public interface MemberWalletCoinDao extends BaseMapper<MemberWalletCoinEntity> {
-
- List<MemberWalletCoinEntity> selectMemberWalletCoinsByMemberId(Long memberId);
-
- MemberWalletCoinEntity selectWalletCoinBymIdAndCode(@Param("memberId") Long memberId, @Param("walletCode") String walletCode);
-
- int updateFrozenBalance(@Param("memberId") Long memberId, @Param("id") Long id, @Param("amount") BigDecimal amount);
-
- int subFrozenBalance(@Param("memberId") Long memberId, @Param("id") Long id, @Param("amount") BigDecimal amount);
-
- int updateBlockBalance(@Param("id") Long id, @Param("availableBalance") BigDecimal availableBalance, @Param("earlyBalance") BigDecimal earlyBalance, @Param("blockNumber") Integer blockNumber);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java
deleted file mode 100644
index e12db7e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-
-import java.math.BigDecimal;
-
-public interface MemberWalletContractDao extends BaseMapper<MemberWalletContractEntity> {
-
- MemberWalletContractEntity findWalletContractByMemberIdAndSymbol(@Param("memberId")Long memberId, @Param("symbol")String symbol);
-
- /**
- * 增减合约钱包(负数为减)
- * @param availableBalance
- * @param totalBalance
- * @param frozenBalance
- * @param id
- */
- void increaseWalletContractBalanceById(@Param("availableBalance") BigDecimal availableBalance,@Param("totalBalance") BigDecimal totalBalance,@Param("frozenBalance") BigDecimal frozenBalance,@Param("id") Long id);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractSimulateDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractSimulateDao.java
deleted file mode 100644
index ca43023..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractSimulateDao.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.xcong.excoin.modules.member.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractSimulateEntity;
-
-/**
- * @author helius
- */
-public interface MemberWalletContractSimulateDao extends BaseMapper<MemberWalletContractSimulateEntity> {
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java
deleted file mode 100644
index 4cefe1a..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-31
- **/
-@Data
-@TableName("agent_return")
-public class AgentReturnEntity extends BaseEntity {
-
- /**
- * 订单类型 开仓
- */
- public static final int ORDER_TYPE_OPEN = 1;
-
- /**
- * 订单类型 平仓
- */
- public static final int ORDER_TYPE_CLOSE = 2;
-
- /**
- * 订单类型 持仓
- */
- public static final int ORDER_TYPE_HOLD = 3;
-
- /**
- * 是否已返佣 0-否
- */
- public static final int IS_RETURN_N = 0;
-
- /**
- * 是否已返佣 1-是
- */
- public static final int IS_RETURN_Y = 1;
-
- private Long memberId;
-
- private Long orderId;
-
- private String orderNo;
-
- private int orderType;
-
- private BigDecimal closingFeeAmount;
-
- private BigDecimal holdingFeeAmount;
-
- private BigDecimal openingFeeAmount;
-
- private BigDecimal returnAmount;
-
- private Long refererId;
-
- private String inviteId;
-
- private BigDecimal returnRatio;
-
- private BigDecimal childReturnRatio;
-
- /**
- * 0-否1-是
- */
- private int isReturn;
-
- private String returnSymbol;
-
- private int closingType;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/AppVersionEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/AppVersionEntity.java
deleted file mode 100644
index 2261fdc..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/AppVersionEntity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import lombok.Data;
-/**
- * 版本表
- *
- **/
-@Data
-@TableName("app_version")
-public class AppVersionEntity implements Serializable {
- /**
- * 账号状态 - 禁用
- */
- public static final Integer type_and = 1;
-
- /**
- * 账号状态 - 启用
- */
- public static final Integer type_app = 2;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createtime;
-
- private String version;
- private String content;
- private String address;
- private Integer type;
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java
deleted file mode 100644
index 619df68..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-/**
- * 用户实名认证信息实体
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@TableName("member_authentication")
-public class MemberAuthenticationEntity extends BaseEntity {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 用户ID
- */
- private Long memberId;
-
- /**
- * 真实姓名
- */
- private String realName;
-
- /**
- * 姓
- */
- private String firstName;
-
- /**
- * 名
- */
- private String secondName;
-
- /**
- * 国家
- */
- private String nation;
-
- /**
- * 身份证号
- */
- private String idcardNo;
-
- /**
- * 证件类型
- */
- private String type;
-
- /**
- * 身份证正面
- */
- private String idcardImageFront;
-
- /**
- * 身份证背面
- */
- private String idcardImageBack;
-
- /**
- * 手持身份证
- */
- private String idcardImageInHand;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinAddressEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinAddressEntity.java
deleted file mode 100644
index 853703c..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinAddressEntity.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-/**
- * 会员币地址
- * @author Administrator
- *
- */
-@Data
-@TableName("member_coin_address")
-public class MemberCoinAddressEntity extends BaseEntity {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * 会员ID
- */
- private Long memberId;
- /**
- * 地址
- */
- private String address;
- /**
- * 私钥
- */
- private String privateKey;
- /**
- * 币种
- */
- private String symbol;
- /**
- * 是否是本平台地址1:是 0:否
- */
- private String isBiyict;
- public static final String IS_BIYICT_YES = "1";
- public static final String IS_BIYICT_NO = "2";
- /**
- *
- */
- private String label;
- /**
- *
- */
- private String tag;
- /**
- * 币种ID
- */
- private Long symbolscoinId;
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinChargeEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinChargeEntity.java
deleted file mode 100644
index 8171578..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinChargeEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-07-02
- **/
-@Data
-@TableName("member_coin_charge")
-public class MemberCoinChargeEntity extends BaseEntity {
-
- private Long memberId;
-
- private String certificate;
-
- private BigDecimal amount;
-
- private BigDecimal lastAmount;
-
- private int status;
-
- private String symbol;
-
- private String address;
-
- private String tag;
-
- private String hash;
-
- private String orderCode;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinWithdrawEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinWithdrawEntity.java
deleted file mode 100644
index cea3765..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinWithdrawEntity.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-/**
- * 会员提币表
- */
-@Data
-@TableName("member_coin_withdraw")
-public class MemberCoinWithdrawEntity extends BaseEntity{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * 会员ID
- */
- private Long memberId;
- /**
- * 地址
- */
- private String address;
- /**
- * 提币数量
- */
- private BigDecimal amount;
- /**
- * 手续费
- */
- private BigDecimal feeAmount;
- /**
- * 币种
- */
- private String symbol;
- /**
- * 状态
- */
- private int status;
- public static final int STATUS_DOING = 1;
- /**
- * 是否内部转账 Y-是N-不是
- */
- private String isInside;
- public static final String ISINSIDE_YES = "Y";
- public static final String ISINSIDE_NO = "N";
-
- private String label;
-
- private String tag;
-
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
deleted file mode 100644
index aaa7e5e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-import java.math.BigDecimal;
-
-/**
- * 会员信息实体
- *
- * @author wzy
- * @date 2020-05-12
- **/
-@Data
-@TableName("member")
-public class MemberEntity extends BaseEntity {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 账号状态 - 禁用
- */
- public static final Integer ACCOUNT_STATUS_DISABLED = 0;
-
- /**
- * 账号状态 - 启用
- */
- public static final Integer ACCOUNT_STATUS_ENABLE = 1;
-
- /**
- * 账号代理级别
- */
- public static final Integer ACCOUNT_AGENT_LEVEL = 6;
-
- /**
- * 账号类型 手机
- */
- public static final Integer ACCOUNT_TYPE_PHONE = 1;
-
- /**
- * 账号类型 邮箱
- */
- public static final Integer ACCOUNT_TYPE_EMAIL = 2;
-
- /**
- * 正常账号
- */
- public static final Integer ACCOUNT_TYPE_NORMAL = 1;
- /**
- * 测试账号
- */
- public static final Integer ACCOUNT_TYPE_TEST = 2;
-
- /**
- * 实名认证 审核通过
- */
- public static final Integer CERTIFY_STATUS_Y = 2;
- /**
- * 实名认证 审核不通过
- */
- public static final Integer CERTIFY_STATUS_N = 0;
- /**
- * 实名认证 审核中
- */
- public static final Integer CERTIFY_STATUS_ING = 1;
- /**
- * 实名认证 未提交
- */
- public static final Integer CERTIFY_STATUS_UN_SUBMIT = 3;
-
- public static final int IS_PROFIT_Y = 1;
-
- public static final int IS_PROFIT_N = 0;
-
- /**
- * 手机号(包含国际手机号)
- */
- private String phone;
-
- /**
- * 邮箱
- */
- private String email;
-
- /**
- * 登陆密码
- */
- private String password;
-
- /**
- * 交易密码
- */
- private String tradePassword;
-
- /**
- * 交易密码时效性设置
- */
- private Integer tradeAgingSetting;
-
- /**
- * 邀请码
- */
- private String inviteId;
-
- /**
- * 账号状态 0-禁用 1-启用
- */
- private int accountStatus;
-
- /**
- * 上级推荐人id
- */
- private String refererId;
-
- /**
- * 上级推荐人ID链
- */
- private String refererIds;
-
- /**
- * 账号类型 1-正常账号 2-测试账号
- */
- private Integer accountType;
-
- /**
- * 代理级别
- */
- private Integer agentLevel;
-
- /**
- * 实名认证状态 0-审核未通过 1-审核通过 2-等待审核
- */
- private Integer certifyStatus;
-
- /**
- * 身份证号
- */
- private String idcardNo;
-
- /**
- * 是否设置盈亏难度系数 0-否1-是
- */
- private Integer isProfit;
-
- /**
- * 是否设置预估强平价系数 0-否1-是
- */
- private Integer isForce;
-
- /**
- * 滑点
- */
- private BigDecimal spread;
-
- /**
- * 平仓点数
- */
- private BigDecimal closingSpread;
-
- /**
- * 强平系数
- */
- private BigDecimal forceParam;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberLevelRateEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberLevelRateEntity.java
deleted file mode 100644
index ef68aab..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberLevelRateEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-/**
- * 用户杠杆设置表
- *
- * @Author wzy
- * @Date 2020/5/18
- **/
-@Data
-@TableName("member_level_rate")
-public class MemberLevelRateEntity extends BaseEntity {
-
- /**
- * 会员ID
- */
- private Long memberId;
-
- /**
- * 多头杠杆
- */
- private int levelRateUp = 100;
-
- /**
- * 空头杠杆
- */
- private int levelRateDown = 100;
-
- /**
- * 币种
- */
- private String symbol;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberPaymentMethodEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberPaymentMethodEntity.java
deleted file mode 100644
index be0e903..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberPaymentMethodEntity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-/**
- * 会员收款方式
- */
-@Data
-@TableName("member_payment_method")
-public class MemberPaymentMethodEntity extends BaseEntity{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 用户Id
- */
- private Long memberId;
- /**
- * 姓名
- */
- private String name;
- /**
- * 账号
- */
- private String account;
- /**
- * 收款二维码
- */
- private String paymentQrcode;
- /**
- * 银行
- */
- private String bank;
- /**
- * 支行
- */
- private String subBank;
- /**
- * 类型 1-支付宝2-微信3-银行卡
- */
- private String paymentType;
- public static final Integer PAYMENTTYPE_ALIPAY = 1;
- public static final Integer PAYMENTTYPE_WECHAT = 2;
- public static final Integer PAYMENTTYPE_CARD = 3;
-
- /**
- * 默认收款方式
- */
- private String isDefualt;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java
deleted file mode 100644
index 8b5b5fd..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-
-/**
- * 会员自选币种
- */
-@Data
-@TableName("member_select_symbols")
-public class MemberSelectSymbolsEntity extends BaseEntity{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * 会员ID
- */
- private long memberId;
- /**
- * 币种
- */
- private String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberSettingEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberSettingEntity.java
deleted file mode 100644
index 36ea5a7..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberSettingEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-08-13
- **/
-@Data
-@TableName("member_setting")
-public class MemberSettingEntity extends BaseEntity {
-
- private Long memberId;
-
- /**
- * 滑点
- */
- private BigDecimal spread;
-
- /**
- * 平仓点数
- */
- private BigDecimal closingSpread;
-
- /**
- * 强平系数
- */
- private BigDecimal forceParam;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java
deleted file mode 100644
index bb067cf..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * 代理用户钱包
- *
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@TableName("member_wallet_agent")
-public class MemberWalletAgentEntity extends BaseEntity {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * 用户Id
- */
- private Long memberId;
-
- /**
- * 可用余额
- */
- private BigDecimal availableBalance = AppContants.INIT_MONEY;
-
- /**
- * 总金额
- */
- private BigDecimal totalBalance = AppContants.INIT_MONEY;
-
- /**
- * 冻结金额
- */
- private BigDecimal frozenBalance = AppContants.INIT_MONEY;
-
- /**
- * 借入资产金额
- */
- private BigDecimal borrowedFund = AppContants.INIT_MONEY;
-
- /**
- * 钱包标识
- */
- private String walletCode;
-
- /**
- * 钱包地址
- */
- private String walletAddress;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java
deleted file mode 100644
index f2bd58c..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@TableName("member_wallet_coin")
-public class MemberWalletCoinEntity extends BaseEntity {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 用户Id
- */
- private Long memberId;
-
- /**
- * 可用余额
- */
- private BigDecimal availableBalance;
-
- /**
- * 总金额
- */
- private BigDecimal totalBalance;
-
- /**
- * 冻结金额
- */
- private BigDecimal frozenBalance;
-
- /**
- * 借入资产金额
- */
- private BigDecimal borrowedFund;
-
- /**
- * 钱包标识
- */
- private String walletCode;
-
- /**
- * 钱包地址
- */
- private String walletAddress;
-
- /**
- * 上次余额
- */
- private BigDecimal earlyBalance;
-
- /**
- * 区块编号
- */
- private int blockNumber;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java
deleted file mode 100644
index 91cd275..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@TableName("member_wallet_contract")
-public class MemberWalletContractEntity extends BaseEntity {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private Long memberId;
-
- private BigDecimal availableBalance;
-
- private BigDecimal totalBalance;
-
- private BigDecimal frozenBalance;
-
- private BigDecimal borrowedFund;
-
- private String walletCode;
-
- private String walletAddress;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractSimulateEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractSimulateEntity.java
deleted file mode 100644
index 6554e6e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractSimulateEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.member.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-18
- **/
-@Data
-@TableName("member_wallet_contract_simulate")
-public class MemberWalletContractSimulateEntity extends BaseEntity {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private Long memberId;
-
- private BigDecimal availableBalance;
-
- private BigDecimal totalBalance;
-
- private BigDecimal frozenBalance;
-
- private BigDecimal borrowedFund;
-
- private String walletCode;
-
- private String walletAddress;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAddCoinAddressDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAddCoinAddressDto.java
deleted file mode 100644
index 4bf9314..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAddCoinAddressDto.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAddCoinAddressDto", description = "增加提币地址参数接收类")
-public class MemberAddCoinAddressDto {
-
- @NotNull(message = "币种ID不能为空")
- @ApiModelProperty(value = "币种ID")
- private Long symbolscoinId;
- /**
- * 地址
- */
- @NotNull(message = "地址不能为空")
- @ApiModelProperty(value = "地址")
- private String address;
- /**
- * 是否是本平台地址1:是 0:否
- */
- @NotNull(message = "是否是本平台地址不能为空")
- @ApiModelProperty(value = "是否是本平台地址1:是 0:否")
- private String isBiyict;
- /**
- * 备注
- */
- @ApiModelProperty(value = "备注")
- private String remark;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAuthenticationDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAuthenticationDto.java
deleted file mode 100644
index 60d7bb2..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberAuthenticationDto.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAuthenticationDto", description = "实名认证参数接收类")
-public class MemberAuthenticationDto {
-
- @NotNull(message = "姓不能为空")
- @ApiModelProperty(value = "姓", example = "姓")
- private String firstName;
-
- @NotNull(message = "名不能为空")
- @ApiModelProperty(value = "名", example = "名")
- private String secondName;
-
- @NotNull(message = "真实姓名不能为空")
- @ApiModelProperty(value = "真实姓名", example = "姓名")
- private String realName;
-
- @NotNull(message = "身份证卡号不能为空")
- @ApiModelProperty(value = "身份证卡号", example = "123456789")
- private String idCardNo;
-
- @NotNull(message = "身份证正面不能为空")
- @ApiModelProperty(value = "身份证正面", example = "身份证正面")
- private String idCardFront;
-
- @NotNull(message = "身份证反面不能为空")
- @ApiModelProperty(value = "身份证反面", example = "身份证反面")
- private String idCardReverse;
-
- @NotNull(message = "手持身份证不能为空")
- @ApiModelProperty(value = "手持身份证", example = "手持身份证")
- private String idCardImage;
-
- @NotNull(message = "国家不能为空")
- @ApiModelProperty(value = "国家", example = "国家")
- private String nation;
-
- @NotNull(message = "类型不能为空")
- @ApiModelProperty(value = "类型1:身份证2:护照编号", example = "1")
- private String type;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindEmailDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindEmailDto.java
deleted file mode 100644
index 1a8f2cc..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindEmailDto.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberBindEmailDto", description = "绑定邮箱参数接收类")
-public class MemberBindEmailDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "邮箱不能为空")
- @ApiModelProperty(value = "邮箱", example = "www.13412341234@134.com")
- private String email;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindPhoneDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindPhoneDto.java
deleted file mode 100644
index f7d6afc..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberBindPhoneDto.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberBindPhoneDto", description = "绑定手机号参数接收类")
-public class MemberBindPhoneDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "电话号码不能为空")
- @ApiModelProperty(value = "电话号码", example = "13412341234")
- private String phone;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelCoinAddressDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelCoinAddressDto.java
deleted file mode 100644
index 0277ead..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelCoinAddressDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberDelCoinAddressDto", description = "删除提币地址参数接收类")
-public class MemberDelCoinAddressDto {
-
- @NotNull(message = "提币地址ID不能为空")
- @ApiModelProperty(value = "提币地址ID", example = "1")
- private Long id;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelPaymethodDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelPaymethodDto.java
deleted file mode 100644
index 1135c4a..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberDelPaymethodDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberDelPaymethodDto", description = "删除收款方式参数接收类")
-public class MemberDelPaymethodDto {
-
- @NotNull(message = "收款方式ID不能为空")
- @ApiModelProperty(value = "收款方式ID", example = "1")
- private Long id;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberForgetPwdDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberForgetPwdDto.java
deleted file mode 100644
index 9ff9a5d..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberForgetPwdDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberForgetPwdDto", description = "忘记密码参数接收类")
-public class MemberForgetPwdDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "新密码不能为空")
- @ApiModelProperty(value = "新密码", example = "qq123456")
- private String password;
-
- @NotNull(message = "验证类型不能为空")
- @ApiModelProperty(value = "验证类型 1 手机号码 2 邮箱", example = "1")
- private int type;
-
- @NotNull(message = "验证账号不能为空")
- @ApiModelProperty(value = "验证账号", example = "13412341234")
- private String account;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberPaymethodDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberPaymethodDto.java
deleted file mode 100644
index fa2a3b2..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberPaymethodDto.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberPaymethodDto", description = "收款方式参数接收类")
-public class MemberPaymethodDto {
- /**
- * 姓名
- */
- @NotNull(message = "姓名不能为空")
- @ApiModelProperty(value = "姓名", example = "姓名")
- private String name;
- /**
- * 账号
- */
- @NotNull(message = "账号不能为空")
- @ApiModelProperty(value = "账号", example = "13412341234")
- private String account;
- /**
- * 收款二维码
- */
- @ApiModelProperty(value = "账号", example = "13412341234")
- private String paymentQrcode;
- /**
- * 银行
- */
- @ApiModelProperty(value = "银行", example = "银行")
- private String bank;
- /**
- * 支行
- */
- @ApiModelProperty(value = "支行", example = "支行")
- private String subBank;
- /**
- * 类型 1-支付宝2-微信3-银行卡
- */
- @NotNull(message = "类型不能为空")
- @ApiModelProperty(value = "类型 1-支付宝2-微信3-银行卡", example = "1")
- private String paymentType;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberSubmitCoinApplyDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberSubmitCoinApplyDto.java
deleted file mode 100644
index 5d4fa7b..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberSubmitCoinApplyDto.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import java.math.BigDecimal;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberSubmitCoinApplyDto", description = "提交提币申请参数接收类")
-public class MemberSubmitCoinApplyDto {
-
- @NotNull(message = "地址不能为空")
- @ApiModelProperty(value = "地址", example = "asfdsdafsdafdsaf1231232sdfsa")
- private String address;
-
- @NotNull(message = "币数量不能为空")
- @ApiModelProperty(value = "币数量", example = "10")
- private BigDecimal coinNumber;
-
- @NotNull(message = "手续费不能为空")
- @ApiModelProperty(value = "手续费", example = "10")
- private BigDecimal feeAmount;
-
- @NotNull(message = "交易密码不能为空")
- @ApiModelProperty(value = "交易密码", example = "123456")
- private String tradePassword;
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "验证方式不能为空")
- @ApiModelProperty(value = "验证方式", example = "13412341234")
- private String account;
-
- @NotNull(message = "币种不能为空")
- @ApiModelProperty(value = "币种", example = "BTC")
- private String symbol;
-
- @ApiModelProperty(value = "姓名", example = "姓名")
- private String lable;
-
- @ApiModelProperty(value = "姓名", example = "姓名")
- private String tag;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberTradersPwdDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberTradersPwdDto.java
deleted file mode 100644
index 884119f..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberTradersPwdDto.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberTradersPwdDto", description = "设置交易密码参数接收类")
-public class MemberTradersPwdDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "新密码不能为空")
- @ApiModelProperty(value = "新密码", example = "qq123456")
- private String password;
-
- @NotNull(message = "验证类型不能为空")
- @ApiModelProperty(value = "验证类型 1 手机号码 2 邮箱", example = "1")
- private int type;
-
- @ApiModelProperty(value = "电话号码", example = "13412341234")
- private String phone;
-
- @ApiModelProperty(value = "邮箱", example = "www.13412341234@123.com")
- private String email;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdatePwdDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdatePwdDto.java
deleted file mode 100644
index 0e2b96c..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdatePwdDto.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberUpdatePwdDto", description = "修改密码参数接收类")
-public class MemberUpdatePwdDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "新密码不能为空")
- @ApiModelProperty(value = "新密码", example = "qq123456")
- private String password;
-
- @NotNull(message = "验证类型不能为空")
- @ApiModelProperty(value = "验证类型 1 手机号码 2 邮箱", example = "1")
- private int type;
-
- @ApiModelProperty(value = "电话号码", example = "13412341234")
- private String phone;
-
- @ApiModelProperty(value = "邮箱", example = "www.13412341234@123.com")
- private String email;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradePwdDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradePwdDto.java
deleted file mode 100644
index 650b4d7..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradePwdDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberUpdateTradePwdDto", description = "修改资金密码参数接收类")
-public class MemberUpdateTradePwdDto {
-
- @NotNull(message = "验证码不能为空")
- @ApiModelProperty(value = "验证码", example = "123456")
- private String code;
-
- @NotNull(message = "新密码不能为空")
- @ApiModelProperty(value = "新密码", example = "qq123456")
- private String password;
-
- @NotNull(message = "验证类型不能为空")
- @ApiModelProperty(value = "验证类型 1 手机号码 2 邮箱", example = "1")
- private int type;
-
- @NotNull(message = "验证账号不能为空")
- @ApiModelProperty(value = "验证账号", example = "13412341234")
- private String account;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradersPwdTimeDto.java b/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradersPwdTimeDto.java
deleted file mode 100644
index 09da5a6..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberUpdateTradersPwdTimeDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.dto;
-
-import javax.validation.constraints.NotNull;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberUpdateTradersPwdTimeDto", description = "修改资金密码时效性接收类")
-public class MemberUpdateTradersPwdTimeDto {
-
- @NotNull(message = "交易密码时效性设置不能为空")
- @ApiModelProperty(value = "交易密码时效性设置1:一直需要输入密码 2不需要输入密码", example = "1")
- private Integer tradeAgingSetting;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionListVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionListVo.java
deleted file mode 100644
index 2d11e03..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "AppVersionListVo", description = "版本信息列表")
-public class AppVersionListVo {
-
- @ApiModelProperty(value = "版本信息")
- private List<AppVersionVo> appVersionVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionVo.java
deleted file mode 100644
index e3da351..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/AppVersionVo.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "AppVersionVo", description = "版本号信息")
-public class AppVersionVo {
-
- @ApiModelProperty(value = "版本号")
- private String version;
-
- @ApiModelProperty(value = "下载地址")
- private String address;
-
- @ApiModelProperty(value = "类型:1安卓,2苹果")
- private Integer type;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAuthenticationInfoVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAuthenticationInfoVo.java
deleted file mode 100644
index c680aa3..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAuthenticationInfoVo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAuthenticationInfoVo", description = "实名认证信息")
-public class MemberAuthenticationInfoVo {
-
- @ApiModelProperty(value = "实名认证状态 0-审核未通过 1-审核中 2-审核通过")
- private Integer certifyStatus;
-
- @ApiModelProperty(value = "姓")
- private String firstName;
-
- @ApiModelProperty(value = "名")
- private String secondName;
-
- @ApiModelProperty(value = "身份证卡号")
- private String idCardNo;
-
- @ApiModelProperty(value = "证件类型")
- private String type;
-
- @ApiModelProperty(value = "国家")
- private String nation;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAvivableCoinInfoVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAvivableCoinInfoVo.java
deleted file mode 100644
index 7231563..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberAvivableCoinInfoVo.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberAvivableCoinInfoVo", description = "提币币种可用资金信息")
-public class MemberAvivableCoinInfoVo {
-
- @ApiModelProperty(value = "可用余额")
- private BigDecimal availableBalance;
-
- @ApiModelProperty(value = "手续费")
- private BigDecimal fee;
-
- @ApiModelProperty(value = "USDT链名")
- private String lable;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountListVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountListVo.java
deleted file mode 100644
index 0ef11f8..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountListVo.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinAddressCountListVo", description = "币种地址信息")
-public class MemberCoinAddressCountListVo {
-
-
- @ApiModelProperty(value = "币种地址")
- private List<MemberCoinAddressCountVo> memberCoinAddressCountVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountVo.java
deleted file mode 100644
index 7d52ead..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressCountVo.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinAddressCountVo", description = "币种地址数量信息")
-public class MemberCoinAddressCountVo {
-
- @ApiModelProperty(value = "ID")
- private Long id;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String name;
- /**
- * 地址数量
- */
- @ApiModelProperty(value = "地址数量")
- private Integer count;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressListVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressListVo.java
deleted file mode 100644
index a35d316..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinAddressListVo", description = "币种地址信息")
-public class MemberCoinAddressListVo {
-
- @ApiModelProperty(value = "币种地址")
- private List<MemberCoinAddressVo> memberCoinAddressVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressVo.java
deleted file mode 100644
index 5532f0b..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinAddressVo.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinAddressVo", description = "地址信息")
-public class MemberCoinAddressVo {
-
- @ApiModelProperty(value = "ID")
- private Long id;
- /**
- * 会员ID
- */
- @ApiModelProperty(value = "会员ID")
- private Long memberId;
- /**
- * 地址
- */
- @ApiModelProperty(value = "地址")
- private String address;
- /**
- * 私钥
- */
- @ApiModelProperty(value = "私钥")
- private String privateKey;
- /**
- * 币种
- */
- @ApiModelProperty(value = "币种")
- private String symbol;
- /**
- * 是否是本平台地址1:是 0:否
- */
- @ApiModelProperty(value = "是否是本平台地址1:是 0:否")
- private String isBiyict;
-
- @ApiModelProperty(value = "备注")
- private String label;
-
- @ApiModelProperty(value = "ID")
- private Long symbolscoinId;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoListVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoListVo.java
deleted file mode 100644
index a5ac662..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinInfoListVo", description = "币种信息")
-public class MemberCoinInfoListVo {
-
- @ApiModelProperty(value = "币种名称")
- private List<MemberCoinInfoVo> memberCoinInfoVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoVo.java
deleted file mode 100644
index 36d950e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberCoinInfoVo.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberCoinInfoVo", description = "币种信息")
-public class MemberCoinInfoVo {
-
- @ApiModelProperty(value = "币种名称")
- private String name;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberInfoVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberInfoVo.java
deleted file mode 100644
index 6ab0a86..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberInfoVo.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberInfoVo", description = "个人信息")
-public class MemberInfoVo {
-
- /**
- * 手机号(包含国际手机号)
- */
- @ApiModelProperty(value = "手机号(包含国际手机号)")
- private String phone;
-
- /**
- * 邀请码
- */
- @ApiModelProperty(value = "邀请码")
- private String inviteId;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailListVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailListVo.java
deleted file mode 100644
index 19f1b91..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailListVo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import java.util.List;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberPaymethodDetailListVo", description = "收款方式列表")
-public class MemberPaymethodDetailListVo {
-
- @ApiModelProperty(value = "收款方式列表")
- private List<MemberPaymethodDetailVo> memberPaymethodDetailVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailVo.java
deleted file mode 100644
index 72161ed..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPaymethodDetailVo.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberPaymethodDetailVo", description = "收款方式信息")
-public class MemberPaymethodDetailVo {
-
- /**
- * Id
- */
- @ApiModelProperty(value = "Id")
- private Long id;
- /**
- * 用户Id
- */
- @ApiModelProperty(value = "用户Id")
- private Long memberId;
- /**
- * 姓名
- */
- @ApiModelProperty(value = "姓名")
- private String name;
- /**
- * 账号
- */
- @ApiModelProperty(value = "账号")
- private String account;
- /**
- * 收款二维码
- */
- @ApiModelProperty(value = "收款二维码")
- private String paymentQrcode;
- /**
- * 银行
- */
- @ApiModelProperty(value = "银行")
- private String bank;
- /**
- * 支行
- */
- @ApiModelProperty(value = "支行")
- private String subBank;
- /**
- * 类型 1-支付宝2-微信3-银行卡
- */
- @ApiModelProperty(value = "类型 1-支付宝2-微信3-银行卡")
- private String paymentType;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPersonCenterInfoVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPersonCenterInfoVo.java
deleted file mode 100644
index 97576fc..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberPersonCenterInfoVo.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberPersonCenterInfoVo", description = "个人中心信息")
-public class MemberPersonCenterInfoVo {
-
- @ApiModelProperty(value = "手机号(包含国际手机号)1:有 0没有")
- private Integer phone;
-
- @ApiModelProperty(value = "邮箱1:有 0没有")
- private Integer email;
-
- @ApiModelProperty(value = "交易密码1:有 0没有")
- private Integer tradePassword;
-
- @ApiModelProperty(value = "收款方式1:有 0没有")
- private Integer memberPaymentMethod;
-
- @ApiModelProperty(value = "实名认证0:审核不通过 1:审核中 2: 审核通过 3:未提交")
- private Integer certifyStatus;
-
- @ApiModelProperty(value = "交易密码时效性设置1:一直需要输入密码 2不需要输入密码")
- private Integer tradeAgingSetting;
- /**
- * 一直需要输入密码
- */
- public static final int PWD_NEED_FORVER = 1;
-
- /**
- * 不需要输入密码
- */
- public static final int PWD_NEED_NO = 2;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberSendCodeWayVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberSendCodeWayVo.java
deleted file mode 100644
index 3f01954..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/MemberSendCodeWayVo.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-@ApiModel(value = "MemberSendCodeWayVo", description = "发送验证码途径信息")
-public class MemberSendCodeWayVo {
-
- /**
- * 手机号(包含国际手机号)
- */
- @ApiModelProperty(value = "手机号(包含国际手机号)")
- private String phone;
-
- /**
- * 邮箱
- */
- @ApiModelProperty(value = "邮箱")
- private String email;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/NeedMoneyMemberVo.java b/src/main/java/com/xcong/excoin/modules/member/parameter/vo/NeedMoneyMemberVo.java
deleted file mode 100644
index 0e06255..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/parameter/vo/NeedMoneyMemberVo.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.xcong.excoin.modules.member.parameter.vo;
-
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * 返佣用户
- */
-@Data
-public class NeedMoneyMemberVo {
- private Long memberId;
- private String inviteId;
- private String referenceId;
- private BigDecimal returnRatio;
- private int levelId;
- private int feeIsSelf;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java b/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java
deleted file mode 100644
index ae6e757..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.xcong.excoin.modules.member.service;
-
-import javax.validation.Valid;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.dto.RegisterDto;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAddCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAuthenticationDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindEmailDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindPhoneDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
-import com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author wzy
- */
-public interface MemberService extends IService<MemberEntity> {
-
- public Result register(RegisterDto registerDto);
-
- public Result getMemberInfo();
-
- public Result memberAuthentication(@Valid MemberAuthenticationDto memberAuthenticationDto);
-
- public Result memberForgetPwd(@Valid MemberForgetPwdDto memberForgetPwdDto);
-
- public Result memberUpdatePwd(@Valid MemberUpdatePwdDto memberUpdatePwdDto);
-
- public Result memberUpdateTradePwd(@Valid MemberUpdateTradePwdDto memberUpdateTradePwdDto);
-
- public Result memberLogout();
-
- public Result memberTradersPwd(@Valid MemberForgetPwdDto memberForgetPwdDto);
-
- public Result memberAddPaymethod(@Valid MemberPaymethodDto memberPaymethodDto);
-
- public Result memberDelPaymethod(@Valid MemberDelPaymethodDto memberDelPaymethodDto);
-
- public Result memberPaymethodDetail(long id);
-
- public Result memberPaymethodDetailList();
-
- public Result memberBindPhone(@Valid MemberBindPhoneDto memberBindPhoneDto);
-
- public Result memberBindEmail(@Valid MemberBindEmailDto memberBindEmailDto);
-
- public Result memberCoinAddressCount();
-
- public Result memberCoinAddressList(String symbol);
-
- public Result memberAddCoinAddress(@Valid MemberAddCoinAddressDto memberAddCoinAddressDto);
-
- public Result memberSendCodeWay();
-
- public Result memberDelCoinAddress(@Valid MemberDelCoinAddressDto memberDelCoinAddressDto);
-
- public Result memberAuthenticationInfo();
-
- public Result memberPersonCenterInfo();
-
- public Result memberCoinInfoList();
-
- public Result memberAvivableCoinInfo(String symbol);
-
- public NeedMoneyMemberVo selectFriendRelationUserByMemberId(Long memberId);
-
- public List<NeedMoneyMemberVo> selectAllNeedMoneyMember(List<String> list);
-
- public MemberEntity selectMemberInfoByInviteId(String inviteId);
-
- public Result memberUpdateTradersPwdTime(@Valid MemberUpdateTradersPwdTimeDto memberUpdateTradersPwdTimeDto);
-
- public Result memberSubmitCoinApply(@Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto);
-
- public Result getMemberAccountInfo(String account,int type);
-
- public Result getAppVersionInfo();
-
- public Result getPcVersionInfo();
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/MemberWalletContractService.java b/src/main/java/com/xcong/excoin/modules/member/service/MemberWalletContractService.java
deleted file mode 100644
index 37840b3..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/service/MemberWalletContractService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.member.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.math.BigDecimal;
-
-public interface MemberWalletContractService extends IService<MemberWalletContractEntity> {
-
- MemberWalletContractEntity findWalletContractByMemberIdAndSymbol(Long memberId, String symbol);
-
- /**
- * 增减合约钱包(负数为减)
- * @param availableBalance
- * @param totalBalance
- * @param frozenBalance
- * @param id
- */
- void increaseWalletContractBalanceById(BigDecimal availableBalance, BigDecimal totalBalance, BigDecimal frozenBalance, Long id);
-
-}
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
deleted file mode 100644
index ec15f5e..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
+++ /dev/null
@@ -1,1006 +0,0 @@
-package com.xcong.excoin.modules.member.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.crypto.SecureUtil;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.LoginUserUtils;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.enumerates.CoinTypeEnum;
-import com.xcong.excoin.common.enumerates.SymbolEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.dto.RegisterDto;
-import com.xcong.excoin.common.system.service.CommonService;
-import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
-import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
-import com.xcong.excoin.modules.member.dao.*;
-import com.xcong.excoin.modules.member.entity.*;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAddCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberAuthenticationDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindEmailDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberBindPhoneDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelCoinAddressDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
-import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
-import com.xcong.excoin.modules.member.parameter.vo.*;
-import com.xcong.excoin.modules.member.service.MemberService;
-import com.xcong.excoin.modules.platform.dao.PlatformFeeSettingDao;
-import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao;
-import com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.ShareCodeUtil;
-import com.xcong.excoin.utils.ThreadPoolUtils;
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-/**
- * @author wzy
- * @date 2020-05-18
- **/
-@Slf4j
-@Service
-public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> implements MemberService {
-
- @Resource
- private MemberDao memberDao;
-
- @Resource
- private MemberWalletAgentDao memberWalletAgentDao;
-
- @Resource
- MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
-
- @Resource
- private MemberWalletContractDao memberWalletContractDao;
-
- @Resource
- private MemberWalletCoinDao memberWalletCoinDao;
-
- @Resource
- private MemberLevelRateDao memberLevelRateDao;
-
- @Resource
- MemberAuthenticationDao memberAuthenticationDao;
-
- @Resource
- RedisUtils redisUtils;
-
- @Resource
- MemberPaymentMethodDao memberPaymentMethodDao;
-
- @Resource
- PlatformSymbolsCoinDao platformSymbolsCoinDao;
-
- @Resource
- PlatformFeeSettingDao platformFeeSettingDao;
-
- @Resource
- MemberCoinAddressDao memberCoinAddressDao;
-
- @Resource
- private CommonService commonservice;
-
- @Resource
- MemberCoinWithdrawDao memberCoinWithdrawDao;
-
- @Resource
- AppVersionDao appVersionDao;
- @Resource
- private MemberSettingDao memberSettingDao;
-
- @Resource
- private MemberWalletContractSimulateDao memberWalletContractSimulateDao;
-
- @Transactional()
- @Override
- public Result register(RegisterDto registerDto) {
- // 查询是否存在该账号用户
- MemberEntity member = memberDao.selectMemberInfoByAccount(registerDto.getAccount());
- if (member != null) {
- return Result.fail("账号已存在");
- }
-
-// boolean isTrue = commonservice.verifyCode(registerDto.getAccount(), registerDto.getCode());
-// if (!isTrue) {
-// return Result.fail(MessageSourceUtils.getString("common_verify_code"));
-// }
-
- member = new MemberEntity();
- member.setPassword(SecureUtil.md5(registerDto.getPassword()));
-
- // 判断账号类型
- if (MemberEntity.ACCOUNT_TYPE_PHONE.equals(registerDto.getType())) {
- member.setPhone(registerDto.getAccount());
- } else if (MemberEntity.ACCOUNT_TYPE_EMAIL.equals(registerDto.getType())) {
- member.setEmail(registerDto.getAccount());
- } else {
- return Result.fail("账号类型错误");
- }
-
- // 判断是否拥有推荐人,若为空则默认系统
-// if (StrUtil.isBlank(registerDto.getRefererId())) {
-// registerDto.setRefererId(AppContants.SYSTEM_REFERER);
-// }
- if (!AppContants.SYSTEM_REFERER.equals(registerDto.getRefererId())) {
- MemberEntity isExist = memberDao.selectMemberInfoByInviteId(registerDto.getRefererId());
- if (isExist == null) {
- return Result.fail("推荐人不存在");
- }
- }
-
- member.setRefererId(registerDto.getRefererId());
- member.setAccountStatus(MemberEntity.ACCOUNT_STATUS_ENABLE);
- member.setAccountType(MemberEntity.ACCOUNT_TYPE_NORMAL);
- member.setAgentLevel(MemberEntity.ACCOUNT_AGENT_LEVEL);
- member.setCertifyStatus(MemberEntity.CERTIFY_STATUS_UN_SUBMIT);
- member.setIsForce(1);
- member.setIsProfit(0);
- memberDao.insert(member);
-
- MemberSettingEntity memberSettingEntity = new MemberSettingEntity();
- memberSettingEntity.setSpread(BigDecimal.ONE);
- memberSettingEntity.setClosingSpread(BigDecimal.valueOf(5));
- memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0055));
- memberSettingEntity.setMemberId(member.getId());
- memberSettingDao.insert(memberSettingEntity);
-
- String inviteId = ShareCodeUtil.toSerialCode(member.getId());
- member.setInviteId(inviteId);
-
- boolean flag = false;
- String parentId = member.getRefererId();
- String ids = "";
- while (!flag) {
- ids += ("," + parentId);
- MemberEntity parentMember = memberDao.selectMemberInfoByInviteId(parentId);
- if (parentMember == null) {
- break;
- }
- parentId = parentMember.getRefererId();
- if (parentMember.getRefererId().equals(parentMember.getInviteId())) {
- flag = true;
- }
- }
- member.setRefererIds(ids);
- memberDao.updateById(member);
-
- //初始化合约钱包
- MemberWalletContractEntity walletContract = new MemberWalletContractEntity();
- walletContract.setMemberId(member.getId());
- walletContract.setAvailableBalance(AppContants.INIT_MONEY);
- walletContract.setFrozenBalance(AppContants.INIT_MONEY);
- walletContract.setTotalBalance(AppContants.INIT_MONEY);
- walletContract.setBorrowedFund(AppContants.INIT_MONEY);
- walletContract.setWalletCode(CoinTypeEnum.USDT.name());
- memberWalletContractDao.insert(walletContract);
-
- MemberWalletContractSimulateEntity walletContractSimulate = new MemberWalletContractSimulateEntity();
- walletContractSimulate.setMemberId(member.getId());
- walletContractSimulate.setAvailableBalance(new BigDecimal(AppContants.INIT_SIMULATE_MONEY));
- walletContractSimulate.setTotalBalance(new BigDecimal(AppContants.INIT_SIMULATE_MONEY));
- walletContractSimulate.setFrozenBalance(AppContants.INIT_MONEY);
- walletContractSimulate.setBorrowedFund(AppContants.INIT_MONEY);
- walletContractSimulate.setWalletCode(CoinTypeEnum.USDT.name());
- memberWalletContractSimulateDao.insert(walletContractSimulate);
-
-
- // 初始化币币钱包
- for (CoinTypeEnum coinTypeEnum : CoinTypeEnum.values()) {
- MemberWalletCoinEntity walletCoin = new MemberWalletCoinEntity();
- walletCoin.setWalletCode(coinTypeEnum.name());
- walletCoin.setMemberId(member.getId());
- walletCoin.setAvailableBalance(AppContants.INIT_MONEY);
- walletCoin.setFrozenBalance(AppContants.INIT_MONEY);
- walletCoin.setTotalBalance(AppContants.INIT_MONEY);
- walletCoin.setBorrowedFund(AppContants.INIT_MONEY);
- memberWalletCoinDao.insert(walletCoin);
- }
-
- // 初始化代理佣金钱包
- MemberWalletAgentEntity walletAgent = new MemberWalletAgentEntity();
- walletAgent.setMemberId(member.getId());
- walletAgent.setWalletCode(CoinTypeEnum.USDT.name());
- memberWalletAgentDao.insert(walletAgent);
-
- // 初始化杠杆
- for (SymbolEnum symbolEnum : SymbolEnum.values()) {
- MemberLevelRateEntity levelRate = new MemberLevelRateEntity();
- levelRate.setMemberId(member.getId());
- levelRate.setSymbol(symbolEnum.getValue());
- memberLevelRateDao.insert(levelRate);
- }
-
- return Result.ok(MessageSourceUtils.getString("home_service_0009"));
- }
-
- @Override
- public Result getMemberInfo() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity memberEntity = memberDao.selectById(memberId);
- MemberInfoVo memberInfoVo = new MemberInfoVo();
- if (ObjectUtil.isNotEmpty(memberEntity)) {
- String email = memberEntity.getEmail();
- String phone = memberEntity.getPhone();
- if (StrUtil.isNotEmpty(phone)) {
- memberInfoVo.setPhone(phone);
- } else if (StrUtil.isNotEmpty(email)) {
- memberInfoVo.setPhone(email);
- }
-
- memberInfoVo.setInviteId(memberEntity.getInviteId());
- }
- return Result.ok(memberInfoVo);
- }
-
- @Override
- @Transactional
- public Result memberForgetPwd(@Valid MemberForgetPwdDto memberForgetPwdDto) {
-
- int type = memberForgetPwdDto.getType();
- String account = memberForgetPwdDto.getAccount();
- String code = memberForgetPwdDto.getCode();
- String password = memberForgetPwdDto.getPassword();
-
- Map<String, Object> hashMap = new HashMap<>();
- if (type == 1) {
- hashMap.put("phone", account);
- } else {
- hashMap.put("email", account);
- }
- List<MemberEntity> member = memberDao.selectByMap(hashMap);
- if (CollUtil.isEmpty(member)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0047"));
- }
-
- boolean flag = commonservice.verifyCode(account, code);
- if (flag) {
- MemberEntity memberEntity = member.get(0);
- memberEntity.setPassword(SecureUtil.md5(password));
- memberDao.updateById(memberEntity);
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_0045"));
- }
- return Result.ok(MessageSourceUtils.getString("member_service_0048"));
- }
-
- @Override
- @Transactional
- public Result memberUpdatePwd(@Valid MemberUpdatePwdDto memberUpdatePwdDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity memberEntity = memberDao.selectById(memberId);
-
- String code = memberUpdatePwdDto.getCode();
- String password = memberUpdatePwdDto.getPassword();
- String phone = memberUpdatePwdDto.getPhone();
- String email = memberUpdatePwdDto.getEmail();
- int type = memberUpdatePwdDto.getType();
- boolean verificationCode = verificationCode(type, phone, code, email);
- if (verificationCode) {
- memberEntity.setPassword(SecureUtil.md5(password));
- memberDao.updateById(memberEntity);
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_0041"));
- }
- return Result.ok(MessageSourceUtils.getString("member_service_0040"));
- }
-
- /**
- * 验证输入的验证码
- *
- * @param type 验证类型1:电话2:邮箱
- * @param phone
- * @param email
- * @param code 验证码
- * @return
- */
- private boolean verificationCode(Integer type, String phone, String code, String email) {
- boolean verificationCode = false;
- if (type == 1) {
- String smsCode = redisUtils.get("SMS_" + phone) + "";
- if (code.equals(smsCode)) {
- verificationCode = true;
- }
- } else {
- String emailCode = redisUtils.get("EMAIL_" + email) + "";
- if (code.equals(emailCode)) {
- verificationCode = true;
- }
- }
- return verificationCode;
- }
-
- @Override
- @Transactional
- public Result memberAuthentication(@Valid MemberAuthenticationDto memberAuthenticationDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
- if (MemberEntity.CERTIFY_STATUS_ING.equals(member.getCertifyStatus())) {
- return Result.fail(MessageSourceUtils.getString("member_service_4000"));
- }
- if (ObjectUtil.isNotEmpty(member)) {
-
- MemberAuthenticationEntity memberAuthenticationEntity = new MemberAuthenticationEntity();
-
- if (MemberEntity.CERTIFY_STATUS_Y == member.getCertifyStatus()) {
- return Result.fail(MessageSourceUtils.getString("member_service_0055"));
- }
- if (MemberEntity.CERTIFY_STATUS_ING == member.getCertifyStatus()) {
- return Result.fail(MessageSourceUtils.getString("member_service_0056"));
- }
- memberAuthenticationEntity.setMemberId(memberId);
-
- if (StrUtil.isBlank(memberAuthenticationDto.getNation())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0057"));
- }
- memberAuthenticationEntity.setNation(memberAuthenticationDto.getNation());
-
- if (StrUtil.isBlank(memberAuthenticationDto.getFirstName())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0058"));
- }
- memberAuthenticationEntity.setFirstName(memberAuthenticationDto.getFirstName());
-
- if (StrUtil.isBlank(memberAuthenticationDto.getSecondName())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0059"));
- }
- memberAuthenticationEntity.setSecondName(memberAuthenticationDto.getSecondName());
-
- String type = memberAuthenticationDto.getType();
- memberAuthenticationEntity.setType(type);
-
- String idCardNo = memberAuthenticationDto.getIdCardNo();
- if (StrUtil.isBlank(idCardNo)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0060"));
- }
- memberAuthenticationEntity.setIdcardNo(idCardNo);
- //同一个身份证号码不能重复实名认证
- int count = memberAuthenticationDao.findMemberbyIdCardNoCount(idCardNo);
- if (count > 0) {
- return Result.fail(MessageSourceUtils.getString("member_service_0060"));
- }
- if (StrUtil.isBlank(memberAuthenticationDto.getIdCardFront())
- || StrUtil.isBlank(memberAuthenticationDto.getIdCardReverse())
- || StrUtil.isBlank(memberAuthenticationDto.getIdCardImage())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0061"));
- }
- memberAuthenticationEntity.setIdcardImageFront(memberAuthenticationDto.getIdCardFront());
- memberAuthenticationEntity.setIdcardImageBack(memberAuthenticationDto.getIdCardReverse());
- memberAuthenticationEntity.setIdcardImageInHand(memberAuthenticationDto.getIdCardImage());
-
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("member_id", memberId);
- List<MemberAuthenticationEntity> selectByMap = memberAuthenticationDao.selectByMap(columnMap);
- if (CollUtil.isEmpty(selectByMap)) {
- memberAuthenticationDao.insert(memberAuthenticationEntity);
- } else {
- memberAuthenticationEntity.setId(selectByMap.get(0).getId());
- memberAuthenticationDao.updateById(memberAuthenticationEntity);
- }
-
- member.setCertifyStatus(MemberEntity.CERTIFY_STATUS_ING);
- member.setIdcardNo(idCardNo);
- memberDao.updateById(member);
-
- ThreadPoolUtils.sendDingTalk(4);
- return Result.ok(MessageSourceUtils.getString("member_service_0024"));
- }
- return Result.fail(MessageSourceUtils.getString("member_service_0063"));
- }
-
- @Override
- @Transactional
- public Result memberUpdateTradePwd(@Valid MemberUpdateTradePwdDto memberUpdateTradePwdDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity memberEntity = memberDao.selectById(memberId);
-
- String code = memberUpdateTradePwdDto.getCode();
- String password = memberUpdateTradePwdDto.getPassword();
- String account = memberUpdateTradePwdDto.getAccount();
- String phone = memberEntity.getPhone();
- String email = memberEntity.getEmail();
- int type = memberUpdateTradePwdDto.getType();
-
- //验证手机号或者邮箱是否是该账户绑定的手机号或者邮箱
- if (MemberEntity.ACCOUNT_TYPE_PHONE.equals(type) && !phone.equals(account)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0041"));
- }
- if (MemberEntity.ACCOUNT_TYPE_EMAIL.equals(type) && !email.equals(account)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0041"));
- }
-
- boolean flag = commonservice.verifyCode(account, code);
- if (flag) {
- memberEntity.setTradePassword(SecureUtil.md5(password));
- memberDao.updateById(memberEntity);
- LoginUserUtils.resetAppLoginUser(memberEntity);
- return Result.ok(MessageSourceUtils.getString("member_service_0051"));
- }
- return Result.fail(MessageSourceUtils.getString("member_service_0045"));
-
- }
-
- @Override
- @Transactional
- public Result memberLogout() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity memberEntity = memberDao.selectById(memberId);
- if (ObjectUtil.isEmpty(memberEntity)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0003"));
- }
- String token = LoginUserUtils.getAppLoginUserToken();
- redisUtils.del(AppContants.APP_LOGIN_PREFIX + token);
- SecurityContextHolder.clearContext();
- return Result.ok(MessageSourceUtils.getString("member_service_0071"));
- }
-
- @Override
- @Transactional
- public Result memberTradersPwd(@Valid MemberForgetPwdDto memberForgetPwdDto) {
- //获取用户ID
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- String code = memberForgetPwdDto.getCode();
- String password = memberForgetPwdDto.getPassword();
- String account = memberForgetPwdDto.getAccount();
- int type = memberForgetPwdDto.getType();
-
- boolean flag = commonservice.verifyCode(account, code);
- if (flag) {
- memberEntity.setTradePassword(SecureUtil.md5(password));
- memberDao.updateById(memberEntity);
- // 重置内存中的用户信息
- LoginUserUtils.resetAppLoginUser(memberEntity);
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_0015"));
- }
-
- return Result.ok(MessageSourceUtils.getString("member_service_0068"));
- }
-
- @Override
- @Transactional
- public Result memberAddPaymethod(@Valid MemberPaymethodDto memberPaymethodDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
-
- if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0077"));
- }
-
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("member_id", memberId);
- List<MemberPaymentMethodEntity> selectByMap = memberPaymentMethodDao.selectByMap(columnMap);
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (MemberPaymentMethodEntity memberPaymentMethodEntity : selectByMap) {
- if (memberPaymethodDto.getAccount().equals(memberPaymentMethodEntity.getAccount())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0097"));
- }
- }
- }
- String account = memberPaymethodDto.getAccount();
- String bank = memberPaymethodDto.getBank();
- String name = memberPaymethodDto.getName();
- String paymentQrcode = memberPaymethodDto.getPaymentQrcode();
- String paymentType = memberPaymethodDto.getPaymentType();
- String subBank = memberPaymethodDto.getSubBank();
- MemberPaymentMethodEntity memberPaymentMethodEntity = new MemberPaymentMethodEntity();
- memberPaymentMethodEntity.setMemberId(memberId);
- memberPaymentMethodEntity.setAccount(account);
- memberPaymentMethodEntity.setBank(bank);
- memberPaymentMethodEntity.setName(name);
- memberPaymentMethodEntity.setPaymentQrcode(paymentQrcode);
- memberPaymentMethodEntity.setPaymentType(paymentType);
- memberPaymentMethodEntity.setSubBank(subBank);
- memberPaymentMethodDao.insert(memberPaymentMethodEntity);
- return Result.ok(MessageSourceUtils.getString("member_service_0024"));
- }
-
- @Override
- @Transactional
- public Result memberDelPaymethod(@Valid MemberDelPaymethodDto memberDelPaymethodDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- Long id = memberDelPaymethodDto.getId();
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("id", id);
- columnMap.put("member_id", memberId);
- memberPaymentMethodDao.deleteByMap(columnMap);
- return Result.ok("success");
- }
-
- @Override
- public Result memberPaymethodDetail(long id) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberPaymentMethodEntity memberPaymentMethod = memberPaymentMethodDao.selectById(id);
-
- MemberPaymethodDetailVo memberPaymethodDetailVo = new MemberPaymethodDetailVo();
- memberPaymethodDetailVo.setAccount(memberPaymentMethod.getAccount());
- memberPaymethodDetailVo.setBank(memberPaymentMethod.getBank());
- memberPaymethodDetailVo.setMemberId(memberId);
- memberPaymethodDetailVo.setName(memberPaymentMethod.getName());
- memberPaymethodDetailVo.setPaymentQrcode(memberPaymentMethod.getPaymentQrcode());
- memberPaymethodDetailVo.setPaymentType(memberPaymentMethod.getPaymentType());
- memberPaymethodDetailVo.setSubBank(memberPaymentMethod.getSubBank());
-
- return Result.ok(memberPaymethodDetailVo);
- }
-
- @Override
- public Result memberPaymethodDetailList() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("member_id", memberId);
- List<MemberPaymentMethodEntity> selectByMap = memberPaymentMethodDao.selectByMap(columnMap);
- List<MemberPaymethodDetailVo> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (MemberPaymentMethodEntity memberPaymentMethodEntity : selectByMap) {
- MemberPaymethodDetailVo memberPaymethodDetailVo = new MemberPaymethodDetailVo();
- memberPaymethodDetailVo.setId(memberPaymentMethodEntity.getId());
- memberPaymethodDetailVo.setAccount(memberPaymentMethodEntity.getAccount());
- memberPaymethodDetailVo.setBank(memberPaymentMethodEntity.getBank());
- memberPaymethodDetailVo.setMemberId(memberId);
- memberPaymethodDetailVo.setName(memberPaymentMethodEntity.getName());
- memberPaymethodDetailVo.setPaymentQrcode(memberPaymentMethodEntity.getPaymentQrcode());
- memberPaymethodDetailVo.setPaymentType(memberPaymentMethodEntity.getPaymentType());
- memberPaymethodDetailVo.setSubBank(memberPaymentMethodEntity.getSubBank());
- arrayList.add(memberPaymethodDetailVo);
- }
- }
-
- MemberPaymethodDetailListVo memberPaymethodDetailListVo = new MemberPaymethodDetailListVo();
- memberPaymethodDetailListVo.setMemberPaymethodDetailVo(arrayList);
- return Result.ok(memberPaymethodDetailListVo);
- }
-
- @Override
- @Transactional
- public Result memberBindPhone(@Valid MemberBindPhoneDto memberBindPhoneDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- String phone = memberBindPhoneDto.getPhone();
- String code = memberBindPhoneDto.getCode();
-
- MemberEntity member = memberDao.selectById(memberId);
-
- if (ObjectUtil.isNotEmpty(member)) {
- if (!commonservice.verifyCode(phone, code)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0013"));
- }
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("phone", phone);
- List<MemberEntity> selectByMap = memberDao.selectByMap(columnMap);
- if (CollUtil.isEmpty(selectByMap)) {
- member.setPhone(phone);
- memberDao.updateById(member);
- return Result.ok(MessageSourceUtils.getString("member_service_0014"));
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_1400"));
- }
- }
-
- return Result.fail(MessageSourceUtils.getString("member_service_0015"));
- }
-
- @Override
- @Transactional
- public Result memberBindEmail(@Valid MemberBindEmailDto memberBindEmailDto) {
-
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- String email = memberBindEmailDto.getEmail();
- String code = memberBindEmailDto.getCode();
-
- MemberEntity member = memberDao.selectById(memberId);
- boolean flag = commonservice.verifyCode(email, code);
- if (ObjectUtil.isNotEmpty(member)) {
- if (flag) {
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("email", email);
- List<MemberEntity> selectByMap = memberDao.selectByMap(columnMap);
- if (CollUtil.isEmpty(selectByMap)) {
- member.setEmail(email);
- memberDao.updateById(member);
- return Result.ok(MessageSourceUtils.getString("member_service_0018"));
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_1400"));
- }
- }
- }
- return Result.fail(MessageSourceUtils.getString("member_service_0019"));
- }
-
- @Override
- public Result memberCoinAddressCount() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- List<MemberCoinAddressCountVo> list = platformSymbolsCoinDao.selectCoinAddressCount(memberId);
- MemberCoinAddressCountListVo memberCoinAddressCountListVo = new MemberCoinAddressCountListVo();
- if (CollUtil.isNotEmpty(list)) {
- memberCoinAddressCountListVo.setMemberCoinAddressCountVo(list);
- return Result.ok(memberCoinAddressCountListVo);
- }
- return Result.fail(MessageSourceUtils.getString("member_service_0020"));
- }
-
- @Override
- public Result memberCoinAddressList(String symbol) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- List<MemberCoinAddressEntity> selectByMap = memberCoinAddressDao.selectCoinAddressListByMap(symbol, memberId);
- MemberCoinAddressListVo memberCoinAddressListVo = new MemberCoinAddressListVo();
- List<MemberCoinAddressVo> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (MemberCoinAddressEntity memberCoinAddressEntity : selectByMap) {
- MemberCoinAddressVo memberCoinAddressVo = new MemberCoinAddressVo();
- memberCoinAddressVo.setId(memberCoinAddressEntity.getId());
- memberCoinAddressVo.setAddress(memberCoinAddressEntity.getAddress());
- memberCoinAddressVo.setIsBiyict(memberCoinAddressEntity.getIsBiyict());
- memberCoinAddressVo.setMemberId(memberCoinAddressEntity.getMemberId());
- memberCoinAddressVo.setPrivateKey(memberCoinAddressEntity.getPrivateKey());
- memberCoinAddressVo.setSymbol(memberCoinAddressEntity.getSymbol());
- memberCoinAddressVo.setLabel(memberCoinAddressEntity.getLabel());
- memberCoinAddressVo.setSymbolscoinId(memberCoinAddressEntity.getSymbolscoinId());
- arrayList.add(memberCoinAddressVo);
- }
- }
- memberCoinAddressListVo.setMemberCoinAddressVo(arrayList);
-
- return Result.ok(memberCoinAddressListVo);
- }
-
- @Override
- @Transactional
- public Result memberAddCoinAddress(@Valid MemberAddCoinAddressDto memberAddCoinAddressDto) {
-
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- String address = memberAddCoinAddressDto.getAddress();
- String isBiyict = memberAddCoinAddressDto.getIsBiyict();
- Long symbolscoinId = memberAddCoinAddressDto.getSymbolscoinId();
- String remark = memberAddCoinAddressDto.getRemark();
-
- PlatformSymbolsCoinEntity platformSymbolsCoinEntity = platformSymbolsCoinDao.selectById(symbolscoinId);
-
- MemberCoinAddressEntity memberCoinAddressEntity = new MemberCoinAddressEntity();
- memberCoinAddressEntity.setAddress(address);
- memberCoinAddressEntity.setMemberId(memberId);
- memberCoinAddressEntity.setIsBiyict(MemberCoinAddressEntity.IS_BIYICT_NO);
- memberCoinAddressEntity.setSymbolscoinId(symbolscoinId);
- memberCoinAddressEntity.setLabel(remark);
- memberCoinAddressEntity.setSymbol(platformSymbolsCoinEntity.getName());
-
- memberCoinAddressDao.insert(memberCoinAddressEntity);
-
- return Result.ok(MessageSourceUtils.getString("member_service_0024"));
- }
-
- @Override
- public Result memberSendCodeWay() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
- MemberSendCodeWayVo memberSendCodeWayVo = new MemberSendCodeWayVo();
- if (ObjectUtil.isNotEmpty(member)) {
- memberSendCodeWayVo.setPhone(member.getPhone());
- memberSendCodeWayVo.setEmail(member.getEmail());
- }
- return Result.ok(memberSendCodeWayVo);
- }
-
- @Override
- @Transactional
- public Result memberDelCoinAddress(@Valid MemberDelCoinAddressDto memberDelCoinAddressDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
- if (ObjectUtil.isNotEmpty(member)) {
- Long id = memberDelCoinAddressDto.getId();
- memberCoinAddressDao.deleteById(id);
- }
- return Result.ok("success");
- }
-
- @Override
- public Result memberAuthenticationInfo() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
-
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("member_id", memberId);
- List<MemberAuthenticationEntity> selectByMap = memberAuthenticationDao.selectByMap(columnMap);
-
- MemberAuthenticationInfoVo memberAuthnticationInfoVo = new MemberAuthenticationInfoVo();
- memberAuthnticationInfoVo.setCertifyStatus(member.getCertifyStatus());
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (MemberAuthenticationEntity memberAuthenticationEntity : selectByMap) {
- memberAuthnticationInfoVo.setFirstName(memberAuthenticationEntity.getFirstName());
- memberAuthnticationInfoVo.setSecondName(memberAuthenticationEntity.getSecondName());
- memberAuthnticationInfoVo.setNation(memberAuthenticationEntity.getNation());
- memberAuthnticationInfoVo.setIdCardNo(memberAuthenticationEntity.getIdcardNo());
- memberAuthnticationInfoVo.setType(memberAuthenticationEntity.getType());
- }
- }
- return Result.ok(memberAuthnticationInfoVo);
- }
-
- @Override
- public Result memberPersonCenterInfo() {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
-
- MemberPersonCenterInfoVo memberPersonCenterInfoVo = new MemberPersonCenterInfoVo();
-
- Integer certifyStatus = member.getCertifyStatus();
- memberPersonCenterInfoVo.setCertifyStatus(certifyStatus);
-
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("member_id", memberId);
- List<MemberPaymentMethodEntity> selectByMap = memberPaymentMethodDao.selectByMap(columnMap);
- if (CollUtil.isEmpty(selectByMap)) {
- memberPersonCenterInfoVo.setMemberPaymentMethod(0);
- } else {
- memberPersonCenterInfoVo.setMemberPaymentMethod(1);
- }
-
- if (StrUtil.isNotEmpty(member.getPhone())) {
- memberPersonCenterInfoVo.setPhone(1);
- } else {
- memberPersonCenterInfoVo.setPhone(0);
- }
-
- if (StrUtil.isNotEmpty(member.getEmail())) {
- memberPersonCenterInfoVo.setEmail(1);
- } else {
- memberPersonCenterInfoVo.setEmail(0);
- }
-
- if (StrUtil.isNotEmpty(member.getTradePassword())) {
- memberPersonCenterInfoVo.setTradePassword(1);
- } else {
- memberPersonCenterInfoVo.setTradePassword(0);
- }
-
- Integer tradeAgingSetting = member.getTradeAgingSetting();
- if (tradeAgingSetting != null && tradeAgingSetting == MemberPersonCenterInfoVo.PWD_NEED_FORVER) {
- memberPersonCenterInfoVo.setTradeAgingSetting(MemberPersonCenterInfoVo.PWD_NEED_FORVER);
- } else {
- memberPersonCenterInfoVo.setTradeAgingSetting(MemberPersonCenterInfoVo.PWD_NEED_NO);
- }
-
- return Result.ok(memberPersonCenterInfoVo);
- }
-
- @Override
- public Result memberCoinInfoList() {
-
- MemberCoinInfoListVo memberCoinInfoListVo = new MemberCoinInfoListVo();
- List<PlatformSymbolsCoinEntity> selectByMap = platformSymbolsCoinDao.selectByMap(new HashMap<>());
- List<MemberCoinInfoVo> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (PlatformSymbolsCoinEntity platformSymbolsCoinEntity : selectByMap) {
- MemberCoinInfoVo memberCoinInfoVo = new MemberCoinInfoVo();
- memberCoinInfoVo.setName(platformSymbolsCoinEntity.getName());
- arrayList.add(memberCoinInfoVo);
- }
- }
- memberCoinInfoListVo.setMemberCoinInfoVo(arrayList);
-
- return Result.ok(memberCoinInfoListVo);
- }
-
- @Override
- public Result memberAvivableCoinInfo(String symbol) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
- if (ObjectUtil.isEmpty(walletCoin)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0087"));
- }
-
- List<MemberAvivableCoinInfoVo> arrayList = new ArrayList<>();
-
-
- List<PlatformFeeSettingEntity> feeSettingByTypeAndSymbolLable = platformFeeSettingDao.getFeeSettingsByTypeAndSymbol(2, symbol);
- if (CollUtil.isEmpty(feeSettingByTypeAndSymbolLable)) {
- return Result.fail(MessageSourceUtils.getString("member_service_0087"));
- }
- for (PlatformFeeSettingEntity platformFeeSettingEntity : feeSettingByTypeAndSymbolLable) {
- MemberAvivableCoinInfoVo memberAvivableCoinInfoVo = new MemberAvivableCoinInfoVo();
- memberAvivableCoinInfoVo.setAvailableBalance(walletCoin.getAvailableBalance());
- memberAvivableCoinInfoVo.setFee(platformFeeSettingEntity.getFeePrice());
- memberAvivableCoinInfoVo.setLable(platformFeeSettingEntity.getLable());
- arrayList.add(memberAvivableCoinInfoVo);
- }
-
- return Result.ok(arrayList);
- }
-
- @Override
- public NeedMoneyMemberVo selectFriendRelationUserByMemberId(Long memberId) {
- return memberDao.selectFriendRelationUserByMemberId(memberId);
- }
-
- @Override
- public List<NeedMoneyMemberVo> selectAllNeedMoneyMember(List<String> list) {
- return memberDao.selectAllNeedMoneyMember(list);
- }
-
- @Override
- public MemberEntity selectMemberInfoByInviteId(String inviteId) {
- return memberDao.selectMemberInfoByInviteId(inviteId);
- }
-
- @Override
- @Transactional
- public Result memberUpdateTradersPwdTime(MemberUpdateTradersPwdTimeDto memberUpdateTradersPwdTimeDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
- member.setTradeAgingSetting(memberUpdateTradersPwdTimeDto.getTradeAgingSetting());
- memberDao.updateById(member);
- return Result.ok("success");
- }
-
- @Override
- public Result memberSubmitCoinApply(@Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto) {
- //获取用户ID
- Long memberId = LoginUserUtils.getAppLoginUser().getId();
- MemberEntity member = memberDao.selectById(memberId);
- if (member.getCertifyStatus() != MemberEntity.CERTIFY_STATUS_Y) {
- return Result.fail(MessageSourceUtils.getString("member_service_0077"));
- }
- if (StrUtil.isEmpty(member.getTradePassword())) {
- return Result.fail(MessageSourceUtils.getString("member_service_0081"));
- }
- if (member.getTradePassword() == null) {
- return Result.fail(MessageSourceUtils.getString("member_service_0082"));
- }
- if (!member.getTradePassword().equals(SecureUtil.md5(memberSubmitCoinApplyDto.getTradePassword()))) {
- return Result.fail(MessageSourceUtils.getString("member_service_0082"));
- }
-
- boolean flag = commonservice.verifyCode(memberSubmitCoinApplyDto.getAccount(), memberSubmitCoinApplyDto.getCode());
- if (flag) {
- MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, memberSubmitCoinApplyDto.getSymbol());
- BigDecimal availableBalance = walletCoin.getAvailableBalance();
- BigDecimal coinNumber = memberSubmitCoinApplyDto.getCoinNumber();
- if (availableBalance.compareTo(BigDecimal.ZERO) > 0
- && availableBalance.compareTo(coinNumber) >= 0) {
- //新增提币记录
- MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
- memberCoinWithdrawEntity.setAddress(memberSubmitCoinApplyDto.getAddress());
- memberCoinWithdrawEntity.setAmount(coinNumber);
- memberCoinWithdrawEntity.setFeeAmount(memberSubmitCoinApplyDto.getFeeAmount());
- memberCoinWithdrawEntity.setSymbol(memberSubmitCoinApplyDto.getSymbol());
- memberCoinWithdrawEntity.setMemberId(memberId);
- memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING);
-
- Map<String, Object> columnMap = new HashMap<>();
- columnMap.put("symbol", memberSubmitCoinApplyDto.getSymbol());
- columnMap.put("address", memberSubmitCoinApplyDto.getAddress());
- columnMap.put("is_biyict", MemberCoinAddressEntity.IS_BIYICT_YES);
- List<MemberCoinAddressEntity> selectByMap = memberCoinAddressDao.selectByMap(columnMap);
- if (CollUtil.isEmpty(selectByMap)) {
- memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_NO);
- } else {
- memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES);
- }
- memberCoinWithdrawDao.insert(memberCoinWithdrawEntity);
- BigDecimal subtract = walletCoin.getAvailableBalance().subtract(coinNumber);
- walletCoin.setAvailableBalance(subtract);
- BigDecimal add = walletCoin.getFrozenBalance().add(coinNumber);
- walletCoin.setFrozenBalance(add);
- memberWalletCoinDao.updateById(walletCoin);
-
- MemberAccountMoneyChange accountRecord = new MemberAccountMoneyChange();
- accountRecord.setContent("提币");
- accountRecord.setMemberId(memberId);
- accountRecord.setAmount(coinNumber);
- accountRecord.setWithdrawId(memberCoinWithdrawEntity.getId());
- accountRecord.setStatus(MemberAccountMoneyChange.STATUS_WAIT_INTEGER);
- accountRecord.setSymbol(memberSubmitCoinApplyDto.getSymbol());
- accountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
- memberAccountMoneyChangeDao.insert(accountRecord);
-
- ThreadPoolUtils.sendDingTalk(3);
- return Result.ok(MessageSourceUtils.getString("member_service_0086"));
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_0005"));
- }
-
- } else {
- return Result.fail(MessageSourceUtils.getString("member_service_0039"));
- }
- }
-
- @Override
- public Result getMemberAccountInfo(String account, int type) {
-
- Map<String, Object> hashMap = new HashMap<>();
- if (type == 1) {
- hashMap.put("phone", account);
- } else {
- hashMap.put("email", account);
- }
- List<MemberEntity> member = memberDao.selectByMap(hashMap);
- if (CollUtil.isEmpty(member)) {
- return Result.fail(MessageSourceUtils.getString("home_service_0003"));
- }
-
- return Result.ok("");
- }
-
- @Override
- public Result getAppVersionInfo() {
- MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
-
- Map<String, Object> columnMap = new HashMap<>();
- List<AppVersionEntity> selectByMap = appVersionDao.selectByMap(columnMap);
- List<Object> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (AppVersionEntity appVersionEntity : selectByMap) {
- AppVersionVo appVersionVo = new AppVersionVo();
- if ("37059551".equals(memberEntity.getInviteId())) {
- appVersionVo.setAddress("www.baidu.com");
- appVersionVo.setType(appVersionEntity.getType());
- appVersionVo.setVersion(appVersionEntity.getVersion());
- } else {
- appVersionVo.setAddress(appVersionEntity.getAddress());
- appVersionVo.setType(appVersionEntity.getType());
- appVersionVo.setVersion(appVersionEntity.getVersion());
- }
- arrayList.add(appVersionVo);
- }
- }
- return Result.ok(arrayList);
- }
-
- @Override
- public Result getPcVersionInfo() {
- Map<String, Object> columnMap = new HashMap<>();
- List<AppVersionEntity> selectByMap = appVersionDao.selectByMap(columnMap);
- List<Object> arrayList = new ArrayList<>();
- if (CollUtil.isNotEmpty(selectByMap)) {
- for (AppVersionEntity appVersionEntity : selectByMap) {
- AppVersionVo appVersionVo = new AppVersionVo();
- appVersionVo.setAddress(appVersionEntity.getAddress());
- appVersionVo.setType(appVersionEntity.getType());
- appVersionVo.setVersion(appVersionEntity.getVersion());
- arrayList.add(appVersionVo);
- }
- }
- return Result.ok(arrayList);
- }
-}
-
-
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberWalletContractServiceImpl.java b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberWalletContractServiceImpl.java
deleted file mode 100644
index 9a7abac..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberWalletContractServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.xcong.excoin.modules.member.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
-import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
-import com.xcong.excoin.modules.member.service.MemberWalletContractService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-
-/**
- * 会员合约钱包
- */
-@Slf4j
-@Service
-public class MemberWalletContractServiceImpl extends ServiceImpl<MemberWalletContractDao, MemberWalletContractEntity> implements MemberWalletContractService {
-
- @Resource
- private MemberWalletContractDao memberWalletContractDao;
-
- @Override
- public MemberWalletContractEntity findWalletContractByMemberIdAndSymbol(Long memberId, String symbol){
- return memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId,symbol);
- }
-
- @Override
- public void increaseWalletContractBalanceById(BigDecimal availableBalance, BigDecimal totalBalance, BigDecimal frozenBalance, Long id) {
- memberWalletContractDao.increaseWalletContractBalanceById(availableBalance,totalBalance,frozenBalance,id);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/Direction.java b/src/main/java/com/xcong/excoin/modules/okxApi/Direction.java
new file mode 100644
index 0000000..aa0affa
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/Direction.java
@@ -0,0 +1,20 @@
+package com.xcong.excoin.modules.okxApi;
+
+/**
+ * 交易方向枚举。
+ *
+ * <ul>
+ * <li>{@link #LONG} — 多头(做多)</li>
+ * <li>{@link #SHORT} — 空头(做空)</li>
+ * </ul>
+ *
+ * <p>从原 {@code TraderParam.Direction} 提取为独立枚举,供策略接口和 WS 处理器共用。
+ *
+ * @author Administrator
+ */
+public enum Direction {
+ /** 多头方向 */
+ LONG,
+ /** 空头方向 */
+ SHORT
+}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/GridElement.java b/src/main/java/com/xcong/excoin/modules/okxApi/GridElement.java
deleted file mode 100644
index 0e3dc15..0000000
--- a/src/main/java/com/xcong/excoin/modules/okxApi/GridElement.java
+++ /dev/null
@@ -1,547 +0,0 @@
-package com.xcong.excoin.modules.okxApi;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 网格价格层级,策略的最小操作单元。
- *
- * <h3>定位</h3>
- * 每个 GridElement 对应网格中的一个价格点,同时持有该点的多仓和空仓挂单状态。
- * 与传统的"价格队列+Map"模式不同,GridElement 将价格、方向、状态、订单ID 聚合到一个对象中,
- * 并维护全局静态 HashMap 索引实现 O(1) 双向查询。
- *
- * <h3>ID 体系与链表</h3>
- * <pre>
- * ID ≦ -1: 空仓队列区域(降序),ID 自减,gridPrice 递减
- * ID = 0: 基座位置,gridPrice = shortBaseEntryPrice
- * ID ≧ 1: 多仓队列区域(升序),ID 自增,gridPrice 递增
- *
- * 链表: ... ← -3 ← -2 ← -1 ← 0 → 1 → 2 → 3 → ...
- * (通过 upId/downId + INDEX 实现 O(1) 遍历)
- * </pre>
- *
- * <h3>字段分组</h3>
- * <table>
- * <tr><th>类别</th><th>字段</th><th>说明</th></tr>
- * <tr><td>标识</td><td>id, gridPrice, upId, downId</td><td>编号、价格、双向链表指针</td></tr>
- * <tr><td>多仓订单</td><td>hasLongOrder, longOrderId, longTraderParam</td><td>是否有挂单、订单ID、完整参数</td></tr>
- * <tr><td>空仓订单</td><td>hasShortOrder, shortOrderId, shortTraderParam</td><td>是否有挂单、订单ID、完整参数</td></tr>
- * <tr><td>止盈</td><td>longTakeProfitOrderId, shortTakeProfitOrderId</td><td>止盈条件单ID</td></tr>
- * </table>
- *
- * <h3>6 个全局 O(1) 索引</h3>
- * <pre>
- * INDEX → findById(int) ID → 元素
- * PRICE_INDEX → findByPrice(BigDecimal) 价格 → 元素
- * LONG_ORDER_ID_INDEX → findByLongOrderId(String) 多仓挂单ID → 元素
- * SHORT_ORDER_ID_INDEX → findByShortOrderId(String) 空仓挂单ID → 元素
- * LONG_TP_ORDER_ID_INDEX→ findByLongTakeProfitOrderId(String) 多止盈ID → 元素
- * SHORT_TP_ORDER_ID_INDEX→ findByShortTakeProfitOrderId(String) 空止盈ID → 元素
- * </pre>
- * 索引通过 {@link #rebuildIndex(List)}(全量重建)或 {@link #refreshIndices()}(增量刷新)
- * 维护,每次操作后自动打印全量网格状态到控制台。
- *
- * <h3>何时填充 TraderParam</h3>
- * 初始化时 {@code updateGridElements()} 为每个元素预填充 longTraderParam 和 shortTraderParam
- * (含 direction/entryPrice/takeProfitPrice/quantity),订单ID字段在挂单成功后由
- *
- * <h3>使用示例</h3>
- * <pre>
- * GridElement elem = GridElement.findById(1);
- * boolean hasLong = elem.isHasLongOrder(); // 是否挂了多单
- * BigDecimal tpPrice = elem.getLongTraderParam().getTakeProfitPrice(); // 止盈价
- * elem.getUp(); // 上一个网格(O(1))
- * elem.getDown(); // 下一个网格(O(1))
- * </pre>
- *
- * @author Administrator
- */
-public class GridElement {
-
- /** 网格层级编号 */
- private int id;
- /** 网格触发价格 */
- private BigDecimal gridPrice;
- /** 是否存在多仓挂单 */
- private boolean hasLongOrder;
- /** 是否存在空仓挂单 */
- private boolean hasShortOrder;
- /** 多仓挂单参数 */
- private TraderParam longTraderParam;
- /** 空仓挂单参数 */
- private TraderParam shortTraderParam;
- /** 上一个网格编号,null 表示无上一级 */
- private Integer upId;
- /** 下一个网格编号,null 表示无下一级 */
- private Integer downId;
- /** 多仓挂单订单 ID */
- private String longOrderId;
- /** 空仓挂单订单 ID */
- private String shortOrderId;
- /** 多仓止盈订单 ID */
- private String longTakeProfitOrderId;
- /** 空仓止盈订单 ID */
- private String shortTakeProfitOrderId;
- /** 多仓止损订单 ID */
- private String longStopLossOrderId;
- /** 空仓止损订单 ID */
- private String shortStopLossOrderId;
-
- /** 索引重建锁,保证 refreshIndices() 与计数读取之间互斥,避免 clear→rebuild 窗口期读到 0 */
- private static final Object INDEX_LOCK = new Object();
-
- /** 全局 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<Integer, GridElement> INDEX = new ConcurrentHashMap<>();
- /** 全局价格索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<BigDecimal, GridElement> PRICE_INDEX = new ConcurrentHashMap<>();
- /** 全局多仓订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<String, GridElement> LONG_ORDER_ID_INDEX = new ConcurrentHashMap<>();
- /** 全局空仓订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<String, GridElement> SHORT_ORDER_ID_INDEX = new ConcurrentHashMap<>();
- /** 全局多仓止盈订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<String, GridElement> LONG_TP_ORDER_ID_INDEX = new ConcurrentHashMap<>();
- /** 全局空仓止盈订单 ID 索引,由 { GateConfig#setGridElements(List)} 触发重建,O(1) 查找 */
- private static final Map<String, GridElement> SHORT_TP_ORDER_ID_INDEX = new ConcurrentHashMap<>();
- /** 全局多仓止损订单 ID 索引 */
- private static final Map<String, GridElement> LONG_SL_ORDER_ID_INDEX = new ConcurrentHashMap<>();
- /** 全局空仓止损订单 ID 索引 */
- private static final Map<String, GridElement> SHORT_SL_ORDER_ID_INDEX = new ConcurrentHashMap<>();
-
- /**
- * 根据 ID 快速查找网格元素(O(1))。
- *
- * @param id 网格层级编号
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findById(int id) {
- return INDEX.get(id);
- }
-
- /**
- * 根据价格快速查找网格元素(O(1))。
- *
- * @param price 网格价格
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findByPrice(BigDecimal price) {
- return PRICE_INDEX.get(price);
- }
-
- /**
- * 根据多仓挂单订单 ID 快速查找网格元素(O(1))。
- *
- * @param orderId 多仓挂单订单 ID
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findByLongOrderId(String orderId) {
- return LONG_ORDER_ID_INDEX.get(orderId);
- }
-
- /**
- * 根据空仓挂单订单 ID 快速查找网格元素(O(1))。
- *
- * @param orderId 空仓挂单订单 ID
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findByShortOrderId(String orderId) {
- return SHORT_ORDER_ID_INDEX.get(orderId);
- }
-
- /**
- * 根据多仓止盈订单 ID 快速查找网格元素(O(1))。
- *
- * @param orderId 多仓止盈订单 ID
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findByLongTakeProfitOrderId(String orderId) {
- return LONG_TP_ORDER_ID_INDEX.get(orderId);
- }
-
- /**
- * 根据空仓止盈订单 ID 快速查找网格元素(O(1))。
- *
- * @param orderId 空仓止盈订单 ID
- * @return 对应的 GridElement,不存在则返回 null
- */
- public static GridElement findByShortTakeProfitOrderId(String orderId) {
- return SHORT_TP_ORDER_ID_INDEX.get(orderId);
- }
-
- /** @return 当前多仓止盈单数量(与 refreshIndices 互斥,避免清空窗口读到 0) */
- public static int getLongTakeProfitCount() {
- synchronized (INDEX_LOCK) { return LONG_TP_ORDER_ID_INDEX.size(); }
- }
-
- /** @return 当前空仓止盈单数量(与 refreshIndices 互斥,避免清空窗口读到 0) */
- public static int getShortTakeProfitCount() {
- synchronized (INDEX_LOCK) { return SHORT_TP_ORDER_ID_INDEX.size(); }
- }
-
- /**
- * 根据多仓止损订单 ID 快速查找网格元素(O(1))。
- */
- public static GridElement findByLongStopLossOrderId(String orderId) {
- return LONG_SL_ORDER_ID_INDEX.get(orderId);
- }
-
- /**
- * 根据空仓止损订单 ID 快速查找网格元素(O(1))。
- */
- public static GridElement findByShortStopLossOrderId(String orderId) {
- return SHORT_SL_ORDER_ID_INDEX.get(orderId);
- }
-
- /**
- * 从列表中重建全局 ID 索引和价格索引。
- * 由 { GateConfig#setGridElements(List)} 在每次列表变更后调用。
- */
- public static void rebuildIndex(List<GridElement> elements) {
- INDEX.clear();
- PRICE_INDEX.clear();
- LONG_ORDER_ID_INDEX.clear();
- SHORT_ORDER_ID_INDEX.clear();
- LONG_TP_ORDER_ID_INDEX.clear();
- SHORT_TP_ORDER_ID_INDEX.clear();
- LONG_SL_ORDER_ID_INDEX.clear();
- SHORT_SL_ORDER_ID_INDEX.clear();
- for (GridElement e : elements) {
- INDEX.put(e.getId(), e);
- putDynamicIndices(e);
- }
- logAll();
- }
-
- /**
- * 刷新动态索引(价格索引、多仓/空仓订单 ID 索引)。
- * 在对 GridElement 的 {@link #longOrderId}、{@link #shortOrderId}、
- * {@link #longTraderParam}、{@link #shortTraderParam} 等字段修改后调用,
- * 使快速查找方法获取到最新数据。
- */
- public static void refreshIndices() {
- synchronized (INDEX_LOCK) {
- PRICE_INDEX.clear();
- LONG_ORDER_ID_INDEX.clear();
- SHORT_ORDER_ID_INDEX.clear();
- LONG_TP_ORDER_ID_INDEX.clear();
- SHORT_TP_ORDER_ID_INDEX.clear();
- LONG_SL_ORDER_ID_INDEX.clear();
- SHORT_SL_ORDER_ID_INDEX.clear();
- for (GridElement e : INDEX.values()) {
- putDynamicIndices(e);
- }
- }
- // logAll 在锁外执行,不阻塞计数查询
- logAll();
- }
-
- /**
- * 打印全部网格数据到日志。
- */
- public static void logAll() {
- List<GridElement> sorted = new ArrayList<>(INDEX.values());
- sorted.sort((a, b) -> Integer.compare(a.getId(), b.getId()));
- StringBuilder sb = new StringBuilder("\n========== 网格数据 ==========\n");
- for (GridElement e : sorted) {
- if (e.isHasLongOrder() || e.isHasShortOrder()
- || e.getLongStopLossOrderId() != null || e.getShortStopLossOrderId() != null){
- sb.append(String.format(
- " ID=%4d 价格=%s up=%s down=%s 多仓=%s(%s) 空仓=%s(%s) 多止盈=%s 空止盈=%s 多止损=%s 空止损=%s\n",
- e.getId(),
- e.getGridPrice(),
- e.getUpId(),
- e.getDownId(),
- e.isHasLongOrder() ? "有" : "无",
- e.getLongOrderId() != null ? e.getLongOrderId() : "-",
- e.isHasShortOrder() ? "有" : "无",
- e.getShortOrderId() != null ? e.getShortOrderId() : "-",
- e.getLongTakeProfitOrderId() != null ? e.getLongTakeProfitOrderId() : "-",
- e.getShortTakeProfitOrderId() != null ? e.getShortTakeProfitOrderId() : "-",
- e.getLongStopLossOrderId() != null ? e.getLongStopLossOrderId() : "-",
- e.getShortStopLossOrderId() != null ? e.getShortStopLossOrderId() : "-"
- ));
- }
- }
- sb.append(String.format(
- "------------------------------------------------------------\n" +
- " 索引统计: ID=%d 价格=%d 多仓订单ID=%d 空仓订单ID=%d 多止盈ID=%d 空止盈ID=%d 多止损ID=%d 空止损ID=%d\n",
- INDEX.size(),
- PRICE_INDEX.size(),
- LONG_ORDER_ID_INDEX.size(),
- SHORT_ORDER_ID_INDEX.size(),
- LONG_TP_ORDER_ID_INDEX.size(),
- SHORT_TP_ORDER_ID_INDEX.size(),
- LONG_SL_ORDER_ID_INDEX.size(),
- SHORT_SL_ORDER_ID_INDEX.size()
- ));
- sb.append(String.format(" 多仓订单ID索引: %s\n", LONG_ORDER_ID_INDEX.keySet()));
- sb.append(String.format(" 空仓订单ID索引: %s\n", SHORT_ORDER_ID_INDEX.keySet()));
- sb.append(String.format(" 多止盈ID索引: %s\n", LONG_TP_ORDER_ID_INDEX.keySet()));
- sb.append(String.format(" 空止盈ID索引: %s\n", SHORT_TP_ORDER_ID_INDEX.keySet()));
- sb.append("================================\n");
- System.out.println(sb);
- }
-
- /**
- * 获取所有已挂多仓条件单的网格元素。
- * 小于空仓仓位线的多单
- *
- * @return 已挂多仓条件单的 GridElement 列表
- */
- public static List<GridElement> findAllShortOrders(BigDecimal currentPrice) {
- List<GridElement> result = new ArrayList<>();
- for (GridElement e : INDEX.values()) {
- if (e.isHasShortOrder() && e.getGridPrice().compareTo(currentPrice) < 0 && e.getShortTakeProfitOrderId() == null) {
- result.add(e);
- }
- }
- return result;
- }
-
- /**
- * 获取所有已挂空仓条件单的网格元素。
- * 大于多仓仓位线的空单
- *
- * @return 已挂空仓条件单的 GridElement 列表
- */
- public static List<GridElement> findAllLongOrders(BigDecimal currentPrice) {
- List<GridElement> result = new ArrayList<>();
- for (GridElement e : INDEX.values()) {
- if (e.isHasLongOrder() && e.getGridPrice().compareTo(currentPrice) > 0 && e.getLongTakeProfitOrderId() == null) {
- result.add(e);
- }
- }
- return result;
- }
-
- private static void putDynamicIndices(GridElement e) {
- PRICE_INDEX.put(e.getGridPrice(), e);
- if (e.getLongOrderId() != null) {
- LONG_ORDER_ID_INDEX.put(e.getLongOrderId(), e);
- }
- if (e.getShortOrderId() != null) {
- SHORT_ORDER_ID_INDEX.put(e.getShortOrderId(), e);
- }
- if (e.getLongTakeProfitOrderId() != null) {
- LONG_TP_ORDER_ID_INDEX.put(e.getLongTakeProfitOrderId(), e);
- }
- if (e.getShortTakeProfitOrderId() != null) {
- SHORT_TP_ORDER_ID_INDEX.put(e.getShortTakeProfitOrderId(), e);
- }
- if (e.getLongStopLossOrderId() != null) {
- LONG_SL_ORDER_ID_INDEX.put(e.getLongStopLossOrderId(), e);
- }
- if (e.getShortStopLossOrderId() != null) {
- SHORT_SL_ORDER_ID_INDEX.put(e.getShortStopLossOrderId(), e);
- }
- }
-
- /**
- * @return 根据 upId 获取上一个网格元素,无上一级则返回 null
- */
- public GridElement getUp() {
- return upId != null ? INDEX.get(upId) : null;
- }
-
- /**
- * @return 根据 downId 获取下一个网格元素,无下一级则返回 null
- */
- public GridElement getDown() {
- return downId != null ? INDEX.get(downId) : null;
- }
-
- private GridElement(Builder builder) {
- this.id = builder.id;
- this.gridPrice = builder.gridPrice;
- this.hasLongOrder = builder.hasLongOrder;
- this.hasShortOrder = builder.hasShortOrder;
- this.longTraderParam = builder.longTraderParam;
- this.shortTraderParam = builder.shortTraderParam;
- this.upId = builder.upId;
- this.downId = builder.downId;
- this.longOrderId = builder.longOrderId;
- this.shortOrderId = builder.shortOrderId;
- this.longTakeProfitOrderId = builder.longTakeProfitOrderId;
- this.shortTakeProfitOrderId = builder.shortTakeProfitOrderId;
- this.longStopLossOrderId = builder.longStopLossOrderId;
- this.shortStopLossOrderId = builder.shortStopLossOrderId;
- }
-
- // ==================== 网格层级编号 ====================
-
- /** @return 网格层级编号 */
- public int getId() { return id; }
- /** 设置网格层级编号 */
- public void setId(int id) { this.id = id; }
-
- // ==================== 网格价格 ====================
-
- /** @return 网格触发价格 */
- public BigDecimal getGridPrice() { return gridPrice; }
- /** 设置网格触发价格 */
- public void setGridPrice(BigDecimal gridPrice) { this.gridPrice = gridPrice; }
-
- // ==================== 多仓挂单标记 ====================
-
- /** @return 是否存在多仓挂单 */
- public boolean isHasLongOrder() { return hasLongOrder; }
- /** 标记是否存在多仓挂单 */
- public void setHasLongOrder(boolean hasLongOrder) { this.hasLongOrder = hasLongOrder; }
-
- // ==================== 空仓挂单标记 ====================
-
- /** @return 是否存在空仓挂单 */
- public boolean isHasShortOrder() { return hasShortOrder; }
- /** 标记是否存在空仓挂单 */
- public void setHasShortOrder(boolean hasShortOrder) { this.hasShortOrder = hasShortOrder; }
-
- // ==================== 多仓挂单参数 ====================
-
- /** @return 多仓挂单参数 */
- public TraderParam getLongTraderParam() { return longTraderParam; }
- /** 设置多仓挂单参数 */
- public void setLongTraderParam(TraderParam longTraderParam) { this.longTraderParam = longTraderParam; }
-
- // ==================== 空仓挂单参数 ====================
-
- /** @return 空仓挂单参数 */
- public TraderParam getShortTraderParam() { return shortTraderParam; }
- /** 设置空仓挂单参数 */
- public void setShortTraderParam(TraderParam shortTraderParam) { this.shortTraderParam = shortTraderParam; }
-
- // ==================== 上一个网格编号 ====================
-
- /** @return 上一个网格编号,null 表示无上一级 */
- public Integer getUpId() { return upId; }
- /** 设置上一个网格编号 */
- public void setUpId(Integer upId) { this.upId = upId; }
-
- // ==================== 下一个网格编号 ====================
-
- /** @return 下一个网格编号,null 表示无下一级 */
- public Integer getDownId() { return downId; }
- /** 设置下一个网格编号 */
- public void setDownId(Integer downId) { this.downId = downId; }
-
- // ==================== 多仓挂单订单 ID ====================
-
- /** @return 多仓挂单订单 ID */
- public String getLongOrderId() { return longOrderId; }
- /** 设置多仓挂单订单 ID */
- public void setLongOrderId(String longOrderId) { this.longOrderId = longOrderId; }
-
- // ==================== 空仓挂单订单 ID ====================
-
- /** @return 空仓挂单订单 ID */
- public String getShortOrderId() { return shortOrderId; }
- /** 设置空仓挂单订单 ID */
- public void setShortOrderId(String shortOrderId) { this.shortOrderId = shortOrderId; }
-
- // ==================== 多仓止盈订单 ID ====================
-
- /** @return 多仓止盈订单 ID */
- public String getLongTakeProfitOrderId() { return longTakeProfitOrderId; }
- /** 设置多仓止盈订单 ID */
- public void setLongTakeProfitOrderId(String longTakeProfitOrderId) { this.longTakeProfitOrderId = longTakeProfitOrderId; }
-
- // ==================== 空仓止盈订单 ID ====================
-
- /** @return 空仓止盈订单 ID */
- public String getShortTakeProfitOrderId() { return shortTakeProfitOrderId; }
- /** 设置空仓止盈订单 ID */
- public void setShortTakeProfitOrderId(String shortTakeProfitOrderId) { this.shortTakeProfitOrderId = shortTakeProfitOrderId; }
-
- // ==================== 多仓止损订单 ID ====================
-
- /** @return 多仓止损订单 ID */
- public String getLongStopLossOrderId() { return longStopLossOrderId; }
- /** 设置多仓止损订单 ID */
- public void setLongStopLossOrderId(String longStopLossOrderId) { this.longStopLossOrderId = longStopLossOrderId; }
-
- // ==================== 空仓止损订单 ID ====================
-
- /** @return 空仓止损订单 ID */
- public String getShortStopLossOrderId() { return shortStopLossOrderId; }
- /** 设置空仓止损订单 ID */
- public void setShortStopLossOrderId(String shortStopLossOrderId) { this.shortStopLossOrderId = shortStopLossOrderId; }
-
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * GridElement 的流式构造器。
- *
- * <h3>必填项</h3>
- * {@code id}、{@code gridPrice} 必须设置。
- *
- * <h3>默认值</h3>
- * hasLongOrder/hasShortOrder 默认为 false,upId/downId/TraderParam 默认为 null
- */
- public static class Builder {
- /** 网格层级编号(必填) */
- private int id;
- /** 网格触发价格(必填) */
- private BigDecimal gridPrice;
- /** 是否有多仓挂单,默认 false */
- private boolean hasLongOrder = false;
- /** 是否有空仓挂单,默认 false */
- private boolean hasShortOrder = false;
- /** 多仓挂单参数 */
- private TraderParam longTraderParam;
- /** 空仓挂单参数 */
- private TraderParam shortTraderParam;
- /** 上一个网格编号,默认 null(无上一级) */
- private Integer upId;
- /** 下一个网格编号,默认 null(无下一级) */
- private Integer downId;
- /** 多仓挂单订单 ID */
- private String longOrderId;
- /** 空仓挂单订单 ID */
- private String shortOrderId;
- /** 多仓止盈订单 ID */
- private String longTakeProfitOrderId;
- /** 空仓止盈订单 ID */
- private String shortTakeProfitOrderId;
- /** 多仓止损订单 ID */
- private String longStopLossOrderId;
- /** 空仓止损订单 ID */
- private String shortStopLossOrderId;
-
- /** 设置网格层级编号 */
- public Builder id(int id) { this.id = id; return this; }
- /** 设置网格触发价格 */
- public Builder gridPrice(BigDecimal gridPrice) { this.gridPrice = gridPrice; return this; }
- /** 设置是否存在多仓挂单 */
- public Builder hasLongOrder(boolean hasLongOrder) { this.hasLongOrder = hasLongOrder; return this; }
- /** 设置是否存在空仓挂单 */
- public Builder hasShortOrder(boolean hasShortOrder) { this.hasShortOrder = hasShortOrder; return this; }
- /** 设置多仓挂单参数 */
- public Builder longTraderParam(TraderParam longTraderParam) { this.longTraderParam = longTraderParam; return this; }
- /** 设置空仓挂单参数 */
- public Builder shortTraderParam(TraderParam shortTraderParam) { this.shortTraderParam = shortTraderParam; return this; }
- /** 设置上一个网格编号 */
- public Builder upId(Integer upId) { this.upId = upId; return this; }
- /** 设置下一个网格编号 */
- public Builder downId(Integer downId) { this.downId = downId; return this; }
- /** 设置多仓挂单订单 ID */
- public Builder longOrderId(String longOrderId) { this.longOrderId = longOrderId; return this; }
- /** 设置空仓挂单订单 ID */
- public Builder shortOrderId(String shortOrderId) { this.shortOrderId = shortOrderId; return this; }
- /** 设置多仓止盈订单 ID */
- public Builder longTakeProfitOrderId(String longTakeProfitOrderId) { this.longTakeProfitOrderId = longTakeProfitOrderId; return this; }
- /** 设置空仓止盈订单 ID */
- public Builder shortTakeProfitOrderId(String shortTakeProfitOrderId) { this.shortTakeProfitOrderId = shortTakeProfitOrderId; return this; }
- /** 设置多仓止损订单 ID */
- public Builder longStopLossOrderId(String longStopLossOrderId) { this.longStopLossOrderId = longStopLossOrderId; return this; }
- /** 设置空仓止损订单 ID */
- public Builder shortStopLossOrderId(String shortStopLossOrderId) { this.shortStopLossOrderId = shortStopLossOrderId; return this; }
-
- public GridElement build() {
- return new GridElement(this);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/IOkxStrategy.java b/src/main/java/com/xcong/excoin/modules/okxApi/IOkxStrategy.java
new file mode 100644
index 0000000..48fa840
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/IOkxStrategy.java
@@ -0,0 +1,78 @@
+package com.xcong.excoin.modules.okxApi;
+
+import java.math.BigDecimal;
+
+/**
+ * OKX 策略通用接口 — WS 频道处理器的回调契约。
+ *
+ * <p>定义所有 OKX 交易策略必须实现的核心回调方法,使得不同的策略实现
+ * 可以无缝接入相同的 WebSocket 基础设施。
+ *
+ * <h3>实现类</h3>
+ * <ul>
+ * <li>{@link OkxProfitRecycleStrategy} — 盈利回收循环策略</li>
+ * </ul>
+ *
+ * <h3>WS 回调映射</h3>
+ * <table>
+ * <tr><th>WS频道</th><th>回调方法</th><th>说明</th></tr>
+ * <tr><td>mark-price</td><td>onKline / setMarkPrice</td><td>价格驱动 + PnL计算</td></tr>
+ * <tr><td>positions</td><td>onPositionUpdate</td><td>仓位变更通知</td></tr>
+ * <tr><td>orders</td><td>onAutoOrder</td><td>条件单状态变更</td></tr>
+ * </table>
+ *
+ * @author Administrator
+ */
+public interface IOkxStrategy {
+
+ /**
+ * K线/价格数据回调(公开频道 mark-price 推送)。
+ *
+ * @param price 最新价格(标记价或最新价)
+ */
+ void onKline(BigDecimal price);
+
+ /**
+ * 标记价格设置(用于 PnL 计算)。
+ *
+ * @param markPrice 标记价格
+ */
+ void setMarkPrice(BigDecimal markPrice);
+
+ /**
+ * 仓位更新回调(私有频道 positions 推送)。
+ *
+ * @param contract 合约名称
+ * @param direction 交易方向(LONG / SHORT)
+ * @param size 持仓张数(绝对值)
+ * @param entryPrice 开仓均价
+ */
+ void onPositionUpdate(String contract, Direction direction,
+ BigDecimal size, BigDecimal entryPrice);
+
+ /**
+ * 自动订单状态变更回调(私有频道 orders 推送)。
+ *
+ * @param orderId 条件单算法 ID(algoId)
+ * @param status 订单状态(如 "finished")
+ * @param reason 状态原因(如 "filled")
+ * @param orderType 订单类型(如 "entry-long", "plan-close-long-position")
+ * @param tradeId 成交 ID
+ */
+ void onAutoOrder(String orderId, String status, String reason,
+ String orderType, String tradeId);
+
+ /**
+ * 策略是否处于活跃状态(非 STOPPED/WAITING_KLINE)。
+ *
+ * @return true 表示策略正在运行
+ */
+ boolean isStrategyActive();
+
+ /**
+ * 保存 WS 客户端引用(用于判断订阅状态)。
+ *
+ * @param wsClient OKX WebSocket 客户端
+ */
+ void setWsClient(OkxKlineWebSocketClient wsClient);
+}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxConfig.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxConfig.java
index 4b6e74b..0e790b0 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxConfig.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/OkxConfig.java
@@ -1,47 +1,22 @@
package com.xcong.excoin.modules.okxApi;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
/**
- * OKX 交易模块全局配置,策略的唯一参数入口。
+ * OKX 交易模块全局配置 — 盈利回收策略的参数入口。
*
- * <h3>定位</h3>
- * 通过 Builder 模式将所有运行参数集中管理,避免策略参数散落在多个类中。
- * 运行时动态参数(step、gridElements、baseLongTraderParam、baseShortTraderParam)
- * 由 OkxGridTradeService 在策略执行过程中写入。
- *
- * <h3>与 GateConfig 的主要差异</h3>
- * <ul>
- * <li>新增 {@code passphrase} 字段 — OKX API 认证需要 passphrase</li>
- * <li>REST 基础路径:生产环境 {@code https://www.okx.com},测试环境 {@code https://www.okx.cab}</li>
- * <li>WebSocket 分为 public/private 两个地址</li>
- * <li>合约格式:{@code ETH-USDT-SWAP}(OKX 用短横线分隔)</li>
- * <li>持仓模式默认值:{@code long_short_mode}(OKX)替代 {@code dual}(Gate)</li>
- * <li>数据模型(GridElement、TraderParam)复用 gateApi 包中的定义</li>
- * </ul>
+ * <p>通过 Builder 模式将所有运行参数集中管理,避免策略参数散落在多个类中。
*
* <h3>参数分类</h3>
* <table>
* <tr><th>类别</th><th>参数</th><th>用途</th></tr>
* <tr><td>认证</td><td>apiKey, apiSecret, passphrase</td><td>REST/WS 签名认证</td></tr>
- * <tr><td>交易标的</td><td>contract, leverage, quantity, contractMultiplier</td><td>合约、杠杆、张数、乘数</td></tr>
- * <tr><td>持仓</td><td>marginMode, positionMode</td><td>全仓/逐仓、单向/双向</td></tr>
- * <tr><td>网格策略</td><td>gridRate, gridQueueSize, priceScale</td><td>间距比例、队列容量、价格精度(交易所tick)</td></tr>
- * <tr><td>止盈止损</td><td>overallTp, maxLoss</td><td>整体止盈/亏损阈值(USDT),触发后策略停止</td></tr>
- * <tr><td>风控</td><td>marginRatioLimit, reopenMaxRetries</td><td>保证金占比上限、补仓重试次数</td></tr>
- * <tr><td>盈亏计算</td><td>contractMultiplier, unrealizedPnlPriceMode</td><td>合约乘数、未实现盈亏计价模式</td></tr>
- * <tr><td>运行时</td><td>step, gridElements, baseLongTraderParam, baseShortTraderParam</td><td>由策略动态填充</td></tr>
+ * <tr><td>交易标的</td><td>contract, leverage, baseQuantity</td><td>合约、杠杆、张数</td></tr>
+ * <tr><td>持仓</td><td>marginMode, positionMode</td><td>全仓/逐仓、双向持仓</td></tr>
+ * <tr><td>风控</td><td>maxLoss, maxPositionSize</td><td>最大亏损阈值、单边持仓上限</td></tr>
+ * <tr><td>盈亏计算</td><td>contractMultiplier, priceScale, unrealizedPnlPriceMode</td><td>合约乘数、价格精度、计价模式</td></tr>
+ * <tr><td>策略核心</td><td>profitTriggerRatio, reinvestRatio</td><td>盈利触发比例、再投资比例</td></tr>
* </table>
- *
- * <h3>gridElements 生命周期</h3>
- * <ol>
- * <li>项目启动时初始化为空 ArrayList</li>
- * <li>队列生成逻辑中通过 {@code updateGridElements()} 填充,同时触发
- * {@link GridElement#rebuildIndex(List)} 建立全局 O(1) 索引</li>
- * <li>每次挂单/止盈操作后通过 {@link GridElement#refreshIndices()} 更新索引</li>
- * </ol>
*
* @author Administrator
*/
@@ -49,82 +24,55 @@
/**
* 未实现盈亏(unrealizedPnl)计价模式。
- *
- * <ul>
- * <li>{@link #LAST_PRICE} — 按最新成交价计算,变动快、更贴近实际平仓价</li>
- * <li>{@link #MARK_PRICE} — 按标记价格计算,变动平稳、过滤市场噪音</li>
- * </ul>
*/
public enum PnLPriceMode {
/** 按最新成交价计算未实现盈亏 */
LAST_PRICE,
- /** 按标记价格计算未实现盈亏,需通过外部注入 */
+ /** 按标记价格计算未实现盈亏 */
MARK_PRICE
}
// ==================== 认证信息 ====================
- /** OKX API v5 密钥 */
private final String apiKey;
- /** OKX API v5 签名密钥 */
private final String apiSecret;
- /** OKX API v5 口令密码(passphrase),创建 API Key 时设置 */
private final String passphrase;
// ==================== 交易标的 ====================
- /** 合约名称(如 ETH-USDT-SWAP,注意 OKX 使用短横线分隔) */
private final String contract;
- /** 杠杆倍数 */
private final String leverage;
- /** 保证金模式(cross / isolated) */
private final String marginMode;
- /** 持仓模式(long_short_mode=双向 / net_mode=单向) */
private final String positionMode;
// ==================== 策略参数 ====================
- /** 网格间距比例(如 0.0035 表示 0.35%) */
- private final BigDecimal gridRate;
- /** 整体止盈阈值(USDT) */
- private final BigDecimal overallTp;
- /** 最大亏损阈值(USDT) */
- private final BigDecimal maxLoss;
- /** 下单数量(合约张数) */
- private final String quantity;
/** 基底开仓张数(初始化时多空各开的张数,如 "10") */
private final String baseQuantity;
- /** 预期收益(USDT),unrealisedPnl + available > 初始本金 + 此值时重置 */
- private final BigDecimal expectedProfit;
+ /** 最大亏损阈值(USDT),触发后策略停止 */
+ private final BigDecimal maxLoss;
/** 是否为生产环境 */
private final boolean isProduction;
- /** 补仓最大重试次数 */
- private final int reopenMaxRetries;
- /** 网格队列容量 */
- private final int gridQueueSize;
- /** 保证金占初始本金比例上限 */
- private final BigDecimal marginRatioLimit;
- /** 合约乘数(单张合约代表的基础资产数量,如 ETH-USDT-SWAP=0.01) */
+ /** 合约乘数(单张合约代表的基础资产数量,如 BTC-USDT-SWAP=0.01) */
private final BigDecimal contractMultiplier;
- /** 价格精度(交易所价格的最小小数位数,如 1 表示 0.1 精度,2 表示 0.01 精度) */
+ /** 价格精度(交易所价格的小数位数) */
private final int priceScale;
- /** 未实现盈亏计价模式:最新价 / 标记价格 */
+ /** 未实现盈亏计价模式 */
private final PnLPriceMode unrealizedPnlPriceMode;
- /** 最大持仓张数(单方向),0=不限制 */
- private final int maxPositionSize;
- /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,0=禁用 */
- private final int restartGridSpan;
- // ==================== 运行时参数 ====================
+ // ==================== 盈利回收策略参数 ====================
- /** 网格绝对步长(shortBaseEntryPrice × gridRate),运行时由队列生成逻辑设置 */
- private BigDecimal step;
- /** 网格元素列表,由队列初始化时同步填充,包含完整的多空仓挂单状态 */
- private volatile List<GridElement> gridElements = new ArrayList<>();
- /** 基座多头挂单参数,在基座成交后由队列生成逻辑填充 */
- private TraderParam baseLongTraderParam;
- /** 基座空头挂单参数,在基座成交后由队列生成逻辑填充 */
- private TraderParam baseShortTraderParam;
+ /** 盈利触发比例(默认0.5=50%),ROI=未实现盈亏/保证金达到此值时触发平仓 */
+ private final BigDecimal profitTriggerRatio;
+ /** 再投资比例(默认0.5=50%),收益A中用于开反方向仓位的比例 */
+ private final BigDecimal reinvestRatio;
+
+ // ==================== 风控参数 ====================
+
+ /** 反向仓位倍数上限(默认10),反方向最大持仓 = baseQuantity × 此值 */
+ private final int maxPositionMultiplier;
+ /** 权益重置比例(默认0.05=5%),账户权益 ≥ 初始权益 × (1+此值) 时全平重置 */
+ private final BigDecimal equityRestartRatio;
// ==================== 构造器 ====================
@@ -136,56 +84,33 @@
this.leverage = builder.leverage;
this.marginMode = builder.marginMode;
this.positionMode = builder.positionMode;
- this.gridRate = builder.gridRate;
- this.overallTp = builder.overallTp;
- this.maxLoss = builder.maxLoss;
- this.quantity = builder.quantity;
this.baseQuantity = builder.baseQuantity;
- this.expectedProfit = builder.expectedProfit;
+ this.maxLoss = builder.maxLoss;
this.isProduction = builder.isProduction;
- this.reopenMaxRetries = builder.reopenMaxRetries;
- this.gridQueueSize = builder.gridQueueSize;
- this.marginRatioLimit = builder.marginRatioLimit;
this.contractMultiplier = builder.contractMultiplier;
this.priceScale = builder.priceScale;
this.unrealizedPnlPriceMode = builder.unrealizedPnlPriceMode;
- this.maxPositionSize = builder.maxPositionSize;
- this.restartGridSpan = builder.restartGridSpan;
+ this.profitTriggerRatio = builder.profitTriggerRatio;
+ this.reinvestRatio = builder.reinvestRatio;
+ this.maxPositionMultiplier = builder.maxPositionMultiplier;
+ this.equityRestartRatio = builder.equityRestartRatio;
}
// ==================== REST/WS 地址 ====================
- /**
- * 返回 REST API 基础路径。
- * <p>实盘和模拟盘使用相同的 REST 地址,通过 {@code x-simulated-trading: 1} 请求头区分。
- * <ul>
- * <li>生产网/测试网: {@code https://openapi.okx.com}</li>
- * </ul>
- */
+ /** @return REST API 基础路径 */
public String getRestBasePath() {
return "https://openapi.okx.com";
}
- /**
- * 根据环境返回 WebSocket 公开频道地址。
- * <ul>
- * <li>测试网: {@code wss://wspap.okx.com:8443/ws/v5/public}</li>
- * <li>生产网: {@code wss://ws.okx.com:8443/ws/v5/public}</li>
- * </ul>
- */
+ /** @return WebSocket 公开频道地址 */
public String getWsPublicUrl() {
return isProduction
? "wss://ws.okx.com:8443/ws/v5/public"
: "wss://wspap.okx.com:8443/ws/v5/public";
}
- /**
- * 根据环境返回 WebSocket 私有频道地址。
- * <ul>
- * <li>测试网: {@code wss://wspap.okx.com:8443/ws/v5/private}</li>
- * <li>生产网: {@code wss://ws.okx.com:8443/ws/v5/private}</li>
- * </ul>
- */
+ /** @return WebSocket 私有频道地址 */
public String getWsPrivateUrl() {
return isProduction
? "wss://ws.okx.com:8443/ws/v5/private"
@@ -194,96 +119,45 @@
// ==================== 认证信息 ====================
- /** @return OKX API v5 密钥 */
public String getApiKey() { return apiKey; }
- /** @return OKX API v5 签名密钥,用于 HMAC-SHA256 签名 */
public String getApiSecret() { return apiSecret; }
- /** @return OKX API v5 口令密码(passphrase) */
public String getPassphrase() { return passphrase; }
// ==================== 交易标的 ====================
- /** @return 合约名称(如 ETH-USDT-SWAP,OKX 使用短横线分隔) */
public String getContract() { return contract; }
- /** @return 杠杆倍数(如 "100" 表示 100x) */
public String getLeverage() { return leverage; }
// ==================== 持仓配置 ====================
- /** @return 保证金模式(cross=全仓 / isolated=逐仓) */
public String getMarginMode() { return marginMode; }
- /** @return 持仓模式(long_short_mode=双向 / net_mode=单向) */
public String getPositionMode() { return positionMode; }
// ==================== 策略参数 ====================
- /** @return 网格间距比例(如 0.0015 表示 0.15%),用于生成价格队列和计算止盈价 */
- public BigDecimal getGridRate() { return gridRate; }
- /** @return 整体止盈阈值(USDT),累计已实现盈亏 ≥ 此值时策略停止 */
- public BigDecimal getOverallTp() { return overallTp; }
- /** @return 最大亏损阈值(USDT),累计已实现盈亏 ≤ -此值时策略停止 */
- public BigDecimal getMaxLoss() { return maxLoss; }
- /** @return 每次下单的张数(如 "1" 表示 1 张合约) */
- public String getQuantity() { return quantity; }
- /** @return 基底开仓张数(初始化时多空各开的张数,如 "10") */
public String getBaseQuantity() { return baseQuantity; }
- /** @return 预期收益(USDT),unrealisedPnl + available > 初始本金 + 此值时重置 */
- public BigDecimal getExpectedProfit() { return expectedProfit; }
- /** @return 网格价格队列的容量上限(超出时截断尾部) */
- public int getGridQueueSize() { return gridQueueSize; }
-
- // ==================== 风险控制 ====================
-
- /** @return 保证金占初始本金比例上限(默认 0.2 即 20%),超限跳过开仓 */
- public BigDecimal getMarginRatioLimit() { return marginRatioLimit; }
- /** @return 补仓最大重试次数(当前版本未使用) */
- public int getReopenMaxRetries() { return reopenMaxRetries; }
+ public BigDecimal getMaxLoss() { return maxLoss; }
// ==================== 盈亏计算 ====================
- /** @return 合约乘数(单张合约代表的基础资产数量,如 ETH-USDT-SWAP=0.01) */
public BigDecimal getContractMultiplier() { return contractMultiplier; }
- /** @return 价格精度(交易所价格的小数位数,如 1=0.1精度,2=0.01精度),用于价格四舍五入 */
public int getPriceScale() { return priceScale; }
- /** @return 未实现盈亏计价模式:LAST_PRICE(最新成交价)/ MARK_PRICE(标记价格) */
public PnLPriceMode getUnrealizedPnlPriceMode() { return unrealizedPnlPriceMode; }
- /** @return 最大持仓张数(单方向),0=不限制 */
- public int getMaxPositionSize() { return maxPositionSize; }
- /** @return 策略重启跨度阈值:多空两边止盈触发数均达到此值后触发重启,0=禁用 */
- public int getRestartGridSpan() { return restartGridSpan; }
- // ==================== 运行时参数 ====================
+ // ==================== 盈利回收策略参数 ====================
- /** @return 网格绝对步长(shortBaseEntryPrice × gridRate),运行时设置 */
- public BigDecimal getStep() { return step; }
- /** 设置网格绝对步长(由队列生成逻辑在运行时计算并注入) */
- public void setStep(BigDecimal step) { this.step = step; }
+ public BigDecimal getProfitTriggerRatio() { return profitTriggerRatio; }
+ public BigDecimal getReinvestRatio() { return reinvestRatio; }
- // ==================== 网格元素列表 ====================
+ // ==================== 风控参数 ====================
- /** @return 网格元素列表(队列初始化后填充),线程不安全,仅由策略线程单线程写入 */
- public List<GridElement> getGridElements() { return gridElements; }
- /** 设置网格元素列表(由队列生成逻辑写入),同时重建全局 ID 索引 */
- public void setGridElements(List<GridElement> gridElements) {
- this.gridElements = gridElements;
- GridElement.rebuildIndex(gridElements);
- }
-
- // ==================== 基座挂单参数 ====================
-
- /** @return 基座多头挂单参数 */
- public TraderParam getBaseLongTraderParam() { return baseLongTraderParam; }
- /** 设置基座多头挂单参数(由队列生成逻辑在基座成交后填充) */
- public void setBaseLongTraderParam(TraderParam baseLongTraderParam) { this.baseLongTraderParam = baseLongTraderParam; }
-
- /** @return 基座空头挂单参数 */
- public TraderParam getBaseShortTraderParam() { return baseShortTraderParam; }
- /** 设置基座空头挂单参数(由队列生成逻辑在基座成交后填充) */
- public void setBaseShortTraderParam(TraderParam baseShortTraderParam) { this.baseShortTraderParam = baseShortTraderParam; }
+ /** @return 反向仓位倍数上限,反方向最大持仓 = baseQuantity × 此值 */
+ public int getMaxPositionMultiplier() { return maxPositionMultiplier; }
+ /** @return 权益重置比例,账户权益 ≥ 初始权益 × (1+此值) 时全平重置 */
+ public BigDecimal getEquityRestartRatio() { return equityRestartRatio; }
// ==================== 环境 ====================
- /** @return 是否为生产环境(true=实盘生产网 / false=模拟盘测试网) */
public boolean isProduction() { return isProduction; }
// ==================== Builder ====================
@@ -293,105 +167,52 @@
}
/**
- * OkxConfig 的流式构造器,提供合理的默认值。
+ * OkxConfig 的流式构造器。
*
* <h3>必填项</h3>
- * {@code apiKey}、{@code apiSecret}、{@code passphrase} 必须设置,其余参数均有默认值。
+ * {@code apiKey}、{@code apiSecret}、{@code passphrase} 必须设置。
*
* <h3>默认值</h3>
- * ETH-USDT-SWAP / 10x / cross(全仓) / long_short_mode(双向) / gridRate=0.35% /
- * overallTp=0.5 / maxLoss=7.5 / quantity=1 / isProduction=false
+ * BTC-USDT-SWAP / 100x / cross / long_short_mode / baseQuantity=10 /
+ * maxLoss=15 / profitTriggerRatio=0.5 / reinvestRatio=0.5 /
+ * maxPositionMultiplier=10 / equityRestartRatio=0.05
*/
public static class Builder {
- /** OKX API v5 密钥(必填) */
private String apiKey;
- /** OKX API v5 签名密钥(必填) */
private String apiSecret;
- /** OKX API v5 口令密码(必填) */
private String passphrase;
- /** 合约名称,默认 ETH-USDT-SWAP */
- private String contract = "ETH-USDT-SWAP";
- /** 杠杆倍数,默认 "10" */
- private String leverage = "10";
- /** 保证金模式,默认 "cross"(全仓) */
+ private String contract = "BTC-USDT-SWAP";
+ private String leverage = "100";
private String marginMode = "cross";
- /** 持仓模式,默认 "long_short_mode"(双向) */
private String positionMode = "long_short_mode";
- /** 网格间距比例,默认 0.0035(0.35%) */
- private BigDecimal gridRate = new BigDecimal("0.0035");
- /** 整体止盈阈值(USDT),默认 0.5 */
- private BigDecimal overallTp = new BigDecimal("0.5");
- /** 最大亏损阈值(USDT),默认 7.5 */
- private BigDecimal maxLoss = new BigDecimal("7.5");
- /** 每次下单张数,默认 "1" */
- private String quantity = "1";
- /** 基底开仓张数,默认 "10"(初始化时多空各开10张) */
private String baseQuantity = "10";
- /** 预期收益(USDT),默认 0.5 */
- private BigDecimal expectedProfit = new BigDecimal("0.5");
- /** 是否为生产环境,默认 false(测试网) */
+ private BigDecimal maxLoss = new BigDecimal("15");
private boolean isProduction = false;
- /** 补仓最大重试次数,默认 3 */
- private int reopenMaxRetries = 3;
- /** 网格队列容量,默认 300 */
- private int gridQueueSize = 300;
- /** 保证金占初始本金比例上限,默认 0.2(20%) */
- private BigDecimal marginRatioLimit = new BigDecimal("0.2");
- /** 合约乘数,默认 0.01(ETH-USDT-SWAP=0.01) */
private BigDecimal contractMultiplier = new BigDecimal("0.01");
- /** 价格精度(交易所价格的小数位数),默认 2(0.01 精度,适配 ETH) */
private int priceScale = 2;
- /** 未实现盈亏计价模式,默认 LAST_PRICE(最新成交价) */
private PnLPriceMode unrealizedPnlPriceMode = PnLPriceMode.LAST_PRICE;
- /** 最大持仓张数(单方向),默认 0=不限制 */
- private int maxPositionSize = 0;
- /** 策略重启跨度阈值:多空两边止盈触发数量均达到此值后触发重启,默认 0=禁用 */
- private int restartGridSpan = 0;
+ private BigDecimal profitTriggerRatio = new BigDecimal("0.5");
+ private BigDecimal reinvestRatio = new BigDecimal("0.5");
+ private int maxPositionMultiplier = 10;
+ private BigDecimal equityRestartRatio = new BigDecimal("0.05");
- /** 设置 API Key */
- public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; }
- /** 设置 API Secret */
- public Builder apiSecret(String apiSecret) { this.apiSecret = apiSecret; return this; }
- /** 设置 API Passphrase */
- public Builder passphrase(String passphrase) { this.passphrase = passphrase; return this; }
- /** 设置合约名称(如 ETH-USDT-SWAP) */
- public Builder contract(String contract) { this.contract = contract; return this; }
- /** 设置杠杆倍数 */
- public Builder leverage(String leverage) { this.leverage = leverage; return this; }
- /** 设置保证金模式(cross=全仓 / isolated=逐仓) */
- public Builder marginMode(String marginMode) { this.marginMode = marginMode; return this; }
- /** 设置持仓模式(long_short_mode=双向 / net_mode=单向) */
- public Builder positionMode(String positionMode) { this.positionMode = positionMode; return this; }
- /** 设置网格间距比例 */
- public Builder gridRate(BigDecimal gridRate) { this.gridRate = gridRate; return this; }
- /** 设置整体止盈阈值(USDT) */
- public Builder overallTp(BigDecimal overallTp) { this.overallTp = overallTp; return this; }
- /** 设置最大亏损阈值(USDT) */
- public Builder maxLoss(BigDecimal maxLoss) { this.maxLoss = maxLoss; return this; }
- /** 设置每次下单张数 */
- public Builder quantity(String quantity) { this.quantity = quantity; return this; }
- /** 设置基底开仓张数 */
- public Builder baseQuantity(String baseQuantity) { this.baseQuantity = baseQuantity; return this; }
- /** 设置预期收益(USDT) */
- public Builder expectedProfit(BigDecimal expectedProfit) { this.expectedProfit = expectedProfit; return this; }
- /** 设置环境(true=实盘生产网 / false=模拟盘测试网) */
- public Builder isProduction(boolean isProduction) { this.isProduction = isProduction; return this; }
- /** 设置补仓最大重试次数 */
- public Builder reopenMaxRetries(int reopenMaxRetries) { this.reopenMaxRetries = reopenMaxRetries; return this; }
- /** 设置合约乘数(单张合约代表的基础资产数量) */
- public Builder contractMultiplier(BigDecimal contractMultiplier) { this.contractMultiplier = contractMultiplier; return this; }
- /** 设置价格精度(交易所价格的小数位数,如 1=0.1精度,2=0.01精度) */
- public Builder priceScale(int priceScale) { this.priceScale = priceScale; return this; }
- /** 设置保证金占初始本金比例上限 */
- public Builder marginRatioLimit(BigDecimal marginRatioLimit) { this.marginRatioLimit = marginRatioLimit; return this; }
- /** 设置网格队列容量 */
- public Builder gridQueueSize(int gridQueueSize) { this.gridQueueSize = gridQueueSize; return this; }
- /** 设置未实现盈亏计价模式 */
- public Builder unrealizedPnlPriceMode(PnLPriceMode mode) { this.unrealizedPnlPriceMode = mode; return this; }
- /** 设置最大持仓张数(单方向),0=不限制 */
- public Builder maxPositionSize(int maxPositionSize) { this.maxPositionSize = maxPositionSize; return this; }
- /** 设置策略重启跨度阈值:多空两边止盈触发数均达到此值后触发重启,0=禁用 */
- public Builder restartGridSpan(int restartGridSpan) { this.restartGridSpan = restartGridSpan; return this; }
+ public Builder apiKey(String v) { this.apiKey = v; return this; }
+ public Builder apiSecret(String v) { this.apiSecret = v; return this; }
+ public Builder passphrase(String v) { this.passphrase = v; return this; }
+ public Builder contract(String v) { this.contract = v; return this; }
+ public Builder leverage(String v) { this.leverage = v; return this; }
+ public Builder marginMode(String v) { this.marginMode = v; return this; }
+ public Builder positionMode(String v) { this.positionMode = v; return this; }
+ public Builder baseQuantity(String v) { this.baseQuantity = v; return this; }
+ public Builder maxLoss(BigDecimal v) { this.maxLoss = v; return this; }
+ public Builder isProduction(boolean v) { this.isProduction = v; return this; }
+ public Builder contractMultiplier(BigDecimal v) { this.contractMultiplier = v; return this; }
+ public Builder priceScale(int v) { this.priceScale = v; return this; }
+ public Builder unrealizedPnlPriceMode(PnLPriceMode v) { this.unrealizedPnlPriceMode = v; return this; }
+ public Builder profitTriggerRatio(BigDecimal v) { this.profitTriggerRatio = v; return this; }
+ public Builder reinvestRatio(BigDecimal v) { this.reinvestRatio = v; return this; }
+ public Builder maxPositionMultiplier(int v) { this.maxPositionMultiplier = v; return this; }
+ public Builder equityRestartRatio(BigDecimal v) { this.equityRestartRatio = v; return this; }
public OkxConfig build() {
return new OkxConfig(this);
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
deleted file mode 100644
index c537429..0000000
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxGridTradeService.java
+++ /dev/null
@@ -1,1219 +0,0 @@
-package com.xcong.excoin.modules.okxApi;
-
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
-import lombok.extern.slf4j.Slf4j;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-
-/**
- * OKX 网格交易策略引擎 — 多空对冲网格。
- *
- * <h3>策略原理</h3>
- * 以空仓基底入场价(shortBaseEntryPrice)为价格基准,向上/向下各生成一个价格网格队列。
- * 价格触发网格层级时挂条件单,成交后自动挂止盈单。每笔止盈盈利 = step - minTick。
- *
- * <h3>与 GateGridTradeService 的关系</h3>
- * 策略逻辑完全一致,仅 API 层(REST/WS/签名)替换为 OKX 实现。
- * GridElement 和 TraderParam 从 gateApi 包复用(交易所无关的数据模型)。
- *
- * <h3>完整生命周期</h3>
- * <pre>
- * init() → startGrid() → WAITING_KLINE
- * ↓
- * onKline(首根K线) → OPENING → 异步市价双开基底(开多+开空)
- * ↓
- * onPositionUpdate() → 基底成交 → baseLongOpened && baseShortOpened
- * ↓
- * tryGenerateQueues()
- * ├── generateShortQueue() ← 空仓价格队列(降序,从 shortBaseEntryPrice-step 向下)
- * ├── generateLongQueue() ← 多仓价格队列(升序,从 shortBaseEntryPrice+step 向上)
- * ├── updateGridElements() ← 构建 GridElement 列表 + TraderParam + 全局索引
- * ├── 挂基座止盈单(ID=0 的 long/short takeProfit)
- * └── 挂初始条件单(up=-1 多单, down=1 空单)
- * ↓
- * state = ACTIVE
- * ↓
- * onKline() → processLongGrid() + processShortGrid()
- * ├── 匹配队列元素 → 队列补偿 → 保证金检查
- * ├── 首元素方向:挂条件开仓单 → 订单ID + GridElement状态同步
- * └── 反向守卫:在 downGrid 位置挂对向单
- * ↓
- * onAutoOrder() ← orders-algo WS 推送
- * ├── 匹配止盈单ID → 清空止盈状态(已成交)
- * └── 匹配挂单ID → 挂止盈条件单 → 止盈ID + GridElement状态同步
- * </pre>
- *
- * @author Administrator
- */
-@Slf4j
-public class OkxGridTradeService {
-
- public enum StrategyState {
- WAITING_KLINE, OPENING, ACTIVE, STOPPED
- }
-
- /** 止盈条件单 order_type:平多仓 */
- private static final String ORDER_TYPE_CLOSE_LONG = "plan-close-long-position";
- /** 止盈条件单 order_type:平空仓 */
- private static final String ORDER_TYPE_CLOSE_SHORT = "plan-close-short-position";
-
- private final OkxConfig config;
- private final OkxTradeExecutor executor;
-
- private volatile StrategyState state = StrategyState.WAITING_KLINE;
-
- /** 空仓价格队列,降序排列(大→小),容量 gridQueueSize */
- private final List<BigDecimal> shortPriceQueue = Collections.synchronizedList(new ArrayList<>());
- /** 多仓价格队列,升序排列(小→大),容量 gridQueueSize */
- private final List<BigDecimal> longPriceQueue = Collections.synchronizedList(new ArrayList<>());
- private final List<BigDecimal> totalLongPriceQueue = Collections.synchronizedList(new ArrayList<>());
- private final List<BigDecimal> totalShortPriceQueue = Collections.synchronizedList(new ArrayList<>());
-
- /** 当前多仓条件单映射 */
- private final Map<String, BigDecimal> currentLongOrderIds = Collections.synchronizedMap(new LinkedHashMap<>());
- /** 当前空仓条件单映射 */
- private final Map<String, BigDecimal> currentShortOrderIds = Collections.synchronizedMap(new LinkedHashMap<>());
-
- /** 基底空头入场价 */
- private BigDecimal shortBaseEntryPrice;
- /** 基底多头入场价 */
- private BigDecimal longBaseEntryPrice;
- /** 基底多头是否已开 */
- private volatile boolean baseLongOpened = false;
- /** 基底空头是否已开 */
- private volatile boolean baseShortOpened = false;
-
- /** 空头是否活跃 */
- private volatile boolean shortActive = false;
- /** 多头是否活跃 */
- private volatile boolean longActive = false;
-
- /** 多头累计止损张数 */
- private volatile int accumulatedLongLossCount = 0;
- /** 空头累计止损张数 */
- private volatile int accumulatedShortLossCount = 0;
-
- private volatile BigDecimal lastKlinePrice;
- private volatile BigDecimal markPrice = BigDecimal.ZERO;
- private volatile BigDecimal cumulativePnl = BigDecimal.ZERO;
- private volatile BigDecimal unrealizedPnl = BigDecimal.ZERO;
- private volatile BigDecimal longEntryPrice = BigDecimal.ZERO;
- private volatile BigDecimal shortEntryPrice = BigDecimal.ZERO;
- private volatile BigDecimal longPositionSize = BigDecimal.ZERO;
- private volatile BigDecimal shortPositionSize = BigDecimal.ZERO;
- private volatile BigDecimal initialPrincipal = BigDecimal.ZERO;
- private volatile OkxKlineWebSocketClient wsClient;
-
- public OkxGridTradeService(OkxConfig config) {
- this.config = config;
- this.executor = new OkxTradeExecutor(config);
- }
-
- // ---- 仓位模式(替代 Gate 的 Position.ModeEnum)----
-
- /** OKX 持仓方向枚举 */
- public enum OkxPosMode { LONG, SHORT }
-
- /** 持仓查询结果 */
- static class OkxPositionInfo {
- String size;
- String entryPrice;
- }
-
- // ---- 初始化 ----
-
- /**
- * 初始化策略环境:获取账户信息 → 切双向持仓 → 清旧条件单 → 平仓 → 设杠杆。
- */
- public void init() {
- try {
- JSONObject account = executorGet("/api/v5/account/balance");
- JSONArray dataArr = account.getJSONArray("data");
- if (dataArr != null && !dataArr.isEmpty()) {
- JSONArray details = dataArr.getJSONObject(0).getJSONArray("details");
- if (details != null) {
- for (int i = 0; i < details.size(); i++) {
- JSONObject currency = details.getJSONObject(i);
- if ("USDT".equals(currency.getString("ccy"))) {
- this.initialPrincipal = currency.getBigDecimal("eq");
- log.info("[OKX] 初始本金(USDT余额): {}", initialPrincipal);
- break;
- }
- }
- }
- }
-
- // 设置双向持仓模式
- JSONObject posModeBody = new JSONObject();
- posModeBody.put("posMode", config.getPositionMode());
- executorPost("/api/v5/account/set-position-mode", posModeBody.toJSONString());
- log.info("[OKX] 持仓模式已设为: {}", config.getPositionMode());
-
- // 设置杠杆
- JSONObject levBody = new JSONObject();
- levBody.put("instId", config.getContract());
- levBody.put("lever", config.getLeverage());
- levBody.put("mgnMode", config.getMarginMode());
- executorPost("/api/v5/account/set-leverage", levBody.toJSONString());
- log.info("[OKX] 杠杆已设为: {}x {}", config.getLeverage(), config.getMarginMode());
-
- executor.cancelAllPriceTriggeredOrders();
- log.info("[OKX] 旧条件单已清除");
- closeExistingPositions();
-
- log.info("[OKX] 初始化完成");
- } catch (Exception e) {
- log.error("[OKX] 初始化失败", e);
- }
- }
-
- /**
- * 平掉当前合约的所有已有仓位。
- */
- private void closeExistingPositions() {
- try {
- JSONObject resp = executorGet("/api/v5/account/positions?instType=SWAP");
- JSONArray data = resp.getJSONArray("data");
- if (data == null || data.isEmpty()) {
- log.info("[OKX] 无已有仓位");
- return;
- }
- for (int i = 0; i < data.size(); i++) {
- JSONObject pos = data.getJSONObject(i);
- String instId = pos.getString("instId");
- if (instId == null || !instId.equals(config.getContract())) {
- continue;
- }
- String posVal = pos.getString("pos");
- if (posVal == null || "0".equals(posVal)) {
- continue;
- }
- String posSide = pos.getString("posSide");
- String side = "long".equals(posSide) ? "sell" : "buy";
-
- JSONObject body = new JSONObject();
- body.put("instId", config.getContract());
- body.put("tdMode", "cross");
- body.put("side", side);
- body.put("posSide", posSide);
- body.put("ordType", "market");
- body.put("sz", posVal);
- executorPost("/api/v5/trade/order", body.toJSONString());
- log.info("[OKX] 平已有仓位, posSide:{}, sz:{}", posSide, posVal);
- }
- } catch (Exception e) {
- log.warn("[OKX] 平仓位异常", e);
- }
- }
-
- // ---- 启动/停止 ----
-
- public void startGrid() {
- if (state != StrategyState.WAITING_KLINE && state != StrategyState.STOPPED) {
- log.warn("[OKX] 策略已在运行中, state:{}", state);
- return;
- }
- state = StrategyState.WAITING_KLINE;
- cumulativePnl = BigDecimal.ZERO;
- unrealizedPnl = BigDecimal.ZERO;
- markPrice = BigDecimal.ZERO;
- longEntryPrice = BigDecimal.ZERO;
- shortEntryPrice = BigDecimal.ZERO;
- longPositionSize = BigDecimal.ZERO;
- shortPositionSize = BigDecimal.ZERO;
- baseLongOpened = false;
- baseShortOpened = false;
- longActive = false;
- shortActive = false;
- accumulatedLongLossCount = 0;
- accumulatedShortLossCount = 0;
- shortPriceQueue.clear();
- longPriceQueue.clear();
- totalShortPriceQueue.clear();
- totalLongPriceQueue.clear();
- currentLongOrderIds.clear();
- currentShortOrderIds.clear();
- refreshInitialPrincipal();
- log.info("[OKX] 网格策略已启动, 当前本金: {} USDT", initialPrincipal);
- }
-
- private void refreshInitialPrincipal() {
- try {
- JSONObject account = executorGet("/api/v5/account/balance");
- JSONArray dataArr = account.getJSONArray("data");
- if (dataArr != null && !dataArr.isEmpty()) {
- JSONArray details = dataArr.getJSONObject(0).getJSONArray("details");
- if (details != null) {
- for (int i = 0; i < details.size(); i++) {
- JSONObject currency = details.getJSONObject(i);
- if ("USDT".equals(currency.getString("ccy"))) {
- this.initialPrincipal = currency.getBigDecimal("eq");
- break;
- }
- }
- }
- }
- } catch (Exception e) {
- log.warn("[OKX] 获取初始化本金失败,使用旧值: {}", initialPrincipal);
- }
- }
-
- public void stopGrid() {
- state = StrategyState.STOPPED;
- executor.cancelAllPriceTriggeredOrders();
- closeExistingPositions();
- executor.shutdown();
- log.info("[OKX] 策略已停止, 累计盈亏: {}", cumulativePnl);
- }
-
- // ---- K线回调 ----
-
- public void onKline(BigDecimal closePrice) {
- lastKlinePrice = closePrice;
-
- if (state == StrategyState.WAITING_KLINE) {
- if (wsClient == null || !wsClient.areAllSubscribed()) {
- return;
- }
- state = StrategyState.OPENING;
- String size = config.getBaseQuantity();
- log.info("[OKX] 首根K线到达,开基底仓位 多空各{}张...", size);
- executor.openLong(size, (orderId) -> {
- TraderParam baseLongTp = TraderParam.builder()
- .entryOrderId(orderId)
- .build();
- config.setBaseLongTraderParam(baseLongTp);
- baseLongOpened = true;
- }, null);
- executor.openShort(size, (orderId) -> {
- TraderParam baseShortTp = TraderParam.builder()
- .entryOrderId(orderId)
- .build();
- config.setBaseShortTraderParam(baseShortTp);
- baseShortOpened = true;
- }, null);
- return;
- }
-
-
-
- if (state == StrategyState.ACTIVE &&
- !longActive &&
- longPositionSize.compareTo(BigDecimal.ZERO) == 0) {
- processShortGrid(closePrice);
- }
-
- if (state == StrategyState.ACTIVE &&
- !shortActive &&
- shortPositionSize.compareTo(BigDecimal.ZERO) == 0) {
- processLongGrid(closePrice);
- }
- }
-
- // ---- 仓位推送回调 ----
-
- /**
- * 仓位推送回调。由 PositionsOkxChannelHandler 调用。
- * direction 使用 TraderParam.Direction:LONG 表示多头,SHORT 表示空头。
- */
- public void onPositionUpdate(String contract, TraderParam.Direction direction, BigDecimal size,
- BigDecimal entryPrice) {
- if (state == StrategyState.STOPPED || state == StrategyState.WAITING_KLINE) {
- return;
- }
-
- boolean hasPosition = size.abs().compareTo(BigDecimal.ZERO) > 0;
- boolean isLong = (direction == TraderParam.Direction.LONG);
-
- if (state == StrategyState.OPENING) {
- // 基底成交通知仅记录价格/数量,flag 在 REST 回调中设置
- if (isLong && hasPosition) {
- longActive = true;
- longPositionSize = size;
- longEntryPrice = entryPrice;
- longBaseEntryPrice = entryPrice;
- log.info("[OKX] 基底多成交价: {}", longBaseEntryPrice);
- tryGenerateQueues();
- } else if (!isLong && hasPosition) {
- shortActive = true;
- shortPositionSize = size.abs();
- shortEntryPrice = entryPrice;
- shortBaseEntryPrice = entryPrice;
- log.info("[OKX] 基底空成交价: {}", shortBaseEntryPrice);
- tryGenerateQueues();
- }
- }
-
- if (state == StrategyState.ACTIVE) {
- if (isLong) {
- if (hasPosition) {
- longActive = true;
- longPositionSize = size;
- longEntryPrice = entryPrice;
- } else {
- log.info("[OKX-0]多仓归零: {}", shortBaseEntryPrice);
- longActive = false;
- longPositionSize = BigDecimal.ZERO;
- longEntryPrice = BigDecimal.ZERO;
- }
- } else {
- if (hasPosition) {
- shortActive = true;
- shortPositionSize = size.abs();
- shortEntryPrice = entryPrice;
- } else {
- log.info("[OKX-0]空仓归零: {}", shortBaseEntryPrice);
- shortActive = false;
- shortPositionSize = BigDecimal.ZERO;
- shortEntryPrice = BigDecimal.ZERO;
- }
- }
- }
-
- if (state == StrategyState.ACTIVE && !shortActive && !longActive) {
- executor.cancelAllPriceTriggeredOrders();
- closeExistingPositions();
- state = StrategyState.STOPPED;
- executor.submitTask(() -> {
- try { Thread.sleep(3000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
- startGrid();
- });
- log.info("[OKX] 重置策略");
- }
- }
-
- // ---- 平仓推送回调 ----
-
- /**
- * 平仓盈亏累加(OKX 目前没有独立的 position_closes 频道,
- * 盈亏信息可从 orders 频道或 REST API 获取,这里保留接口以备将来使用)。
- */
- public void onPositionClose(String contract, String side, BigDecimal pnl) {
- if (state == StrategyState.STOPPED) {
- return;
- }
- cumulativePnl = cumulativePnl.add(pnl);
- updateUnrealizedPnl();
- BigDecimal totalPnl = cumulativePnl.add(unrealizedPnl);
- log.info("[OKX] 已实现:{}, 未实现:{}, 合计:{}",
- cumulativePnl, unrealizedPnl, totalPnl);
- if (totalPnl.compareTo(config.getMaxLoss().negate()) <= 0) {
- String logMessage = StrUtil.format("[OKX] 已达亏损风险值(合计{}), 已实现:{}, 未实现:{}",
- totalPnl, cumulativePnl, unrealizedPnl);
- log.info(logMessage);
- DingTalkUtils.getDefault().sendActionCard("风险提醒", logMessage, config.getApiKey(), "");
- }
- }
-
- // ---- 自动订单(条件单)状态变更回调 ----
-
- /**
- * 自动订单状态变更回调。由 OrdersOkxChannelHandler 调用。
- */
- public void onAutoOrder(String orderId, String status, String reason, String orderType, String tradeId) {
- if (state == StrategyState.STOPPED) {
- return;
- }
- log.info("[OKX] 条件单状态变更, id:{}, status:{}, reason:{}, order_type:{}",
- orderId, status, reason, orderType);
- if (!"finished".equals(status)) {
- return;
- }
-
- // 多仓止盈触发
- GridElement longTpElem = GridElement.findByLongTakeProfitOrderId(orderId);
- if (longTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- longTakeProfitTraderIdParam(longTpElem, null, false);
- log.info("[OKX] 多仓止盈触发 gridId:{}, orderId:{}", longTpElem.getId(), orderId);
- cancelFarthestLongStopLoss();
- checkLastTakeProfitAndRestart();
- return;
- }
- // 空仓止盈触发
- GridElement shortTpElem = GridElement.findByShortTakeProfitOrderId(orderId);
- if (shortTpElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- shortTakeProfitTraderIdParam(shortTpElem, null, false);
- log.info("[OKX] 空仓止盈触发 gridId:{}, orderId:{}", shortTpElem.getId(), orderId);
- cancelFarthestShortStopLoss();
- checkLastTakeProfitAndRestart();
- return;
- }
-
- // 多仓止损触发
- GridElement longStopLossElem = GridElement.findByLongStopLossOrderId(orderId);
- if (longStopLossElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- handleLongStopLossTriggered(longStopLossElem);
- return;
- }
- // 空仓止损触发
- GridElement shortStopLossElem = GridElement.findByShortStopLossOrderId(orderId);
- if (shortStopLossElem != null && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- handleShortStopLossTriggered(shortStopLossElem);
- return;
- }
-
- // 空仓挂单成交
- GridElement shortGridElement = GridElement.findByShortOrderId(orderId);
- if (shortGridElement != null) {
- if (shortGridElement.isHasShortOrder() && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- int filledQty = Integer.parseInt(shortGridElement.getShortTraderParam().getQuantity());
- shortEntryTraderIdParam(shortGridElement, null, false);
- cancelAllShortTakeProfitsAndStopLosses();
- int posSize = queryPositionSize(OkxPosMode.SHORT);
- extendShortStopLoss(posSize, shortGridElement.getId());
- accumulatedShortLossCount = 0;
- log.info("[OKX] 空单成交 gridId:{}, 成交{}张, 当前持仓:{}张",
- shortGridElement.getId(), filledQty, posSize);
-
- BigDecimal shortBaseQty = new BigDecimal(config.getBaseQuantity());
- BigDecimal shortGridQty = new BigDecimal(config.getQuantity());
- if (BigDecimal.valueOf(posSize).compareTo(shortBaseQty) > 0) {
- BigDecimal shortExcess = BigDecimal.valueOf(posSize).subtract(shortBaseQty);
- int shortExcessCount = shortExcess.divide(shortGridQty, 0, RoundingMode.DOWN).intValue();
- for (int i = 0; i < shortExcessCount; i++) {
- int tpGridId = shortGridElement.getId() - 2 * (i + 1);
- GridElement tpElem = GridElement.findById(tpGridId);
- if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) {
- continue;
- }
- BigDecimal tpPrice = tpElem.getGridPrice();
- int finalTpGridId = tpGridId;
- executor.placeTakeProfit(
- tpPrice,
- "close_short",
- config.getQuantity(),
- profitId -> {
- shortTakeProfitTraderIdParam(tpElem, profitId, true);
- log.info("[OKX] 空仓止盈挂单, gridId:{}, 触发价:{}, takeProfitId:{}",
- finalTpGridId, tpPrice, profitId);
- }
- );
- }
- }
- }
- }
- // 多仓挂单成交
- GridElement longGridElement = GridElement.findByLongOrderId(orderId);
- if (longGridElement != null) {
- if (longGridElement.isHasLongOrder() && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
- int filledQty = Integer.parseInt(longGridElement.getLongTraderParam().getQuantity());
- longEntryTraderIdParam(longGridElement, null, false);
- cancelAllLongTakeProfitsAndStopLosses();
- int posSize = queryPositionSize(OkxPosMode.LONG);
- extendLongStopLoss(posSize, longGridElement.getId());
- accumulatedLongLossCount = 0;
- log.info("[OKX] 多单成交 gridId:{}, 成交{}张, 当前持仓:{}张",
- longGridElement.getId(), filledQty, posSize);
-
- BigDecimal longBaseQty = new BigDecimal(config.getBaseQuantity());
- BigDecimal longGridQty = new BigDecimal(config.getQuantity());
- if (BigDecimal.valueOf(posSize).compareTo(longBaseQty) > 0) {
- BigDecimal longExcess = BigDecimal.valueOf(posSize).subtract(longBaseQty);
- int longExcessCount = longExcess.divide(longGridQty, 0, RoundingMode.DOWN).intValue();
- for (int i = 0; i < longExcessCount; i++) {
- int tpGridId = longGridElement.getId() + 2 * (i + 1);
- GridElement tpElem = GridElement.findById(tpGridId);
- if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) {
- continue;
- }
- BigDecimal tpPrice = tpElem.getGridPrice();
- int finalTpGridId = tpGridId;
- executor.placeTakeProfit(
- tpPrice,
- "close_long",
- config.getQuantity(),
- profitId -> {
- longTakeProfitTraderIdParam(tpElem, profitId, true);
- log.info("[OKX] 多仓止盈挂单, gridId:{}, 触发价:{}, takeProfitId:{}",
- finalTpGridId, tpPrice, profitId);
- }
- );
- }
- }
- }
- }
- }
-
- // ========== REST 查询辅助 ==========
-
- private int queryPositionSize(OkxPosMode mode) {
- OkxPositionInfo p = queryPosition(mode);
- if (p != null) {
- return new BigDecimal(p.size).abs().intValue();
- }
- return 0;
- }
-
- private BigDecimal queryEntryPrice(OkxPosMode mode) {
- OkxPositionInfo p = queryPosition(mode);
- if (p != null && p.entryPrice != null) {
- return new BigDecimal(p.entryPrice);
- }
- return BigDecimal.ZERO;
- }
-
- private OkxPositionInfo queryPosition(OkxPosMode mode) {
- try {
- JSONObject resp = executorGet("/api/v5/account/positions?instType=SWAP");
- JSONArray data = resp.getJSONArray("data");
- if (data != null) {
- for (int i = 0; i < data.size(); i++) {
- JSONObject p = data.getJSONObject(i);
- if (config.getContract().equals(p.getString("instId"))
- && mode.name().toLowerCase().equals(p.getString("posSide"))) {
- OkxPositionInfo info = new OkxPositionInfo();
- info.size = p.getString("pos");
- info.entryPrice = p.getString("avgPx");
- return info;
- }
- }
- }
- } catch (Exception e) {
- log.warn("[OKX] 查询{}持仓失败", mode, e);
- }
- return null;
- }
-
- // ---- REST 快捷方法 ----
-
- private JSONObject executorGet(String path) throws Exception {
- return executor.okGet(path);
- }
-
- private JSONObject executorPost(String path, String body) throws Exception {
- return executor.okPost(path, body);
- }
-
- // ---- 网格队列处理 ----
-
- private void tryGenerateQueues() {
- // OPENING 状态下若 WS 仓位已确认但 REST 回调尚未完成,等标记价格推送时重试队列生成
- if (state == StrategyState.OPENING && baseLongOpened && baseShortOpened) {
- // 确保 openLong/openShort 的 REST 回调已完成(WS 推送可能比回调更快到达)
- if (config.getBaseLongTraderParam() == null || config.getBaseShortTraderParam() == null) {
- log.warn("[OKX] 基底REST回调尚未完成, 延后队列生成");
- return;
- }
-
- generateShortQueue();
- generateLongQueue();
- updateGridElements();
-
- GridElement baseGridElement = GridElement.findById(0);
- TraderParam baseLongTraderParam = config.getBaseLongTraderParam();
- baseGridElement.setLongOrderId(baseLongTraderParam.getEntryOrderId());
- baseGridElement.setHasLongOrder(true);
- TraderParam baseShortTraderParam = config.getBaseShortTraderParam();
- baseGridElement.setShortOrderId(baseShortTraderParam.getEntryOrderId());
- baseGridElement.setHasShortOrder(true);
-
- // 挂初始止损
- int stopCount = Integer.parseInt(config.getBaseQuantity()) / Integer.parseInt(config.getQuantity()) + 1;
- for (int id = 2; id <= stopCount; id++) {
- GridElement elem = GridElement.findById(id);
- if (elem == null) {
- continue;
- }
- BigDecimal triggerPrice = elem.getGridPrice();
- int finalId = id;
- executor.placeStopLoss(triggerPrice, "close_short", config.getQuantity(),
- profitId -> {
- elem.setShortStopLossOrderId(profitId);
- GridElement.refreshIndices();
- log.info("[OKX] 空仓止损已挂, gridId:{}, 触发价:{}, slId:{}", finalId, triggerPrice, profitId);
- });
- }
- for (int id = -2; id >= -stopCount; id--) {
- GridElement elem = GridElement.findById(id);
- if (elem == null) {
- continue;
- }
- BigDecimal triggerPrice = elem.getGridPrice();
- int finalId = id;
- executor.placeStopLoss(triggerPrice, "close_long", config.getQuantity(),
- profitId -> {
- elem.setLongStopLossOrderId(profitId);
- GridElement.refreshIndices();
- log.info("[OKX] 多仓止损已挂, gridId:{}, 触发价:{}, slId:{}", finalId, triggerPrice, profitId);
- });
- }
- log.info("[OKX] 止损单已全部挂完, 空仓止损: 2~{}, 多仓止损: -2~-{}", stopCount, stopCount);
-
- state = StrategyState.ACTIVE;
- }
- }
-
- // ---- TraderParam 更新辅助方法 ----
-
- private void longTakeProfitTraderIdParam(GridElement e, String profitId, boolean flag) {
- TraderParam tp = e.getLongTraderParam();
- tp.setTakeProfitOrderId(profitId);
- tp.setTakeProfitPlaced(flag);
- e.setLongTakeProfitOrderId(profitId);
- GridElement.refreshIndices();
- }
-
- private void shortTakeProfitTraderIdParam(GridElement e, String profitId, boolean flag) {
- TraderParam tp = e.getShortTraderParam();
- tp.setTakeProfitOrderId(profitId);
- tp.setTakeProfitPlaced(flag);
- e.setShortTakeProfitOrderId(profitId);
- GridElement.refreshIndices();
- }
-
- private void longEntryTraderIdParam(GridElement e, String entryId, boolean flag) {
- TraderParam tp = e.getLongTraderParam();
- tp.setEntryOrderId(entryId);
- tp.setEntryOrderPlaced(flag);
- e.setHasLongOrder(flag);
- e.setLongOrderId(entryId);
- GridElement.refreshIndices();
- }
-
- private void shortEntryTraderIdParam(GridElement e, String entryId, boolean flag) {
- TraderParam tp = e.getShortTraderParam();
- tp.setEntryOrderId(entryId);
- tp.setEntryOrderPlaced(flag);
- e.setHasShortOrder(flag);
- e.setShortOrderId(entryId);
- GridElement.refreshIndices();
- }
-
- // ---- 队列生成 ----
-
- private void generateShortQueue() {
- shortPriceQueue.clear();
- totalShortPriceQueue.clear();
- totalLongPriceQueue.clear();
- int prec = config.getPriceScale();
- BigDecimal step = shortBaseEntryPrice.multiply(config.getGridRate()).setScale(prec, RoundingMode.HALF_UP);
- config.setStep(step);
- BigDecimal elem = shortBaseEntryPrice.subtract(step).setScale(prec, RoundingMode.HALF_UP);
- for (int i = 0; i < config.getGridQueueSize(); i++) {
- shortPriceQueue.add(elem);
- totalLongPriceQueue.add(elem);
- totalShortPriceQueue.add(elem);
- elem = elem.subtract(step).setScale(prec, RoundingMode.HALF_UP);
- if (elem.compareTo(BigDecimal.ZERO) <= 0) {
- break;
- }
- }
- shortPriceQueue.sort((a, b) -> b.compareTo(a));
- log.info("[OKX] 空队列:{}", shortPriceQueue);
- }
-
- private void generateLongQueue() {
- longPriceQueue.clear();
- int prec = config.getPriceScale();
- BigDecimal step = config.getStep();
- BigDecimal elem = shortBaseEntryPrice.add(step).setScale(prec, RoundingMode.HALF_UP);
- for (int i = 0; i < config.getGridQueueSize(); i++) {
- longPriceQueue.add(elem);
- totalLongPriceQueue.add(elem);
- totalShortPriceQueue.add(elem);
- elem = elem.add(step).setScale(prec, RoundingMode.HALF_UP);
- }
- longPriceQueue.sort(BigDecimal::compareTo);
- log.info("[OKX] 多队列:{}", longPriceQueue);
- totalShortPriceQueue.sort((a, b) -> b.compareTo(a));
- totalLongPriceQueue.sort(BigDecimal::compareTo);
- }
-
- private void updateGridElements() {
- List<GridElement> elements = new ArrayList<>();
- int shortSize = shortPriceQueue.size();
- int longSize = longPriceQueue.size();
- int prec = config.getPriceScale();
- BigDecimal step = config.getStep();
- String qty = config.getQuantity();
-
- // 空仓队列:id 从 -1 自减
- for (int i = 0; i < shortSize; i++) {
- int id = -(i + 1);
- Integer upId = (i == 0) ? 0 : id + 1;
- Integer downId = (i == shortSize - 1) ? null : id - 1;
- BigDecimal price = shortPriceQueue.get(i);
- elements.add(GridElement.builder()
- .id(id).gridPrice(price).upId(upId).downId(downId)
- .longTraderParam(TraderParam.builder().direction(TraderParam.Direction.LONG)
- .entryPrice(price).takeProfitPrice(price.add(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .shortTraderParam(TraderParam.builder().direction(TraderParam.Direction.SHORT)
- .entryPrice(price).takeProfitPrice(price.subtract(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .build());
- }
-
- // 位置 0
- {
- BigDecimal price = shortBaseEntryPrice;
- elements.add(GridElement.builder()
- .id(0).gridPrice(price)
- .upId(longSize > 0 ? 1 : null).downId(shortSize > 0 ? -1 : null)
- .longTraderParam(TraderParam.builder().direction(TraderParam.Direction.LONG)
- .entryPrice(price).takeProfitPrice(price.add(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .shortTraderParam(TraderParam.builder().direction(TraderParam.Direction.SHORT)
- .entryPrice(price).takeProfitPrice(price.subtract(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .build());
- }
-
- // 多仓队列:id 从 1 自增
- for (int i = 0; i < longSize; i++) {
- int id = i + 1;
- Integer downId = (i == 0) ? 0 : id - 1;
- Integer upId = (i == longSize - 1) ? null : id + 1;
- BigDecimal price = longPriceQueue.get(i);
- elements.add(GridElement.builder()
- .id(id).gridPrice(price).upId(upId).downId(downId)
- .longTraderParam(TraderParam.builder().direction(TraderParam.Direction.LONG)
- .entryPrice(price).takeProfitPrice(price.add(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .shortTraderParam(TraderParam.builder().direction(TraderParam.Direction.SHORT)
- .entryPrice(price).takeProfitPrice(price.subtract(step).setScale(prec, RoundingMode.HALF_UP))
- .quantity(qty).build())
- .build());
- }
-
- config.setGridElements(elements);
- log.info("[OKX] 网格元素列表已构建, 共{}个元素 (空仓:{} 位置:0 多仓:{})", elements.size(), shortSize, longSize);
- }
-
- // ---- processShortGrid / processLongGrid ----
-
- private void processShortGrid(BigDecimal currentPrice) {
- BigDecimal matched = BigDecimal.ZERO;
- synchronized (totalLongPriceQueue) {
- for (BigDecimal p : totalLongPriceQueue) {
- if (p.compareTo(currentPrice) >= 0) { matched = p; break; }
- }
- if (BigDecimal.ZERO.compareTo(matched) == 0) {
- return;
- }
- GridElement matchedUpGridElement = GridElement.findByPrice(matched);
- if (matchedUpGridElement != null && !matchedUpGridElement.isHasLongOrder()) {
- Integer upId = matchedUpGridElement.getUpId();
- GridElement newEntryGrid = GridElement.findById(upId);
- if (newEntryGrid != null) {
- GridElement cancelGridElement = GridElement.findById(newEntryGrid.getUpId());
- String quantity = cancelGridElement != null
- ? cancelGridElement.getLongTraderParam().getQuantity()
- : config.getBaseQuantity();
- if (cancelGridElement != null && cancelGridElement.isHasLongOrder()) {
- String longOrderId = cancelGridElement.getLongOrderId();
- executor.cancelConditionalOrder(longOrderId, oid -> {
- longEntryTraderIdParam(cancelGridElement, null, false);
- log.info("[OKX] 多仓仓位归零, 取消gridId:{}的多单,{}", cancelGridElement.getId(), longOrderId);
- });
- }
- if (!newEntryGrid.isHasLongOrder()) {
- BigDecimal triggerPrice = newEntryGrid.getGridPrice();
- String size = quantity;
- log.info("[OKX] 多仓仓位归零 gridId:{}, 挂{}基础张多单", newEntryGrid.getId(), size);
- newEntryGrid.getLongTraderParam().setQuantity(size);
- placeEntryOrderWithPreFlag(newEntryGrid, true, triggerPrice, size);
- }
- }
- }
- }
- }
-
- private void processLongGrid(BigDecimal currentPrice) {
- BigDecimal matched = BigDecimal.ZERO;
- synchronized (totalShortPriceQueue) {
- for (BigDecimal p : totalShortPriceQueue) {
- if (p.compareTo(currentPrice) <= 0) { matched = p; break; }
- }
- if (BigDecimal.ZERO.compareTo(matched) == 0) {
- return;
- }
- GridElement matchedUpGridElement = GridElement.findByPrice(matched);
- if (matchedUpGridElement != null && !matchedUpGridElement.isHasShortOrder()) {
- Integer downId = matchedUpGridElement.getDownId();
- GridElement newEntryGrid = GridElement.findById(downId);
- if (newEntryGrid != null) {
- GridElement cancelGridElement = GridElement.findById(newEntryGrid.getDownId());
- String quantity = cancelGridElement != null
- ? cancelGridElement.getShortTraderParam().getQuantity()
- : config.getBaseQuantity();
- if (cancelGridElement != null && cancelGridElement.isHasShortOrder()) {
- String shortOrderId = cancelGridElement.getShortOrderId();
- executor.cancelConditionalOrder(shortOrderId, oid -> {
- shortEntryTraderIdParam(cancelGridElement, null, false);
- log.info("[OKX] 空仓仓位归零, 取消gridId:{}的空单{}", cancelGridElement.getId(), shortOrderId);
- });
- }
- if (!newEntryGrid.isHasShortOrder()) {
- BigDecimal triggerPrice = newEntryGrid.getGridPrice();
- String size = quantity;
- log.info("[OKX] 空仓仓位归零 gridId:{}, 挂{}基础张空单", newEntryGrid.getId(), size);
- newEntryGrid.getShortTraderParam().setQuantity(size);
- placeEntryOrderWithPreFlag(newEntryGrid, false, triggerPrice, negate(size));
- }
- }
- }
- }
- }
-
- // ---- 止损处理 ----
-
- private void handleLongStopLossTriggered(GridElement gridElement) {
- gridElement.setLongStopLossOrderId(null);
- int gridId = gridElement.getId();
- log.info("[OKX] 多仓止损触发 gridId:{}, 开始追单", gridId);
- int newEntryGridId = gridId + 1;
- GridElement newEntryGrid = GridElement.findById(newEntryGridId);
- if (newEntryGrid == null) {
- log.warn("[OKX] 多仓止损触发 but gridId:{} 不存在", newEntryGridId);
- GridElement.refreshIndices();
- return;
- }
- if (!newEntryGrid.isHasLongOrder()) {
- BigDecimal triggerPrice = newEntryGrid.getGridPrice();
- accumulatedLongLossCount += Integer.parseInt(config.getQuantity());
- String size = String.valueOf(accumulatedLongLossCount + Integer.parseInt(config.getQuantity()));
- log.info("[OKX] 多仓止损触发 gridId:{}, 在gridId:{}挂{}基础张多单", gridId, newEntryGridId, size);
- newEntryGrid.getLongTraderParam().setQuantity(size);
- placeEntryOrderWithPreFlag(newEntryGrid, true, triggerPrice, size);
- } else {
- log.warn("[OKX] 多仓止损触发 gridId:{}, 目标gridId:{}已有挂单,跳过", gridId, newEntryGridId);
- }
- int cancelGridId = gridId + 2;
- GridElement cancelGrid = GridElement.findById(cancelGridId);
- if (cancelGrid != null && cancelGrid.isHasLongOrder()) {
- executor.cancelConditionalOrder(cancelGrid.getLongOrderId(), oid -> {
- longEntryTraderIdParam(cancelGrid, null, false);
- log.info("[OKX] 多仓止损触发, 取消gridId:{}的多单", cancelGridId);
- });
- }
- GridElement farthestLongTp = null;
- for (GridElement e : config.getGridElements()) {
- if (e.getLongTakeProfitOrderId() != null) {
- if (farthestLongTp == null || e.getGridPrice().compareTo(farthestLongTp.getGridPrice()) > 0) {
- farthestLongTp = e;
- }
- }
- }
- if (farthestLongTp != null) {
- String tpOrderId = farthestLongTp.getLongTakeProfitOrderId();
- GridElement finalFarthest = farthestLongTp;
- executor.cancelConditionalOrder(tpOrderId, oid -> {
- longTakeProfitTraderIdParam(finalFarthest, null, false);
- log.info("[OKX] 多仓止损触发, 取消最远止盈 gridId:{}, orderId:{}", finalFarthest.getId(), tpOrderId);
- });
- }
- }
-
- private void handleShortStopLossTriggered(GridElement gridElement) {
- gridElement.setShortStopLossOrderId(null);
- int gridId = gridElement.getId();
- log.info("[OKX] 空仓止损触发 gridId:{}, 开始追单", gridId);
- int newEntryGridId = gridId - 1;
- GridElement newEntryGrid = GridElement.findById(newEntryGridId);
- if (newEntryGrid == null) {
- log.warn("[OKX] 空仓止损触发 but gridId:{} 不存在", newEntryGridId);
- GridElement.refreshIndices();
- return;
- }
- if (!newEntryGrid.isHasShortOrder()) {
- BigDecimal triggerPrice = newEntryGrid.getGridPrice();
- accumulatedShortLossCount += Integer.parseInt(config.getQuantity());
- String size = String.valueOf(accumulatedShortLossCount + Integer.parseInt(config.getQuantity()));
- log.info("[OKX] 空仓止损触发 gridId:{}, 在gridId:{}挂{}基础张空单", gridId, newEntryGridId, size);
- newEntryGrid.getShortTraderParam().setQuantity(size);
- placeEntryOrderWithPreFlag(newEntryGrid, false, triggerPrice, negate(size));
- } else {
- log.warn("[OKX] 空仓止损触发 gridId:{}, 目标gridId:{}已有挂单,跳过", gridId, newEntryGridId);
- }
- int cancelGridId = gridId - 2;
- GridElement cancelGrid = GridElement.findById(cancelGridId);
- if (cancelGrid != null && cancelGrid.isHasShortOrder()) {
- executor.cancelConditionalOrder(cancelGrid.getShortOrderId(), oid -> {
- shortEntryTraderIdParam(cancelGrid, null, false);
- log.info("[OKX] 空仓止损触发, 取消gridId:{}的空单", cancelGridId);
- });
- }
- GridElement farthestShortTp = null;
- for (GridElement e : config.getGridElements()) {
- if (e.getShortTakeProfitOrderId() != null) {
- if (farthestShortTp == null || e.getGridPrice().compareTo(farthestShortTp.getGridPrice()) < 0) {
- farthestShortTp = e;
- }
- }
- }
- if (farthestShortTp != null) {
- String tpOrderId = farthestShortTp.getShortTakeProfitOrderId();
- GridElement finalFarthest = farthestShortTp;
- executor.cancelConditionalOrder(tpOrderId, oid -> {
- shortTakeProfitTraderIdParam(finalFarthest, null, false);
- log.info("[OKX] 空仓止损触发, 取消最远止盈 gridId:{}, orderId:{}", finalFarthest.getId(), tpOrderId);
- });
- }
- }
-
- // ---- 止盈/止损取消辅助 ----
-
- private void checkLastTakeProfitAndRestart() {
- int span = config.getRestartGridSpan();
- if (span <= 0) {
- return;
- }
-
- if (GridElement.getLongTakeProfitCount() > 0 || GridElement.getShortTakeProfitCount() > 0) {
- log.info("[OKX] 尚有未触发止盈单, 暂不检查跨度重启 longTpCount:{}, shortTpCount:{}",
- GridElement.getLongTakeProfitCount(), GridElement.getShortTakeProfitCount());
- return;
- }
-
- BigDecimal step = config.getStep();
- if (step == null || step.compareTo(BigDecimal.ZERO) == 0) {
- return;
- }
- BigDecimal threshold = step.multiply(new BigDecimal(span));
- BigDecimal currentPrice = lastKlinePrice;
- if (currentPrice == null || currentPrice.compareTo(BigDecimal.ZERO) == 0) {
- return;
- }
-
- // 查交易所获取最新持仓均价
- OkxPositionInfo longPos = queryPosition(OkxPosMode.LONG);
- OkxPositionInfo shortPos = queryPosition(OkxPosMode.SHORT);
- boolean hasLong = longPos != null && Math.abs(Integer.parseInt(longPos.size)) > 0;
- boolean hasShort = shortPos != null && Math.abs(Integer.parseInt(shortPos.size)) > 0;
- BigDecimal longAvgPrice = (longPos != null && longPos.entryPrice != null)
- ? new BigDecimal(longPos.entryPrice) : BigDecimal.ZERO;
- BigDecimal shortAvgPrice = (shortPos != null && shortPos.entryPrice != null)
- ? new BigDecimal(shortPos.entryPrice) : BigDecimal.ZERO;
-
- boolean shouldRestart = false;
- String reason = "";
-
- if (hasLong && hasShort) {
- BigDecimal gap = shortAvgPrice.subtract(longAvgPrice);
- if (gap.compareTo(threshold) >= 0) {
- shouldRestart = true;
- reason = StrUtil.format("双边跨度 |多均价:{} − 空均价:{}| = {} >= {} (span:{}×step:{})",
- longAvgPrice, shortAvgPrice, gap, threshold, span, step);
- }
- } else if (hasLong) {
- BigDecimal gap = currentPrice.subtract(longAvgPrice);
- if (gap.compareTo(threshold) >= 0) {
- shouldRestart = true;
- reason = StrUtil.format("多仓跨度 当前价:{} − 多均价:{} = {} > {} (span:{}×step:{})",
- currentPrice, longAvgPrice, gap, threshold, span, step);
- }
- } else if (hasShort) {
- BigDecimal gap = shortAvgPrice.subtract(currentPrice);
- if (gap.compareTo(threshold) >= 0) {
- shouldRestart = true;
- reason = StrUtil.format("空仓跨度 空均价:{} − 当前价:{} = {} > {} (span:{}×step:{})",
- shortAvgPrice, currentPrice, gap, threshold, span, step);
- }
- }
-
- if (shouldRestart) {
- log.info("[OKX] 跨度已达要求 → {},最后一个止盈触发策略重启", reason);
- executor.cancelAllPriceTriggeredOrders();
- closeExistingPositions();
- state = StrategyState.STOPPED;
- executor.submitTask(() -> {
- try { Thread.sleep(3000); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); }
- startGrid();
- });
- }
- }
-
- private void cancelFarthestLongStopLoss() {
- GridElement farthest = null;
- for (GridElement e : config.getGridElements()) {
- if (e.getLongStopLossOrderId() != null) {
- if (farthest == null || e.getId() < farthest.getId()) {
- farthest = e;
- }
- }
- }
- if (farthest != null) {
- String slId = farthest.getLongStopLossOrderId();
- farthest.setLongStopLossOrderId(null);
- GridElement.refreshIndices();
- GridElement finalFarthest = farthest;
- executor.cancelConditionalOrder(slId, oid ->
- log.info("[OKX] 止盈触发, 取消最远多仓止损 gridId:{}, orderId:{}", finalFarthest.getId(), slId));
- }
- }
-
- private void cancelFarthestShortStopLoss() {
- GridElement farthest = null;
- for (GridElement e : config.getGridElements()) {
- if (e.getShortStopLossOrderId() != null) {
- if (farthest == null || e.getId() > farthest.getId()) {
- farthest = e;
- }
- }
- }
- if (farthest != null) {
- String slId = farthest.getShortStopLossOrderId();
- farthest.setShortStopLossOrderId(null);
- GridElement.refreshIndices();
- GridElement finalFarthest = farthest;
- executor.cancelConditionalOrder(slId, oid ->
- log.info("[OKX] 止盈触发, 取消最远空仓止损 gridId:{}, orderId:{}", finalFarthest.getId(), slId));
- }
- }
-
- private void cancelAllLongTakeProfitsAndStopLosses() {
- for (GridElement e : config.getGridElements()) {
- String tpId = e.getLongTakeProfitOrderId();
- if (tpId != null) { e.setLongTakeProfitOrderId(null); executor.cancelConditionalOrder(tpId, oid -> {}); }
- String slId = e.getLongStopLossOrderId();
- if (slId != null) { e.setLongStopLossOrderId(null); executor.cancelConditionalOrder(slId, oid -> {}); }
- }
- GridElement.refreshIndices();
- log.info("[OKX] 已提交取消所有多仓止盈+止损");
- }
-
- private void cancelAllShortTakeProfitsAndStopLosses() {
- for (GridElement e : config.getGridElements()) {
- String tpId = e.getShortTakeProfitOrderId();
- if (tpId != null) { e.setShortTakeProfitOrderId(null); executor.cancelConditionalOrder(tpId, oid -> {}); }
- String slId = e.getShortStopLossOrderId();
- if (slId != null) { e.setShortStopLossOrderId(null); executor.cancelConditionalOrder(slId, oid -> {}); }
- }
- GridElement.refreshIndices();
- log.info("[OKX] 已提交取消所有空仓止盈+止损");
- }
-
- // ---- 止损追单 ----
-
- private void extendLongStopLoss(int filledQty, int gridId) {
- int furthestSlId = 0;
- for (GridElement e : config.getGridElements()) {
- if (e.getLongStopLossOrderId() != null && e.getId() < furthestSlId) {
- furthestSlId = e.getId();
- }
- }
- int interval = 1;
- if (furthestSlId == 0) { furthestSlId = gridId; interval = 2; }
- int stopLossCount = filledQty / Integer.parseInt(config.getQuantity());
- log.info("[OKX] 多仓追挂止损, 当前最远止损gridId:{}, 成交{}张, 追加{}个止损单", furthestSlId, filledQty, stopLossCount);
- for (int i = 0; i < stopLossCount; i++) {
- int newSlId = furthestSlId - i - interval;
- GridElement elem = GridElement.findById(newSlId);
- if (elem == null) {
- continue;
- }
- BigDecimal triggerPrice = elem.getGridPrice();
- int finalSlId = newSlId;
- executor.placeStopLoss(triggerPrice, "close_long", config.getQuantity(),
- profitId -> {
- elem.setLongStopLossOrderId(profitId);
- GridElement.refreshIndices();
- log.info("[OKX] 多仓止损追加, gridId:{}, 触发价:{}, slId:{}", finalSlId, triggerPrice, profitId);
- });
- }
- }
-
- private void extendShortStopLoss(int filledQty, int gridId) {
- int furthestSlId = 0;
- for (GridElement e : config.getGridElements()) {
- if (e.getShortStopLossOrderId() != null && e.getId() > furthestSlId) {
- furthestSlId = e.getId();
- }
- }
- int interval = 1;
- if (furthestSlId == 0) { furthestSlId = gridId; interval = 2; }
- int stopLossCount = filledQty / Integer.parseInt(config.getQuantity());
- log.info("[OKX] 空仓追挂止损, 当前最远止损gridId:{}, 成交{}张, 追加{}个止损单", furthestSlId, filledQty, stopLossCount);
- for (int i = 0; i < stopLossCount; i++) {
- int newSlId = furthestSlId + i + interval;
- GridElement elem = GridElement.findById(newSlId);
- if (elem == null) {
- continue;
- }
- BigDecimal triggerPrice = elem.getGridPrice();
- int finalSlId = newSlId;
- executor.placeStopLoss(triggerPrice, "close_short", config.getQuantity(),
- profitId -> {
- elem.setShortStopLossOrderId(profitId);
- GridElement.refreshIndices();
- log.info("[OKX] 空仓止损追加, gridId:{}, 触发价:{}, slId:{}", finalSlId, triggerPrice, profitId);
- });
- }
- }
-
- // ---- 工具 ----
-
- private String negate(String qty) {
- return qty.startsWith("-") ? qty.substring(1) : "-" + qty;
- }
-
- private void placeEntryOrderWithPreFlag(GridElement gridElement, boolean isLong,
- BigDecimal triggerPrice, String size) {
- if (isLong) {
- gridElement.setHasLongOrder(true);
- } else {
- gridElement.setHasShortOrder(true);
- }
- executor.placeConditionalEntryOrder(triggerPrice, isLong, size,
- orderId -> {
- if (isLong) {
- longEntryTraderIdParam(gridElement, orderId, true);
- } else {
- shortEntryTraderIdParam(gridElement, orderId, true);
- }
- },
- () -> {
- if (isLong) {
- gridElement.setHasLongOrder(false);
- gridElement.setLongOrderId(null);
- } else {
- gridElement.setHasShortOrder(false);
- gridElement.setShortOrderId(null);
- }
- GridElement.refreshIndices();
- log.warn("[OKX] 条件单创建失败,回滚标志位 gridId:{}, isLong:{}", gridElement.getId(), isLong);
- });
- }
-
- private void updateUnrealizedPnl() {
- BigDecimal price = resolvePnlPrice();
- if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
- return;
- }
- BigDecimal multiplier = config.getContractMultiplier();
- BigDecimal longPnl = BigDecimal.ZERO;
- BigDecimal shortPnl = BigDecimal.ZERO;
- if (longPositionSize.compareTo(BigDecimal.ZERO) > 0 && longEntryPrice.compareTo(BigDecimal.ZERO) > 0) {
- longPnl = longPositionSize.multiply(multiplier).multiply(price.subtract(longEntryPrice));
- }
- if (shortPositionSize.compareTo(BigDecimal.ZERO) > 0 && shortEntryPrice.compareTo(BigDecimal.ZERO) > 0) {
- shortPnl = shortPositionSize.multiply(multiplier).multiply(shortEntryPrice.subtract(price));
- }
- unrealizedPnl = longPnl.add(shortPnl);
- log.info("[OKX] 未实现盈亏: {}", unrealizedPnl);
- }
-
- private BigDecimal resolvePnlPrice() {
- if (config.getUnrealizedPnlPriceMode() == OkxConfig.PnLPriceMode.MARK_PRICE
- && markPrice.compareTo(BigDecimal.ZERO) > 0) {
- return markPrice;
- }
- return lastKlinePrice;
- }
-
- // ---- getters ----
-
- public BigDecimal getLastKlinePrice() { return lastKlinePrice; }
- public void setMarkPrice(BigDecimal markPrice) { this.markPrice = markPrice; }
- public boolean isStrategyActive() { return state != StrategyState.STOPPED && state != StrategyState.WAITING_KLINE; }
- public BigDecimal getCumulativePnl() { return cumulativePnl; }
- public BigDecimal getUnrealizedPnl() { return unrealizedPnl; }
- public StrategyState getState() { return state; }
- public void setWsClient(OkxKlineWebSocketClient wsClient) { this.wsClient = wsClient; }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxProfitRecycleStrategy.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxProfitRecycleStrategy.java
new file mode 100644
index 0000000..a30a95f
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/OkxProfitRecycleStrategy.java
@@ -0,0 +1,548 @@
+package com.xcong.excoin.modules.okxApi;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
+import lombok.extern.slf4j.Slf4j;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * OKX 盈利回收循环策略 — 永远持有多空双向底仓,盈利兑现 + 利润反向加仓。
+ *
+ * <h3>核心思想</h3>
+ * <ol>
+ * <li>永远持有多空双向底仓</li>
+ * <li>盈利的一边不断兑现利润</li>
+ * <li>用部分利润强化亏损的一边</li>
+ * <li>利用市场波动不断放大利润</li>
+ * </ol>
+ *
+ * <h3>策略流程(状态机)</h3>
+ * <pre>
+ * INIT → 双开底仓 → MONITOR
+ * ↓
+ * 盈利达到50% → 平50%盈利仓 → 利润拆分 → 反向加仓 → 继续监控
+ * ↓
+ * 账户盈利5% → 全部平仓 → 重新双开
+ * </pre>
+ *
+ * <h3>数学模型</h3>
+ * <ul>
+ * <li>ROI = 未实现盈亏 / 该方向保证金</li>
+ * <li>触发条件:ROI ≥ profitTriggerRatio (默认50%)</li>
+ * <li>平仓张数:floor(positionSize / 2)</li>
+ * <li>收益 A = 已实现利润</li>
+ * <li>保证金 B = A × reinvestRatio (默认50%)</li>
+ * <li>单张保证金 = contractMultiplier × entryPrice / leverage</li>
+ * <li>补仓张数 = max(baseQty, floor(B / 单张保证金))</li>
+ * </ul>
+ *
+ * <h3>风控</h3>
+ * <ul>
+ * <li>风控1:反向仓位倍数上限 maxPositionMultiplier(默认10x)</li>
+ * <li>风控2:保证金占比检查(全局亏损 maxLoss 阈值)</li>
+ * <li>风控3:权益增长 equityRestartRatio(默认5%)全平重置</li>
+ * </ul>
+ *
+ * @author Administrator
+ */
+@Slf4j
+public class OkxProfitRecycleStrategy implements IOkxStrategy {
+
+ public enum StrategyState {
+ WAITING_KLINE,
+ OPENING,
+ ACTIVE,
+ RESTARTING,
+ STOPPED
+ }
+
+ private final OkxConfig config;
+ private final OkxTradeExecutor executor;
+
+ private volatile StrategyState state = StrategyState.WAITING_KLINE;
+
+ // ---- 价格 ----
+ private volatile BigDecimal lastPrice = BigDecimal.ZERO;
+ private volatile BigDecimal markPrice = BigDecimal.ZERO;
+
+ // ---- 持仓 ----
+ private volatile BigDecimal longPositionSize = BigDecimal.ZERO;
+ private volatile BigDecimal longEntryPrice = BigDecimal.ZERO;
+ private volatile BigDecimal shortPositionSize = BigDecimal.ZERO;
+ private volatile BigDecimal shortEntryPrice = BigDecimal.ZERO;
+
+ // ---- 盈亏 ----
+ private volatile BigDecimal cumulativePnl = BigDecimal.ZERO;
+ private volatile BigDecimal initialPrincipal = BigDecimal.ZERO;
+ private volatile boolean rebalancing = false;
+ /** 循环计数器(每完成一次"平仓+反向加仓"计数+1) */
+ private volatile int cycleCount = 0;
+ /** 重置计数器(每完成一次权益重置计数+1) */
+ private volatile int restartCount = 0;
+
+ private volatile OkxKlineWebSocketClient wsClient;
+
+ public OkxProfitRecycleStrategy(OkxConfig config) {
+ this.config = config;
+ this.executor = new OkxTradeExecutor(config);
+ }
+
+ // ==================== 生命周期 ====================
+
+ public void init() {
+ try {
+ refreshInitialPrincipal();
+ JSONObject posModeBody = new JSONObject();
+ posModeBody.put("posMode", config.getPositionMode());
+ executorPost("/api/v5/account/set-position-mode", posModeBody.toJSONString());
+ log.info("[ProfitRecycle] 持仓模式: {}", config.getPositionMode());
+
+ JSONObject levBody = new JSONObject();
+ levBody.put("instId", config.getContract());
+ levBody.put("lever", config.getLeverage());
+ levBody.put("mgnMode", config.getMarginMode());
+ executorPost("/api/v5/account/set-leverage", levBody.toJSONString());
+ log.info("[ProfitRecycle] 杠杆: {}x {}", config.getLeverage(), config.getMarginMode());
+
+ executor.cancelAllPriceTriggeredOrders();
+ closeExistingPositions();
+ log.info("[ProfitRecycle] 初始化完成, 本金: {} USDT, 合约: {}, 基础张数: {}",
+ initialPrincipal, config.getContract(), config.getBaseQuantity());
+ } catch (Exception e) {
+ log.error("[ProfitRecycle] 初始化失败", e);
+ }
+ }
+
+ public void startStrategy() {
+ if (state != StrategyState.WAITING_KLINE && state != StrategyState.STOPPED) {
+ log.warn("[ProfitRecycle] 策略已在运行中, state:{}", state);
+ return;
+ }
+ resetState();
+ refreshInitialPrincipal();
+ log.info("[ProfitRecycle] ✅ 策略启动 — 本金: {} USDT | 基础仓位: {}张 | 杠杆: {}x | "
+ + "触发ROI: {}% | 再投资: {}% | 仓位上限: {}x | 重置阈值: {}%",
+ initialPrincipal, config.getBaseQuantity(), config.getLeverage(),
+ config.getProfitTriggerRatio().multiply(new BigDecimal("100")),
+ config.getReinvestRatio().multiply(new BigDecimal("100")),
+ config.getMaxPositionMultiplier(),
+ config.getEquityRestartRatio().multiply(new BigDecimal("100")));
+ }
+
+ public void stopStrategy() {
+ state = StrategyState.STOPPED;
+ executor.cancelAllPriceTriggeredOrders();
+ closeExistingPositions();
+ executor.shutdown();
+ log.info("[ProfitRecycle] ⏹ 策略停止 — 累计盈亏: {} | 循环: {} | 重置: {}",
+ cumulativePnl, cycleCount, restartCount);
+ }
+
+ @Override
+ public boolean isStrategyActive() {
+ return state != StrategyState.STOPPED && state != StrategyState.WAITING_KLINE;
+ }
+
+ private void resetState() {
+ state = StrategyState.WAITING_KLINE;
+ cumulativePnl = BigDecimal.ZERO;
+ lastPrice = BigDecimal.ZERO;
+ markPrice = BigDecimal.ZERO;
+ longPositionSize = BigDecimal.ZERO;
+ longEntryPrice = BigDecimal.ZERO;
+ shortPositionSize = BigDecimal.ZERO;
+ shortEntryPrice = BigDecimal.ZERO;
+ rebalancing = false;
+ cycleCount = 0;
+ }
+
+ // ==================== WS 回调 ====================
+
+ @Override
+ public void onKline(BigDecimal closePrice) {
+ lastPrice = closePrice;
+
+ if (state == StrategyState.WAITING_KLINE) {
+ if (wsClient == null || !wsClient.areAllSubscribed()) return;
+ state = StrategyState.OPENING;
+ final String size = config.getBaseQuantity();
+ log.info("[ProfitRecycle] 🚀 首根K线到达,多空双开各{}张", size);
+ executor.openLong(size, ordId -> log.info("[ProfitRecycle] 多仓已提交 ordId:{}", ordId), null);
+ executor.openShort(size, ordId -> log.info("[ProfitRecycle] 空仓已提交 ordId:{}", ordId), null);
+ return;
+ }
+
+ if (state == StrategyState.ACTIVE) {
+ checkAndRecycle();
+ }
+ }
+
+ @Override
+ public void setMarkPrice(BigDecimal markPrice) {
+ this.markPrice = markPrice;
+ }
+
+ @Override
+ public void onPositionUpdate(String contract, Direction direction,
+ BigDecimal size, BigDecimal entryPrice) {
+ if (state == StrategyState.STOPPED || state == StrategyState.WAITING_KLINE) return;
+
+ boolean hasPos = size.abs().compareTo(BigDecimal.ZERO) > 0;
+ boolean isLong = (direction == Direction.LONG);
+
+ if (state == StrategyState.OPENING || state == StrategyState.RESTARTING) {
+ if (isLong && hasPos) {
+ longPositionSize = size;
+ longEntryPrice = entryPrice;
+ log.info("[ProfitRecycle] 多仓确认: {}张 @ {}", size, entryPrice);
+ tryActivate();
+ } else if (!isLong && hasPos) {
+ shortPositionSize = size.abs();
+ shortEntryPrice = entryPrice;
+ log.info("[ProfitRecycle] 空仓确认: {}张 @ {}", size.abs(), entryPrice);
+ tryActivate();
+ }
+ }
+
+ if (state == StrategyState.ACTIVE) {
+ if (isLong) {
+ longPositionSize = hasPos ? size : BigDecimal.ZERO;
+ longEntryPrice = hasPos ? entryPrice : BigDecimal.ZERO;
+ } else {
+ shortPositionSize = hasPos ? size.abs() : BigDecimal.ZERO;
+ shortEntryPrice = hasPos ? entryPrice : BigDecimal.ZERO;
+ }
+ }
+ }
+
+ @Override
+ public void onAutoOrder(String orderId, String status, String reason,
+ String orderType, String tradeId) {
+ log.debug("[ProfitRecycle] 条件单: id={} status={}", orderId, status);
+ }
+
+ // ==================== 核心循环 ====================
+
+ private void checkAndRecycle() {
+ if (rebalancing) return;
+
+ final BigDecimal price = resolvePrice();
+ if (price.compareTo(BigDecimal.ZERO) <= 0) return;
+
+ final BigDecimal mult = config.getContractMultiplier();
+ final BigDecimal lev = new BigDecimal(config.getLeverage());
+ final BigDecimal trigger = config.getProfitTriggerRatio();
+
+ // 检查多仓
+ if (longPositionSize.compareTo(BigDecimal.ZERO) > 0
+ && longEntryPrice.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal pnl = longPositionSize.multiply(mult).multiply(price.subtract(longEntryPrice));
+ BigDecimal margin = calcMargin(longPositionSize, longEntryPrice);
+ BigDecimal roi = margin.compareTo(BigDecimal.ZERO) > 0
+ ? pnl.divide(margin, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+
+ if (pnl.compareTo(margin.multiply(trigger)) >= 0) {
+ log.info("[ProfitRecycle] 🔔 多头触发 | pnl={} margin={} ROI={}%", pnl, margin, roi.multiply(hundred()));
+ executeRecycle(Direction.LONG, longPositionSize, pnl, longEntryPrice, price);
+ return;
+ }
+ }
+
+ // 检查空仓
+ if (shortPositionSize.compareTo(BigDecimal.ZERO) > 0
+ && shortEntryPrice.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal pnl = shortPositionSize.multiply(mult).multiply(shortEntryPrice.subtract(price));
+ BigDecimal margin = calcMargin(shortPositionSize, shortEntryPrice);
+ BigDecimal roi = margin.compareTo(BigDecimal.ZERO) > 0
+ ? pnl.divide(margin, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+
+ if (pnl.compareTo(margin.multiply(trigger)) >= 0) {
+ log.info("[ProfitRecycle] 🔔 空头触发 | pnl={} margin={} ROI={}%", pnl, margin, roi.multiply(hundred()));
+ executeRecycle(Direction.SHORT, shortPositionSize, pnl, shortEntryPrice, price);
+ }
+ }
+ }
+
+ /**
+ * 执行一次完整的盈利回收操作:
+ * 平50%盈利仓 → 利润A → B=A×50% → 计算反方向张数 → 开反向仓
+ */
+ private void executeRecycle(Direction profitableSide,
+ BigDecimal posSize, BigDecimal totalPnl,
+ BigDecimal entryPrice, BigDecimal price) {
+ rebalancing = true;
+ final boolean isLongProfit = (profitableSide == Direction.LONG);
+ final BigDecimal mult = config.getContractMultiplier();
+ final BigDecimal lev = new BigDecimal(config.getLeverage());
+ final String label = isLongProfit ? "多头" : "空头";
+
+ // ---- Step 1: 平50%仓位 ----
+ final int closeQty = Math.max(posSize.divide(two(), 0, RoundingMode.DOWN).intValue(), 1);
+ final BigDecimal priceDiff = isLongProfit ? price.subtract(entryPrice) : entryPrice.subtract(price);
+ final BigDecimal profitA = new BigDecimal(closeQty).multiply(mult).multiply(priceDiff);
+
+ log.info("[ProfitRecycle] ═══ {} 触发回收 ═══", label);
+ log.info("[ProfitRecycle] Step1 平仓: {}张(总{}张) → 预期利润A = {} USDT", closeQty, posSize, profitA);
+
+ // ---- Step 2: B = A × reinvestRatio ----
+ final BigDecimal reinvestRatio = config.getReinvestRatio();
+ final BigDecimal marginB = profitA.multiply(reinvestRatio);
+ log.info("[ProfitRecycle] Step2 拆分: B = {} × {} = {} USDT", profitA, reinvestRatio, marginB);
+
+ // ---- Step 3: 计算反方向张数 (单张保证金法) ----
+ // 单张保证金 = contractMultiplier × entryPrice / leverage
+ final BigDecimal perContractMargin = mult.multiply(entryPrice).divide(lev, 8, RoundingMode.HALF_UP);
+ final int rawQty = marginB.divide(perContractMargin, 0, RoundingMode.DOWN).intValue();
+ final int baseQty = Integer.parseInt(config.getBaseQuantity());
+
+ // 风控1: 反向仓位倍数上限
+ final BigDecimal oppositeSize = isLongProfit ? shortPositionSize : longPositionSize;
+ final int maxQty = baseQty * config.getMaxPositionMultiplier();
+ final int availableSlots = maxQty - oppositeSize.intValue();
+
+ int newQty = Math.max(rawQty, baseQty); // 至少开基础仓位
+ if (availableSlots <= 0) {
+ log.warn("[ProfitRecycle] 🛑 风控1触发: 反方向已达上限 {}张, 跳过加仓", maxQty);
+ rebalancing = false;
+ return;
+ }
+ if (newQty > availableSlots) {
+ newQty = availableSlots;
+ log.info("[ProfitRecycle] 风控1限制: 调整张数 {} → {}", Math.max(rawQty, baseQty), newQty);
+ }
+ final String openSize = String.valueOf(newQty);
+
+ log.info("[ProfitRecycle] Step3 补仓: 单张保证金={} | raw={} | base={} | max={} | final={}张",
+ perContractMargin, rawQty, baseQty, maxQty, openSize);
+
+ // ---- Step 4: 执行平仓 → 回调中开反方向 ----
+ final String closePosSide = isLongProfit ? "long" : "short";
+
+ executor.marketClosePosition(String.valueOf(closeQty), closePosSide,
+ () -> {
+ cumulativePnl = cumulativePnl.add(profitA);
+ cycleCount++;
+ updatePositionAfterClose(profitableSide, closeQty);
+
+ log.info("[ProfitRecycle] ✅ 平仓完成 | 累计盈亏: {} | 第{}次循环",
+ cumulativePnl, cycleCount);
+
+ // 开反方向
+ if (!isLongProfit) {
+ executor.openLong(openSize,
+ ordId -> log.info("[ProfitRecycle] 反方向开多{}张 ok ordId:{}", openSize, ordId),
+ () -> log.error("[ProfitRecycle] ❌ 反方向开多{}张失败", openSize));
+ } else {
+ executor.openShort(openSize,
+ ordId -> log.info("[ProfitRecycle] 反方向开空{}张 ok ordId:{}", openSize, ordId),
+ () -> log.error("[ProfitRecycle] ❌ 反方向开空{}张失败", openSize));
+ }
+
+ // 当前仓位状态
+ log.info("[ProfitRecycle] 当前仓位: LONG={}张 SHORT={}张",
+ longPositionSize, shortPositionSize);
+
+ // 风控检查
+ if (checkLossStop()) return;
+ if (checkEquityRestart()) return;
+ rebalancing = false;
+ },
+ () -> {
+ log.error("[ProfitRecycle] ❌ 平仓失败 direction:{}", closePosSide);
+ rebalancing = false;
+ });
+ }
+
+ // ==================== 风控 ====================
+
+ /** 风控2: 全局亏损超限 → 停止策略 */
+ private boolean checkLossStop() {
+ BigDecimal totalPnl = cumulativePnl.add(calcUnrealizedPnl());
+ if (config.getMaxLoss() != null && config.getMaxLoss().compareTo(BigDecimal.ZERO) > 0
+ && totalPnl.compareTo(config.getMaxLoss().negate()) <= 0) {
+ String msg = StrUtil.format("[ProfitRecycle] 🛑 亏损超限! 合计:{} 已实现:{}",
+ totalPnl, cumulativePnl);
+ log.warn(msg);
+ DingTalkUtils.getDefault().sendActionCard("风险提醒", msg, config.getApiKey(), "");
+ stopStrategy();
+ return true;
+ }
+ return false;
+ }
+
+ /** 风控3: 账户权益增长≥5% → 全平重置 */
+ private boolean checkEquityRestart() {
+ BigDecimal equity = fetchCurrentEquity();
+ if (equity.compareTo(BigDecimal.ZERO) <= 0) return false;
+
+ BigDecimal threshold = initialPrincipal.multiply(
+ BigDecimal.ONE.add(config.getEquityRestartRatio()));
+ if (equity.compareTo(threshold) >= 0) {
+ restartCount++;
+ log.info("[ProfitRecycle] 🔄 权益重置触发! 当前权益: {} ≥ 目标: {} (初始: {} + {}%) | 第{}次重置",
+ equity, threshold, initialPrincipal,
+ config.getEquityRestartRatio().multiply(hundred()), restartCount);
+ executeRestart();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 执行权益重置:全平 → 取消所有订单 → 刷新本金 → 重新双开底仓
+ */
+ private void executeRestart() {
+ rebalancing = true;
+ state = StrategyState.RESTARTING;
+ log.info("[ProfitRecycle] 开始重置: 平所有仓位...");
+
+ executor.cancelAllPriceTriggeredOrders();
+ // 全平多空
+ if (longPositionSize.compareTo(BigDecimal.ZERO) > 0) {
+ executor.marketClosePosition(longPositionSize.toPlainString(), "long", null, null);
+ }
+ if (shortPositionSize.compareTo(BigDecimal.ZERO) > 0) {
+ executor.marketClosePosition(shortPositionSize.toPlainString(), "short", null, null);
+ }
+
+ // 延迟后重新开仓
+ executor.submitTask(() -> {
+ try { Thread.sleep(2000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
+ refreshInitialPrincipal();
+ resetState();
+ state = StrategyState.OPENING;
+ final String size = config.getBaseQuantity();
+ log.info("[ProfitRecycle] 🔄 重置开仓: 多空各{}张, 新本金: {} USDT", size, initialPrincipal);
+ executor.openLong(size, ordId -> log.info("[ProfitRecycle] 重置多仓 ordId:{}", ordId), null);
+ executor.openShort(size, ordId -> log.info("[ProfitRecycle] 重置空仓 ordId:{}", ordId), null);
+ rebalancing = false;
+ // 等待 WS 仓位确认后 tryActivate()
+ });
+ }
+
+ // ==================== 辅助 ====================
+
+ private BigDecimal calcMargin(BigDecimal size, BigDecimal entry) {
+ return size.multiply(config.getContractMultiplier())
+ .multiply(entry)
+ .divide(new BigDecimal(config.getLeverage()), 8, RoundingMode.HALF_UP);
+ }
+
+ private BigDecimal calcUnrealizedPnl() {
+ BigDecimal price = resolvePrice();
+ if (price.compareTo(BigDecimal.ZERO) <= 0) return BigDecimal.ZERO;
+ BigDecimal m = config.getContractMultiplier();
+ BigDecimal lp = BigDecimal.ZERO, sp = BigDecimal.ZERO;
+ if (longPositionSize.compareTo(BigDecimal.ZERO) > 0 && longEntryPrice.compareTo(BigDecimal.ZERO) > 0)
+ lp = longPositionSize.multiply(m).multiply(price.subtract(longEntryPrice));
+ if (shortPositionSize.compareTo(BigDecimal.ZERO) > 0 && shortEntryPrice.compareTo(BigDecimal.ZERO) > 0)
+ sp = shortPositionSize.multiply(m).multiply(shortEntryPrice.subtract(price));
+ return lp.add(sp);
+ }
+
+ private BigDecimal resolvePrice() {
+ return (config.getUnrealizedPnlPriceMode() == OkxConfig.PnLPriceMode.MARK_PRICE
+ && markPrice.compareTo(BigDecimal.ZERO) > 0) ? markPrice : lastPrice;
+ }
+
+ private BigDecimal fetchCurrentEquity() {
+ try {
+ JSONObject account = executorGet("/api/v5/account/balance");
+ JSONArray details = account.getJSONArray("data").getJSONObject(0).getJSONArray("details");
+ if (details != null) for (int i = 0; i < details.size(); i++) {
+ if ("USDT".equals(details.getJSONObject(i).getString("ccy")))
+ return details.getJSONObject(i).getBigDecimal("eq");
+ }
+ } catch (Exception e) { log.warn("[ProfitRecycle] 获取权益失败", e); }
+ return BigDecimal.ZERO;
+ }
+
+ private void refreshInitialPrincipal() {
+ BigDecimal eq = fetchCurrentEquity();
+ if (eq.compareTo(BigDecimal.ZERO) > 0) this.initialPrincipal = eq;
+ }
+
+ private void updatePositionAfterClose(Direction side, int closed) {
+ if (side == Direction.LONG) {
+ longPositionSize = longPositionSize.subtract(new BigDecimal(closed));
+ if (longPositionSize.compareTo(BigDecimal.ZERO) <= 0) {
+ longPositionSize = BigDecimal.ZERO;
+ longEntryPrice = BigDecimal.ZERO;
+ }
+ } else {
+ shortPositionSize = shortPositionSize.subtract(new BigDecimal(closed));
+ if (shortPositionSize.compareTo(BigDecimal.ZERO) <= 0) {
+ shortPositionSize = BigDecimal.ZERO;
+ shortEntryPrice = BigDecimal.ZERO;
+ }
+ }
+ }
+
+ private void tryActivate() {
+ if ((state == StrategyState.OPENING || state == StrategyState.RESTARTING)
+ && longPositionSize.compareTo(BigDecimal.ZERO) > 0
+ && shortPositionSize.compareTo(BigDecimal.ZERO) > 0) {
+ state = StrategyState.ACTIVE;
+ log.info("[ProfitRecycle] ═══ 策略激活 ═══");
+ log.info("[ProfitRecycle] LONG: {}张 @ {} | SHORT: {}张 @ {} | "
+ + "多保证金: {} | 空保证金: {}",
+ longPositionSize, longEntryPrice, shortPositionSize, shortEntryPrice,
+ calcMargin(longPositionSize, longEntryPrice),
+ calcMargin(shortPositionSize, shortEntryPrice));
+ }
+ }
+
+ private void closeExistingPositions() {
+ try {
+ JSONObject resp = executorGet("/api/v5/account/positions?instType=SWAP");
+ JSONArray data = resp.getJSONArray("data");
+ if (data == null || data.isEmpty()) return;
+ for (int i = 0; i < data.size(); i++) {
+ JSONObject pos = data.getJSONObject(i);
+ if (!config.getContract().equals(pos.getString("instId"))) continue;
+ String posVal = pos.getString("pos");
+ if (posVal == null || "0".equals(posVal)) continue;
+ String posSide = pos.getString("posSide");
+ String side = "long".equals(posSide) ? "sell" : "buy";
+ JSONObject body = new JSONObject();
+ body.put("instId", config.getContract());
+ body.put("tdMode", "cross");
+ body.put("side", side);
+ body.put("posSide", posSide);
+ body.put("ordType", "market");
+ body.put("sz", posVal);
+ executorPost("/api/v5/trade/order", body.toJSONString());
+ log.info("[ProfitRecycle] 平旧仓 posSide:{} sz:{}", posSide, posVal);
+ }
+ } catch (Exception e) { log.warn("[ProfitRecycle] 平仓异常", e); }
+ }
+
+ // ==================== REST 快捷 ====================
+
+ private JSONObject executorGet(String path) throws Exception { return executor.okGet(path); }
+
+ private JSONObject executorPost(String path, String body) throws Exception { return executor.okPost(path, body); }
+
+ private static BigDecimal two() { return new BigDecimal("2"); }
+
+ private static BigDecimal hundred() { return new BigDecimal("100"); }
+
+ // ==================== Getters ====================
+
+ public BigDecimal getLastKlinePrice() { return lastPrice; }
+ public BigDecimal getCumulativePnl() { return cumulativePnl; }
+ public StrategyState getState() { return state; }
+ public int getCycleCount() { return cycleCount; }
+ public int getRestartCount() { return restartCount; }
+ public BigDecimal getInitialPrincipal() { return initialPrincipal; }
+ public BigDecimal getLongPositionSize() { return longPositionSize; }
+ public BigDecimal getShortPositionSize() { return shortPositionSize; }
+ public BigDecimal getLongEntryPrice() { return longEntryPrice; }
+ public BigDecimal getShortEntryPrice() { return shortEntryPrice; }
+ @Override
+ public void setWsClient(OkxKlineWebSocketClient wsClient) { this.wsClient = wsClient; }
+}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxTradeExecutor.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxTradeExecutor.java
index 29874b6..9f1d7c2 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxTradeExecutor.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/OkxTradeExecutor.java
@@ -330,6 +330,50 @@
}
/**
+ * 对外暴露的市价平仓接口(含回调),供策略层直接调用。
+ *
+ * @param size 平仓张数(正数)
+ * @param posSide 持仓方向(long=平多 / short=平空)
+ * @param onSuccess 成功回调(可为 null)
+ * @param onFailure 失败回调(可为 null)
+ */
+ public void marketClosePosition(String size, String posSide,
+ Runnable onSuccess, Runnable onFailure) {
+ executor.execute(() -> {
+ String side = "long".equals(posSide) ? "sell" : "buy";
+ try {
+ JSONObject body = new JSONObject();
+ body.put("instId", contract);
+ body.put("tdMode", "cross");
+ body.put("side", side);
+ body.put("posSide", posSide);
+ body.put("ordType", "market");
+ body.put("sz", size);
+
+ JSONObject resp = okPost("/api/v5/trade/order", body.toJSONString());
+ String code = resp.getString("code");
+ if (!"0".equals(code)) {
+ log.error("[TradeExec-OKX] 市价平仓失败, side:{}, posSide:{}, sz:{}, code:{}, msg:{}",
+ side, posSide, size, code, resp.getString("msg"));
+ if (onFailure != null) {
+ onFailure.run();
+ }
+ return;
+ }
+ log.info("[TradeExec-OKX] 市价平仓成功, side:{}, posSide:{}, sz:{}", side, posSide, size);
+ if (onSuccess != null) {
+ onSuccess.run();
+ }
+ } catch (Exception e) {
+ log.error("[TradeExec-OKX] 市价平仓失败, side:{}, posSide:{}, sz:{}", side, posSide, size, e);
+ if (onFailure != null) {
+ onFailure.run();
+ }
+ }
+ });
+ }
+
+ /**
* 指定方向的市价平仓。
*
* @param sz 平仓张数
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientMain.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientMain.java
deleted file mode 100644
index 5e8823e..0000000
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientMain.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.xcong.excoin.modules.okxApi;
-
-import com.xcong.excoin.modules.okxApi.wsHandler.handler.MarkPriceOkxChannelHandler;
-import com.xcong.excoin.modules.okxApi.wsHandler.handler.OrdersOkxChannelHandler;
-import com.xcong.excoin.modules.okxApi.wsHandler.handler.PositionsOkxChannelHandler;
-
-import java.math.BigDecimal;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * OKX 网格策略独立启动入口(用于测试或非 Spring 环境)。
- *
- * @author Administrator
- */
-public class OkxWebSocketClientMain {
-
- public static void main(String[] args) throws InterruptedException {
- OkxConfig config = OkxConfig.builder()
- .apiKey("YOUR_OKX_API_KEY")
- .apiSecret("YOUR_OKX_API_SECRET")
- .passphrase("YOUR_OKX_PASSPHRASE")
- .contract("ETH-USDT-SWAP")
- .leverage("100")
- .marginMode("cross")
- .positionMode("long_short_mode")
- .gridRate(new BigDecimal("0.003"))
- .expectedProfit(new BigDecimal("25"))
- .maxLoss(new BigDecimal("15"))
- .baseQuantity("15")
- .quantity("15")
- .restartGridSpan(6)
- .priceScale(2)
- .contractMultiplier(new BigDecimal("0.01"))
- .isProduction(false)
- .build();
-
- OkxGridTradeService gridTradeService = new OkxGridTradeService(config);
- gridTradeService.init();
-
- OkxKlineWebSocketClient wsClient = new OkxKlineWebSocketClient(config);
-
- wsClient.addPublicHandler(new MarkPriceOkxChannelHandler(
- config.getContract(), gridTradeService));
- wsClient.addPrivateHandler(new PositionsOkxChannelHandler(
- config, gridTradeService));
- wsClient.addPrivateHandler(new OrdersOkxChannelHandler(
- config, gridTradeService));
-
- gridTradeService.setWsClient(wsClient);
- wsClient.init();
-
- gridTradeService.startGrid();
-
- // 保持主线程不退出
- CountDownLatch latch = new CountDownLatch(1);
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- gridTradeService.stopGrid();
- wsClient.destroy();
- latch.countDown();
- }));
- latch.await();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientManager.java b/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientManager.java
index 0ea9325..8959797 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientManager.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/OkxWebSocketClientManager.java
@@ -11,28 +11,55 @@
import java.math.BigDecimal;
/**
- * OKX 模块 Spring 容器入口 — 组件组装 + 生命周期管理。
+ * OKX 盈利回收策略 — 唯一入口,所有参数集中在此。
*
- * <h3>组装顺序({@code @PostConstruct})</h3>
- * <ol>
- * <li>{@link OkxConfig} — 构建配置(API 密钥、合约、策略参数)</li>
- * <li>{@link OkxGridTradeService} — init():切双向持仓 → 清旧条件单 → 平仓 → 设杠杆</li>
- * <li>{@link OkxKlineWebSocketClient} — 注册 3 个频道处理器 → init():建立 WS 连接并订阅</li>
- * <li>{@code gridTradeService.startGrid()} — 状态重置,等待首根 K 线</li>
- * </ol>
+ * <pre>
+ * ┌─────────────────────────────────────────────────────────────────┐
+ * │ 🔧 全部参数在此修改 │
+ * ├──────────────────┬──────────────────────────────────────────────┤
+ * │ 参数名 │ 值 │ 说明 │
+ * ├──────────────────┼──────────────────────────────────────┼────────┤
+ * │ apiKey │ ac76252d-... │ API密钥 │
+ * │ apiSecret │ A8168543... │ 签名密钥│
+ * │ passphrase │ Aa12345678@ │ 口令密码│
+ * ├──────────────────┼──────────────────────────────────────┼────────┤
+ * │ contract │ BTC-USDT-SWAP │ 交易合约│
+ * │ leverage │ 50 │ 杠杆倍数│
+ * │ baseQuantity │ 10 │ 底仓张数│
+ * ├──────────────────┼──────────────────────────────────────┼────────┤
+ * │ profitTriggerRatio│ 0.5 │ 触发ROI │
+ * │ reinvestRatio │ 0.5 │ 补仓比例│
+ * ├──────────────────┼──────────────────────────────────────┼────────┤
+ * │ maxPositionMult │ 10 (= base×10 = 100张上限) │ 风控1 │
+ * │ maxLoss │ 15 USDT │ 风控2 │
+ * │ equityRestartRatio│ 0.05 (= 5%) │ 风控3 │
+ * ├──────────────────┼──────────────────────────────────────┼────────┤
+ * │ contractMult │ 0.01 (BTC 每张0.01个币) │ 合约乘数│
+ * │ priceScale │ 2 (价格精度0.01) │ 价格精度│
+ * │ pnlPriceMode │ LAST_PRICE │ 盈亏计价│
+ * │ isProduction │ false (false=模拟盘) │ 交易环境│
+ * └──────────────────┴──────────────────────────────────────────────┘
+ * </pre>
*
- * <h3>3 个频道处理器</h3>
- * <ol>
- * <li>MarkPriceOkxChannelHandler — 公开频道,标记价格 → onKline() + setMarkPrice()</li>
- * <li>PositionsOkxChannelHandler — 私有频道,仓位 → onPositionUpdate()</li>
- * <li>OrdersOkxChannelHandler — 私有频道,订单成交(含algoId) → onAutoOrder()</li>
- * </ol>
+ * <h3>策略核心公式</h3>
+ * <ul>
+ * <li>保证金 = 张数 × 合约乘数 × 开仓均价 / 杠杆</li>
+ * <li>ROI = 未实现盈亏 / 该方向保证金</li>
+ * <li>触发条件:ROI ≥ profitTriggerRatio</li>
+ * <li>平仓:floor(盈利仓位张数 / 2)</li>
+ * <li>补仓保证金 B = 已实现利润 × reinvestRatio</li>
+ * <li>单张保证金 = 合约乘数 × 开仓均价 / 杠杆</li>
+ * <li>补仓张数 = max(baseQuantity, floor(B / 单张保证金))</li>
+ * </ul>
*
- * <h3>销毁顺序({@code @PreDestroy})</h3>
- * <ol>
- * <li>gridTradeService.stopGrid():取消所有条件单 → 关闭交易线程池</li>
- * <li>wsClient.destroy():取消订阅 → 断开 WS → 关闭线程池</li>
- * </ol>
+ * <h3>仓位演化示例 (BTC-USDT-SWAP, 50x, base10)</h3>
+ * <pre>
+ * 初始: LONG=10 SHORT=10
+ * 多盈: LONG=5 SHORT=12
+ * 多盈: LONG=3 SHORT=15
+ * 多盈: LONG=2 SHORT=18
+ * → 权益达+5% → 全平重置 → LONG=10 SHORT=10
+ * </pre>
*
* @author Administrator
*/
@@ -40,78 +67,117 @@
@Component
public class OkxWebSocketClientManager {
+ // ╔══════════════════════════════════════════════════════════════╗
+ // ║ 🔐 OKX API 认证信息 ║
+ // ╚══════════════════════════════════════════════════════════════╝
+ private static final String OKX_API_KEY = "ac76252d-e717-4459-a6f9-80512aed5ea0";
+ private static final String OKX_API_SECRET = "A8168543EF4F08A6DBFE27AB23956898";
+ private static final String OKX_PASSPHRASE = "Aa12345678@";
+
+ // ╔══════════════════════════════════════════════════════════════╗
+ // ║ 📊 交易标的参数 ║
+ // ╚══════════════════════════════════════════════════════════════╝
+ private static final String CONTRACT = "BTC-USDT-SWAP"; // 合约名称
+ private static final String LEVERAGE = "50"; // 杠杆倍数
+ private static final String MARGIN_MODE = "cross"; // 全仓 cross / 逐仓 isolated
+ private static final String POSITION_MODE = "long_short_mode"; // 双向持仓
+
+ // ╔══════════════════════════════════════════════════════════════╗
+ // ║ 🎯 策略核心参数 ║
+ // ╚══════════════════════════════════════════════════════════════╝
+ /** 基础仓位张数 — 初始化时多空各开此张数,也是最小开仓单位 */
+ private static final String BASE_QUANTITY = "10";
+ /** 盈利触发比例 — ROI=未实现盈亏/保证金 达到此值时触发平仓 */
+ private static final BigDecimal PROFIT_TRIGGER_RATIO = new BigDecimal("0.5"); // 50%
+ /** 再投资比例 — 已实现利润中用于补反向仓的比例 */
+ private static final BigDecimal REINVEST_RATIO = new BigDecimal("0.5"); // 50%
+
+ // ╔══════════════════════════════════════════════════════════════╗
+ // ║ 🛡 风控参数 ║
+ // ╚══════════════════════════════════════════════════════════════╝
+ /** 风控1: 反向仓位倍数上限 — 反向最大持仓 = baseQuantity × 此值 (10×10=100张) */
+ private static final int MAX_POSITION_MULTIPLIER = 10;
+ /** 风控2: 最大亏损阈值(USDT) — 全局盈亏≤-此值时停止策略 */
+ private static final BigDecimal MAX_LOSS = new BigDecimal("15");
+ /** 风控3: 权益重置比例 — 账户权益 ≥ 初始权益 × (1+此值) 时全平重新双开 */
+ private static final BigDecimal EQUITY_RESTART_RATIO = new BigDecimal("0.05"); // 5%
+
+ // ╔══════════════════════════════════════════════════════════════╗
+ // ║ ⚙ 技术与环境参数 ║
+ // ╚══════════════════════════════════════════════════════════════╝
+ /** 合约乘数 — BTC-USDT-SWAP 每张=0.01 BTC */
+ private static final BigDecimal CONTRACT_MULTIPLIER = new BigDecimal("0.01");
+ /** 价格精度 — OKX 价格小数位数 (BTC=2, ETH=2) */
+ private static final int PRICE_SCALE = 2;
+ /** 盈亏计价模式 — LAST_PRICE(最新价) / MARK_PRICE(标记价) */
+ private static final OkxConfig.PnLPriceMode PNL_PRICE_MODE = OkxConfig.PnLPriceMode.LAST_PRICE;
+ /** false=模拟盘 (wspap.okx.com) / true=实盘 (ws.okx.com) */
+ private static final boolean IS_PRODUCTION = false;
+
+ // ==================== 以下为启动代码,通常无需修改 ====================
+
private OkxKlineWebSocketClient wsClient;
- private OkxGridTradeService gridTradeService;
+ private OkxProfitRecycleStrategy strategy;
private OkxConfig config;
@PostConstruct
public void init() {
- log.info("[OKX管理器] 开始初始化...");
+ log.info("[OKX] 正在初始化盈利回收策略...");
try {
- // TODO: 替换为实际 API 密钥
config = OkxConfig.builder()
- .apiKey("ac76252d-e717-4459-a6f9-80512aed5ea0")
- .apiSecret("A8168543EF4F08A6DBFE27AB23956898")
- .passphrase("Aa12345678@")
- .contract("ETH-USDT-SWAP")
- .leverage("100")
- .marginMode("cross")
- .positionMode("long_short_mode")
- .gridRate(new BigDecimal("0.0025"))
- .expectedProfit(new BigDecimal("25"))
- .maxLoss(new BigDecimal("15"))
- .baseQuantity("1")
- .quantity("1")
- .restartGridSpan(6)
- .maxPositionSize(2)
- .priceScale(2)
- .contractMultiplier(new BigDecimal("0.01"))
- .unrealizedPnlPriceMode(OkxConfig.PnLPriceMode.LAST_PRICE)
- .isProduction(false)
- .reopenMaxRetries(3)
+ .apiKey(OKX_API_KEY)
+ .apiSecret(OKX_API_SECRET)
+ .passphrase(OKX_PASSPHRASE)
+ .contract(CONTRACT)
+ .leverage(LEVERAGE)
+ .marginMode(MARGIN_MODE)
+ .positionMode(POSITION_MODE)
+ .baseQuantity(BASE_QUANTITY)
+ .maxLoss(MAX_LOSS)
+ .priceScale(PRICE_SCALE)
+ .contractMultiplier(CONTRACT_MULTIPLIER)
+ .unrealizedPnlPriceMode(PNL_PRICE_MODE)
+ .isProduction(IS_PRODUCTION)
+ .profitTriggerRatio(PROFIT_TRIGGER_RATIO)
+ .reinvestRatio(REINVEST_RATIO)
+ .maxPositionMultiplier(MAX_POSITION_MULTIPLIER)
+ .equityRestartRatio(EQUITY_RESTART_RATIO)
.build();
- // 1. 初始化交易服务
- gridTradeService = new OkxGridTradeService(config);
- gridTradeService.init();
+ strategy = new OkxProfitRecycleStrategy(config);
+ strategy.init();
- // 2. 创建 WS 客户端并注册频道处理器
wsClient = new OkxKlineWebSocketClient(config);
+ wsClient.addPublicHandler(new MarkPriceOkxChannelHandler(config.getContract(), strategy));
+ wsClient.addPrivateHandler(new PositionsOkxChannelHandler(config, strategy));
+ wsClient.addPrivateHandler(new OrdersOkxChannelHandler(config, strategy));
- // 公开频道:标记价格(替代 K 线,同时驱动策略 onKline 和 PnL 计算)
- wsClient.addPublicHandler(new MarkPriceOkxChannelHandler(
- config.getContract(), gridTradeService));
- // 私有频道:仓位
- wsClient.addPrivateHandler(new PositionsOkxChannelHandler(
- config, gridTradeService));
- // 私有频道:条件单(orders 频道含 algoId,可追溯到源条件单)
- wsClient.addPrivateHandler(new OrdersOkxChannelHandler(
- config, gridTradeService));
-
- gridTradeService.setWsClient(wsClient);
+ strategy.setWsClient(wsClient);
wsClient.init();
- log.info("[OKX管理器] WS已连接, 已注册 3 个频道处理器");
+ log.info("[OKX] WS已连接 | 合约: {} | 杠杆: {}x | 基础张数: {} | "
+ + "触发ROI: {}% | 补仓比例: {}% | 仓位上限: {}x | 重置阈值: {}%",
+ CONTRACT, LEVERAGE, BASE_QUANTITY,
+ PROFIT_TRIGGER_RATIO.multiply(new BigDecimal("100")),
+ REINVEST_RATIO.multiply(new BigDecimal("100")),
+ MAX_POSITION_MULTIPLIER,
+ EQUITY_RESTART_RATIO.multiply(new BigDecimal("100")));
- // 3. 激活策略
- gridTradeService.startGrid();
+ strategy.startStrategy();
} catch (Exception e) {
- log.error("[OKX管理器] 初始化失败", e);
+ log.error("[OKX] 初始化失败", e);
}
}
@PreDestroy
public void destroy() {
- log.info("[OKX管理器] 开始销毁...");
- if (gridTradeService != null) {
- gridTradeService.stopGrid();
- }
- if (wsClient != null) {
- wsClient.destroy();
- }
- log.info("[OKX管理器] 销毁完成");
+ log.info("[OKX] 正在销毁...");
+ if (strategy != null) strategy.stopStrategy();
+ if (wsClient != null) wsClient.destroy();
+ log.info("[OKX] 销毁完成");
}
public OkxKlineWebSocketClient getKlineWebSocketClient() { return wsClient; }
- public OkxGridTradeService getGridTradeService() { return gridTradeService; }
+ public OkxProfitRecycleStrategy getStrategy() { return strategy; }
+ public IOkxStrategy getActiveStrategy() { return strategy; }
}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/TraderParam.java b/src/main/java/com/xcong/excoin/modules/okxApi/TraderParam.java
deleted file mode 100644
index 3a7bf58..0000000
--- a/src/main/java/com/xcong/excoin/modules/okxApi/TraderParam.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package com.xcong.excoin.modules.okxApi;
-
-import java.math.BigDecimal;
-
-/**
- * 单笔挂单的完整参数,封装条件开仓单及止盈单的状态。
- *
- * <h3>定位</h3>
- * 每个 GridElement 内嵌两个 TraderParam(longTraderParam / shortTraderParam),
- * 分别记录该价格层级上多仓和空仓的挂单参数。所有字段通过 getter/setter
- * 在挂单/成交/止盈各阶段逐步填充。
- *
- * <h3>字段分组</h3>
- * <table>
- * <tr><th>类别</th><th>字段</th><th>生命周期</th></tr>
- * <tr><td>开仓准备</td><td>direction, entryPrice, quantity</td><td>updateGridElements() 预填充</td></tr>
- * <tr><td>止盈预定</td><td>takeProfitPrice</td><td>updateGridElements() 预填充(entryPrice ± (step - minTick))</td></tr>
- * <tr><td>挂单确认</td><td>entryOrderPlaced, entryOrderId</td><td>条件单挂成功后由 longEntryTraderIdParam 等写入</td></tr>
- * <tr><td>止盈确认</td><td>takeProfitPlaced, takeProfitOrderId</td><td>止盈单挂成功后由 longTakeProfitTraderIdParam 等写入</td></tr>
- * <tr><td>定位</td><td>entryGridPosition, takeProfitGridPosition</td><td>当前策略中由 upId/downId 替代</td></tr>
- * </table>
- *
- * <h3>盈利公式(正向合约)</h3>
- * <pre>
- * 多仓止盈盈利 = takeProfitPrice - entryPrice = (entryPrice + step - minTick) - entryPrice = step - minTick
- * 空仓止盈盈利 = entryPrice - takeProfitPrice = entryPrice - (entryPrice - step + minTick) = step - minTick
- * </pre>
- *
- * @author Administrator
- */
-public class TraderParam {
-
- /**
- * 交易方向。
- * <ul>
- * <li>{@link #LONG} — 多头</li>
- * <li>{@link #SHORT} — 空头</li>
- * </ul>
- */
- public enum Direction {
- /** 多头方向 */
- LONG,
- /** 空头方向 */
- SHORT
- }
-
- /** 交易方向(多 / 空) */
- private Direction direction;
- /** 下单数量(合约张数) */
- private String quantity;
- /** 挂单价在网格队列中的位置(索引,-1 表示未定位) */
- private int entryGridPosition;
- /** 条件开仓触发价 */
- private BigDecimal entryPrice;
- /** 挂单(条件开仓单)订单 ID */
- private String entryOrderId;
- /** 挂单价(条件开仓单)是否挂成功 */
- private boolean entryOrderPlaced;
- /** 止盈价在网格队列中的位置(索引,-1 表示未定位) */
- private int takeProfitGridPosition;
- /** 止盈触发价 */
- private BigDecimal takeProfitPrice;
- /** 止盈条件单订单 ID */
- private String takeProfitOrderId;
- /** 止盈价是否挂成功 */
- private boolean takeProfitPlaced;
-
- private TraderParam(Builder builder) {
- this.direction = builder.direction;
- this.entryPrice = builder.entryPrice;
- this.takeProfitPrice = builder.takeProfitPrice;
- this.quantity = builder.quantity;
- this.takeProfitPlaced = builder.takeProfitPlaced;
- this.entryOrderPlaced = builder.entryOrderPlaced;
- this.entryGridPosition = builder.entryGridPosition;
- this.takeProfitGridPosition = builder.takeProfitGridPosition;
- this.takeProfitOrderId = builder.takeProfitOrderId;
- this.entryOrderId = builder.entryOrderId;
- }
-
- // ==================== 交易方向 ====================
-
- /** @return 交易方向(多 / 空) */
- public Direction getDirection() { return direction; }
- /** 设置交易方向 */
- public void setDirection(Direction direction) { this.direction = direction; }
-
- // ==================== 条件开仓触发价 ====================
-
- /** @return 条件开仓触发价 */
- public BigDecimal getEntryPrice() { return entryPrice; }
- /** 设置条件开仓触发价 */
- public void setEntryPrice(BigDecimal entryPrice) { this.entryPrice = entryPrice; }
-
- // ==================== 止盈触发价 ====================
-
- /** @return 止盈触发价 */
- public BigDecimal getTakeProfitPrice() { return takeProfitPrice; }
- /** 设置止盈触发价 */
- public void setTakeProfitPrice(BigDecimal takeProfitPrice) { this.takeProfitPrice = takeProfitPrice; }
-
- // ==================== 下单数量 ====================
-
- /** @return 下单数量(合约张数) */
- public String getQuantity() { return quantity; }
- /** 设置下单数量 */
- public void setQuantity(String quantity) { this.quantity = quantity; }
-
- // ==================== 挂单价网格位置 ====================
-
- /** @return 挂单价在网格队列中的索引位置,-1 表示未定位 */
- public int getEntryGridPosition() { return entryGridPosition; }
- /** 设置挂单价在网格队列中的索引位置 */
- public void setEntryGridPosition(int entryGridPosition) { this.entryGridPosition = entryGridPosition; }
-
- // ==================== 止盈价网格位置 ====================
-
- /** @return 止盈价在网格队列中的索引位置,-1 表示未定位 */
- public int getTakeProfitGridPosition() { return takeProfitGridPosition; }
- /** 设置止盈价在网格队列中的索引位置 */
- public void setTakeProfitGridPosition(int takeProfitGridPosition) { this.takeProfitGridPosition = takeProfitGridPosition; }
-
- // ==================== 止盈价是否挂成功 ====================
-
- /** @return 止盈条件单是否已挂成功 */
- public boolean isTakeProfitPlaced() { return takeProfitPlaced; }
- /** 标记止盈条件单已挂成功 */
- public void setTakeProfitPlaced(boolean takeProfitPlaced) { this.takeProfitPlaced = takeProfitPlaced; }
-
- // ==================== 挂单价是否挂成功 ====================
-
- /** @return 条件开仓单是否已挂成功 */
- public boolean isEntryOrderPlaced() { return entryOrderPlaced; }
- /** 标记条件开仓单已挂成功 */
- public void setEntryOrderPlaced(boolean entryOrderPlaced) { this.entryOrderPlaced = entryOrderPlaced; }
-
- // ==================== 止盈订单 ID ====================
-
- /** @return 止盈条件单订单 ID(挂成功后由交易所返回) */
- public String getTakeProfitOrderId() { return takeProfitOrderId; }
- /** 记录止盈条件单订单 ID */
- public void setTakeProfitOrderId(String takeProfitOrderId) { this.takeProfitOrderId = takeProfitOrderId; }
-
- // ==================== 挂单订单 ID ====================
-
- /** @return 挂单(条件开仓单)订单 ID(挂成功后由交易所返回) */
- public String getEntryOrderId() { return entryOrderId; }
- /** 记录条件开仓单订单 ID */
- public void setEntryOrderId(String entryOrderId) { this.entryOrderId = entryOrderId; }
-
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * TraderParam 的流式构造器。
- *
- * <h3>必填项</h3>
- * {@code direction}、{@code entryPrice}、{@code takeProfitPrice} 必须设置。
- *
- * <h3>默认值</h3>
- * quantity=1 / entryGridPosition=-1 / takeProfitGridPosition=-1 / 挂单状态均为 false
- */
- public static class Builder {
- /** 交易方向(必填) */
- private Direction direction;
- /** 条件开仓触发价(必填) */
- private BigDecimal entryPrice;
- /** 止盈触发价(必填) */
- private BigDecimal takeProfitPrice;
- /** 下单数量,默认 "1" */
- private String quantity = "1";
- /** 止盈价是否挂成功,默认 false */
- private boolean takeProfitPlaced = false;
- /** 挂单价是否挂成功,默认 false */
- private boolean entryOrderPlaced = false;
- /** 挂单价网格位置,默认 -1(未定位) */
- private int entryGridPosition = -1;
- /** 止盈价网格位置,默认 -1(未定位) */
- private int takeProfitGridPosition = -1;
- /** 止盈订单 ID */
- private String takeProfitOrderId;
- /** 挂单订单 ID */
- private String entryOrderId;
-
- /** 设置交易方向(多 / 空) */
- public Builder direction(Direction direction) { this.direction = direction; return this; }
- /** 设置条件开仓触发价 */
- public Builder entryPrice(BigDecimal entryPrice) { this.entryPrice = entryPrice; return this; }
- /** 设置止盈触发价 */
- public Builder takeProfitPrice(BigDecimal takeProfitPrice) { this.takeProfitPrice = takeProfitPrice; return this; }
- /** 设置下单数量(合约张数) */
- public Builder quantity(String quantity) { this.quantity = quantity; return this; }
- /** 设置止盈价是否已挂成功 */
- public Builder takeProfitPlaced(boolean takeProfitPlaced) { this.takeProfitPlaced = takeProfitPlaced; return this; }
- /** 设置挂单价是否已挂成功 */
- public Builder entryOrderPlaced(boolean entryOrderPlaced) { this.entryOrderPlaced = entryOrderPlaced; return this; }
- /** 设置挂单价在网格队列中的索引位置 */
- public Builder entryGridPosition(int entryGridPosition) { this.entryGridPosition = entryGridPosition; return this; }
- /** 设置止盈价在网格队列中的索引位置 */
- public Builder takeProfitGridPosition(int takeProfitGridPosition) { this.takeProfitGridPosition = takeProfitGridPosition; return this; }
- /** 设置止盈条件单订单 ID */
- public Builder takeProfitOrderId(String takeProfitOrderId) { this.takeProfitOrderId = takeProfitOrderId; return this; }
- /** 设置挂单(条件开仓单)订单 ID */
- public Builder entryOrderId(String entryOrderId) { this.entryOrderId = entryOrderId; return this; }
-
- public TraderParam build() {
- return new TraderParam(this);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/AbstractOkxPrivateChannelHandler.java b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/AbstractOkxPrivateChannelHandler.java
index ce9f6c9..428bdbe 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/AbstractOkxPrivateChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/AbstractOkxPrivateChannelHandler.java
@@ -2,7 +2,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.modules.okxApi.OkxGridTradeService;
+import com.xcong.excoin.modules.okxApi.IOkxStrategy;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
@@ -54,8 +54,8 @@
/** 交易对标识,如 "ETH-USDT-SWAP" */
private final String instId;
- /** 网格交易服务实例 */
- private final OkxGridTradeService gridTradeService;
+ /** 策略服务实例 */
+ private final IOkxStrategy strategy;
/** 订阅确认状态 */
private volatile boolean subscribed = false;
@@ -63,24 +63,24 @@
/**
* 构造私有频道处理器。
*
- * @param channelName 频道名称(如 "positions"、"orders-algo")
- * @param apiKey OKX API Key
- * @param apiSecret OKX API Secret
- * @param passphrase OKX API Passphrase
- * @param instId 交易对标识(如 "ETH-USDT-SWAP")
- * @param gridTradeService 网格交易服务实例
+ * @param channelName 频道名称(如 "positions"、"orders-algo")
+ * @param apiKey OKX API Key
+ * @param apiSecret OKX API Secret
+ * @param passphrase OKX API Passphrase
+ * @param instId 交易对标识(如 "ETH-USDT-SWAP")
+ * @param strategy OKX 交易策略服务实例
*/
public AbstractOkxPrivateChannelHandler(String channelName,
String apiKey, String apiSecret,
String passphrase,
String instId,
- OkxGridTradeService gridTradeService) {
+ IOkxStrategy strategy) {
this.channelName = channelName;
this.apiKey = apiKey;
this.apiSecret = apiSecret;
this.passphrase = passphrase;
this.instId = instId;
- this.gridTradeService = gridTradeService;
+ this.strategy = strategy;
}
/**
@@ -140,10 +140,10 @@
}
/**
- * @return 网格交易服务实例
+ * @return 策略服务实例
*/
- protected OkxGridTradeService getGridTradeService() {
- return gridTradeService;
+ protected IOkxStrategy getStrategy() {
+ return strategy;
}
// ==================== 订阅状态 ====================
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/MarkPriceOkxChannelHandler.java b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/MarkPriceOkxChannelHandler.java
index cdcd091..ba97075 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/MarkPriceOkxChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/MarkPriceOkxChannelHandler.java
@@ -2,7 +2,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.modules.okxApi.OkxGridTradeService;
+import com.xcong.excoin.modules.okxApi.IOkxStrategy;
import com.xcong.excoin.modules.okxApi.wsHandler.OkxChannelHandler;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
@@ -19,8 +19,8 @@
*
* <h3>双回调</h3>
* <ul>
- * <li>{@link OkxGridTradeService#onKline(BigDecimal)} — 驱动网格策略(处理开仓/止盈逻辑)</li>
- * <li>{@link OkxGridTradeService#setMarkPrice(BigDecimal)} — PnLPriceMode.MARK_PRICE 计算未实现盈亏</li>
+ * <li>{@link IOkxStrategy#onKline(BigDecimal)} — 驱动策略(处理开仓/止盈逻辑)</li>
+ * <li>{@link IOkxStrategy#setMarkPrice(BigDecimal)} — PnLPriceMode.MARK_PRICE 计算未实现盈亏</li>
* </ul>
*
* <h3>订阅格式</h3>
@@ -58,8 +58,8 @@
/** 交易对标识,如 "ETH-USDT-SWAP" */
private final String instId;
- /** 网格交易服务,接收标记价格回调 */
- private final OkxGridTradeService gridTradeService;
+ /** 策略服务实例,接收标记价格回调 */
+ private final IOkxStrategy strategy;
/** 订阅确认状态 */
private volatile boolean subscribed = false;
@@ -67,12 +67,12 @@
/**
* 构造标记价格频道处理器。
*
- * @param instId 交易对标识(如 "ETH-USDT-SWAP")
- * @param gridTradeService OKX 网格交易策略服务实例
+ * @param instId 交易对标识(如 "ETH-USDT-SWAP")
+ * @param strategy OKX 交易策略服务实例
*/
- public MarkPriceOkxChannelHandler(String instId, OkxGridTradeService gridTradeService) {
+ public MarkPriceOkxChannelHandler(String instId, IOkxStrategy strategy) {
this.instId = instId;
- this.gridTradeService = gridTradeService;
+ this.strategy = strategy;
}
/**
@@ -164,9 +164,9 @@
}
BigDecimal markPrice = new BigDecimal(markPxStr);
- if (gridTradeService != null) {
- gridTradeService.setMarkPrice(markPrice);
- gridTradeService.onKline(markPrice);
+ if (strategy != null) {
+ strategy.setMarkPrice(markPrice);
+ strategy.onKline(markPrice);
}
} catch (Exception e) {
log.error("[OKX-WS] 处理 mark-price 数据失败", e);
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/OrdersOkxChannelHandler.java b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/OrdersOkxChannelHandler.java
index abe2bd0..e61f808 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/OrdersOkxChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/OrdersOkxChannelHandler.java
@@ -2,8 +2,8 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.modules.okxApi.IOkxStrategy;
import com.xcong.excoin.modules.okxApi.OkxConfig;
-import com.xcong.excoin.modules.okxApi.OkxGridTradeService;
import com.xcong.excoin.modules.okxApi.wsHandler.AbstractOkxPrivateChannelHandler;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
@@ -70,14 +70,14 @@
/**
* 构造订单频道处理器。
*
- * @param config OKX 配置实例
- * @param gridTradeService OKX 网格交易策略服务实例
+ * @param config OKX 配置实例
+ * @param strategy OKX 交易策略服务实例
*/
- public OrdersOkxChannelHandler(OkxConfig config, OkxGridTradeService gridTradeService) {
+ public OrdersOkxChannelHandler(OkxConfig config, IOkxStrategy strategy) {
super(CHANNEL_NAME,
config.getApiKey(), config.getApiSecret(), config.getPassphrase(),
config.getContract(),
- gridTradeService);
+ strategy);
this.config = config;
}
@@ -141,8 +141,8 @@
log.info("[OKX-WS] orders fill, algoId:{}, state:filled, orderType:{}, side:{}, posSide:{}, fillSz:{}, tradeId:{}",
algoId, orderType, side, posSide, fillSz, tradeId);
- if (getGridTradeService() != null) {
- getGridTradeService().onAutoOrder(algoId, "finished", state, orderType, tradeId);
+ if (getStrategy() != null) {
+ getStrategy().onAutoOrder(algoId, "finished", state, orderType, tradeId);
}
}
} catch (Exception e) {
diff --git a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/PositionsOkxChannelHandler.java b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/PositionsOkxChannelHandler.java
index a4b78c3..b7b051e 100644
--- a/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/PositionsOkxChannelHandler.java
+++ b/src/main/java/com/xcong/excoin/modules/okxApi/wsHandler/handler/PositionsOkxChannelHandler.java
@@ -2,17 +2,17 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.modules.okxApi.Direction;
+import com.xcong.excoin.modules.okxApi.IOkxStrategy;
import com.xcong.excoin.modules.okxApi.OkxConfig;
-import com.xcong.excoin.modules.okxApi.OkxGridTradeService;
import com.xcong.excoin.modules.okxApi.wsHandler.AbstractOkxPrivateChannelHandler;
-import com.xcong.excoin.modules.okxApi.TraderParam;
import lombok.extern.slf4j.Slf4j;
import java.math.BigDecimal;
/**
* OKX 仓位频道处理器(positions),接收仓位更新推送并回调
- * {@link OkxGridTradeService#onPositionUpdate(String, TraderParam.Direction, BigDecimal, BigDecimal)}。
+ * {@link IOkxStrategy#onPositionUpdate(String, Direction, BigDecimal, BigDecimal)}。
*
* <h3>订阅格式</h3>
* 私有频道,需要先登录认证。订阅 arg 使用 instType: "SWAP"(不指定具体 instId,
@@ -21,24 +21,10 @@
* {"op":"subscribe","args":[{"channel":"positions","instType":"SWAP"}]}
* </pre>
*
- * <h3>数据推送格式</h3>
- * <pre>
- * {
- * "arg": {"channel":"positions","instType":"SWAP"},
- * "data": [{
- * "instId": "ETH-USDT-SWAP",
- * "posSide": "long", // "long" 或 "short"
- * "pos": "1", // 持仓张数
- * "avgPx": "3000", // 开仓均价
- * ...
- * }]
- * }
- * </pre>
- *
* <h3>数据映射</h3>
* <ul>
- * <li>posSide "long" → {@link TraderParam.Direction#LONG},映射为 DUAL_LONG</li>
- * <li>posSide "short" → {@link TraderParam.Direction#SHORT},映射为 DUAL_SHORT</li>
+ * <li>posSide "long" → {@link Direction#LONG}</li>
+ * <li>posSide "short" → {@link Direction#SHORT}</li>
* <li>pos → 持仓张数(绝对值)</li>
* <li>avgPx → 开仓均价</li>
* </ul>
@@ -57,14 +43,14 @@
/**
* 构造仓位频道处理器。
*
- * @param config OKX 配置实例(提供合约名称等)
- * @param gridTradeService OKX 网格交易策略服务实例
+ * @param config OKX 配置实例(提供合约名称等)
+ * @param strategy OKX 交易策略服务实例
*/
- public PositionsOkxChannelHandler(OkxConfig config, OkxGridTradeService gridTradeService) {
+ public PositionsOkxChannelHandler(OkxConfig config, IOkxStrategy strategy) {
super(CHANNEL_NAME,
config.getApiKey(), config.getApiSecret(), config.getPassphrase(),
config.getContract(),
- gridTradeService);
+ strategy);
this.config = config;
}
@@ -107,11 +93,11 @@
// 解析持仓方向:OKX 的 posSide 可以是 "long" 或 "short"
String posSide = posData.getString("posSide");
- TraderParam.Direction direction;
+ Direction direction;
if ("long".equals(posSide)) {
- direction = TraderParam.Direction.LONG;
+ direction = Direction.LONG;
} else if ("short".equals(posSide)) {
- direction = TraderParam.Direction.SHORT;
+ direction = Direction.SHORT;
} else {
log.debug("[OKX-WS] positions 忽略 net 方向: {}", posSide);
continue;
@@ -128,8 +114,8 @@
// log.info("[OKX-WS] positions 持仓更新, instId:{}, posSide:{}, pos:{}, avgPx:{}",
// dataInstId, posSide, size, entryPrice);
- if (getGridTradeService() != null) {
- getGridTradeService().onPositionUpdate(contract, direction, size, entryPrice);
+ if (getStrategy() != null) {
+ getStrategy().onPositionUpdate(contract, direction, size, entryPrice);
}
}
} catch (Exception e) {
diff --git a/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java b/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
deleted file mode 100644
index ccd9d98..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.xcong.excoin.modules.platform.controller;
-
-import javax.annotation.Resource;
-
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.service.PlatformBannerService;
-import com.xcong.excoin.modules.platform.service.PlatformNoticeService;
-import com.xcong.excoin.modules.platform.service.PlatformCnyUsdtExchangeService;
-import com.xcong.excoin.modules.platform.service.PlatformPaymentMethodService;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import lombok.extern.slf4j.Slf4j;
-
-@RestController
-@Slf4j
-@RequestMapping(value = "/api/exchange")
-@Api(value = "PlatformController", tags = "平台系统设置类")
-public class PlatformController {
-
- @Resource
- PlatformCnyUsdtExchangeService platformCnyUsdtExchangeService;
- @Resource
- PlatformPaymentMethodService platformPaymentMethodService;
-
- @Resource
- PlatformBannerService platformBannerService;
-
- @Resource
- PlatformNoticeService PlatformNoticeService;
-
-
- @ApiOperation(value = "findUsdtCnyExchange", notes = "Cny|Usdt兑换")
- @GetMapping(value = "/findUsdtCnyExchange")
- public Result findUsdtCnyExchange(@ApiParam(name = "type", value = "类型", type="string", required=true) @RequestParam("type") String type) {
- log.info("type值----->{}", type);
- return platformCnyUsdtExchangeService.findUsdtCnyExchange(type);
- }
-
- @ApiOperation(value = "findAllPaymentMethod", notes = "查询平台收款方式")
- @GetMapping(value = "/findAllPaymentMethod")
- public Result findAllPaymentMethod() {
- return platformPaymentMethodService.findAll();
- }
-
- @ApiOperation(value = "首页轮播图", notes = "首页轮播图")
- @GetMapping(value = "/findPlatformBannerList")
- public Result findPlatformBannerList() {
- return platformBannerService.findAll();
- }
-
- @ApiOperation(value = "首页公告查询", notes = "首页公告查询")
- @GetMapping(value = "/findPlatformNoticeList")
- public Result findPlatformNoticeList() {
- return PlatformNoticeService.findPlatformNoticeList();
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformBannerDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformBannerDao.java
deleted file mode 100644
index 47bfb50..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformBannerDao.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformBannerEntity;
-
-public interface PlatformBannerDao extends BaseMapper<PlatformBannerEntity> {
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformCnyUsdtExchangeDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformCnyUsdtExchangeDao.java
deleted file mode 100644
index 59171d1..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformCnyUsdtExchangeDao.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-
-import java.math.BigDecimal;
-
-public interface PlatformCnyUsdtExchangeDao extends BaseMapper<PlatformCnyUsdtExchangeEntity> {
-
- PlatformCnyUsdtExchangeEntity getCNYAndUSDTOne();
-
- void updateUsdt(BigDecimal value);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformFeeSettingDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformFeeSettingDao.java
deleted file mode 100644
index 03ea822..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformFeeSettingDao.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity;
-
-public interface PlatformFeeSettingDao extends BaseMapper<PlatformFeeSettingEntity> {
-
- PlatformFeeSettingEntity getFeeSettingByTypeAndSymbolLable(@Param("type")Integer type,@Param("symbol")String symbol,@Param("lable")String lable);
-
- PlatformFeeSettingEntity getFeeSettingByTypeAndSymbol(@Param("type")Integer type,@Param("symbol")String symbol);
-
- List<PlatformFeeSettingEntity> getFeeSettingsByTypeAndSymbol(@Param("type")int i,@Param("symbol")String symbol);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformNoticeDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformNoticeDao.java
deleted file mode 100644
index 5625867..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformNoticeDao.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformNoticeEntity;
-
-public interface PlatformNoticeDao extends BaseMapper<PlatformNoticeEntity> {
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java
deleted file mode 100644
index ecabe6d..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-
-public interface PlatformPaymentMethodDao extends BaseMapper<PlatformPaymentMethodEntity> {
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsCoinDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsCoinDao.java
deleted file mode 100644
index a116b5a..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsCoinDao.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import java.util.List;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.parameter.vo.MemberCoinAddressCountVo;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
-
-public interface PlatformSymbolsCoinDao extends BaseMapper<PlatformSymbolsCoinEntity> {
-
- List<MemberCoinAddressCountVo> selectCoinAddressCount(Long memberId);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsSkuDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsSkuDao.java
deleted file mode 100644
index cf6399b..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformSymbolsSkuDao.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.member.parameter.vo.MemberCoinAddressCountVo;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-public interface PlatformSymbolsSkuDao extends BaseMapper<PlatformSymbolsSkuEntity> {
-
- PlatformSymbolsSkuEntity findSymbolSkuByName(@Param("name") String name);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/dao/TradeSettingDao.java b/src/main/java/com/xcong/excoin/modules/platform/dao/TradeSettingDao.java
deleted file mode 100644
index aec081a..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/dao/TradeSettingDao.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.xcong.excoin.modules.platform.dao;
-
-import java.util.List;
-
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity;
-import org.apache.ibatis.annotations.Param;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.platform.entity.PlatformLeverageSettingEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-
-public interface TradeSettingDao extends BaseMapper<PlatformTradeSettingEntity> {
-
- PlatformTradeSettingEntity findTradeSetting();
-
- PlatformSymbolsSkuEntity findSymbolSkubySymbol(@Param("symbol") String symbol);
-
- List<PlatformSymbolsSkuEntity> findAllSymbolSkubySymbol();
-
- List<PlatformLeverageSettingEntity> findLeverageSetting();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformBannerEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformBannerEntity.java
deleted file mode 100644
index 6a511c6..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformBannerEntity.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-
-import lombok.Data;
-@Data
-@TableName("platform_banner")
-public class PlatformBannerEntity extends BaseEntity{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * 标题
- */
- private String name;
- /**
- * 图片链接
- */
- private String imageUrl;
- /**
- * 是否可跳转 1-是2-否
- */
- private String isJump;
- /**
- * 跳转外部或内部 1-内2-外
- */
- private int isInside;
- /**
- * 跳转链接
- */
- private String jumpUrl;
- /**
- * 显示端口 1-pc2-手机
- */
- private int showPort;
- /**
- * 联系方式
- */
- private String sort;
- /**
- * 是否置顶 1-是2-否
- */
- private String isTop;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformCnyUsdtExchangeEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformCnyUsdtExchangeEntity.java
deleted file mode 100644
index 4afacaf..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformCnyUsdtExchangeEntity.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-@Data
-@TableName("platform_cny_usdt_exchange")
-public class PlatformCnyUsdtExchangeEntity implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private Long id;
-
- /**
- * 兑换比例
- */
- private BigDecimal value;
- /**
- * 增减偏量
- */
- private BigDecimal diff;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformFeeSettingEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformFeeSettingEntity.java
deleted file mode 100644
index ecea14f..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformFeeSettingEntity.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-
-@Data
-@TableName("platform_fee_setting")
-public class PlatformFeeSettingEntity implements Serializable {
-
- private static final long serialVersionUID = 1L;
- /**
- * 主键ID
- */
- private Long id;
- /**
- * 类型 1-充币2-提币3-充值USDT4-提现USDT
- */
- private Integer type;
- /**
- * 最低价
- */
- private BigDecimal minPrice;
- /**
- * 最高价
- */
- private BigDecimal maxPrice;
- /**
- * 手续费价
- */
- private BigDecimal feePrice;
- /**
- *
- */
- private Date createTime;
- /**
- * 人民币价格
- */
- private BigDecimal cnyPrice;
- /**
- * 币种
- */
- private String symbol;
- /**
- * USDT链名
- */
- private String lable;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformLeverageSettingEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformLeverageSettingEntity.java
deleted file mode 100644
index 8d72d42..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformLeverageSettingEntity.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-
-/**
- * 杠杆设置表
- */
-@Data
-@TableName("platform_leverage_setting")
-public class PlatformLeverageSettingEntity implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
- /**
- * 杠杆值
- */
- private String value;
- /**
- * 杠杆名称
- */
- private String name;
- /**
- * 币种
- */
- private String symbol;
- /**
- * 维持保证金率
- */
- private String prePriceRate;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformNoticeEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformNoticeEntity.java
deleted file mode 100644
index af6308d..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformNoticeEntity.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-
-import java.util.Date;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import lombok.Data;
-
-@Data
-@TableName("platform_notice")
-public class PlatformNoticeEntity{
-
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
- /**
- * 标题
- */
- private String title;
-
- /**
- * 类别
- */
- private Integer categoryid;
-
- private String categoryname;
- private String source;
- private String content;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createTime;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java
deleted file mode 100644
index e8a2fff..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-@Data
-@TableName("platform_payment_method")
-public class PlatformPaymentMethodEntity{
-
-
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
-
- /**
- * 姓名
- */
- private String name;
- /**
- * 账号
- */
- private String account;
- /**
- * 收款二维码
- */
- private String paymentQrcode;
- /**
- * 类型【1、支付宝2、微信3、银行卡】
- */
- private int type;
- /**
- * 银行名
- */
- private String bank;
- /**
- * 状态
- */
- private int status;
- /**
- * 联系方式
- */
- private String phone;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsCoinEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsCoinEntity.java
deleted file mode 100644
index d3c893e..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsCoinEntity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-
-/**
- * 币种表
- */
-@Data
-@TableName("platform_symbols_coin")
-public class PlatformSymbolsCoinEntity implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
- /**
- * 币种名称
- */
- private String name;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsSkuEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsSkuEntity.java
deleted file mode 100644
index 17b2e0e..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformSymbolsSkuEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-
-/**
- * 币种规格表
- * @author helius
- */
-@Data
-@TableName("platform_symbols_sku")
-public class PlatformSymbolsSkuEntity implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
- /**
- * 币种名称
- */
- private String name;
- /**
- * 规格
- */
- private BigDecimal lotnumber;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformTradeSettingEntity.java b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformTradeSettingEntity.java
deleted file mode 100644
index b0e342e..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformTradeSettingEntity.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.xcong.excoin.modules.platform.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import lombok.Data;
-/**
- * 交易设置表
- * @author Administrator
- *
- */
-@Data
-@TableName("platform_trade_setting")
-public class PlatformTradeSettingEntity implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @TableId(value = "id",type = IdType.AUTO)
- private Long id;
- /**
- * 点差
- */
- private BigDecimal spread;
- /**
- * 杠杆
- */
- private BigDecimal leverageRatio;
- /**
- * 爆仓
- */
- private BigDecimal outstock;
- /**
- * 手续费率
- */
- private BigDecimal feeRatio;
- /**
- * 币币手续费率
- */
- private BigDecimal coinFeeRatio;
- /**
- * 代理返佣比例
- */
- private BigDecimal agentReturnRatio;
- /**
- * 持仓系数
- */
- private BigDecimal doingRatio;
- /**
- * 预估强平价系数
- */
- private BigDecimal forceParam;
-
- /**
- *盈亏难度系数
- */
- private BigDecimal profitParam;
-
- /**
- * 手续费系数
- */
- private BigDecimal feeSpreadRatio;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformBannerService.java b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformBannerService.java
deleted file mode 100644
index 51d6428..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformBannerService.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.xcong.excoin.modules.platform.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformBannerEntity;
-
-public interface PlatformBannerService extends IService<PlatformBannerEntity> {
-
- public Result findAll();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformCnyUsdtExchangeService.java b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformCnyUsdtExchangeService.java
deleted file mode 100644
index 264f3c3..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformCnyUsdtExchangeService.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.modules.platform.service;
-
-import org.springframework.web.bind.annotation.RequestParam;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-
-public interface PlatformCnyUsdtExchangeService extends IService<PlatformCnyUsdtExchangeEntity> {
-
- public Result findUsdtCnyExchange(@RequestParam("type") String type);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformNoticeService.java b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformNoticeService.java
deleted file mode 100644
index ad6f68b..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformNoticeService.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.xcong.excoin.modules.platform.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformNoticeEntity;
-
-public interface PlatformNoticeService extends IService<PlatformNoticeEntity> {
-
- Result findPlatformNoticeList();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java
deleted file mode 100644
index 55edcbc..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.xcong.excoin.modules.platform.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-
-public interface PlatformPaymentMethodService extends IService<PlatformPaymentMethodEntity> {
-
- public Result findAll();
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformSymbolsSkuService.java b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformSymbolsSkuService.java
deleted file mode 100644
index fe62d33..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/PlatformSymbolsSkuService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.xcong.excoin.modules.platform.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformBannerEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity;
-
-public interface PlatformSymbolsSkuService extends IService<PlatformSymbolsSkuEntity> {
-
- public PlatformSymbolsSkuEntity findSymbolSkuByName(String name);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformBannerServiceImpl.java b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformBannerServiceImpl.java
deleted file mode 100644
index a6e0c72..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformBannerServiceImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.xcong.excoin.modules.platform.service.impl;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.dao.PlatformBannerDao;
-import com.xcong.excoin.modules.platform.dao.PlatformPaymentMethodDao;
-import com.xcong.excoin.modules.platform.entity.PlatformBannerEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-import com.xcong.excoin.modules.platform.service.PlatformBannerService;
-
-@Service
-public class PlatformBannerServiceImpl extends ServiceImpl<PlatformBannerDao, PlatformBannerEntity> implements PlatformBannerService{
- @Resource
- PlatformBannerDao platformBannerDao;
-
- @Override
- public Result findAll() {
- QueryWrapper<PlatformBannerEntity> queryWrapper = new QueryWrapper<>();
- List<PlatformBannerEntity> paymentMethodList = platformBannerDao.selectList(queryWrapper);
- return Result.ok(paymentMethodList);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformCnyUsdtExchangeServiceImpl.java b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformCnyUsdtExchangeServiceImpl.java
deleted file mode 100644
index 701ca20..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformCnyUsdtExchangeServiceImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.xcong.excoin.modules.platform.service.impl;
-
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-import com.xcong.excoin.modules.platform.service.PlatformCnyUsdtExchangeService;
-
-@Service
-public class PlatformCnyUsdtExchangeServiceImpl extends ServiceImpl<PlatformCnyUsdtExchangeDao, PlatformCnyUsdtExchangeEntity> implements PlatformCnyUsdtExchangeService{
- @Resource
- PlatformCnyUsdtExchangeDao platformCnyUsdtExchangeDao;
-
- @Override
- public Result findUsdtCnyExchange(String type) {
- // 查询当前兑换价格
- Map<String, Object> map = new HashMap<String, Object>();
- PlatformCnyUsdtExchangeEntity platformCnyUsdtExchangeEntity = platformCnyUsdtExchangeDao.selectById(1);
- BigDecimal cnyUsdt = platformCnyUsdtExchangeEntity.getValue();
- if ("B".equals(type)) {
- // 买的时候提高价格
- map.put("exchange", cnyUsdt.add(platformCnyUsdtExchangeEntity.getDiff()));
- }else {
- // 卖的时候降低
- map.put("exchange", cnyUsdt.subtract(platformCnyUsdtExchangeEntity.getDiff()));
- }
- return Result.ok(map);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformNoticeServiceImpl.java b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformNoticeServiceImpl.java
deleted file mode 100644
index f4106a1..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformNoticeServiceImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.platform.service.impl;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.dao.PlatformNoticeDao;
-import com.xcong.excoin.modules.platform.entity.PlatformNoticeEntity;
-import com.xcong.excoin.modules.platform.service.PlatformNoticeService;
-
-@Service
-public class PlatformNoticeServiceImpl extends ServiceImpl<PlatformNoticeDao, PlatformNoticeEntity> implements PlatformNoticeService {
-
- @Resource
- PlatformNoticeDao platformNoticeDao;
-
- @Override
- public Result findPlatformNoticeList() {
- QueryWrapper<PlatformNoticeEntity> queryWrapper = new QueryWrapper<>();
- List<PlatformNoticeEntity> paymentMethodList = platformNoticeDao.selectList(queryWrapper);
- return Result.ok(paymentMethodList);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java
deleted file mode 100644
index b4a011e..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.platform.service.impl;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.platform.dao.PlatformPaymentMethodDao;
-import com.xcong.excoin.modules.platform.entity.PlatformPaymentMethodEntity;
-import com.xcong.excoin.modules.platform.service.PlatformPaymentMethodService;
-
-@Service
-public class PlatformPaymentMethodServiceImpl extends ServiceImpl<PlatformPaymentMethodDao, PlatformPaymentMethodEntity> implements PlatformPaymentMethodService{
- @Resource
- PlatformPaymentMethodDao platformPaymentMethodDao;
-
- @Override
- public Result findAll() {
- QueryWrapper<PlatformPaymentMethodEntity> queryWrapper = new QueryWrapper<>();
- List<PlatformPaymentMethodEntity> paymentMethodList = platformPaymentMethodDao.selectList(queryWrapper);
- return Result.ok(paymentMethodList);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformSymbolsSkuServiceImpl.java b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformSymbolsSkuServiceImpl.java
deleted file mode 100644
index 39c0248..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformSymbolsSkuServiceImpl.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.xcong.excoin.modules.platform.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.modules.platform.dao.PlatformSymbolsSkuDao;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity;
-import com.xcong.excoin.modules.platform.service.PlatformSymbolsSkuService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-
-/**
- * 币种规格服务类
- */
-@Service
-public class PlatformSymbolsSkuServiceImpl extends ServiceImpl<PlatformSymbolsSkuDao, PlatformSymbolsSkuEntity> implements PlatformSymbolsSkuService {
-
- @Resource
- private PlatformSymbolsSkuDao platformSymbolsSkuDao;
-
- @Override
- public PlatformSymbolsSkuEntity findSymbolSkuByName(String name) {
- return platformSymbolsSkuDao.findSymbolSkuByName(name);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/platform/vo/PlatformCnyUsdtExchangeVo.java b/src/main/java/com/xcong/excoin/modules/platform/vo/PlatformCnyUsdtExchangeVo.java
deleted file mode 100644
index 8a06fc6..0000000
--- a/src/main/java/com/xcong/excoin/modules/platform/vo/PlatformCnyUsdtExchangeVo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.modules.platform.vo;
-
-import java.math.BigDecimal;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-@Data
-@ApiModel(value = "会员快捷买入卖出", description = "会员快捷买入卖出类")
-public class PlatformCnyUsdtExchangeVo {
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java b/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java
deleted file mode 100644
index 64fe133..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.xcong.excoin.modules.symbols.controller;
-
-import com.huobi.client.model.Candlestick;
-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;
-import com.xcong.excoin.modules.symbols.parameter.vo.KlineDataVo;
-import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.TypeJudgeUtils;
-import io.swagger.annotations.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-/**
- * @author wzy
- * @date 2020-05-28
- **/
-@Api(value = "K线以及币种相关轮询接口类", tags = "K线以及币种相关轮询接口类")
-@Slf4j
-@RestController
-@RequestMapping(value = "/api/symbols")
-public class SymbolsController {
-
- @Resource
- private SymbolsService symbolsService;
-
- @Resource
- private RedisUtils redisUtils;
-
- @ApiOperation(value = "轮询获取app首页币种交易信息", notes = "轮询获取app首页币种交易信息")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = HomeSymbolsVo.class)
- })
- @GetMapping(value = "/homeSymbols")
- public Result homeSymbols(@ApiParam(name = "type", value = "类型1-币币2-合约3-自选", required = true, example = "1") @RequestParam(value = "type") Integer type) {
- return symbolsService.homeSymbols(type);
- }
-
- @ApiOperation(value = "根据币种查询币种当前各种数据", notes = "根据币种查询币种当前各种数据")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = HomeSymbolsVo.class)
- })
- @GetMapping(value = "/findSymbolData")
- public Result findSymbolData(@ApiParam(name = "symbol", value = "币种", required = true, example = "BTC/USDT") @RequestParam(value = "symbol") String symbol) {
- return symbolsService.findSymbolData(symbol);
- }
-
- @ApiOperation(value = "查询历史K线数据", notes = "查询历史K线数据")
- @ApiResponses({
- @ApiResponse(code = 0, message = "success", response = KlineDataVo.class)
- })
- @PostMapping(value = "/klineDetail")
- public Result klineDetail(@RequestBody @Valid KlineDetailDto klineDetailDto) {
- if (!TypeJudgeUtils.klinePeriod(klineDetailDto.getPeriod())) {
- return Result.fail("非法参数");
- }
- return symbolsService.findKlineDetails(klineDetailDto);
- }
-
- @ApiOperation(value = "查询当日最高最低价")
- @GetMapping(value = "/getDayHighAndLow")
- public Result getDayHighAndLow(@ApiParam(name = "symbol", value = "币种", required = true, example = "BTC/USDT") @RequestParam(value = "symbol") String symbol) {
- Candlestick object = (Candlestick) redisUtils.get(symbol);
- return Result.ok(object);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/dao/PlatformSymbolsContractDao.java b/src/main/java/com/xcong/excoin/modules/symbols/dao/PlatformSymbolsContractDao.java
deleted file mode 100644
index 5887d22..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/dao/PlatformSymbolsContractDao.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.xcong.excoin.modules.symbols.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.xcong.excoin.modules.symbols.entity.PlatformSymbolsContractEntity;
-
-import java.util.List;
-
-/**
- *
- * @author wzy
- */
-public interface PlatformSymbolsContractDao extends BaseMapper<PlatformSymbolsContractEntity> {
-
- List<PlatformSymbolsContractEntity> selectAllContractSymbols();
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/entity/PlatformSymbolsContractEntity.java b/src/main/java/com/xcong/excoin/modules/symbols/entity/PlatformSymbolsContractEntity.java
deleted file mode 100644
index 4322b00..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/entity/PlatformSymbolsContractEntity.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.modules.symbols.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * @author wzy
- * @date 2020-05-26
- **/
-@Data
-@TableName("platform_symbols_contract")
-public class PlatformSymbolsContractEntity implements Serializable {
-
- private static final long serialVersionUID = -1L;
-
- private Long id;
-
- private String name;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/parameter/dto/KlineDetailDto.java b/src/main/java/com/xcong/excoin/modules/symbols/parameter/dto/KlineDetailDto.java
deleted file mode 100644
index 32aa355..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/parameter/dto/KlineDetailDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.symbols.parameter.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-/**
- *
- * @Author wzy
- * @Date 2020/5/28
- **/
-@Data
-@ApiModel(value = "KlineDetailDto", description = "请求K线类")
-public class KlineDetailDto {
-
- @NotNull
- @ApiModelProperty(value = "币种", example = "BTC/USDT")
- private String symbol;
-
- @NotNull
- @ApiModelProperty(value = "k线时长", example = "5min")
- private String period;
-
- @NotNull
- @ApiModelProperty(value = "类型 1-币币2-合约", example = "1")
- private Integer type;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/HomeSymbolsVo.java b/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/HomeSymbolsVo.java
deleted file mode 100644
index c607ae1..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/HomeSymbolsVo.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.modules.symbols.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * @author wzy
- * @date 2020-05-28
- **/
-@Data
-@ApiModel(value = "HomeSymbolsVo", description = "首页币种行情返回类")
-public class HomeSymbolsVo {
-
- @ApiModelProperty(value = "币种")
- private String symbol;
-
- @ApiModelProperty("当前价")
- private BigDecimal currentPrice;
-
- @ApiModelProperty("对应人民币转换")
- private BigDecimal cnyPrice;
-
- @ApiModelProperty("成交量")
- private BigDecimal volume;
-
- @ApiModelProperty("涨跌幅")
- private BigDecimal upOrDown;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/KlineDataVo.java b/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/KlineDataVo.java
deleted file mode 100644
index 3484e4d..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/parameter/vo/KlineDataVo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.xcong.excoin.modules.symbols.parameter.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-/**
- * k线返回类
- *
- * @author wzy
- * @date 2020-05-29
- **/
-@Data
-@ApiModel(value = "KlineDataVo", description = "k线返回类")
-public class KlineDataVo {
-
- @ApiModelProperty(value = "时间")
- private long time;
-
- @ApiModelProperty(value = "开盘指数价")
- private BigDecimal open;
-
- @ApiModelProperty(value = "收盘指数价")
- private BigDecimal high;
-
- @ApiModelProperty(value = "最低指数价")
- private BigDecimal low;
-
- @ApiModelProperty(value = "最高指数价")
- private BigDecimal close;
-
- @ApiModelProperty(value = "成交量张数")
- private BigDecimal volume;
-
- @ApiModelProperty(value = "成交量")
- private BigDecimal amount;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/service/SymbolsService.java b/src/main/java/com/xcong/excoin/modules/symbols/service/SymbolsService.java
deleted file mode 100644
index be91c71..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/service/SymbolsService.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.modules.symbols.service;
-
-
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.symbols.parameter.dto.KlineDetailDto;
-
-/**
- * @author wzy
- * @date 2020-05-26
- **/
-public interface SymbolsService {
-
- public void updateSymbolsKine(String time);
-
- public Result homeSymbols(Integer type);
-
- public Result findSymbolData(String symbol);
-
- public Result findKlineDetails(KlineDetailDto klineDetailDto);
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/service/impl/SymbolsServiceImpl.java b/src/main/java/com/xcong/excoin/modules/symbols/service/impl/SymbolsServiceImpl.java
deleted file mode 100644
index 95d294a..0000000
--- a/src/main/java/com/xcong/excoin/modules/symbols/service/impl/SymbolsServiceImpl.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package com.xcong.excoin.modules.symbols.service.impl;
-
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.huobi.client.model.Candlestick;
-import com.xcong.excoin.common.contants.AppContants;
-import com.xcong.excoin.common.enumerates.SymbolEnum;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.common.system.mapper.CandlestickMapper;
-import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
-import com.xcong.excoin.modules.symbols.parameter.dto.KlineDetailDto;
-import com.xcong.excoin.modules.symbols.parameter.vo.HomeSymbolsVo;
-import com.xcong.excoin.modules.symbols.parameter.vo.KlineDataVo;
-import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.utils.api.ApiClient;
-import com.xcong.excoin.utils.api.response.Kline;
-import com.xcong.excoin.utils.api.response.KlineResponse;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-26
- **/
-@Slf4j
-@Service
-public class SymbolsServiceImpl implements SymbolsService {
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private PlatformCnyUsdtExchangeDao platformCnyUsdtExchangeDao;
-
- private static final String API_KEY = "3938f004-bfe31905-f7581c1a-6abe0";
- private static final String API_SECRET = "a0f7a154-ghxertfvbf-6ce2d90c-a0bab";
-
-
- private static volatile ApiClient client;
-
- private static ApiClient getClient() {
- if (client == null) {
- synchronized (ApiClient.class) {
- if (client == null) {
- client = new ApiClient(API_KEY, API_SECRET);
- }
- }
- }
- return client;
- }
-
- @Override
- public void updateSymbolsKine(String time) {
- synchronized (this) {
- //更新币币交易K线历史数据
- for (SymbolEnum symbol : SymbolEnum.values()) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- String[] symbols = symbol.getValue().toLowerCase().split("/");
- ApiClient client = getClient();
- KlineResponse kline = client.kline(symbols[0] + symbols[1], time, 1000 + "");
- if (kline != null) {
- if ("ok".equalsIgnoreCase(kline.getStatus())) {
- List<Kline> klines = (List<Kline>) kline.data;
- List<Candlestick> list = new ArrayList<Candlestick>();
- Candlestick candlestick = null;
- for (Kline kline1 : klines) {
- candlestick = new Candlestick();
- candlestick.setAmount(BigDecimal.valueOf(kline1.getAmount()));
- candlestick.setClose(BigDecimal.valueOf(kline1.getClose()));
- candlestick.setCount(kline1.getCount());
- candlestick.setHigh(BigDecimal.valueOf(kline1.getHigh()));
- candlestick.setLow(BigDecimal.valueOf(kline1.getLow()));
- candlestick.setVolume(BigDecimal.valueOf(kline1.getVol()));
- candlestick.setTimestamp(kline1.getId() * 1000);
- candlestick.setOpen(BigDecimal.valueOf(kline1.getOpen()));
- list.add(candlestick);
- }
-
- if (klines.size() > 0) {
- redisUtils.set("KINE_" + symbol.getValue() + "_" + time, list);
- }
- }
- }
- }
- }
- }
-
- @Override
- public Result homeSymbols(Integer type) {
- List<HomeSymbolsVo> list = new ArrayList<>();
- // 币币行情
- if (AppContants.HOME_SYMBOLS_COIN == type) {
- for (SymbolEnum symbolEnum : SymbolEnum.values()) {
- list.add(getSymbolReturnData(symbolEnum.getValue()));
- }
- // 合约行情
- } else if (AppContants.HOME_SYMBOLS_CONTRACT == type) {
- for (SymbolEnum symbolEnum : SymbolEnum.values()) {
- list.add(getSymbolReturnData(symbolEnum.getValue()));
- }
- // 自选行情
- } else {
-
- }
-
- return Result.ok(list);
- }
-
- @Override
- public Result findSymbolData(String symbol) {
- HomeSymbolsVo homeSymbolsVo = getSymbolReturnData(symbol);
- return Result.ok(homeSymbolsVo);
- }
-
- public HomeSymbolsVo getSymbolReturnData(String symbol) {
- PlatformCnyUsdtExchangeEntity cnyUsdtExchange = platformCnyUsdtExchangeDao.getCNYAndUSDTOne();
- // 获取当日k线数据
- Candlestick symbolObject = (Candlestick) redisUtils.get(symbol);
- // 获取当前币种最新价
- BigDecimal newestPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol)));
- // 获取当日k线的开盘价
- BigDecimal openPrice = symbolObject.getOpen();
-
- BigDecimal upOrDown = newestPrice.subtract(openPrice).divide(openPrice, 8, BigDecimal.ROUND_HALF_UP);
- HomeSymbolsVo homeSymbolsVo = new HomeSymbolsVo();
-
- homeSymbolsVo.setSymbol(symbol);
- homeSymbolsVo.setCurrentPrice(newestPrice);
- homeSymbolsVo.setUpOrDown(upOrDown);
- homeSymbolsVo.setVolume(symbolObject.getAmount());
- if (cnyUsdtExchange != null) {
- BigDecimal cnyPrice = newestPrice.multiply(cnyUsdtExchange.getValue()).setScale(2, BigDecimal.ROUND_HALF_UP);
- homeSymbolsVo.setCnyPrice(cnyPrice);
- }
-
- return homeSymbolsVo;
- }
-
- @Override
- public Result findKlineDetails(KlineDetailDto klineDetailDto) {
- String key = "KINE_{}_{}";
- // 币币k线数据
- if (AppContants.HOME_SYMBOLS_COIN == klineDetailDto.getType()) {
- key = StrUtil.format(key, klineDetailDto.getSymbol(), klineDetailDto.getPeriod());
- // 合约k线数据
- } else {
- key = StrUtil.format(key, klineDetailDto.getSymbol(), klineDetailDto.getPeriod());
- }
-
- Object data = redisUtils.get(key);
- if (data != null) {
- List list = (List) data;
- int length = 0;
- // 默认获取k线900个柱状(超出会报错)
- int size = 900;
-
- if (list.size() > size) {
- length = size - 1;
- } else {
- length = list.size() - 1;
- }
-
- List<KlineDataVo> result = new ArrayList<>(length);
- for (int i = length; i > 0; i--) {
- Candlestick object = (Candlestick) list.get(i);
- KlineDataVo klineDataVo = CandlestickMapper.INSTANCE.toKlineDataVo(object);
- result.add(klineDataVo);
- }
- return Result.ok(result);
- }
- return Result.fail("获取数据失败");
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java b/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
deleted file mode 100644
index 0be8a3b..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.xcong.excoin.modules.test.controller;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.common.annotations.UserAuth;
-import com.xcong.excoin.common.response.Result;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.test.dto.TestUserDto;
-import com.xcong.excoin.modules.test.entity.TestUserEntity;
-import com.xcong.excoin.modules.test.mapper.TestUserEntityMapper;
-import com.xcong.excoin.modules.test.service.TestUserService;
-import com.xcong.excoin.modules.test.vo.TestUserVo;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import io.swagger.annotations.*;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-/**
- * @author wzy
- * @date 2020-04-24 15:25
- **/
-@RestController
-@RequestMapping(value = "/test")
-@Slf4j
-@Api(value = "这是测试用类", tags = "这是测试用类")
-public class TestUserController {
-
- @Resource
- private TestUserService testUserService;
-
- @ApiOperation(value = "测试用户分页请求", notes = "说明")
- @ApiResponses({@ApiResponse(code = 0, message = "ok", response = TestUserVo.class)})
- @PostMapping(value = "/findUserInPage")
- public Result findUserInPage(@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
- @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
- @RequestBody @Validated TestUserDto testUserDto, @UserAuth MemberEntity memberEntity) {
- log.info("--->{}",SecurityContextHolder.getContext().getAuthentication());
- log.info("----->{}", memberEntity);
- Page<TestUserEntity> page = new Page<>(pageNum, pageSize);
- IPage<TestUserEntity> list = testUserService.page(page);
-
- IPage<TestUserVo> aa = TestUserEntityMapper.INSTANCE.pageEntityToPageVO(list);
- return Result.ok(MessageSourceUtils.getString("111"), aa);
- }
-
-
- @ApiOperation(value = "添加测试用户", notes = "该接口用于添加测试用户")
- @PostMapping(value = "/add")
- public Result add(@RequestBody @Valid TestUserDto testUserDto) {
- TestUserEntity testUserEntity = TestUserEntityMapper.INSTANCE.dtoToEntity(testUserDto);
- boolean flag = testUserService.save(testUserEntity);
- if (flag) {
- return Result.ok("success");
- }
- return Result.fail("fail");
- }
-
- @ApiOperation(value = "修改测试用户", notes = "该接口用户修改测试用户")
- @PostMapping(value = "/modify")
- public Result modify(@RequestBody @Validated TestUserDto testUserDto) {
- TestUserEntity testUserEntity = TestUserEntityMapper.INSTANCE.dtoToEntity(testUserDto);
- log.info("#-------->{}#", testUserEntity);
- boolean flag = testUserService.updateById(testUserEntity);
- if (flag) {
- return Result.ok("success");
- }
- return Result.fail("fail");
- }
-
-
- @ApiOperation(value = "根据ID删除用户", notes = "根据ID删除用户")
- @GetMapping(value = "/del/{id}")
- public Result del(@PathVariable(value = "id") Long id) {
- boolean flag = testUserService.removeById(id);
- if (flag) {
- return Result.ok("success");
- }
- return Result.fail("fail");
- }
-
- @ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
- @GetMapping(value = "/findById/{id}")
- public Result findById(@ApiParam(name = "id", value = "用户ID", required = true, example = "1") @PathVariable(value = "id") Long id) {
- TestUserEntity testUserEntity = testUserService.getById(id);
- TestUserVo testUserVo = TestUserEntityMapper.INSTANCE.entityToVo(testUserEntity);
- return Result.ok("success", testUserVo);
- }
-
- @ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
- @GetMapping(value = "/findByIdAndName/{id}/{name}")
- public Result findByIdAndName(@ApiParam(name = "id", value="用户ID", required = true, example = "1") @PathVariable(value = "id") Long id,
- @ApiParam(name = "name", value="用户姓名", required = true, example = "wzy") @PathVariable(value = "name") String name) {
- log.info("---->{}", id);
- log.info("----<{}", name);
- return Result.ok("success");
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/dao/TestUserDao.java b/src/main/java/com/xcong/excoin/modules/test/dao/TestUserDao.java
deleted file mode 100644
index eba5557..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/dao/TestUserDao.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.xcong.excoin.modules.test.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.test.entity.TestUserEntity;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface TestUserDao extends BaseMapper<TestUserEntity> {
-
- public List<TestUserEntity> selectAll();
-
- IPage<TestUserEntity> selectInPage(Page<TestUserEntity> page);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/dto/TestUserDto.java b/src/main/java/com/xcong/excoin/modules/test/dto/TestUserDto.java
deleted file mode 100644
index fa1d08a..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/dto/TestUserDto.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.modules.test.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.hibernate.validator.constraints.Length;
-
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-
-/**
- * @author wzy
- * @date 2020-05-08 10:17
- **/
-@Data
-@ApiModel(value = "testUser参数接收类", description = "findUserInPage 参数接收类")
-public class TestUserDto {
-
- @NotNull(message = "id不能为空")
- @ApiModelProperty(value = "这是名字啊", example = "张三")
- private String name;
-
- @Length(min = 6, max = 16, message = "账号长度需为6-16位")
- @ApiModelProperty(value = "账号", example = "admin")
- private String account;
-
- @NotBlank(message = "密码不能为空")
- @ApiModelProperty(value = "这是密码字段啊", example = "123456")
- private String password;
-
- @ApiModelProperty(value = "这是地址ID", example = "123")
- private Long addressId;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java b/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java
deleted file mode 100644
index 13a3879..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.xcong.excoin.modules.test.entity;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.xcong.excoin.common.system.base.BaseEntity;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * @author wzy
- * @date 2020-04-24 15:00
- **/
-@EqualsAndHashCode(callSuper = true)
-@Data
-@TableName("test_user")
-public class TestUserEntity extends BaseEntity {
-
- private String name;
-
- private String account;
-
- private String password;
-
- @TableField(exist = false)
- private String aaaaa;
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/mapper/TestUserEntityMapper.java b/src/main/java/com/xcong/excoin/modules/test/mapper/TestUserEntityMapper.java
deleted file mode 100644
index f116802..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/mapper/TestUserEntityMapper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.xcong.excoin.modules.test.mapper;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.test.dto.TestUserDto;
-import com.xcong.excoin.modules.test.entity.TestUserEntity;
-import com.xcong.excoin.modules.test.vo.TestUserVo;
-import com.xcong.excoin.modules.test.vo.TestVo;
-import org.mapstruct.InheritInverseConfiguration;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mapping;
-import org.mapstruct.factory.Mappers;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-09 15:26
- **/
-@Mapper
-public abstract class TestUserEntityMapper {
- public static final TestUserEntityMapper INSTANCE = Mappers.getMapper(TestUserEntityMapper.class);
-
- public abstract TestUserEntity dtoToEntity(TestUserDto testUserDto);
-
- @Mapping(source = "name", target = "name")
- @Mapping(source = "password", target = "pwd")
- public abstract TestVo entityToTestVo(TestUserEntity testUserEntity);
-
- @Mapping(source = "name", target = "userName")
- public abstract TestUserVo entityToVo(TestUserEntity testUserEntity);
-
- public abstract List<TestUserVo> entityListToVoList(List<TestUserEntity> testUserEntities);
-
- public abstract Page<TestUserVo> pageEntityToPageVO(IPage<TestUserEntity> list);
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/service/TestUserService.java b/src/main/java/com/xcong/excoin/modules/test/service/TestUserService.java
deleted file mode 100644
index 448ffb3..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/service/TestUserService.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.xcong.excoin.modules.test.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.xcong.excoin.modules.test.entity.TestUserEntity;
-
-import java.util.List;
-
-/**
- * @author helius
- */
-public interface TestUserService extends IService<TestUserEntity> {
-
- public List<TestUserEntity> findAll();
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/service/impl/TestUserServiceImpl.java b/src/main/java/com/xcong/excoin/modules/test/service/impl/TestUserServiceImpl.java
deleted file mode 100644
index ab2b9f2..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/service/impl/TestUserServiceImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.xcong.excoin.modules.test.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xcong.excoin.modules.test.dao.TestUserDao;
-import com.xcong.excoin.modules.test.entity.TestUserEntity;
-import com.xcong.excoin.modules.test.service.TestUserService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-04-24 15:23
- **/
-@Service
-@Slf4j
-public class TestUserServiceImpl extends ServiceImpl<TestUserDao, TestUserEntity> implements TestUserService {
-
- @Resource
- private TestUserDao testUserDao;
-
- @Override
- public List<TestUserEntity> findAll() {
- return testUserDao.selectAll();
- }
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/vo/TestUserVo.java b/src/main/java/com/xcong/excoin/modules/test/vo/TestUserVo.java
deleted file mode 100644
index efd4073..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/vo/TestUserVo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.xcong.excoin.modules.test.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @author wzy
- * @date 2020-05-07 17:24
- **/
-@Data
-@ApiModel(value = "测试", description = "测试用户类")
-public class TestUserVo {
-
- @ApiModelProperty(value = "主键ID")
- private Long id;
-
- @ApiModelProperty(value = "用户姓名")
- private String userName;
-
- @ApiModelProperty(value = "密码")
- private String password;
-
- @ApiModelProperty(value = "12345")
- private List<TestVo> testVo;
-
-}
diff --git a/src/main/java/com/xcong/excoin/modules/test/vo/TestVo.java b/src/main/java/com/xcong/excoin/modules/test/vo/TestVo.java
deleted file mode 100644
index ba344b3..0000000
--- a/src/main/java/com/xcong/excoin/modules/test/vo/TestVo.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xcong.excoin.modules.test.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * @author wzy
- * @date 2020-05-08 10:09
- **/
-@Data
-@ApiModel(value = "12345", description = "2222222")
-public class TestVo {
-
- @ApiModelProperty(value = "名字")
- private String name;
-
- @ApiModelProperty(value = "密码")
- private String pwd;
-}
diff --git a/src/main/java/com/xcong/excoin/netty/ChatServer.java b/src/main/java/com/xcong/excoin/netty/ChatServer.java
deleted file mode 100644
index 58f0cd7..0000000
--- a/src/main/java/com/xcong/excoin/netty/ChatServer.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.xcong.excoin.netty;
-
-/**
- * @author wzy
- * @date 2019-05-06
- */
-public interface ChatServer {
- void start() throws Exception;
-
- void shutdown();
-}
diff --git a/src/main/java/com/xcong/excoin/netty/bean/RequestBean.java b/src/main/java/com/xcong/excoin/netty/bean/RequestBean.java
deleted file mode 100644
index 289b4ae..0000000
--- a/src/main/java/com/xcong/excoin/netty/bean/RequestBean.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.xcong.excoin.netty.bean;
-
-
-import java.io.Serializable;
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-09
- */
-public class RequestBean implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 请求类型
- */
- private String type;
-
- /**
- * 当前通道id
- */
- private String channelId;
-
- /**
- * web端通道ID
- */
- private String reqId;
-
- /**
- * 请求参数
- */
- private String params;
-
- /**
- * 手持端是否同意连接 0-否 1-是
- */
- private String tag;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
- this.channelId = channelId;
- }
-
- public String getParams() {
- return params;
- }
-
- public void setParams(String params) {
- this.params = params;
- }
-
- public String getReqId() {
- return reqId;
- }
-
- public void setReqId(String reqId) {
- this.reqId = reqId;
- }
-
- public String getTag() {
- return tag;
- }
-
- public void setTag(String tag) {
- this.tag = tag;
- }
-
- @Override
- public String toString() {
- return "RequestBean{" +
- "type='" + type + '\'' +
- ", channelId='" + channelId + '\'' +
- ", reqId='" + reqId + '\'' +
- ", params='" + params + '\'' +
- ", tag='" + tag + '\'' +
- '}';
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/bean/ResponseBean.java b/src/main/java/com/xcong/excoin/netty/bean/ResponseBean.java
deleted file mode 100644
index b595122..0000000
--- a/src/main/java/com/xcong/excoin/netty/bean/ResponseBean.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.xcong.excoin.netty.bean;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author wzy
- * @date 2020-04-18 16:17
- **/
-public class ResponseBean implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String SUCCESS = "200";
-
- private String status;
-
- private String type;
-
- private String info;
-
- private String channelId;
-
- private Map<Object, Object> mapInfo = new HashMap<>();
-
- private List<?> row;
-
- public static ResponseBean ok(String type, String info) {
- ResponseBean responseBean = new ResponseBean();
- responseBean.status = SUCCESS;
- responseBean.type = type;
- responseBean.info = info;
- return responseBean;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getInfo() {
- return info;
- }
-
- public void setInfo(String info) {
- this.info = info;
- }
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
- this.channelId = channelId;
- }
-
- public Map<Object, Object> getMapInfo() {
- return mapInfo;
- }
-
- public void setMapInfo(Map<Object, Object> mapInfo) {
- this.mapInfo = mapInfo;
- }
-
- public void putInfo(Object key, Object value) {
- this.mapInfo.put(key, value);
- }
-
- public List<?> getRow() {
- return row;
- }
-
- public void setRow(List<?> row) {
- this.row = row;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java b/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java
deleted file mode 100644
index 5d158f6..0000000
--- a/src/main/java/com/xcong/excoin/netty/common/ChannelManager.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.xcong.excoin.netty.common;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.netty.bean.ResponseBean;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelId;
-import io.netty.channel.group.ChannelGroup;
-import io.netty.channel.group.DefaultChannelGroup;
-import io.netty.util.concurrent.GlobalEventExecutor;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-06
- */
-public class ChannelManager {
-
- private static final ChannelGroup WEBSOCKET_GROUP = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
-
- // 当前连接到服务器的通道(tcp和websocket)
- private static final ConcurrentMap<String, ChannelId> CHANNEL_MAP = new ConcurrentHashMap<>();
-
- public static void addWebSocketChannel(Channel channel) {
- WEBSOCKET_GROUP.add(channel);
- CHANNEL_MAP.put(channel.id().asShortText(), channel.id());
- }
-
- public static void removeWebSocketChannel(Channel channel) {
- WEBSOCKET_GROUP.remove(channel);
- CHANNEL_MAP.remove(channel.id().asShortText());
- }
-
- public static Channel findWebSocketChannel(String id){
- ChannelId channelId = CHANNEL_MAP.get(id);
- return WEBSOCKET_GROUP.find(channelId);
- }
-
- public static ChannelGroup getWebSocketGroup() {
- return WEBSOCKET_GROUP;
- }
-
- public static void send2All(Object object, String type) {
- if (WEBSOCKET_GROUP.size() == 0) {
- return;
- }
- ResponseBean responseBean = ResponseBean.ok(type, null);
- responseBean.putInfo("data", object);
- String msg = JSONObject.toJSONString(responseBean);
- WEBSOCKET_GROUP.writeAndFlush(NettyTools.webSocketBytes(msg));
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/netty/common/Contans.java b/src/main/java/com/xcong/excoin/netty/common/Contans.java
deleted file mode 100644
index 1a64913..0000000
--- a/src/main/java/com/xcong/excoin/netty/common/Contans.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.netty.common;
-
-/**
- * @author wzy
- * @date 2019-05-06
- */
-public class Contans {
-
- public static final String HEART_BEAT = "ping pong pang";
-
- public static final String WEB_REQ_CONNECTION = "000_000";
-
- public static final String HOME_SYMBOLS = "001_001";
-
- public static final String ORDER_COIN_PRE_ORDER_DATA = "002_001";
-
- public static final String ORDER_COIN_FIND_TRUST_ORDER = "002_002";
-
- public static final String ORDER_PRE_ORDER_DATA = "003_001";
-
- public static final String ORDER_FIND_TRUST_ORDER = "003_002";
-
-}
diff --git a/src/main/java/com/xcong/excoin/netty/common/NettyTools.java b/src/main/java/com/xcong/excoin/netty/common/NettyTools.java
deleted file mode 100644
index ead90db..0000000
--- a/src/main/java/com/xcong/excoin/netty/common/NettyTools.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.xcong.excoin.netty.common;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
-
-/**
- * @author wzy
- * @date 2019-05-14
- */
-public class NettyTools {
-
-
- /**
- * socket字符串传输转码
- *
- * @param msg
- * @return
- */
- public static ByteBuf textBytes(String msg) {
- return Unpooled.copiedBuffer((msg + "_split").getBytes());
- }
-
- public static TextWebSocketFrame webSocketBytes(String msg) {
- return new TextWebSocketFrame(msg);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/dispatch/MsgDispatch.java b/src/main/java/com/xcong/excoin/netty/dispatch/MsgDispatch.java
deleted file mode 100644
index 540fd36..0000000
--- a/src/main/java/com/xcong/excoin/netty/dispatch/MsgDispatch.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.xcong.excoin.netty.dispatch;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.netty.bean.RequestBean;
-import com.xcong.excoin.netty.common.NettyTools;
-import com.xcong.excoin.netty.logic.MsgLogic;
-import io.netty.channel.ChannelHandlerContext;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-
-/**
- * @author wzy
- * @date 2019-05-08
- */
-@Slf4j
-@Component("msgDispatch")
-public class MsgDispatch implements ApplicationContextAware {
-
- private ApplicationContext applicationContext;
-
- @Autowired
- private MsgLogic msgLogic;
-
- public void webSocketDispatch(ChannelHandlerContext ctx, String msg) {
- RequestBean requestBean = null;
- try {
- requestBean = JSONObject.parseObject(msg, RequestBean.class);
- requestBean.setChannelId(ctx.channel().id().asShortText());
- msgLogic.webSocketMsgLogic(requestBean);
- } catch (Exception e) {
- log.info("#websocket json error:{}#", e);
- ctx.channel().writeAndFlush(NettyTools.webSocketBytes("params error"));
- }
- }
-
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- this.applicationContext = applicationContext;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/handler/WebSocketServerHandler.java b/src/main/java/com/xcong/excoin/netty/handler/WebSocketServerHandler.java
deleted file mode 100644
index 3e57246..0000000
--- a/src/main/java/com/xcong/excoin/netty/handler/WebSocketServerHandler.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package com.xcong.excoin.netty.handler;
-
-
-import com.xcong.excoin.netty.common.ChannelManager;
-import com.xcong.excoin.netty.common.Contans;
-import com.xcong.excoin.netty.common.NettyTools;
-import com.xcong.excoin.netty.dispatch.MsgDispatch;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.*;
-import io.netty.handler.codec.http.DefaultFullHttpResponse;
-import io.netty.handler.codec.http.FullHttpRequest;
-import io.netty.handler.codec.http.HttpResponseStatus;
-import io.netty.handler.codec.http.HttpVersion;
-import io.netty.handler.codec.http.websocketx.*;
-import io.netty.handler.timeout.IdleState;
-import io.netty.handler.timeout.IdleStateEvent;
-import io.netty.util.CharsetUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.Date;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import static io.netty.handler.codec.http.HttpUtil.isKeepAlive;
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-06
- */
-@Slf4j
-@Component
-@ChannelHandler.Sharable
-public class WebSocketServerHandler extends ChannelInboundHandlerAdapter {
-
- private final ConcurrentMap<String, Integer> pingTimes = new ConcurrentHashMap<>();
-
- private static final int MAX_UN_REC_PING_TIMES = 3;
-
- private WebSocketServerHandshaker handshaker;
-
- @Resource(name = "msgDispatch")
- private MsgDispatch msgDispatch;
-
- @Override
- public void channelActive(ChannelHandlerContext ctx) throws Exception {
- log.info("[websocket客户端连入服务器]-->{}", ctx.channel().id());
- ChannelManager.addWebSocketChannel(ctx.channel());
- }
-
- @Override
- public void channelInactive(ChannelHandlerContext ctx) throws Exception {
- log.info("[离开websocket服务器]-->{}", ctx.channel().id());
- ChannelManager.removeWebSocketChannel(ctx.channel());
- }
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-// LogUtil.info("[websocket服务器收到消息]-->{}, {}", ctx.channel().id(), msg);
- if (msg instanceof FullHttpRequest) {
- // 以http请求形式接入,但是走的是websocket
- handleHttpRequest(ctx, (FullHttpRequest) msg);
- } else if (msg instanceof WebSocketFrame) {
- // 处理websocket客户端的消息
- handlerWebSocketFrame(ctx, (WebSocketFrame) msg);
-
- WebSocketFrame frame = (WebSocketFrame) msg;
- String content;
- try {
- content = ((TextWebSocketFrame) frame).text();
- if (content.contains(Contans.HEART_BEAT)) {
- resetTimes(ctx.channel());
- } else {
- this.msgDispatch.webSocketDispatch(ctx, content);
- }
- } catch (ClassCastException e) {
- content = ((CloseWebSocketFrame) frame).reasonText();
- ctx.writeAndFlush(new TextWebSocketFrame(content));
- }
- }
- }
-
- @Override
- public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
- log.info("[触发器触发]");
-// super.userEventTriggered(ctx, evt);
- if (evt instanceof IdleStateEvent) {
- IdleStateEvent event = (IdleStateEvent) evt;
- if (event.state() == IdleState.READER_IDLE) {
-
- } else if (event.state() == IdleState.WRITER_IDLE) {
- /*写超时*/
- ctx.channel().writeAndFlush(NettyTools.webSocketBytes(Contans.HEART_BEAT));
- Integer times = pingTimes.get(ctx.channel().id().asShortText());
- if (times == null) {
- times = 0;
- }
- /*读超时*/
- log.info("===服务端===({}写超时, {})", ctx.channel().id().asShortText(), times);
- // 失败计数器次数大于等于3次的时候,关闭链接,等待client重连
- if (times >= MAX_UN_REC_PING_TIMES) {
- log.info("===服务端===(写超时,关闭chanel)");
- // 连续超过N次未收到client的ping消息,那么关闭该通道,等待client重连
- ctx.channel().close();
- } else {
- // 失败计数器加1
- times++;
- pingTimes.remove(ctx.channel().id().asShortText());
- pingTimes.put(ctx.channel().id().asShortText(), times);
- }
- } else if (event.state() == IdleState.ALL_IDLE) {
- /*总超时*/
- System.out.println("===服务端===(ALL_IDLE 总超时)");
- }
- }
- }
-
- private void resetTimes(Channel channel) {
- pingTimes.remove(channel.id().asShortText());
- pingTimes.put(channel.id().asShortText(), 0);
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- log.error("[websocket服务器发生异常]-->{},{}#", ctx.channel().id(), cause);
- super.exceptionCaught(ctx, cause);
- }
-
-
- private void handlerWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
- // 判断是否关闭链路的指令
- if (frame instanceof CloseWebSocketFrame) {
- handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
- return;
- }
- // 判断是否ping消息
- if (frame instanceof PingWebSocketFrame) {
- ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
- return;
- }
- // 本例程仅支持文本消息,不支持二进制消息
- if (!(frame instanceof TextWebSocketFrame)) {
- System.out.println("本例程仅支持文本消息,不支持二进制消息");
- throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass().getName()));
- }
- // 返回应答消息
- String request = ((TextWebSocketFrame) frame).text();
- TextWebSocketFrame tws = new TextWebSocketFrame(new Date().toString() + ctx.channel().id() + ":" + request);
- // 群发
- // ChannelSupervise.send2All(tws);
- // 返回【谁发的发给谁】
- // ctx.channel().writeAndFlush(tws);
- }
-
- /**
- * 唯一的一次http请求,用于创建websocket
- */
- private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) ctx.channel().remoteAddress();
- InetAddress inetAddress = inetSocketAddress.getAddress();
- String ip = inetAddress.getHostAddress();
- int port = inetSocketAddress.getPort();
-
- //要求Upgrade为websocket,过滤掉get/Post
- if (!req.decoderResult().isSuccess() || (!"websocket".equals(req.headers().get("Upgrade")))) {
- //若不是websocket方式,则创建BAD_REQUEST的req,返回给客户端
- sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST));
- return;
- }
- WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory("ws://" + ip + ":" + port + "/websocket", null, false);
- handshaker = wsFactory.newHandshaker(req);
- if (handshaker == null) {
- WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
- } else {
- handshaker.handshake(ctx.channel(), req);
- }
- }
-
- /**
- * 拒绝不合法的请求,并返回错误信息
- */
- private static void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, DefaultFullHttpResponse res) {
- // 返回应答给客户端
- if (res.status().code() != 200) {
- ByteBuf buf = Unpooled.copiedBuffer(res.status().toString(),
- CharsetUtil.UTF_8);
- res.content().writeBytes(buf);
- buf.release();
- }
- //服务端向客户端发送数据
- ChannelFuture f = ctx.channel().writeAndFlush(res);
- // 如果是非Keep-Alive,关闭连接
- if (!isKeepAlive(req) || res.status().code() != 200) {
- f.addListener(ChannelFutureListener.CLOSE);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/initalizer/WebSocketServerInitializer.java b/src/main/java/com/xcong/excoin/netty/initalizer/WebSocketServerInitializer.java
deleted file mode 100644
index 54cb224..0000000
--- a/src/main/java/com/xcong/excoin/netty/initalizer/WebSocketServerInitializer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.netty.initalizer;
-
-import com.xcong.excoin.netty.handler.WebSocketServerHandler;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.handler.codec.http.HttpObjectAggregator;
-import io.netty.handler.codec.http.HttpServerCodec;
-import io.netty.handler.stream.ChunkedWriteHandler;
-import io.netty.handler.timeout.IdleStateHandler;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-06
- */
-@Component
-public class WebSocketServerInitializer extends ChannelInitializer<NioSocketChannel> {
-
- @Autowired
- private WebSocketServerHandler webSocketServerHandler;
-
- @Override
- protected void initChannel(NioSocketChannel ch) throws Exception {
- ChannelPipeline cp = ch.pipeline();
-
- // http编码器
- cp.addLast(new HttpServerCodec());
- // 聚合器,使用websocket会用到
- cp.addLast(new HttpObjectAggregator(65536));
- cp.addLast(new ChunkedWriteHandler());
- // 心跳
- ch.pipeline().addLast(new IdleStateHandler(0, 10, 0));
- // 自定义业务handler
- cp.addLast(webSocketServerHandler);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/logic/MsgLogic.java b/src/main/java/com/xcong/excoin/netty/logic/MsgLogic.java
deleted file mode 100644
index 2fc8280..0000000
--- a/src/main/java/com/xcong/excoin/netty/logic/MsgLogic.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.xcong.excoin.netty.logic;
-
-
-import com.xcong.excoin.netty.bean.RequestBean;
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-09
- */
-public interface MsgLogic {
- void webSocketMsgLogic(RequestBean requestBean);
-}
diff --git a/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java b/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java
deleted file mode 100644
index d1c9322..0000000
--- a/src/main/java/com/xcong/excoin/netty/logic/WebSocketLogic.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.xcong.excoin.netty.logic;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.netty.bean.RequestBean;
-import com.xcong.excoin.netty.bean.ResponseBean;
-import com.xcong.excoin.netty.common.ChannelManager;
-import com.xcong.excoin.netty.common.NettyTools;
-import io.netty.channel.Channel;
-import org.springframework.stereotype.Component;
-
-
-/**
- * @author wzy
- * @email wangdoubleone@gmail.com
- * @date 2019-05-09
- */
-@Component
-public class WebSocketLogic {
-
-
- public void webReqConnection(RequestBean requestBean) {
- Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId());
- channel.writeAndFlush(NettyTools.webSocketBytes("this is ok"));
- }
-
- public void reqHomeSymbols(RequestBean requestBean) {
- String params = requestBean.getParams();
- JSONObject jsonObject = JSONObject.parseObject(params);
- String token = jsonObject.getString("token");
- String type = jsonObject.getString("type");
- ResponseBean responseBean = ResponseBean.ok(requestBean.getType(), null);
-
- Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId());
- channel.writeAndFlush(NettyTools.webSocketBytes(JSONObject.toJSONString(responseBean)));
- }
-
- public void defaultReq(RequestBean requestBean) {
- Channel channel = ChannelManager.findWebSocketChannel(requestBean.getChannelId());
- channel.writeAndFlush("this is error type");
- }
-}
diff --git a/src/main/java/com/xcong/excoin/netty/logic/impl/MsgLogicImpl.java b/src/main/java/com/xcong/excoin/netty/logic/impl/MsgLogicImpl.java
deleted file mode 100644
index c1fbb4c..0000000
--- a/src/main/java/com/xcong/excoin/netty/logic/impl/MsgLogicImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.xcong.excoin.netty.logic.impl;
-
-import com.xcong.excoin.netty.bean.RequestBean;
-import com.xcong.excoin.netty.common.Contans;
-import com.xcong.excoin.netty.logic.MsgLogic;
-import com.xcong.excoin.netty.logic.WebSocketLogic;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-
-/**
- * @author wzy
- * @date 2019-05-09
- */
-@Component
-public class MsgLogicImpl implements MsgLogic {
-
- @Autowired
- private WebSocketLogic webSocketLogic;
-
- @Override
- public void webSocketMsgLogic(RequestBean requestBean) {
- switch (requestBean.getType()) {
- case Contans.WEB_REQ_CONNECTION :
- webSocketLogic.webReqConnection(requestBean);
- break;
- case Contans.HOME_SYMBOLS:
- webSocketLogic.reqHomeSymbols(requestBean);
- default:
- webSocketLogic.defaultReq(requestBean);
- break;
- }
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/netty/server/WebSocketServer.java b/src/main/java/com/xcong/excoin/netty/server/WebSocketServer.java
deleted file mode 100644
index 84b1290..0000000
--- a/src/main/java/com/xcong/excoin/netty/server/WebSocketServer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.xcong.excoin.netty.server;
-
-import com.xcong.excoin.netty.ChatServer;
-import com.xcong.excoin.netty.initalizer.WebSocketServerInitializer;
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wzy
- * @date 2019-05-06
- */
-@Slf4j
-@Component("webSocketServer")
-public class WebSocketServer implements ChatServer {
-
-
- private EventLoopGroup boss = new NioEventLoopGroup();
- private EventLoopGroup work = new NioEventLoopGroup();
-
- private ChannelFuture channelFuture;
-
- @Autowired
- private WebSocketServerInitializer webSocketServerInitializer;
-
- @Override
- public void start() throws Exception {
- log.info("[websocket服务器启动]");
- try {
- ServerBootstrap b = new ServerBootstrap();
- b.group(boss, work)
- .channel(NioServerSocketChannel.class)
- .childHandler(webSocketServerInitializer);
-
- channelFuture = b.bind(9999).sync();
-
- log.info("[websocket服务器启动完成]-->{}", channelFuture.channel().localAddress());
- } finally {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- shutdown();
- }
- });
- }
- }
-
- @Override
- public void shutdown() {
- if (channelFuture != null) {
- channelFuture.channel().close().syncUninterruptibly();
- }
-
- if (boss != null) {
- boss.shutdownGracefully();
- }
-
- if (work != null) {
- work.shutdownGracefully();
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/BlockCoinUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/BlockCoinUpdateJob.java
deleted file mode 100644
index 4138bee..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/BlockCoinUpdateJob.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.xcong.excoin.modules.coin.service.BlockCoinService;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-
-/**
- * 链上币种同步任务
- *
- * @author wzy
- * @date 2020-07-02
- **/
-@Component
-@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true")
-public class BlockCoinUpdateJob {
-
- @Resource
- private BlockCoinService blockCoinService;
-
-
- /**
- * ETH_USDT 同步
- */
- @Scheduled(cron = "0 0/10 * * * ? ")
- public void ethUsdtUpdate() {
- blockCoinService.updateEthUsdt();
- }
-
- /**
- * eth 同步
- */
- @Scheduled(cron = "0 1/20 * * * ? ")
- public void ethUpdate() {
- blockCoinService.updateEth();
- }
-
- /**
- * BTC_USDT 同步
- */
- @Scheduled(cron = "0 2/10 * * * ? ")
- public void btcUsdtUpdate() {
- blockCoinService.updateBtcUsdt();
- }
-
- @Scheduled(cron = "0 3/20 * * * ? ")
- public void btcUpdate() {
- blockCoinService.updateBtc();
- }
-
- @Scheduled(cron = "0 4/20 * * * ? ")
- public void eosUpdate() {
- blockCoinService.updateEos();
- }
-
- @Scheduled(cron = "0 6/20 * * * ? ")
- public void xrpUpdate() {
- blockCoinService.updateXrp();
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/DayLineDataUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/DayLineDataUpdateJob.java
deleted file mode 100644
index 6d6438c..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/DayLineDataUpdateJob.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.huobi.client.SubscriptionClient;
-import com.huobi.client.SubscriptionOptions;
-import com.huobi.client.model.Candlestick;
-import com.huobi.client.model.enums.CandlestickInterval;
-import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import com.xcong.excoin.rabbit.pricequeue.WebsocketPriceService;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.RedisUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-/**
- * 最新价更新
- *
- * @author wzy
- * @date 2020-05-28
- **/
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "day-line", havingValue = "true")
-public class DayLineDataUpdateJob {
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private SymbolsService symbolsService;
-
- @Resource
- private WebsocketPriceService websocketPriceService;
-
- @PostConstruct
- public void initNewestPrice() {
- log.info("#=======价格更新开启=======#");
- SubscriptionOptions subscriptionOptions = new SubscriptionOptions();
- subscriptionOptions.setConnectionDelayOnFailure(5);
- subscriptionOptions.setUri("wss://api.hadax.com/ws");
- SubscriptionClient subscriptionClient = SubscriptionClient.create("", "", subscriptionOptions);
-
- subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> {
- Candlestick data = candlestickEvent.getData();
- redisUtils.set(CoinTypeConvert.convert(candlestickEvent.getSymbol()), data);
- });
-
- }
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/KlineDataUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/KlineDataUpdateJob.java
deleted file mode 100644
index ca41425..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/KlineDataUpdateJob.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-
-/**
- * k线数据更新任务
- *
- * @author wzy
- * @date 2020-05-26
- **/
-@Component
-@ConditionalOnProperty(prefix = "app", name = "kline-update-job", havingValue = "true")
-public class KlineDataUpdateJob {
-
- @Resource
- private SymbolsService symbolsService;
-
-
- private static boolean min1 = true;
- private static boolean min5 = true;
- private static boolean min30 = true;
- private static boolean min60 = true;
- private static boolean hour4 = true;
- private static boolean day1 = true;
- private static boolean week = true;
-
-
- /**
- * 定时更新每一分钟的K线数据
- */
- @Scheduled(cron = "0/1 * * * * ? ")
- public void updateSymbolsKineOneMin() {
- if (min1) {
- min1 = false;
- try {
- symbolsService.updateSymbolsKine("1min");
- } catch (Exception e) {
- // e.printStackTrace();
- } finally {
- min1 = true;
- }
- }
- }
-
- /**
- * 定时更新每十分钟的K线数据
- */
- @Scheduled(cron = "0/10 * * * * ? ")
- public void updateSymbolsKineFiveMin() {
- if (min5) {
- min5 = false;
- try {
- symbolsService.updateSymbolsKine("5min");
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- min5 = true;
- }
- }
- }
-
- /**
- * 定时更新每30分钟的K线数据
- */
- @Scheduled(cron = "0/120 * * * * ? ")
- public void updateSymbolsKineMin() {
- if (min30) {
- min30 = false;
- try {
- symbolsService.updateSymbolsKine("30min");
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- min30 = true;
- }
- }
- }
-
- /**
- * 定时更新1小时的K线数据
- */
- @Scheduled(cron = "* 0/2 * * * ? ")
- public void updateSymbolsKineOneHour() {
- if (min60) {
- min60 = false;
- try {
- symbolsService.updateSymbolsKine("60min");
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- min60 = true;
- }
- }
- }
-
- /**
- * 定时更新4小时的K线数据
- */
- @Scheduled(cron = "* 0/1 * * * ? ")
- public void updateSymbolsKineFourHour() {
- if (hour4) {
- hour4 = false;
- try {
- symbolsService.updateSymbolsKine("4hour");
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- hour4 = true;
- }
- }
- }
-
-
- /**
- * 定时更新1天的K线数据
- */
- @Scheduled(cron = "* 0/1 * * * ? ")
- public void updateSymbolsKineOneDay() {
- if (day1) {
- day1 = false;
- try {
- symbolsService.updateSymbolsKine("1day");
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- day1 = true;
- }
- }
- }
-
- /**
- * 定时更新1周的K线数据
- */
- @Scheduled(cron = "* 0/1 * * * ? ")
- public void updateSymbolsKineOneWeek() {
- if (week) {
- week = false;
- try {
- symbolsService.updateSymbolsKine("1week");
- } catch (Exception e) {
- // e.printStackTrace();
- } finally {
- week = true;
- }
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/LoopExecutorJob.java b/src/main/java/com/xcong/excoin/quartz/job/LoopExecutorJob.java
deleted file mode 100644
index 9fc7240..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/LoopExecutorJob.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.xcong.excoin.modules.coin.service.OrderCoinService;
-import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
-import com.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-
-/**
- * @author wzy
- * @date 2020-06-08
- **/
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "loop-job", havingValue = "true")
-public class LoopExecutorJob {
-
- @Resource
- private MemberQuickBuySaleDao memberQuickBuySaleDao;
-
- @Resource
- private ContractHoldOrderService contractHoldOrderService;
-
- @Resource
- private OrderCoinService orderCoinService;
-
- /**
- * 更新快捷充值超时状态
- */
- @Scheduled(cron = "0/5 * * * * ? ")
- @Transactional(rollbackFor = Exception.class)
- public void updateChargeUsdt() {
- try {
- memberQuickBuySaleDao.updateQuickBuySaleTimeOut();
- } catch (Exception e) {
- log.error("更新快捷充值超时状态", e);
- }
- }
-
-
- /**
- * 持仓费计算
- */
- @Scheduled(cron = "0 0 0/8 * * ?")
- public void updateDoingPrice() {
- log.info("#持仓费计算#");
- try {
- contractHoldOrderService.calHoldFeeAmountForBondAmount();
- } catch (Exception e) {
- log.error("#持仓费计算错误#", e);
- }
- }
-
- /**
- * 币币委托单成交
- */
- @Scheduled(cron = "0/5 * * * * ? ")
- public void coinEntrustToDeal() {
- try {
- orderCoinService.dealEntrustCoinOrder();
- } catch (Exception e) {
- log.error("#币币委托单成交错误#", e);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/NewestPriceUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/NewestPriceUpdateJob.java
deleted file mode 100644
index 0ac98f7..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/NewestPriceUpdateJob.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.huobi.client.SubscriptionClient;
-import com.huobi.client.SubscriptionOptions;
-import com.huobi.client.model.Candlestick;
-import com.huobi.client.model.enums.CandlestickInterval;
-import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import com.xcong.excoin.rabbit.pricequeue.WebsocketPriceService;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.RedisUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-/**
- * 最新价更新
- *
- * @author wzy
- * @date 2020-05-28
- **/
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "newest-price-update-job", havingValue = "true")
-public class NewestPriceUpdateJob {
-
- @Resource
- private RedisUtils redisUtils;
-
- @Resource
- private SymbolsService symbolsService;
-
- @Resource
- private WebsocketPriceService websocketPriceService;
-
- @PostConstruct
- public void initNewestPrice() {
- log.info("#=======价格更新开启=======#");
- SubscriptionOptions subscriptionOptions = new SubscriptionOptions();
- subscriptionOptions.setConnectionDelayOnFailure(5);
- subscriptionOptions.setUri("wss://api.hadax.com/ws");
- SubscriptionClient subscriptionClient = SubscriptionClient.create("", "", subscriptionOptions);
- subscriptionClient.subscribeTradeEvent("btcusdt,ethusdt,xrpusdt,ltcusdt,bchusdt,eosusdt,etcusdt", tradeEvent -> {
- String symbol = tradeEvent.getSymbol();
- // 根据symbol判断做什么操作
- symbol = CoinTypeConvert.convert(symbol);
- if (null != symbol) {
- String price = tradeEvent.getTradeList().get(0).getPrice().toPlainString();
- // TODO 测试环境关闭这个插入redis
- redisUtils.set(CoinTypeConvert.convertToKey(symbol), price);
- // 比较
- websocketPriceService.comparePriceAsc(symbol, price);
- websocketPriceService.comparePriceDesc(symbol, price);
- //System.out.println("比较完毕:"+symbol+"-"+price);
-
- }
-
- });
-// subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> {
-// Candlestick data = candlestickEvent.getData();
-// redisUtils.set(CoinTypeConvert.convert(candlestickEvent.getSymbol()), data);
-// });
- }
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/NotionalPoolingJob.java b/src/main/java/com/xcong/excoin/quartz/job/NotionalPoolingJob.java
deleted file mode 100644
index 75f36ad..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/NotionalPoolingJob.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.xcong.excoin.modules.blackchain.service.UsdtEthService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.concurrent.ExecutionException;
-
-/**
- * 归集定时任务
- *
- * @author wzy
- * @date 2020-07-02
- **/
-
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true")
-public class NotionalPoolingJob {
-
- @Resource
- private UsdtEthService usdtEthService;
-
- /**
- * usdt 归集
- */
- @Scheduled(cron = "0 5/30 * * * ? ")
- public void poolUsdtEth() {
- try {
- log.info("USDT归集开始");
- usdtEthService.pool();
- log.info("USDT归集结束");
- } catch (ExecutionException | InterruptedException e) {
- log.error("#usdt归集错误#", e);
- }
- }
-
- @Scheduled(cron = "0 2/8 * * * ? ")
- public void usdtEthPoolCheck() {
- log.info("USDTETH归集结果扫描开始");
- usdtEthService.usdtEthPoolCheck();
- }
-
- @Scheduled(cron = "0 2/30 * * * ? ")
- public void poolEth() {
- try {
- usdtEthService.ethPool();
- } catch (ExecutionException | InterruptedException e) {
- log.info("#ETH归集错误#", e);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/quartz/job/UsdtCnyExchangePriceUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/UsdtCnyExchangePriceUpdateJob.java
deleted file mode 100644
index 96dc366..0000000
--- a/src/main/java/com/xcong/excoin/quartz/job/UsdtCnyExchangePriceUpdateJob.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.xcong.excoin.quartz.job;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.math.BigDecimal;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-/**
- * 美元-人民币汇率定时任务
- *
- * @author wzy
- * @date 2020-05-28
- **/
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "other-job", havingValue = "true")
-public class UsdtCnyExchangePriceUpdateJob {
-
- @Resource
- private PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao;
-
- @Scheduled(cron = "0 */5 * * * ? ")
- public void updateUsdtCnyExchange() {
- BufferedReader reader = null;
- String result = null;
- StringBuffer sbf = new StringBuffer();
- // 模拟浏览器
- String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
- try {
- URL url = new URL("https://otc-api-hk.eiijo.cn/v1/data/config/purchase-price?coinId=2¤cyId=1&matchType=0");
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setReadTimeout(30000);
- connection.setConnectTimeout(30000);
- connection.setRequestProperty("User-agent", userAgent);
- connection.connect();
- InputStream is = connection.getInputStream();
- reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- String strRead = null;
- while ((strRead = reader.readLine()) != null) {
- sbf.append(strRead);
- sbf.append("\r\n");
- }
- reader.close();
- result = sbf.toString();
-
- JSONObject jsonObject = (JSONObject) JSONObject.parse(result);
- String code = jsonObject.getString("code");
- if ("200".equals(code)) {
- JSONObject jsonData = (JSONObject) jsonObject.get("data");
- cnyUsdtExchangeDao.updateUsdt(BigDecimal.valueOf(jsonData.getDouble("price")));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/consumer/OperateOrderPriceConsumer.java b/src/main/java/com/xcong/excoin/rabbit/consumer/OperateOrderPriceConsumer.java
deleted file mode 100644
index 45ff0f7..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/consumer/OperateOrderPriceConsumer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.xcong.excoin.rabbit.consumer;
-
-import com.alibaba.fastjson.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.xcong.excoin.configurations.RabbitMqConfig;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import com.xcong.excoin.rabbit.pricequeue.OrderOperatePriceService;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
-
-
-/**
- * 用户修改止损止盈价格、提价限价委托、下单爆仓价等消息
- * 后台打包开启 APP 不开启
- * @author helius
- */
-@Component
-@ConditionalOnProperty(prefix = "app", name = "newest-price-update-job", havingValue = "true")
-public class OperateOrderPriceConsumer {
-
-
- /**
- * 用户修改止损止盈价格、提价限价委托、下单爆仓价等消息
- *
- * @param message 消息体
- * @param channel 信道
- * @date 2019年4月19日
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_PRICEOPERATE)
- public void onMessageMorePro(Message message, Channel channel) {
- String content = new String(message.getBody());
- System.out.println("我收到了用户的订单操作消息:" + content);
- // 操作前的map
- // 转为model
- OrderModel orderModel = JSONObject.parseObject(content, OrderModel.class);
- // 向优先队列添加
- OrderOperatePriceService.dealWithNewMq(orderModel);
-
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java b/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java
deleted file mode 100644
index aea3c07..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.xcong.excoin.rabbit.consumer;
-
-import com.xcong.excoin.configurations.RabbitMqConfig;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wzy
- * @date 2020-05-25
- **/
-@Slf4j
-@Component
-public class TestConsumer {
-
-
- @RabbitListener(queues = RabbitMqConfig.QUEUE_TEST)
- public void doSomething(String content) {
- log.info("#---->{}#", content);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/consumer/WebsocketPriceConsumer.java b/src/main/java/com/xcong/excoin/rabbit/consumer/WebsocketPriceConsumer.java
deleted file mode 100644
index b959b0e..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/consumer/WebsocketPriceConsumer.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.xcong.excoin.rabbit.consumer;
-
-import com.alibaba.fastjson.JSONArray;
-import com.rabbitmq.client.Channel;
-import com.xcong.excoin.configurations.RabbitMqConfig;
-import com.xcong.excoin.modules.contract.service.RabbitOrderService;
-import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-
-/**
- * APP和后台打包都开启
- *
- * @author helius
- */
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "rabbit-consumer", havingValue = "true")
-public class WebsocketPriceConsumer {
-
- @Resource
- OrderWebsocketServiceImpl orderWebsocketService;
-
- @Resource
- RabbitOrderService orderService;
-
-
- /**
- * 开多止盈
- *
- * @param message 消息体
- * @param channel 信道
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_MOREPRO)
- public void onMessageMorePro(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了开多止盈 : {}", content);
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealOrderFromMq(list, 9);
- }
- // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空
-
- /**
- * 开空止盈
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_LESSPRO)
- public void onMessageLessPro(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了开空止盈 : {}", content);
- // 开始处理
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealOrderFromMq(list, 10);
- }
-
-
- /**
- * 开多止损
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_MORELOSS)
- public void onMessageMoreLoss(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了开多止损 : {}", content);
- // 开始处理
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealOrderFromMq(list, 11);
- }
-
- /**
- * 开空止损
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_LESSLOSS)
- public void onMessageLessLoss(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了开空止损 : {}", content);
- // 开始处理
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealOrderFromMq(list, 12);
- }
-
- /**
- * 限价委托
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_LIMIT)
- public void onMessageLimit(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了限价委托 : {}", content);
- // 开始处理
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealForLimitMq(list);
- }
-
- /**
- * 爆仓消费者
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_COINOUT)
- public void onMessageCoinout(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了爆仓 : {}", content);
- // 开始处理
- List<OrderModel> list = JSONArray.parseArray(content, OrderModel.class);
- // 开始处理
- orderWebsocketService.dealOrderFromMq(list, 6);
- }
-
- /**
- * 平仓
- *
- * @param message
- * @param channel
- */
- @RabbitListener(queues = RabbitMqConfig.QUEUE_CLOSETRADE)
- public void onMessageCloseTrade(Message message, Channel channel) {
- String content = new String(message.getBody());
- log.info("==message-price-consumer==我收到消息了平仓: {}", content);
- // 订单
- List<Long> ids = JSONArray.parseArray(content, Long.class);
- orderService.cancelHoldOrder(ids);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java b/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java
deleted file mode 100644
index 25638d8..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.xcong.excoin.rabbit.init;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum;
-import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao;
-import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
-import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
-import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
-import com.xcong.excoin.rabbit.pricequeue.OrderModel;
-import com.xcong.excoin.rabbit.producer.OrderProducer;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.List;
-
-/**
- * 后台开启 APP不开启
- *
- * @author helius
- */
-@Slf4j
-@Component
-@ConditionalOnProperty(prefix = "app", name = "newest-price-update-job", havingValue = "true")
-public class OrderProducerInit {
-
- @Resource
- private ContractEntrustOrderDao contractEntrustOrderDao;
-
- @Resource
- private ContractHoldOrderDao contractHoldOrderDao;
-
- @Resource
- private OrderProducer producer;
-
- @PostConstruct
- public void initOrder() {
- log.info("=======初始化未完成订单信息=======");
-
- // 查询所有未平仓的单
- List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectAllHoldOrder();
- // 查询所有未完成的委托单
- List<ContractEntrustOrderEntity> entrustOrderEntities = contractEntrustOrderDao.selectAllEntrustOrder();
-
- if (CollectionUtils.isNotEmpty(holdOrderEntities)) {
- for (ContractHoldOrderEntity order : holdOrderEntities) {
- // 开多1,开空 2
- int openingType = order.getOpeningType();
- // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空
- // 9:止盈平多10:止盈平空11:止损平多12:止损平空
- if (ContractHoldOrderEntity.OPENING_TYPE_MORE == openingType) {
- // 开多 发送开多止损 止盈 爆仓
- // 爆仓价
- BigDecimal forceSetPrice = order.getForceClosingPrice();
- if (forceSetPrice != null) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceSetPrice.toPlainString(),
- order.getSymbol(), order.getOperateNo());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 止损
- BigDecimal stopLossPrice = order.getStopLossPrice();
- if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(),
- stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 止盈
- BigDecimal stopProfitPrice = order.getStopProfitPrice();
- if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(),
- stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
-
- } else {
- // 开空 发送开空止损 止盈 爆仓
- // 爆仓价
- BigDecimal forceSetPrice = order.getForceClosingPrice();
- if (forceSetPrice != null) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceSetPrice.toPlainString(),
- order.getSymbol(), order.getOperateNo());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 止损
- BigDecimal stopLossPrice = order.getStopLossPrice();
- if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(),
- stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- // 止盈
- BigDecimal stopProfitPrice = order.getStopProfitPrice();
- if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) {
- OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(),
- stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- }
-
- }
- }
-
- if (CollectionUtils.isNotEmpty(entrustOrderEntities)) {
- for (ContractEntrustOrderEntity order : entrustOrderEntities) {
- // 开多1,开空 2
- int entrustType = order.getEntrustType();
- // 开多
- BigDecimal entrustPrice = order.getEntrustPrice();
- OrderModel model;
- if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE == entrustType) {
- // 开多委托
- model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(),
- entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
-
- } else {
- model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(),
- entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
- order.getSymbol());
- }
- producer.sendPriceOperate(JSONObject.toJSONString(model));
- }
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/AscBigDecimal.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/AscBigDecimal.java
deleted file mode 100644
index 73762bf..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/AscBigDecimal.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-/**
- * 正序的 从小到大 头元素最小
- */
-public class AscBigDecimal implements Comparable{
-
- private BigDecimal value;
-
- public AscBigDecimal(String val) {
- this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP);
- }
-
- public AscBigDecimal(double val){
- this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP);
- }
-
- public BigDecimal getValue() {
- return value;
- }
-
- public void setValue(BigDecimal value) {
- this.value = value;
- }
-
- @Override
- public int compareTo(Object o) {
- if(o==null){
- return -1;
- }
- AscBigDecimal val = (AscBigDecimal)o;
- if(this.value.compareTo(val.getValue())>0){
- return 1;
- }else if(this.value.compareTo(val.getValue())<0){
- return -1;
- }else {
- return 0;
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/DescBigDecimal.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/DescBigDecimal.java
deleted file mode 100644
index 3ed88f0..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/DescBigDecimal.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-/**
- * 倒叙序的 从大到小 头元素最大
- */
-public class DescBigDecimal implements Comparable{
-
-
- private BigDecimal value;
-
- public DescBigDecimal(String val) {
- this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP);
- }
-
- public DescBigDecimal(double val){
- this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP);
- }
-
- public BigDecimal getValue() {
- return value;
- }
-
- public void setValue(BigDecimal value) {
- this.value = value;
- }
-
- @Override
- public int compareTo(Object o) {
- if(o==null){
- return -1;
- }
- DescBigDecimal val = (DescBigDecimal)o;
- if(this.value.compareTo(val.getValue())>0){
- return -1;
- }else if(this.value.compareTo(val.getValue())<0){
- return 1;
- }else {
- return 0;
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderModel.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderModel.java
deleted file mode 100644
index abc7c7c..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderModel.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-public class OrderModel {
- /**
- * 订单ID
- */
- private Long orderId;
- /**
- * 类型
- */
- private Integer type;
-
- /**
- * 触发价格
- */
- private String price;
-
- /**
- * 币种
- */
- private String symbol;
-
- /**
- * 爆仓价位设置次数
- */
- private Integer operateNo;
-
-
- public OrderModel(Long orderId, Integer type, String price, String symbol){
- this.orderId= orderId;
- this.type= type;
- this.price= price;
- this.symbol= symbol;
- }
-
- public OrderModel(Long orderId,Integer type,String price, String symbol,Integer operateNo){
- this.orderId= orderId;
- this.type= type;
- this.price= price;
- this.symbol= symbol;
- this.operateNo= operateNo;
- }
-
- public Integer getOperateNo() {
- return operateNo;
- }
-
- public void setOperateNo(Integer operateNo) {
- this.operateNo = operateNo;
- }
-
- public Long getOrderId() {
- return orderId;
- }
-
- public void setOrderId(Long orderId) {
- this.orderId = orderId;
- }
-
- public Integer getType() {
- return type;
- }
-
- public void setType(Integer type) {
- this.type = type;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
deleted file mode 100644
index d936325..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.PriorityBlockingQueue;
-
-/**
- * 处理消费者的订单止盈等价格信息
- */
-@Slf4j
-public class OrderOperatePriceService {
-
- /**
- * 处理用户提交的止盈止损价格 爆仓 限价委托
- *
- * @param orderModel
- */
- public static void dealWithNewMq(OrderModel orderModel) {
- // 根据不同的类型将价格信息加入到对应队列和MAP
- // 【1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空】
- int type = orderModel.getType();
- Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(orderModel.getSymbol(), type);
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- // 需要价格涨的
- PriorityBlockingQueue<AscBigDecimal> queue = PricePriorityQueue.getQueueAsc(orderModel.getSymbol());
- dealPriceAsc(orderModel, orderMap, queue);
- } else {
- // 需要价格跌的
- PriorityBlockingQueue<DescBigDecimal> queue = PricePriorityQueue.getQueueDesc(orderModel.getSymbol());
- dealPriceDesc(orderModel, orderMap, queue);
- }
-
- }
-
- /**
- * 倒叙的添加价格和订单
- *
- * @param orderMap
- * @param queue
- */
- public static void dealPriceDesc(OrderModel order, Map<String, List<OrderModel>> orderMap, PriorityBlockingQueue<DescBigDecimal> queue) {
- // 添加币种的价格和价格订单信息
- String price = order.getPrice();
- int type = order.getType();
- Long orderId = order.getOrderId();
- queue.add(new DescBigDecimal(price));
-
- log.info("原有:{}", JSONObject.toJSONString(orderMap));
- removeExistOrder(type, orderId, orderMap);
- log.info("删除后:{}", JSONObject.toJSONString(orderMap));
- if (orderMap.containsKey(price)) {
- // 有这个价的key
- List<OrderModel> list = orderMap.get(price);
- // 判断这个单的这个类型是否有
-// if (CollectionUtils.isNotEmpty(list)) {
- // 新增
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
- list.add(orderModel);
-// }
- } else {
- List<OrderModel> list = new ArrayList<OrderModel>();
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
- list.add(orderModel);
- orderMap.put(price, list);
- }
- log.info("调整后:{}", JSONObject.toJSONString(orderMap));
- }
-
-
- /**
- * 正序的添加价格和订单
- *
- * @param orderMap
- * @param queue
- */
- public static void dealPriceAsc(OrderModel order, Map<String, List<OrderModel>> orderMap, PriorityBlockingQueue<AscBigDecimal> queue) {
- // 添加币种的价格和价格订单信息
- String price = order.getPrice();
- int type = order.getType();
- Long orderId = order.getOrderId();
- queue.add(new AscBigDecimal(price));
- log.info("原有:{}", JSONObject.toJSONString(orderMap));
- // 需要找到这个订单的原始的单进行处理
- removeExistOrder(type, orderId, orderMap);
- log.info("删除后:{}", JSONObject.toJSONString(orderMap));
- if (orderMap.containsKey(price)) {
- // 有这个价的key
- List<OrderModel> list = orderMap.get(price);
- // 判断这个单的这个类型是否有
-// if (CollectionUtils.isNotEmpty(list)) {
- // 新增
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
- list.add(orderModel);
-// }
- } else {
- List<OrderModel> list = new ArrayList<OrderModel>();
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
- list.add(orderModel);
- orderMap.put(price, list);
- }
- log.info("调整后:{}", JSONObject.toJSONString(orderMap));
- }
-
- private static void removeExistOrder(Integer type, Long orderId, Map<String, List<OrderModel>> orderMap) {
- // 需要找到这个订单的原始的单进行处理
- boolean breakFlag = false;
- for (Map.Entry<String, List<OrderModel>> entry : orderMap.entrySet()) {
- List<OrderModel> value = entry.getValue();
- if (CollectionUtils.isNotEmpty(value)) {
- Iterator<OrderModel> iterator = value.iterator();
- if (iterator.hasNext()) {
- OrderModel next = iterator.next();
- if (next.getType().equals(type) && orderId.equals(next.getOrderId())) {
- // 移除这个
- System.out.println("存在相同的平仓类型,删除原来的:"+next.getOrderId()+",价格:"+next.getPrice());
- iterator.remove();
- break;
-
- }
- }
-
- }
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/PricePriorityQueue.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/PricePriorityQueue.java
deleted file mode 100644
index 36cbffa..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/PricePriorityQueue.java
+++ /dev/null
@@ -1,300 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.PriorityBlockingQueue;
-
-/**
- * 止盈止损的价格队列
- */
-public class PricePriorityQueue {
-
- /**
- * BTC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- public static PriorityBlockingQueue<AscBigDecimal> BTC_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> BTC_MAP_ASC = null;
-
- /**
- * BTC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- public static PriorityBlockingQueue<DescBigDecimal> BTC_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> BTC_MAP_DESC = null;
- /**
- * ETH 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> ETH_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> ETH_MAP_ASC = null;
-
- /**
- * ETH 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> ETH_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> ETH_MAP_DESC = null;
-
- /**
- * XRP 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> XRP_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> XRP_MAP_ASC = null;
-
- /**
- * XRP 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> XRP_QUEUE_DESC = null;
- private static Map<String, List<OrderModel>> XRP_MAP_DESC = null;
-
- /**
- * LTC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> LTC_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> LTC_MAP_ASC = null;
-
- /**
- * LTC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> LTC_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> LTC_MAP_DESC = null;
-
- /**
- * BCH 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> BCH_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> BCH_MAP_ASC = null;
-
- /**
- * BCH 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> BCH_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> BCH_MAP_DESC = null;
-
- /**
- * EOS 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> EOS_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> EOS_MAP_ASC = null;
-
- /**
- * EOS 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> EOS_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> EOS_MAP_DESC = null;
-
- /**
- * ETC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多
- */
- private static PriorityBlockingQueue<AscBigDecimal> ETC_QUEUE_ASC = null;
-
- private static Map<String, List<OrderModel>> ETC_MAP_ASC = null;
-
- /**
- * ETC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空
- */
- private static PriorityBlockingQueue<DescBigDecimal> ETC_QUEUE_DESC = null;
-
- private static Map<String, List<OrderModel>> ETC_MAP_DESC = null;
-
-
- // 收到消息队列的方法 即收取到新的止盈止损等
- // 【1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空】
- public static PriorityBlockingQueue<AscBigDecimal> getQueueAsc(String symbol) {
- switch (symbol) {
- case "BTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (BTC_QUEUE_ASC == null) {
- BTC_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
-
- return BTC_QUEUE_ASC;
- case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (ETH_QUEUE_ASC == null) {
- ETH_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return ETH_QUEUE_ASC;
- case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (XRP_QUEUE_ASC == null) {
- XRP_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return XRP_QUEUE_ASC;
- case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (LTC_QUEUE_ASC == null) {
- LTC_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return LTC_QUEUE_ASC;
- case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (BCH_QUEUE_ASC == null) {
- BCH_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return BCH_QUEUE_ASC;
- case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (EOS_QUEUE_ASC == null) {
- EOS_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return EOS_QUEUE_ASC;
- case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (ETC_QUEUE_ASC == null) {
- ETC_QUEUE_ASC = new PriorityBlockingQueue<AscBigDecimal>();
- }
- return ETC_QUEUE_ASC;
- default:
- break;
- }
- return null;
- }
-
- public static PriorityBlockingQueue<DescBigDecimal> getQueueDesc(String symbol) {
- switch (symbol) {
- case "BTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- //if (type == 11 || type == 10 || type == 7 || type == 6 || type == 2) {
- if (BTC_QUEUE_DESC == null) {
- BTC_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return BTC_QUEUE_DESC;
- case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (ETH_QUEUE_DESC == null) {
- ETH_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return ETH_QUEUE_DESC;
- case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (XRP_QUEUE_DESC == null) {
- XRP_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return XRP_QUEUE_DESC;
- case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (LTC_QUEUE_DESC == null) {
- LTC_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return LTC_QUEUE_DESC;
- case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (BCH_QUEUE_DESC == null) {
- BCH_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return BCH_QUEUE_DESC;
- case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (EOS_QUEUE_DESC == null) {
- EOS_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return EOS_QUEUE_DESC;
- case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (ETC_QUEUE_DESC == null) {
- ETC_QUEUE_DESC = new PriorityBlockingQueue<DescBigDecimal>();
- }
- return ETC_QUEUE_DESC;
- default:
- break;
- }
- return null;
- }
-
- /**
- * 获得币种价格订单map
- * @param symbol
- * @param type
- * @return
- */
- public static Map<String,List<OrderModel>> getOrderMap(String symbol, int type) {
- switch (symbol) {
- case "BTC/USDT": // 开空止损 开多止盈 开空爆仓 限价开空
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (BTC_MAP_ASC == null) {
- BTC_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return BTC_MAP_ASC;
- } else {
- if (BTC_MAP_DESC == null) {
- BTC_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return BTC_MAP_DESC;
- }
- case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (ETH_MAP_ASC == null) {
- ETH_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return ETH_MAP_ASC;
- } else {
- if (ETH_MAP_DESC == null) {
- ETH_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return ETH_MAP_DESC;
- }
- case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (XRP_MAP_ASC == null) {
- XRP_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return XRP_MAP_ASC;
- } else {
- if (XRP_MAP_DESC == null) {
- XRP_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return XRP_MAP_DESC;
- }
- case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (LTC_MAP_ASC == null) {
- LTC_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return LTC_MAP_ASC;
- } else {
- if (LTC_MAP_DESC == null) {
- LTC_MAP_DESC =new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return LTC_MAP_DESC;
- }
- case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (BCH_MAP_ASC == null) {
- BCH_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return BCH_MAP_ASC;
- } else {
- if (BCH_MAP_DESC == null) {
- BCH_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return BCH_MAP_DESC;
- }
- case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (EOS_MAP_ASC == null) {
- EOS_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return EOS_MAP_ASC;
- } else {
- if (EOS_MAP_DESC == null) {
- EOS_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return EOS_MAP_DESC;
- }
- case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多
- if (type == 12 || type == 9 || type == 7 || type == 3) {
- if (ETC_MAP_ASC == null) {
- ETC_MAP_ASC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return ETC_MAP_ASC;
- } else {
- if (ETC_MAP_DESC == null) {
- ETC_MAP_DESC = new ConcurrentHashMap<String,List<OrderModel>>();
- }
- return ETC_MAP_DESC;
- }
- default:
- break;
- }
- return null;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java
deleted file mode 100644
index af91983..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java
+++ /dev/null
@@ -1,224 +0,0 @@
-package com.xcong.excoin.rabbit.pricequeue;
-
-import com.alibaba.fastjson.JSONObject;
-import com.xcong.excoin.rabbit.producer.OrderProducer;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.PriorityBlockingQueue;
-
-@Slf4j
-@Component
-public class WebsocketPriceService {
-
- @Autowired
- OrderProducer orderProducer;
-
- /**
- * @param symbol
- * @param price
- */
- public void comparePriceAsc(String symbol, String price) {
- // 比较价格 正序的 最小元素在头部 开多止盈 开空止损等
- PriorityBlockingQueue<AscBigDecimal> queue = PricePriorityQueue.getQueueAsc(symbol);
- // 最小的
- AscBigDecimal b = queue.peek();
- // 当前价
- AscBigDecimal now = new AscBigDecimal(price);
- List<AscBigDecimal> list = new ArrayList<AscBigDecimal>();
- // 找到所有比当前价格大的 是需要操作的
- if (b != null && b.compareTo(now) <= 0) {
- // 可以操作
- System.out.println("当前价格:" + price + "---正序---" + "队列价格:" + b.getValue().toPlainString() + " time:" + new Date());
- while (queue.peek() != null && queue.peek().compareTo(now) <= 0) {
- // 可以发送消息操作
- list.add(queue.remove());
- }
- }
-
- if (CollectionUtils.isNotEmpty(list)) {
- dealAscPriceOrderAndSenMq(list, symbol);
- }
-
- }
-
- public void comparePriceDesc(String symbol, String price) {
- // 比较价格 倒叙的 开多止损 开空止盈
- PriorityBlockingQueue<DescBigDecimal> queue = PricePriorityQueue.getQueueDesc(symbol);
- // 最大价格
- DescBigDecimal b = queue.peek();
- // 当前价格
- DescBigDecimal now = new DescBigDecimal(price);
- List<DescBigDecimal> list = new ArrayList<DescBigDecimal>();
- // 找到比当前价格还大的就是需要操作的 开多止损
- // 即最大的币当前价大 那么需要开多止损
- if (b != null && b.compareTo(now) <= 0) {
- // 可以操作
- System.out.println("当前价格:" + price + "---倒序操作---" + "队列:" + b.getValue().toPlainString() + " time:" + new Date());
-
- while (queue.peek() != null && queue.peek().compareTo(now) <= 0) {
- // 可以发送消息操作
- list.add(queue.remove());
- log.info("#{}#", JSONObject.toJSONString(list));
- }
- }
- if (CollectionUtils.isNotEmpty(list)) {
- dealDescPriceOrderAndSenMq(list, symbol);
- }
-
- }
-
- // 处理消息 正序的 包括
- // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空
- public void dealAscPriceOrderAndSenMq(List<AscBigDecimal> list, String symbol) {
- if (CollectionUtils.isNotEmpty(list)) {
- // 根据不同类型发送不同消息 1 倒序 2 正序
- List<OrderModel> orderModelList = new ArrayList<OrderModel>();
- // 3 正序
- Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(symbol, 3);
- // 根据价格查询到对应的订单
- for (AscBigDecimal asc : list) {
- String key = asc.getValue().toPlainString();
- assert orderMap != null;
- log.info("----->->{}, --> {}", JSONObject.toJSONString(orderMap), key);
- if (orderMap.containsKey(key)) {
- orderModelList.addAll(orderMap.get(key));
- orderMap.remove(key);
- }
-
- }
- log.info("------>{}", JSONObject.toJSONString(orderModelList));
- if (CollectionUtils.isEmpty(orderModelList)) {
- return;
- }
- System.out.println("本次执行的列表ASC");
- System.out.println(JSONObject.toJSONString(orderModelList));
- // 根据订单的类型发送消息
- // 3:开空 7:爆仓平空
- // 9:止盈平多 12:止损平空
- for (OrderModel model : orderModelList) {
- // 止损平空
- List<OrderModel> kkzsList = new ArrayList<OrderModel>();
- // 止盈平多
- List<OrderModel> kdzyList = new ArrayList<OrderModel>();
- // 爆仓平空
- List<OrderModel> bcList = new ArrayList<OrderModel>();
- // 开空
- List<OrderModel> wtkkList = new ArrayList<OrderModel>();
- switch (model.getType()) {
- case 3:
- wtkkList.add(model);
- break;
- case 7:
- bcList.add(model);
- break;
- case 9:
- kdzyList.add(model);
- break;
- case 12:
- kkzsList.add(model);
- break;
- default:
- log.info("#price-service unknown type#");
- break;
- }
-
- // 发送消息
- if (CollectionUtils.isNotEmpty(kkzsList)) {
- String kkzs = JSONObject.toJSONString(kkzsList);
- orderProducer.sendLessLoss(kkzs);
- }
- if (CollectionUtils.isNotEmpty(kdzyList)) {
- String kdzy = JSONObject.toJSONString(kdzyList);
- orderProducer.sendMorePro(kdzy);
- }
- if (CollectionUtils.isNotEmpty(bcList)) {
- orderProducer.sendCoinout(JSONObject.toJSONString(bcList));
- }
- if (CollectionUtils.isNotEmpty(wtkkList)) {
- orderProducer.sendLimit(JSONObject.toJSONString(wtkkList));
- }
- }
- }
- }
-
- // 处理消息 正序的 包括
- // 1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空
- public void dealDescPriceOrderAndSenMq(List<DescBigDecimal> list, String symbol) {
- if (CollectionUtils.isNotEmpty(list)) {
- // 根据不同类型发送不同消息 1 倒序 2 正序
- List<OrderModel> orderModelList = new ArrayList<OrderModel>();
- Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(symbol, 2);
- // 根据价格查询到对应的订单
- for (DescBigDecimal desc : list) {
- String key = desc.getValue().toPlainString();
- assert orderMap != null;
- log.info("----->->{}, --> {}", JSONObject.toJSONString(orderMap), key);
- if (orderMap.containsKey(key)) {
- orderModelList.addAll(orderMap.get(key));
- orderMap.remove(key);
- }
-
- }
-
- if (CollectionUtils.isEmpty(orderModelList)) {
- return;
- }
- System.out.println("本次执行的列表Desc");
- System.out.println(JSONObject.toJSONString(orderModelList));
- // 根据订单的类型发送消息
- // 2:开多6:爆仓平多
- // 10:止盈平空11:止损平多
- for (OrderModel model : orderModelList) {
- // 开空止盈
- List<OrderModel> kkzyList = new ArrayList<OrderModel>();
- // 开多止损
- List<OrderModel> kdzsList = new ArrayList<OrderModel>();
- // 爆仓
- List<OrderModel> bcList = new ArrayList<OrderModel>();
- // 开多委托
- List<OrderModel> wtkdList = new ArrayList<OrderModel>();
- switch (model.getType()) {
- case 2:
- wtkdList.add(model);
- break;
- case 6:
- bcList.add(model);
- break;
- case 10:
- kkzyList.add(model);
- break;
- case 11:
- kdzsList.add(model);
- break;
- default:
- break;
- }
-
- // 发送消息
- if (CollectionUtils.isNotEmpty(kkzyList)) {
- String kkzy = JSONObject.toJSONString(kkzyList);
- orderProducer.sendLessPro(kkzy);
- }
- if (CollectionUtils.isNotEmpty(kdzsList)) {
- String kdzs = JSONObject.toJSONString(kdzsList);
- orderProducer.sendMoreLoss(kdzs);
- }
- if (CollectionUtils.isNotEmpty(bcList)) {
- orderProducer.sendCoinout(JSONObject.toJSONString(bcList));
- }
- if (CollectionUtils.isNotEmpty(wtkdList)) {
- orderProducer.sendLimit(JSONObject.toJSONString(wtkdList));
-
- }
- }
- }
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/producer/OrderProducer.java b/src/main/java/com/xcong/excoin/rabbit/producer/OrderProducer.java
deleted file mode 100644
index 400cf46..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/producer/OrderProducer.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package com.xcong.excoin.rabbit.producer;
-
-import com.xcong.excoin.configurations.RabbitMqConfig;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.rabbit.connection.CorrelationData;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.UUID;
-
-
-/**
- * rabbitMq示例生产者
- */
-@Slf4j
-@Component
-public class OrderProducer implements ConfirmCallback {
-
- /**
- * 配置中配置的RabbitTemplate的是prototype类型,不能直接注入
- */
- private RabbitTemplate rabbitTemplate;
-
- /**
- * 在构造方法上注入RabbitTemplate
- *
- * @param
- */
- @Autowired
- public OrderProducer(RabbitTemplate rabbitTemplate) {
- this.rabbitTemplate = rabbitTemplate;
- rabbitTemplate.setConfirmCallback(this);
- }
-
- /**
- * P发送消息方法 开多止盈
- */
- public void sendMorePro(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送开多止盈:" + content + "==pid:" + correlationData.getId());
-
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_MOREPRO, content, correlationData);
- }
-
- /**
- * 开空止盈
- *
- * @param content
- */
- public void sendLessPro(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送开空止盈:" + content + "==pid:" + correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_LESSPRO, content, correlationData);
- }
-
- /**
- * 开多止损
- *
- * @param content
- */
- public void sendMoreLoss(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送开多止损:" + content + "==pid:" + correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_MORELOSS, content, correlationData);
- }
-
- /**
- * 开空止损
- *
- * @param content
- */
- public void sendLessLoss(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送开空止损:" + content + "==pid:" + correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_LESSLOSS, content, correlationData);
- }
-
- /**
- * 发送委托交易消息
- *
- * @param content
- */
- public void sendLimit(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送限价委托:" + content + "==pid:" + correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_LIMIT, content, correlationData);
- }
-
- /**
- * 发送爆仓消息
- *
- * @param content
- */
- public void sendCoinout(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- System.out.println("发送爆仓:" + content + "==pid:" + correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_COINOUT, content, correlationData);
- }
-
-
- /**
- * 发送价格操作消息
- *
- * @param content
- */
- public void sendPriceOperate(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- log.info("发送价格操作 : {}==pid : {}", content, correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_PRICEOPERATE, content, correlationData);
- }
-
- /**
- * 发送平仓
- *
- * @param content
- */
- public void sendCloseTrade(String content) {
- CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
- log.info("发送平仓消息:{}==pid : {}", content, correlationData.getId());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_A, RabbitMqConfig.ROUTINGKEY_CLOSETRADE, content, correlationData);
- }
-
-
- /**
- * 用于确认消息是否成功发送到队列
- */
- @Override
- public void confirm(CorrelationData correlationData, boolean ack, String cause) {
- if (ack) {
- //System.out.println("消息发送成功"+correlationData.getId());
- //LogUtil.info("消息发送成功,correlationId={}", correlationData.getId());
- } else {
- System.out.println("消息发送失败" + correlationData.getId());
- //LogUtil.info("消息发送失败,correlationId={}", correlationData.getId());
- }
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java b/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java
deleted file mode 100644
index 00ffd52..0000000
--- a/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.xcong.excoin.rabbit.producer;
-
-import cn.hutool.core.util.IdUtil;
-import com.xcong.excoin.configurations.RabbitMqConfig;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.rabbit.connection.CorrelationData;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wzy
- * @date 2020-05-25
- **/
-@Slf4j
-@Component
-public class TestProducer implements RabbitTemplate.ConfirmCallback {
-
- private RabbitTemplate rabbitTemplate;
-
- @Autowired
- public TestProducer(RabbitTemplate rabbitTemplate) {
- this.rabbitTemplate = rabbitTemplate;
- rabbitTemplate.setConfirmCallback(this);
- }
-
- public void sendTestMsg(String content) {
- CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID());
- rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTING_KEY_TEST, content, correlationData);
- }
-
-
- @Override
- public void confirm(CorrelationData correlationData, boolean ack, String cause) {
- log.info("#----->{}#", correlationData);
- if (ack) {
- log.info("success");
- } else {
- log.info("--->{}", cause);
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/CacheSettingUtils.java b/src/main/java/com/xcong/excoin/utils/CacheSettingUtils.java
deleted file mode 100644
index 9145008..0000000
--- a/src/main/java/com/xcong/excoin/utils/CacheSettingUtils.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.xcong.excoin.utils;
-
-import cn.hutool.core.bean.BeanUtil;
-import com.xcong.excoin.modules.platform.dao.TradeSettingDao;
-import com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author wzy
- * @date 2020-05-28
- **/
-@Component
-public class CacheSettingUtils {
-
-
- /**
- * 交易设置缓存Key
- */
- private final static String TRADE_SETTING_KEY = "trade_setting_key";
-
- /**
- * 币种规格缓存key
- */
- private final static String TRADE_SYMBOL_SKU_KEY = "trade_symbol_sku_key";
-
- @Resource
- private TradeSettingDao tradeSettingDao;
-
- @Resource
- private RedisUtils redisUtils;
-
-
- /**
- * 获取币种规格
- *
- * @param symbol
- * @return
- */
- public BigDecimal getSymbolSku(String symbol) {
- Object hget = redisUtils.hget(TRADE_SYMBOL_SKU_KEY, symbol);
- if (hget == null) {
- List<PlatformSymbolsSkuEntity> symbolSkubySymbol = tradeSettingDao.findAllSymbolSkubySymbol();
- Map<String, Object> map = new HashMap<String, Object>();
- if (CollectionUtils.isNotEmpty(symbolSkubySymbol)) {
- for (PlatformSymbolsSkuEntity symbolSku : symbolSkubySymbol) {
- map.put(symbolSku.getName(), symbolSku.getLotnumber());
- }
- // 存入redis
- redisUtils.hmset(TRADE_SYMBOL_SKU_KEY, map);
- }
-
- hget = redisUtils.hget(TRADE_SYMBOL_SKU_KEY, symbol);
- }
-
- return new BigDecimal(hget.toString());
- }
-
- /**
- * 获取交易设置缓存
- *
- * @return
- */
- public PlatformTradeSettingEntity getTradeSetting() {
- Map<Object, Object> hmget = redisUtils.hmget(TRADE_SETTING_KEY);
-
- if (hmget == null || hmget.size() == 0) {
- PlatformTradeSettingEntity tradeSetting = tradeSettingDao.findTradeSetting();
- redisUtils.hmset(TRADE_SETTING_KEY, BeanUtil.beanToMap(tradeSetting));
- return tradeSetting;
- }
- return BeanUtil.mapToBean(hmget, PlatformTradeSettingEntity.class, true);
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/CalculateUtil.java b/src/main/java/com/xcong/excoin/utils/CalculateUtil.java
deleted file mode 100644
index 0ef6ae6..0000000
--- a/src/main/java/com/xcong/excoin/utils/CalculateUtil.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.xcong.excoin.utils;
-
-
-import com.xcong.excoin.modules.member.dao.MemberSettingDao;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.entity.MemberSettingEntity;
-import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
-import lombok.extern.slf4j.Slf4j;
-
-import java.math.BigDecimal;
-
-/**
- * @author helius
- */
-@Slf4j
-public class CalculateUtil {
-
- /**
- * 计算预估强平价
- *
- * @param bondAmount 保证金
- * @param openPrice 开仓价
- * @param symbolSkuNumber 张数
- * @param lotNumber 规格
- * @param type 1:买多2:卖空
- * @return
- */
- public static BigDecimal getForceSetPrice(BigDecimal bondAmount, BigDecimal openPrice, int symbolSkuNumber, BigDecimal lotNumber,
- int type, MemberEntity member) {
- MemberSettingDao memberSettingDao = SpringContextHolder.getBean(MemberSettingDao.class);
- BigDecimal forcePrice = BigDecimal.ZERO;
- BigDecimal money = bondAmount.divide(new BigDecimal(symbolSkuNumber).multiply(lotNumber), 8, BigDecimal.ROUND_DOWN);
- if (member.getIsForce() == 1) {
- MemberSettingEntity memberSetting = memberSettingDao.selectMemberSettingByMemberId(member.getId());
- money = money.multiply(memberSetting.getForceParam().multiply(BigDecimal.valueOf(100)));
- }
- //卖空
- if (type == 2) {
- forcePrice = money.add(openPrice);
- } else {//开多
- forcePrice = openPrice.subtract(money);
- }
- if (forcePrice.compareTo(BigDecimal.ZERO) < 0) {
- forcePrice = BigDecimal.ZERO;
- }
- return forcePrice;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/CoinTypeConvert.java b/src/main/java/com/xcong/excoin/utils/CoinTypeConvert.java
deleted file mode 100644
index 560eca7..0000000
--- a/src/main/java/com/xcong/excoin/utils/CoinTypeConvert.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.xcong.excoin.utils;
-
-/**
- * @author wzy
- * @date 2020-05-28
- **/
-public class CoinTypeConvert {
-
- public static String convert(String symbol) {
- switch (symbol) {
- case "btcusdt":
- return "BTC/USDT";
- case "ethusdt":
- return "ETH/USDT";
- case "xrpusdt":
- return "XRP/USDT";
- case "ltcusdt":
- return "LTC/USDT";
- case "bchusdt":
- return "BCH/USDT";
- case "eosusdt":
- return "EOS/USDT";
- case "etcusdt":
- return "ETC/USDT";
- default:
- return null;
- }
- }
-
- public static String okxConvert(String symbol) {
- //将xxx-USDT转换成xxx/USDT
- if (symbol.contains("-")) {
- symbol = symbol.replace("-", "/");
- }
-
- return symbol;
- }
-
- public static String convertToKey(String symbol) {
- switch (symbol) {
- case "BTC/USDT":
- return "BTC_NEW_PRICE";
- case "ETH/USDT":
- return "ETH_NEW_PRICE";
- case "XRP/USDT":
- return "XRP_NEW_PRICE";
- case "LTC/USDT":
- return "LTC_NEW_PRICE";
- case "BCH/USDT":
- return "BCH_NEW_PRICE";
- case "EOS/USDT":
- return "EOS_NEW_PRICE";
- case "ETC/USDT":
- return "ETC_NEW_PRICE";
- default:
- return null;
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/LogRecordUtils.java b/src/main/java/com/xcong/excoin/utils/LogRecordUtils.java
deleted file mode 100644
index 6bf4189..0000000
--- a/src/main/java/com/xcong/excoin/utils/LogRecordUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin.utils;
-
-import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao;
-import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
-import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
-import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
-
-import java.math.BigDecimal;
-
-/**
- * 日志记录工具类
- *
- * @author wzy
- * @date 2020-07-02
- **/
-public class LogRecordUtils {
-
- public static void insertMemberAccountMoneyChange(Long memberId,String content, BigDecimal amount, String symbol, Integer status, Integer type) {
- MemberAccountMoneyChange accountRecord = new MemberAccountMoneyChange();
- accountRecord.setContent(content);
- accountRecord.setMemberId(memberId);
- accountRecord.setAmount(amount);
- accountRecord.setStatus(status);
- accountRecord.setSymbol(symbol);
- accountRecord.setType(type);
- SpringContextHolder.getBean(MemberAccountMoneyChangeDao.class).insert(accountRecord);
- }
-
- public static void insertMemberAccountFlow(Long memberId, BigDecimal price, BigDecimal balance, String symbol, String source, String remark) {
- MemberAccountFlowEntity memberAccountFlowEntity = new MemberAccountFlowEntity();
- memberAccountFlowEntity.setMemberId(memberId);
- memberAccountFlowEntity.setPrice(price);
- memberAccountFlowEntity.setBalance(balance);
- memberAccountFlowEntity.setSymbol(symbol);
- memberAccountFlowEntity.setSource(source);
- memberAccountFlowEntity.setRemark(remark);
- SpringContextHolder.getBean(MemberAccountFlowEntityDao.class).insert(memberAccountFlowEntity);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/MessageSourceUtils.java b/src/main/java/com/xcong/excoin/utils/MessageSourceUtils.java
deleted file mode 100644
index 4663dd4..0000000
--- a/src/main/java/com/xcong/excoin/utils/MessageSourceUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.xcong.excoin.utils;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.MessageSource;
-import org.springframework.context.NoSuchMessageException;
-import org.springframework.context.i18n.LocaleContextHolder;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wzy
- * @date 2020-05-05 16:57
- **/
-@Component
-@Slf4j
-public class MessageSourceUtils {
-
- private static MessageSource messageSource;
-
- public MessageSourceUtils(MessageSource messageSource) {
- MessageSourceUtils.messageSource = messageSource;
- }
-
- public static String getString(String key) {
- try {
- return messageSource.getMessage(key, null, LocaleContextHolder.getLocale());
- } catch (NoSuchMessageException e) {
- log.error("#获取国际化异常#", e);
- return key;
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/OssUtils.java b/src/main/java/com/xcong/excoin/utils/OssUtils.java
deleted file mode 100644
index eb9cc89..0000000
--- a/src/main/java/com/xcong/excoin/utils/OssUtils.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.xcong.excoin.utils;
-
-import com.aliyun.oss.OSS;
-import lombok.extern.slf4j.Slf4j;
-import sun.misc.BASE64Decoder;
-
-import java.io.ByteArrayInputStream;
-
-/**
- * @author wzy
- * @date 2020-05-22
- **/
-@Slf4j
-public class OssUtils {
-
- private static final OSS OSS_CLIENT = (OSS) SpringContextHolder.getBean("ossClient");
-
- public static boolean uploadFileWithBase64(String base64, String pathName) {
- ByteArrayInputStream stream = null;
- try {
- BASE64Decoder decoder = new BASE64Decoder();
- byte[] bytes = decoder.decodeBuffer(base64);
- stream = new ByteArrayInputStream(bytes);
- OSS_CLIENT.putObject("excoin", pathName, stream);
- return true;
- } catch (Exception e) {
- log.error("#上传失败:{}#", e);
- return false;
- }
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/RedisUtils.java b/src/main/java/com/xcong/excoin/utils/RedisUtils.java
deleted file mode 100644
index 6110ef3..0000000
--- a/src/main/java/com/xcong/excoin/utils/RedisUtils.java
+++ /dev/null
@@ -1,583 +0,0 @@
-package com.xcong.excoin.utils;
-
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @Author wzy
- * @Date 2020/5/10
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@Component
-public class RedisUtils {
-
-
- @Resource
- private RedisTemplate<String, Object> redisTemplate;
-
-
- // =============================common============================
- /**
- * 指定缓存失效时间
- * @param key 键
- * @param time 时间(秒)
- * @return
- */
- public boolean expire(String key, long time) {
- try {
- if (time > 0) {
- redisTemplate.expire(key, time, TimeUnit.SECONDS);
- }
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /**
- * 根据key 获取过期时间
- * @param key 键 不能为null
- * @return 时间(秒) 返回0代表为永久有效
- */
- public long getExpire(String key) {
- return redisTemplate.getExpire(key, TimeUnit.SECONDS);
- }
-
- /**
- * 判断key是否存在
- * @param key 键
- * @return true 存在 false不存在
- */
- public boolean hasKey(String key) {
- try {
- return redisTemplate.hasKey(key);
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /**
- * 删除缓存
- * @param key 可以传一个值 或多个
- */
- @SuppressWarnings("unchecked")
- public void del(String... key) {
- if (key != null && key.length > 0) {
- if (key.length == 1) {
- redisTemplate.delete(key[0]);
- } else {
- redisTemplate.delete(CollectionUtils.arrayToList(key));
- }
- }
- }
-
- // ============================String=============================
- /**
- * 普通缓存获取
- * @param key 键
- * @return 值
- */
- public Object get(String key) {
- return key == null ? null : redisTemplate.opsForValue().get(key);
- }
- public Object getWithDelay(String key) {
- // 在读取前添加短暂延迟
- try {
- Thread.sleep(50); // 等待50ms让Redis同步完成
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- return key == null ? null : redisTemplate.opsForValue().get(key);
- }
-
-
- /**
- * 普通缓存获取
- * @param key 键
- * @return 值
- */
- public String getStringWithDelay(String key) {
- // 在读取前添加短暂延迟
- try {
- Thread.sleep(50); // 等待50ms让Redis同步完成
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- Object obj = key == null ? null : redisTemplate.opsForValue().get(key);
- if(obj!=null){
- return obj.toString();
- }
- return null;
- }
-
-
- /**
- * 普通缓存获取
- * @param key 键
- * @return 值
- */
- public String getString(String key) {
- Object obj = key == null ? null : redisTemplate.opsForValue().get(key);
- if(obj!=null){
- return obj.toString();
- }
- return null;
- }
-
- /**
- * 普通缓存放入
- * @param key 键
- * @param value 值
- * @return true成功 false失败
- */
- public boolean set(String key, Object value) {
- try {
- redisTemplate.opsForValue().set(key, value);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /**
- * 普通缓存放入并设置时间
- * @param key 键
- * @param value 值
- * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
- * @return true成功 false 失败
- */
- public boolean set(String key, Object value, long time) {
- try {
- if (time > 0) {
- redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
- } else {
- set(key, value);
- }
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- public boolean setNotExist(String key, Object value, long time) {
- return redisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
- }
-
- /**
- * 递增
- * @param key 键
- * @param delta 要增加几(大于0)
- * @return
- */
- public long incr(String key, long delta) {
- if (delta < 0) {
- throw new RuntimeException("递增因子必须大于0");
- }
- return redisTemplate.opsForValue().increment(key, delta);
- }
-
- /**
- * 递减
- * @param key 键
- * @param delta 要减少几(小于0)
- * @return
- */
- public long decr(String key, long delta) {
- if (delta < 0) {
- throw new RuntimeException("递减因子必须大于0");
- }
- return redisTemplate.opsForValue().increment(key, -delta);
- }
-
-
- // ================================Map=================================
-
- /**
- * HashGet
- * @param key 键 不能为null
- * @param item 项 不能为null
- * @return 值
- */
- public Object hget(String key, String item) {
- return redisTemplate.opsForHash().get(key, item);
- }
-
- /**
- * 获取hashKey对应的所有键值
- * @param key 键
- * @return 对应的多个键值
- */
- public Map<Object, Object> hmget(String key) {
- return redisTemplate.opsForHash().entries(key);
- }
- /**
- * HashSet
-
- * @param key 键
- * @param map 对应多个键值
- * @return true 成功 false 失败
- */
- public boolean hmset(String key, Map<String, Object> map) {
- try {
- redisTemplate.opsForHash().putAll(key, map);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * HashSet 并设置时间
- * @param key 键
- * @param map 应多个键值
- * @param time 时间(秒)
- * @return true成功 false失败
- */
- public boolean hmset(String key, Map<String, Object> map, long time) {
- try {
- redisTemplate.opsForHash().putAll(key, map);
- if (time > 0) {
- expire(key, time);
- }
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
-
- /**
- * 向一张hash表中放入数据,如果不存在将创建
- * @param key 键
- * @param item 项
- * @param value 值
- * @return true 成功 false失败
- */
- public boolean hset(String key, String item, Object value) {
- try {
- redisTemplate.opsForHash().put(key, item, value);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 向一张hash表中放入数据,如果不存在将创建
- * @param key 键
- * @param item 项
- * @param value 值
- * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
- * @return true 成功 false失败
- */
- public boolean hset(String key, String item, Object value, long time) {
- try {
- redisTemplate.opsForHash().put(key, item, value);
- if (time > 0) {
- expire(key, time);
- }
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 删除hash表中的值
- * @param key 键 不能为null
- * @param item 项 可以使多个 不能为null
- */
- public void hdel(String key, Object... item) {
- redisTemplate.opsForHash().delete(key, item);
- }
- /**
- * 判断hash表中是否有该项的值
- * @param key 键 不能为null
- * @param item 项 不能为null
- * @return true 存在 false不存在
- */
- public boolean hHasKey(String key, String item) {
- return redisTemplate.opsForHash().hasKey(key, item);
- }
-
- /**
- * hash递增 如果不存在,就会创建一个 并把新增后的值返回
- * @param key 键
- * @param item 项
- * @param by 要增加几(大于0)
- * @return
- */
- public double hincr(String key, String item, double by) {
- return redisTemplate.opsForHash().increment(key, item, by);
- }
-
- /**
- * hash递减
- * @param key 键
- * @param item 项
- * @param by 要减少记(小于0)
- * @return
- */
- public double hdecr(String key, String item, double by) {
- return redisTemplate.opsForHash().increment(key, item, -by);
- }
- // ============================set=============================
- /**
- * 根据key获取Set中的所有值
- * @param key 键
- * @return
- */
- public Set<Object> sGet(String key) {
- try {
- return redisTemplate.opsForSet().members(key);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
- /**
- * 根据value从一个set中查询,是否存在
- * @param key 键
- * @param value 值
- * @return true 存在 false不存在
- */
- public boolean sHasKey(String key, Object value) {
- try {
- return redisTemplate.opsForSet().isMember(key, value);
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 将数据放入set缓存
- * @param key 键
- * @param values 值 可以是多个
- * @return 成功个数
- */
- public long sSet(String key, Object... values) {
- try {
- return redisTemplate.opsForSet().add(key, values);
- } catch (Exception e) {
- e.printStackTrace();
-
- return 0;
- }
- }
- /**
- 336
- * 将set数据放入缓存
- 337
- * @param key 键
- * @param time 时间(秒)
- * @param values 值 可以是多个
- * @return 成功个数
- */
- public long sSetAndTime(String key, long time, Object... values) {
- try {
- Long count = redisTemplate.opsForSet().add(key, values);
- if (time > 0)
- expire(key, time);
- return count;
-
- }catch(Exception e) {
- e.printStackTrace();
- return 0;
- }
- }
- /**
- * 获取set缓存的长度
- * @param key 键
- * @return
- */
-
- public long sGetSetSize(String key) {
- try {
- return redisTemplate.opsForSet().size(key);
-
- } catch (Exception e) {
- e.printStackTrace();
- return 0;
- }
-
- }
-
- /**
- * 移除值为value的
- * @param key 键
- * @param values 值 可以是多个
- * @return 移除的个数
-
- */
- public long setRemove(String key, Object... values) {
- try {
- Long count = redisTemplate.opsForSet().remove(key, values);
- return count;
-
- } catch (Exception e) {
- e.printStackTrace();
- return 0;
- }
- }
- // ===============================list=================================
- /**
- * 获取list缓存的内容 * @param key 键
- * @param start 开始
- * @param end 结束 0 到 -1代表所有值
- * @return
- */
- public List<Object> lGet(String key, long start, long end) {
- try {
- return redisTemplate.opsForList().range(key, start, end);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
-
- }
-
- /**
- * 获取list缓存的长度
- * @param key 键
-
- * @return
- */
- public long lGetListSize(String key) { try {
- return redisTemplate.opsForList().size(key);
- } catch (Exception e) {
-
- e.printStackTrace();
- return 0;
- }
- } /**
- * 通过索引 获取list中的值
- * @param key 键
- * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
- * @return
- */
- public Object lGetIndex(String key, long index) {
-
- try {
- return redisTemplate.opsForList().index(key, index);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * 将list放入缓存
- * @param key 键
- * @param value 值
- * @return
- */
- public boolean lSet(String key, Object value) {
- try {
- redisTemplate.opsForList().rightPush(key, value);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /**
- * 将list放入缓存
- * @param key 键
- * @param value 值
- * @param time 时间(秒)
- * @return
- */
- public boolean lSet(String key, Object value, long time) {
- try {
- redisTemplate.opsForList().rightPush(key, value);
- if (time > 0)
- expire(key, time);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 将list放入缓存
- * @param key 键
- * @param value 值
- * @return
- */
- public boolean lSet(String key, List<Object> value) {
- try {
- redisTemplate.opsForList().rightPushAll(key, value);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 将list放入缓存
- *
- * @param key 键
- * @param value 值
- * @param time 时间(秒)
- * @return
- */
- public boolean lSet(String key, List<Object> value, long time) {
- try {
- redisTemplate.opsForList().rightPushAll(key, value);
- if (time > 0)
- expire(key, time);
- return true;
-
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 根据索引修改list中的某条数据
- * @param key 键
- * @param index 索引
- * @param value 值
- * @return
- */
- public boolean lUpdateIndex(String key, long index, Object value) {
- try {
- redisTemplate.opsForList().set(key, index, value);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
-
- /**
- * 移除N个值为value
- * @param key 键
- * @param count 移除多少个
- * @param value 值
- * @return 移除的个数
- */
- public long lRemove(String key, long count, Object value) {
- try {
- return redisTemplate.opsForList().remove(key, count, value);
- } catch (Exception e) {
- e.printStackTrace();
- return 0;
- }
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/SSLClient.java b/src/main/java/com/xcong/excoin/utils/SSLClient.java
deleted file mode 100644
index 0b26d23..0000000
--- a/src/main/java/com/xcong/excoin/utils/SSLClient.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.xcong.excoin.utils;
-
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-
-@SuppressWarnings("deprecation")
-class SSLClient extends DefaultHttpClient {
- public SSLClient() throws Exception {
- super();
- SSLContext ctx = SSLContext.getInstance("TLS");
- X509TrustManager tm = new X509TrustManager() {
-
- @Override
- public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- // TODO Auto-generated method stub
- return null;
- }
-
- };
- ctx.init(null, new TrustManager[] { tm }, null);
-
- SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
- ClientConnectionManager ccm = this.getConnectionManager();
- SchemeRegistry sr = ccm.getSchemeRegistry();
- sr.register(new Scheme("https", 443, ssf));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/xcong/excoin/utils/ShareCodeUtil.java b/src/main/java/com/xcong/excoin/utils/ShareCodeUtil.java
deleted file mode 100644
index 881f5e1..0000000
--- a/src/main/java/com/xcong/excoin/utils/ShareCodeUtil.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.xcong.excoin.utils;
-
-import java.util.Random;
-
-/**
- * 邀请码生成器,算法原理:<br/>
- * 1) 获取id: 1127738 <br/>
- * 2) 使用自定义进制转为:gpm6 <br/>
- * 3) 转为字符串,并在后面加'o'字符:gpm6o <br/>
- * 4)在后面随机产生若干个随机数字字符:gpm6o7 <br/>
- * 转为自定义进制后就不会出现o这个字符,然后在后面加个'o',这样就能确定唯一性。最后在后面产生一些随机字符进行补全。<br/>
- */
-public class ShareCodeUtil {
-
- /**
- * 自定义进制(0,1没有加入,容易与o,l混淆)
- */
-// private static final char[] r=new char[]{'q', 'w', 'e', '8', 'a', 's', '2', 'd', 'z', 'x', '9', 'c', '7', 'p', '5', 'i', 'k', '3', 'm', 'j', 'u', 'f', 'r', '4', 'v', 'y', 'l', 't', 'n', '6', 'b', 'g', 'h'};
- private static final char[] r = new char[]{'1', '2', '3', '4', '5', '6', '7', '8', '9'};
-
- /**
- * (不能与自定义进制有重复)
- */
- private static final char b = '0';
-
- /**
- * 进制长度
- */
- private static final int binLen = r.length;
-
- /**
- * 序列最小长度
- */
- private static final int s = 8;
-
- /**
- * 根据ID生成六位随机码
- *
- * @param id ID
- * @return 随机码
- */
- public static String toSerialCode(long id) {
- char[] buf = new char[32];
- int charPos = 32;
-
- while ((id / binLen) > 0) {
- int ind = (int) (id % binLen);
- buf[--charPos] = r[ind];
- id /= binLen;
- }
- buf[--charPos] = r[(int) (id % binLen)];
- String str = new String(buf, charPos, (32 - charPos));
- // 不够长度的自动随机补全
- if (str.length() < s) {
- StringBuilder sb = new StringBuilder();
- sb.append(b);
- Random rnd = new Random();
- for (int i = 1; i < s - str.length(); i++) {
- sb.append(r[rnd.nextInt(binLen)]);
- }
- str += sb.toString();
- }
- return str;
- }
-
- /**
- * 根据ID生成六位随机码
- *
- * @param id ID
- * @return 随机码
- */
- public static String toSerialNumberCode(long id) {
- char[] buf = new char[32];
- int charPos = 32;
-
- while ((id / binLen) > 0) {
- int ind = (int) (id % binLen);
- buf[--charPos] = r[ind];
- id /= binLen;
- }
- buf[--charPos] = r[(int) (id % binLen)];
- String str = new String(buf, charPos, (32 - charPos));
- // 不够长度的自动随机补全
- if (str.length() < s) {
- StringBuilder sb = new StringBuilder();
- sb.append(b);
- Random rnd = new Random();
- for (int i = 1; i < s - str.length(); i++) {
- sb.append(r[rnd.nextInt(binLen)]);
- }
- str += sb.toString();
- }
- return str;
- }
-
- public static long codeToId(String code) {
- char chs[] = code.toCharArray();
- long res = 0L;
- for (int i = 0; i < chs.length; i++) {
- int ind = 0;
- for (int j = 0; j < binLen; j++) {
- if (chs[i] == r[j]) {
- ind = j;
- break;
- }
- }
- if (chs[i] == b) {
- break;
- }
- if (i > 0) {
- res = res * binLen + ind;
- } else {
- res = ind;
- }
- }
- return res;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/xcong/excoin/utils/SmsUtils.java b/src/main/java/com/xcong/excoin/utils/SmsUtils.java
deleted file mode 100644
index 4adc0ee..0000000
--- a/src/main/java/com/xcong/excoin/utils/SmsUtils.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.xcong.excoin.utils;
-
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-import org.dom4j.Document;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 短信发送工具
- *
- * @author wzy
- * @date 2020-05-18
- **/
-public class SmsUtils {
-
-
- private static HttpClient httpclient;
-
- @SuppressWarnings("deprecation")
- public static Map<String, Object> hxSmsSend(String mobile, String sendContent) {
- Map<String, Object> map = new HashMap<String, Object>();
- try {
- httpclient = new SSLClient();
- //TFT001
- String url = "https://dx.ipyy.net/sms.aspx";
- //excoin DX001 //ctcoin:OT00028 //改为实际账号名
- String accountName = "DX001";
- //excoin 1qaz2wsx //ctcoin: atvckt //改为实际发送密码
- String password = "1qaz2wsx";
- String text = sendContent;
- HttpPost post = new HttpPost(url);
- post.setHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
- List<NameValuePair> nvps = new ArrayList<NameValuePair>();
- nvps.add(new BasicNameValuePair("action", "send"));
- nvps.add(new BasicNameValuePair("userid", ""));
- nvps.add(new BasicNameValuePair("account", accountName));
- nvps.add(new BasicNameValuePair("password", password));
- //多个手机号用逗号分隔
- nvps.add(new BasicNameValuePair("mobile", mobile));
- nvps.add(new BasicNameValuePair("content", text));
- nvps.add(new BasicNameValuePair("sendTime", ""));
- nvps.add(new BasicNameValuePair("extno", ""));
-
- post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
-
- HttpResponse response = httpclient.execute(post);
- HttpEntity entity = response.getEntity();
- // 将字符转化为XML
- String returnString = EntityUtils.toString(entity, "UTF-8");
- Document doc = DocumentHelper.parseText(returnString);
- // 获取根节点
- Element rootElt = doc.getRootElement();
- // 获取根节点下的子节点的值
- String returnstatus = rootElt.elementText("returnstatus").trim();
- String message = rootElt.elementText("message").trim();
- String remainpoint = rootElt.elementText("remainpoint").trim();
- String taskID = rootElt.elementText("taskID").trim();
- String successCounts = rootElt.elementText("successCounts").trim();
-
- map.put("returnstatus", returnstatus);
- map.put("message", message);
- map.put("remainpoint", remainpoint);
- map.put("taskID", taskID);
- map.put("successCounts", successCounts);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return map;
- }
-
- /**
- * 短信验证码
- *
- * @param phone 手机号
- * @param code 验证码
- * @return
- */
- public static Map<String, Object> sendVerifyCode(String phone, int code) {
- String smsContent = "【Excoin】您的验证码为:"+code+",该验证码有效期为2分钟,请勿泄露于他人。";
- return hxSmsSend(phone, smsContent);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java b/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
deleted file mode 100644
index 857d02c..0000000
--- a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.xcong.excoin.utils;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author wzy
- * @Date 2020/5/11
- * @email wangdoubleone@gmail.com
- * @Version V1.0
- **/
-@Component
-@Slf4j
-public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
-
- private static ApplicationContext applicationContext = null;
-
- /**
- * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
- */
- @SuppressWarnings("unchecked")
- public static <T> T getBean(String name) {
- assertContextInjected();
- return (T) applicationContext.getBean(name);
- }
-
- /**
- * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
- */
- public static <T> T getBean(Class<T> requiredType) {
- assertContextInjected();
- return applicationContext.getBean(requiredType);
- }
-
- private static void assertContextInjected() {
- if (applicationContext == null) {
- throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" +
- ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
- }
- }
-
- /**
- * 检查ApplicationContext不为空.
- */
- private static void clearHolder() {
- log.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
- applicationContext = null;
- }
-
- @Override
- public void destroy() throws Exception {
- SpringContextHolder.clearHolder();
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- if (SpringContextHolder.applicationContext != null) {
- log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
- }
- SpringContextHolder.applicationContext = applicationContext;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java b/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java
deleted file mode 100644
index 10c1e06..0000000
--- a/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.xcong.excoin.utils;
-
-import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
-import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl;
-import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
-
-import java.math.BigDecimal;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author wzy
- * @date 2020-06-01
- **/
-public class ThreadPoolUtils {
-
- public static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(20);
-
- /**
- * 计算佣金
- *
- * @param id 用户ID
- * @param price 手续费
- * @param entity 订单实体
- * @param type 订单类型
- */
- public static void calReturnMoney(Long id, BigDecimal price, ContractOrderEntity entity, int type) {
- OrderWebsocketServiceImpl orderWebsocketService = SpringContextHolder.getBean(OrderWebsocketServiceImpl.class);
- EXECUTOR.execute(new Runnable() {
- @Override
- public void run() {
- orderWebsocketService.calYj(id, price, entity, type);
- }
- });
- }
-
- /**
- * 发送钉钉消息
- *
- * @param type 类型
- */
- public static void sendDingTalk(int type) {
- EXECUTOR.execute(new Runnable() {
- @Override
- public void run() {
- DingTalkUtils.sendActionCard(type);
- }
- });
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/TypeJudgeUtils.java b/src/main/java/com/xcong/excoin/utils/TypeJudgeUtils.java
deleted file mode 100644
index c7f511a..0000000
--- a/src/main/java/com/xcong/excoin/utils/TypeJudgeUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.xcong.excoin.utils;
-
-/**
- * 接受参数 类型判断
- *
- * @author wzy
- * @date 2020-05-27
- **/
-public class TypeJudgeUtils {
-
- /**
- * 委托类型 1开多 2开空 3平多 4平空
- *
- * @param type
- * @return
- */
- public static boolean entrustType(int type) {
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- return true;
- default:
- return false;
- }
- }
-
- /**
- * 判断k线区间
- *
- * @param period
- * @return
- */
- public static boolean klinePeriod(String period) {
- switch (period) {
- case "1min":
- case "5min":
- case "30min":
- case "60min":
- case "4hour":
- case "1day":
- case "1week":
- return true;
- default:
- return false;
- }
-
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/ApiClient.java b/src/main/java/com/xcong/excoin/utils/api/ApiClient.java
deleted file mode 100644
index 39f72d9..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/ApiClient.java
+++ /dev/null
@@ -1,607 +0,0 @@
-package com.xcong.excoin.utils.api;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.PropertyNamingStrategy;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.xcong.excoin.utils.api.request.CreateOrderRequest;
-import com.xcong.excoin.utils.api.request.IntrustOrdersDetailRequest;
-import com.xcong.excoin.utils.api.response.*;
-import okhttp3.*;
-import okhttp3.OkHttpClient.Builder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.bind.DatatypeConverter;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.security.InvalidKeyException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-/**
- * API client.
- *
- * @Date 2018/1/14
- * @Time 16:02
- */
-public class ApiClient {
-
- static final int CONN_TIMEOUT = 50;
- static final int READ_TIMEOUT = 50;
- static final int WRITE_TIMEOUT = 50;
-
-
- // static final String API_URL = "https://api.huobi.pro:443";
- // static final String API_URL = "https://api.huobi.pro";
- // static final String API_URL = "https://api.hbdm.com";
- // static final String API_URL = "https://api.huobi.br.com";
- // static final String API_URL = "https://api.btcgateway.pro";
- static final String API_URL = "https://api.hadax.com";
- static final String API_HOST = getHost();
-
- static final MediaType JSON = MediaType.parse("application/json");
- static final OkHttpClient client = createOkHttpClient();
-
- final String accessKeyId;
- final String accessKeySecret;
- final String assetPassword;
-
- /**
- * 创建一个ApiClient实例
- *
- * @param accessKeyId AccessKeyId
- * @param accessKeySecret AccessKeySecret
- */
- public ApiClient(String accessKeyId, String accessKeySecret) {
- this.accessKeyId = accessKeyId;
- this.accessKeySecret = accessKeySecret;
- this.assetPassword = null;
- }
-
- /**
- * 创建一个ApiClient实例
- *
- * @param accessKeyId AccessKeyId
- * @param accessKeySecret AccessKeySecret
- * @param assetPassword AssetPassword
- */
- public ApiClient(String accessKeyId, String accessKeySecret, String assetPassword) {
- this.accessKeyId = accessKeyId;
- this.accessKeySecret = accessKeySecret;
- this.assetPassword = assetPassword;
- }
-
- /**
- * 查询交易对
- *
- * @return List of symbols.
- */
- public List<Symbol> getSymbols() {
- ApiResponse<List<Symbol>> resp =
- get("/v1/common/symbols", null, new TypeReference<ApiResponse<List<Symbol>>>() {
- });
- return resp.checkAndReturn();
- }
-
- /**
- * 查询所有账户信息
- *
- * @return List of accounts.
- */
- public List<Account> getAccounts() {
- ApiResponse<List<Account>> resp =
- get("/v1/account/accounts", null, new TypeReference<ApiResponse<List<Account>>>() {
- });
- return resp.checkAndReturn();
- }
-
- /**
- * 创建订单
- *
- * @param request CreateOrderRequest object.
- * @return Order id.
- */
- public Long createOrder(CreateOrderRequest request) {
- ApiResponse<Long> resp =
- post("/v1/order/orders/place", request, new TypeReference<ApiResponse<Long>>() {
- });
- return resp.checkAndReturn();
- }
-
- /**
- * 执行订单
- *
- * @param orderId The id of created order.
- * @return Order id.
- */
- public String placeOrder(long orderId) {
- ApiResponse<String> resp = post("/v1/order/orders/" + orderId + "/place", null,
- new TypeReference<ApiResponse<String>>() {
- });
- return resp.checkAndReturn();
- }
-
-
- // ----------------------------------------行情API-------------------------------------------
-
- /**
- * GET /market/history/kline 获取K线数据
- *
- * @param symbol
- * @param period
- * @param size
- * @return
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public KlineResponse kline(String symbol, String period, String size) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- map.put("period", period);
- map.put("size", size);
- KlineResponse resp = get("/market/history/kline", map, new TypeReference<KlineResponse<List<Kline>>>() {
- });
- return resp;
- }
-
- /**
- * GET /market/detail/merged 获取聚合行情(Ticker)
- *
- * @param symbol
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public MergedResponse merged(String symbol) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- MergedResponse resp = get("/market/detail/merged", map, new TypeReference<MergedResponse<List<Merged>>>() {
- });
- return resp;
- }
-
- /**
- * GET /market/depth 获取 Market Depth 数据
- *
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public DepthResponse depth(String symbol, String type, String depth) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- map.put("type", type);
- map.put("depth", depth);
- DepthResponse resp = get("/market/depth", map, new TypeReference<DepthResponse<List<Depth>>>() {
- });
- return resp;
- }
-
- /**
- * GET /market/trade 获取 Trade Detail 数据
- *
- * @param symbol
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public TradeResponse trade(String symbol) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- TradeResponse resp = get("/market/trade", map, new TypeReference<TradeResponse>() {
- });
- return resp;
- }
-
- /**
- * GET /market/history/trade 批量获取最近的交易记录
- *
- * @param symbol
- * @param size
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public HistoryTradeResponse historyTrade(String symbol, String size) {
-// System.out.println("symbol = "+symbol+" size = "+size);
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- map.put("size", size);
- HistoryTradeResponse resp = get("/market/history/trade", map, new TypeReference<HistoryTradeResponse>() {
- });
- return resp;
- }
-
- /**
- * GET /market/detail 获取 Market Detail 24小时成交量数据
- *
- * @param symbol
- * @return
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public DetailResponse detail(String symbol) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- DetailResponse resp = get("/market/detail", map, new TypeReference<DetailResponse<Details>>() {
- });
- return resp;
- }
-
-
- /**
- * GET /v1/common/symbols 查询系统支持的所有交易对及精度
- *
- * @param symbol
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public SymbolsResponse symbols(String symbol) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- SymbolsResponse resp = get("/v1/common/symbols", map, new TypeReference<SymbolsResponse<Symbols>>() {
- });
- return resp;
- }
-
- /**
- * GET /v1/common/currencys 查询系统支持的所有币种
- *
- * @param symbol
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public CurrencysResponse currencys(String symbol) {
- HashMap map = new HashMap();
- map.put("symbol", symbol);
- CurrencysResponse resp = get("/v1/common/currencys", map, new TypeReference<CurrencysResponse>() {
- });
- return resp;
- }
-
- /**
- * GET /v1/common/timestamp 查询系统当前时间
- *
- * @return
- */
- public TimestampResponse timestamp() {
- TimestampResponse resp = get("/v1/common/timestamp", null, new TypeReference<TimestampResponse>() {
- });
- return resp;
- }
-
- /**
- * GET /v1/account/accounts 查询当前用户的所有账户(即account-id)
- *
- * @return
- */
- @SuppressWarnings({"rawtypes"})
- public AccountsResponse accounts() {
- AccountsResponse resp = get("/v1/account/accounts", null, new TypeReference<AccountsResponse<List<Accounts>>>() {
- });
- return resp;
- }
-
- /**
- * GET /v1/account/accounts/{account-id}/balance 查询指定账户的余额
- *
- * @param accountId
- * @return
- */
- @SuppressWarnings({"rawtypes"})
- public BalanceResponse balance(String accountId) {
- BalanceResponse resp = get("/v1/account/accounts/" + accountId + "/balance", null, new TypeReference<BalanceResponse<Balance>>() {
- });
- return resp;
- }
-
- /**
- * POST /v1/order/orders/{order-id}/submitcancel 申请撤销一个订单请求
- *
- * @param orderId
- * @return
- */
- public SubmitcancelResponse submitcancel(String orderId) {
- SubmitcancelResponse resp = post("/v1/order/orders/" + orderId + "/submitcancel", null, new TypeReference<SubmitcancelResponse>() {
- });
- return resp;
- }
-
- /**
- * POST /v1/order/orders/batchcancel 批量撤销订单
- *
- * @param orderList
- * @return
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public BatchcancelResponse submitcancels(List orderList) {
- Map<String, List> parameterMap = new HashMap();
- parameterMap.put("order-ids", orderList);
- BatchcancelResponse resp = post("/v1/order/orders/batchcancel", parameterMap, new TypeReference<BatchcancelResponse<Batchcancel<List, List<BatchcancelBean>>>>() {
- });
- return resp;
- }
-
- /**
- * GET /v1/order/orders/{order-id} 查询某个订单详情
- *
- * @param orderId
- * @return
- */
- @SuppressWarnings({"rawtypes"})
- public OrdersDetailResponse ordersDetail(String orderId) {
- OrdersDetailResponse resp = get("/v1/order/orders/" + orderId, null, new TypeReference<OrdersDetailResponse>() {
- });
- return resp;
- }
-
-
- /**
- * GET /v1/order/orders/{order-id}/matchresults 查询某个订单的成交明细
- *
- * @param orderId
- * @return
- */
- @SuppressWarnings({"rawtypes"})
- public MatchresultsOrdersDetailResponse matchresults(String orderId) {
- MatchresultsOrdersDetailResponse resp = get("/v1/order/orders/" + orderId + "/matchresults", null, new TypeReference<MatchresultsOrdersDetailResponse>() {
- });
- return resp;
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- public IntrustDetailResponse intrustOrdersDetail(IntrustOrdersDetailRequest req) {
- HashMap map = new HashMap();
- map.put("symbol", req.symbol);
- map.put("states", req.states);
- if (req.startDate != null) {
- map.put("startDate", req.startDate);
- }
- if (req.startDate != null) {
- map.put("start-date", req.startDate);
- }
- if (req.endDate != null) {
- map.put("end-date", req.endDate);
- }
- if (req.types != null) {
- map.put("types", req.types);
- }
- if (req.from != null) {
- map.put("from", req.from);
- }
- if (req.direct != null) {
- map.put("direct", req.direct);
- }
- if (req.size != null) {
- map.put("size", req.size);
- }
- IntrustDetailResponse resp = get("/v1/order/orders/", map, new TypeReference<IntrustDetailResponse<List<IntrustDetail>>>() {
- });
- return resp;
- }
-
-// public IntrustDetailResponse getALlOrdersDetail(String orderId) {
-// IntrustDetailResponse resp = get("/v1/order/orders/"+orderId, null,new TypeReference<IntrustDetailResponse>() {});
-// return resp;
-// }
-
-
- // send a GET request.
- <T> T get(String uri, Map<String, String> params, TypeReference<T> ref) {
- if (params == null) {
- params = new HashMap<>();
- }
- return call("GET", uri, null, params, ref);
- }
-
- // send a POST request.
- <T> T post(String uri, Object object, TypeReference<T> ref) {
- return call("POST", uri, object, new HashMap<String, String>(), ref);
- }
-
- // call api by endpoint.
- <T> T call(String method, String uri, Object object, Map<String, String> params,
- TypeReference<T> ref) {
- ApiSignature sign = new ApiSignature();
- sign.createSignature(this.accessKeyId, this.accessKeySecret, method, API_HOST, uri, params);
- try {
- Request.Builder builder = null;
- if ("POST".equals(method)) {
- RequestBody body = RequestBody.create(JSON, JsonUtil.writeValue(object));
- builder = new Request.Builder().url(API_URL + uri + "?" + toQueryString(params)).post(body);
- } else {
- builder = new Request.Builder().url(API_URL + uri + "?" + toQueryString(params)).get();
- }
- if (this.assetPassword != null) {
- builder.addHeader("AuthData", authData());
- }
- Request request = builder.build();
- Response response = client.newCall(request).execute();
- String s = response.body().string();
- //System.out.println("-----s:"+JsonUtil.writeValue(s));
- return JsonUtil.readValue(s, ref);
- } catch (IOException e) {
- // throw new ApiException(e);
- e.printStackTrace();
- return null;
- }
- }
-
- String authData() {
- MessageDigest md = null;
- try {
- md = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
- md.update(this.assetPassword.getBytes(StandardCharsets.UTF_8));
- md.update("hello, moto".getBytes(StandardCharsets.UTF_8));
- Map<String, String> map = new HashMap<>();
- map.put("assetPwd", DatatypeConverter.printHexBinary(md.digest()).toLowerCase());
- try {
- return ApiSignature.urlEncode(JsonUtil.writeValue(map));
- } catch (IOException e) {
- throw new RuntimeException("Get json failed: " + e.getMessage());
- }
- }
-
- // Encode as "a=1&b=%20&c=&d=AAA"
- String toQueryString(Map<String, String> params) {
- return String.join("&", params.entrySet().stream().map((entry) -> {
- return entry.getKey() + "=" + ApiSignature.urlEncode(entry.getValue());
- }).collect(Collectors.toList()));
- }
-
- // create OkHttpClient:
- static OkHttpClient createOkHttpClient() {
- return new Builder().connectTimeout(CONN_TIMEOUT, TimeUnit.SECONDS)
- .readTimeout(READ_TIMEOUT, TimeUnit.SECONDS).writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
- .build();
- }
-
- static String getHost() {
- String host = null;
- try {
- host = new URL(API_URL).getHost();
- } catch (MalformedURLException e) {
- System.err.println("parse API_URL error,system exit!,please check API_URL:" + API_URL);
- System.exit(0);
- }
- return host;
- }
-
-}
-
-
-/**
- * API签名,签名规范:
- * <p>
- * http://docs.aws.amazon.com/zh_cn/general/latest/gr/signature-version-2.html
- *
- * @Date 2018/1/14
- * @Time 16:02
- */
-class ApiSignature {
-
- final Logger log = LoggerFactory.getLogger(getClass());
-
- static final DateTimeFormatter DT_FORMAT = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss");
- static final ZoneId ZONE_GMT = ZoneId.of("Z");
-
- /**
- * 创建一个有效的签名。该方法为客户端调用,将在传入的params中添加AccessKeyId、Timestamp、SignatureVersion、SignatureMethod、Signature参数。
- *
- * @param appKey AppKeyId.
- * @param appSecretKey AppKeySecret.
- * @param method 请求方法,"GET"或"POST"
- * @param host 请求域名,例如"be.huobi.com"
- * @param uri 请求路径,注意不含?以及后的参数,例如"/v1/api/info"
- * @param params 原始请求参数,以Key-Value存储,注意Value不要编码
- */
- public void createSignature(String appKey, String appSecretKey, String method, String host,
- String uri, Map<String, String> params) {
- StringBuilder sb = new StringBuilder(1024);
- sb.append(method.toUpperCase()).append('\n') // GET
- .append(host.toLowerCase()).append('\n') // Host
- .append(uri).append('\n'); // /path
- params.remove("Signature");
- params.put("AccessKeyId", appKey);
- params.put("SignatureVersion", "2");
- params.put("SignatureMethod", "HmacSHA256");
- params.put("Timestamp", gmtNow());
- // build signature:
- SortedMap<String, String> map = new TreeMap<>(params);
- for (Map.Entry<String, String> entry : map.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- sb.append(key).append('=').append(urlEncode(value)).append('&');
- }
- // remove last '&':
- sb.deleteCharAt(sb.length() - 1);
- // sign:
- Mac hmacSha256 = null;
- try {
- hmacSha256 = Mac.getInstance("HmacSHA256");
- SecretKeySpec secKey =
- new SecretKeySpec(appSecretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
- hmacSha256.init(secKey);
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("No such algorithm: " + e.getMessage());
- } catch (InvalidKeyException e) {
- throw new RuntimeException("Invalid key: " + e.getMessage());
- }
- String payload = sb.toString();
- byte[] hash = hmacSha256.doFinal(payload.getBytes(StandardCharsets.UTF_8));
- String actualSign = Base64.getEncoder().encodeToString(hash);
- params.put("Signature", actualSign);
-
-
- if (log.isDebugEnabled()) {
- log.debug("Dump parameters:");
- for (Map.Entry<String, String> entry : params.entrySet()) {
- log.debug(" key: " + entry.getKey() + ", value: " + entry.getValue());
- }
- }
- }
-
-
- /**
- * 使用标准URL Encode编码。注意和JDK默认的不同,空格被编码为%20而不是+。
- *
- * @param s String字符串
- * @return URL编码后的字符串
- */
- public static String urlEncode(String s) {
- try {
- return URLEncoder.encode(s, "UTF-8").replaceAll("\\+", "%20");
- } catch (UnsupportedEncodingException e) {
- throw new IllegalArgumentException("UTF-8 encoding not supported!");
- }
- }
-
- /**
- * Return epoch seconds
- */
- long epochNow() {
- return Instant.now().getEpochSecond();
- }
-
- String gmtNow() {
- return Instant.ofEpochSecond(epochNow()).atZone(ZONE_GMT).format(DT_FORMAT);
- }
-}
-
-
-class JsonUtil {
-
- public static String writeValue(Object obj) throws IOException {
- return objectMapper.writeValueAsString(obj);
- }
-
- public static <T> T readValue(String s, TypeReference<T> ref) throws IOException {
- return objectMapper.readValue(s, ref);
- }
-
- static final ObjectMapper objectMapper = createObjectMapper();
-
- static ObjectMapper createObjectMapper() {
- final ObjectMapper mapper = new ObjectMapper();
- mapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
- mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
- // disabled features:
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
- return mapper;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/ApiException.java b/src/main/java/com/xcong/excoin/utils/api/ApiException.java
deleted file mode 100644
index f3c436b..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/ApiException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.xcong.excoin.utils.api;
-
-/**
- * ApiException if api returns error.
- *
- * @Date 2018/1/14
- * @Time 16:02
- */
-
-public class ApiException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 8196662756375909063L;
-
- final String errCode;
-
- public ApiException(String errCode, String errMsg) {
- super(errMsg);
- this.errCode = errCode;
- }
-
- public ApiException(Exception e) {
- super(e);
- this.errCode = e.getClass().getName();
- }
-
- public String getErrCode() {
- return this.errCode;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/request/CreateOrderRequest.java b/src/main/java/com/xcong/excoin/utils/api/request/CreateOrderRequest.java
deleted file mode 100644
index 9426571..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/request/CreateOrderRequest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.xcong.excoin.utils.api.request;
-
-public class CreateOrderRequest {
- public static interface OrderType {
- /**
- * 限价买入
- */
- static final String BUY_LIMIT = "buy-limit";
- /**
- * 限价卖出
- */
- static final String SELL_LIMIT = "sell-limit";
- /**
- * 市价买入
- */
- static final String BUY_MARKET = "buy-market";
- /**
- * 市价卖出
- */
- static final String SELL_MARKET = "sell-market";
- }
-
- /**
- * 交易对,必填,例如:"ethcny",
- */
- public String symbol;
-
- /**
- * 账户ID,必填,例如:"12345"
- */
- public String accountId;
-
- /**
- * 当订单类型为buy-limit,sell-limit时,表示订单数量, 当订单类型为buy-market时,表示订单总金额, 当订单类型为sell-market时,表示订单总数量
- */
- public String amount;
-
- /**
- * 订单价格,仅针对限价单有效,例如:"1234.56"
- */
- public String price = "0.0";
-
- /**
- * 订单类型,取值范围"buy-market,sell-market,buy-limit,sell-limit"
- */
- public String type;
-
- /**
- * 订单来源,例如:"api"
- */
- public String source = "com/huobi/client/api";
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/request/DepthRequest.java b/src/main/java/com/xcong/excoin/utils/api/request/DepthRequest.java
deleted file mode 100644
index 2f75636..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/request/DepthRequest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.xcong.excoin.utils.api.request;
-
-public class DepthRequest {
-
- //交易对
- public String symbol;
-
- //Depth 类型 step0, step1, step2, step3, step4, step5(合并深度0-5);step0时,不合并深度
- public String type;
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/request/IntrustOrdersDetailRequest.java b/src/main/java/com/xcong/excoin/utils/api/request/IntrustOrdersDetailRequest.java
deleted file mode 100644
index b364539..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/request/IntrustOrdersDetailRequest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.xcong.excoin.utils.api.request;
-
-
-public class IntrustOrdersDetailRequest {
-
- public static interface OrderType {
- /**
- * 限价买入
- */
- static final String BUY_LIMIT = "buy-limit";
- /**
- * 限价卖出
- */
- static final String SELL_LIMIT = "sell-limit";
- /**
- * 市价买入
- */
- static final String BUY_MARKET = "buy-market";
- /**
- * 市价卖出
- */
- static final String SELL_MARKET = "sell-market";
- }
-
- public static interface OrderStates {
- /**
- * pre-submitted 准备提交
- */
- static final String PRE_SUBMITTED = "pre-submitted";
- /**
- * submitted 已提交
- */
- static final String SUBMITTED = "submitted";
- /**
- * partial-filled 部分成交
- */
- static final String PARTIAL_FILLED = "partial-filled";
- /**
- * partial-canceled 部分成交撤销
- */
- static final String PARTIAL_CANCELED = "partial-canceled";
-
- /**
- * filled 完全成交
- */
- static final String FILLED = "filled";
- /**
- * canceled 已撤销
- */
- static final String CANCELED = "canceled";
- }
-
- public String symbol; //true string 交易对 btcusdt, bccbtc, rcneth ...
- public String types; //false string 查询的订单类型组合,使用','分割 buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖
- public String startDate; //false string 查询开始日期, 日期格式yyyy-mm-dd
- public String endDate; //false string 查询结束日期, 日期格式yyyy-mm-dd
- public String states; //true string 查询的订单状态组合,使用','分割 pre-submitted 准备提交, submitted 已提交, partial-filled 部分成交,
- // partial-canceled 部分成交撤销, filled 完全成交, canceled 已撤销
- public String from; //false string 查询起始 ID
- public String direct; //false string 查询方向 prev 向前,next 向后
- public String size; //false string 查询记录大小
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Account.java b/src/main/java/com/xcong/excoin/utils/api/response/Account.java
deleted file mode 100644
index a5d8c39..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Account.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-public class Account {
- public long id;
- public String type;
- public String state;
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Accounts.java b/src/main/java/com/xcong/excoin/utils/api/response/Accounts.java
deleted file mode 100644
index b5ac8ee..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Accounts.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-public class Accounts {
- /**
- * id : 100009
- * type : spot
- * state : working
- * user-id : 1000
- */
-
- private int id;
- private String type;
- private String state;
- private int userid;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public int getUserid() {
- return userid;
- }
-
- public void setUserid(int userid) {
- this.userid = userid;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/AccountsResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/AccountsResponse.java
deleted file mode 100644
index 6d1aed2..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/AccountsResponse.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-import com.xcong.excoin.utils.api.ApiException;
-
-public class AccountsResponse<T> {
-
- /**
- * status : ok
- * data : [{"id":100009,"type":"spot","state":"working","user-id":1000}]
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public T checkAndReturn() {
- if ("ok".equals(status)) {
- return data;
- }
- throw new ApiException(errCode, errMsg);
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/ApiResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/ApiResponse.java
deleted file mode 100644
index 5731897..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/ApiResponse.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-import com.xcong.excoin.utils.api.ApiException;
-
-public class ApiResponse<T> {
-
- public String status;
- public String errCode;
- public String errMsg;
- public T data;
-
- public T checkAndReturn() {
- if ("ok".equals(status)) {
- return data;
- }
- throw new ApiException(errCode, errMsg);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Balance.java b/src/main/java/com/xcong/excoin/utils/api/response/Balance.java
deleted file mode 100644
index 9f2f7c1..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Balance.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Balance<T> {
- /**
- * id : 100009
- * type : spot
- * state : working
- * list : [{"currency":"usdt","type":"trade","balance":"500009195917.4362872650"}]
- * user-id : 1000
- */
-
- private String id;
- private String type;
- private String state;
- private String userid;
- private T list;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public String getUserid() {
- return userid;
- }
-
- public void setUserid(String userid) {
- this.userid = userid;
- }
-
- public T getList() {
- return list;
- }
-
- public void setList(T list) {
- this.list = list;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/BalanceBean.java b/src/main/java/com/xcong/excoin/utils/api/response/BalanceBean.java
deleted file mode 100644
index 16a430d..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/BalanceBean.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class BalanceBean {
- /**
- * currency : usdt
- * type : trade
- * balance : 500009195917.4362872650
- */
-
- private String currency;
- private String type;
- private String balance;
-
- public String getCurrency() {
- return currency;
- }
-
- public void setCurrency(String currency) {
- this.currency = currency;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getBalance() {
- return balance;
- }
-
- public void setBalance(String balance) {
- this.balance = balance;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/BalanceResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/BalanceResponse.java
deleted file mode 100644
index 7f9e8cb..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/BalanceResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class BalanceResponse<T> {
-
-
- /**
- * status : ok
- * data : {"id":"100009","type":"spot","state":"working","list":[{"currency":"usdt","type":"trade","balance":"500009195917.4362872650"}],"user-id":"1000"}
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Batchcancel.java b/src/main/java/com/xcong/excoin/utils/api/response/Batchcancel.java
deleted file mode 100644
index 5ac256a..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Batchcancel.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Batchcancel<T1, T2> {
- private T1 success;
- private T2 failed;
-
- public T1 getSuccess() {
- return success;
- }
-
- public void setSuccess(T1 success) {
- this.success = success;
- }
-
- public T2 getFailed() {
- return failed;
- }
-
- public void setFailed(T2 failed) {
- this.failed = failed;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelBean.java b/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelBean.java
deleted file mode 100644
index f536f0d..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelBean.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-/** @Author ISME @Date 2018/1/14 @Time 17:53 */
-public class BatchcancelBean {
- /** err-msg : 记录无效 order-id : 2 err-code : base-record-invalid */
- private String errMsg;
-
- private String orderId;
- private String errCode;
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- public String getOrderId() {
- return orderId;
- }
-
- public void setOrderId(String orderId) {
- this.orderId = orderId;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelResponse.java
deleted file mode 100644
index d32d0a0..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/BatchcancelResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class BatchcancelResponse<T> {
-
-
- /**
- * status : ok
- * data : {"success":["1","3"],"failed":[{"err-msg":"记录无效","order-id":"2","err-code":"base-record-invalid"}]}
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Currencys.java b/src/main/java/com/xcong/excoin/utils/api/response/Currencys.java
deleted file mode 100644
index 3c5f82d..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Currencys.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Currencys {
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/CurrencysResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/CurrencysResponse.java
deleted file mode 100644
index 9497ab8..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/CurrencysResponse.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-import java.util.List;
-
-/**
- * @Author ISME
- * @Date 2018/1/14
- * @Time 15:46
- */
-
-public class CurrencysResponse {
-
-
- /**
- * status : ok
- * data : ["usdt","eth","etc"]
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private List<String> data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public List<String> getData() {
- return data;
- }
-
- public void setData(List<String> data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Depth.java b/src/main/java/com/xcong/excoin/utils/api/response/Depth.java
deleted file mode 100644
index 14fed2b..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Depth.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-/**
- * @Author ISME
- * @Date 2018/1/14
- * @Time 14:39
- */
-
-public class Depth {
-
- /**
- * id : 1489464585407
- * ts : 1489464585407
- * bids : [[7964,0.0678],[7963,0.9162]]
- * asks : [[7979,0.0736],[8020,13.6584]]
- */
-
- private String id;
- private String ts;
- private List<List<BigDecimal>> bids;
- private List<List<BigDecimal>> asks;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getTs() {
- return ts;
- }
-
- public void setTs(String ts) {
- this.ts = ts;
- }
-
- public List<List<BigDecimal>> getBids() {
- return bids;
- }
-
- public void setBids(List<List<BigDecimal>> bids) {
- this.bids = bids;
- }
-
- public List<List<BigDecimal>> getAsks() {
- return asks;
- }
-
- public void setAsks(List<List<BigDecimal>> asks) {
- this.asks = asks;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/DepthResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/DepthResponse.java
deleted file mode 100644
index 2cc35a8..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/DepthResponse.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class DepthResponse<T> {
-
-
- /**
- * status : ok
- * ch : market.btcusdt.depth.step1
- * ts : 1489472598812
- * tick : {"id":"1489464585407","ts":"1489464585407","bids":[[7964,0.0678],[7963,0.9162]],"asks":[[7979,0.0736],[8020,13.6584]]}
- */
-
- private String status;
- private String ch;
- private String ts;
- public String errCode;
- public String errMsg;
-
- /**
- * tick 说明:
- * "tick": {
- * "id": 消息id,
- * "ts": 消息生成时间,单位:毫秒,
- * "bids": 买盘,[price(成交价), amount(成交量)], 按price降序,
- * "asks": 卖盘,[price(成交价), amount(成交量)], 按price升序
- * }
- */
- private Depth tick;
-
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public String getTs() {
- return ts;
- }
-
- public void setTs(String ts) {
- this.ts = ts;
- }
-
- public Depth getTick() {
- return tick;
- }
-
- public void setTick(Depth tick) {
- this.tick = tick;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/DetailResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/DetailResponse.java
deleted file mode 100644
index db6c564..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/DetailResponse.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class DetailResponse<T> {
-
-
- /**
- * status : ok
- * ch : market.btcusdt.detail
- * ts : 1489473538996
- * tick : {"amount":4316.4346,"open":8090.54,"close":7962.62,"high":8119,"ts":1489464451000,"id":1489464451,"count":9595,"low":7875,"vol":3.449727690576E7}
- */
-
- private String status;
- private String ch;
- private long ts;
- public String errCode;
- public String errMsg;
- private T tick;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- public T getTick() {
- return tick;
- }
-
- public void setTick(T tick) {
- this.tick = tick;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Details.java b/src/main/java/com/xcong/excoin/utils/api/response/Details.java
deleted file mode 100644
index 2fa3fed..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Details.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Details {
-
- /**
- * amount : 4316.4346
- * open : 8090.54
- * close : 7962.62
- * high : 8119
- * ts : 1489464451000
- * id : 1489464451
- * count : 9595
- * low : 7875
- * vol : 3.449727690576E7
- */
-
- private double amount;
- private double open;
- private double close;
- private int high;
- private long ts;
- private long id;
- private int count;
- private int low;
- private double vol;
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public double getOpen() {
- return open;
- }
-
- public void setOpen(double open) {
- this.open = open;
- }
-
- public double getClose() {
- return close;
- }
-
- public void setClose(double close) {
- this.close = close;
- }
-
- public int getHigh() {
- return high;
- }
-
- public void setHigh(int high) {
- this.high = high;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public int getLow() {
- return low;
- }
-
- public void setLow(int low) {
- this.low = low;
- }
-
- public double getVol() {
- return vol;
- }
-
- public void setVol(double vol) {
- this.vol = vol;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTrade.java b/src/main/java/com/xcong/excoin/utils/api/response/HistoryTrade.java
deleted file mode 100644
index ebe5b55..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTrade.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class HistoryTrade {
- /**
- * id : 17592256642623
- * amount : 0.04
- * price : 1997
- * direction : buy
- * ts : 1502448920106
- */
-
- private long id;
- private double amount;
- private int price;
- private String direction;
- private long ts;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public int getPrice() {
- return price;
- }
-
- public void setPrice(int price) {
- this.price = price;
- }
-
- public String getDirection() {
- return direction;
- }
-
- public void setDirection(String direction) {
- this.direction = direction;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradeResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradeResponse.java
deleted file mode 100644
index 7007b27..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradeResponse.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class HistoryTradeResponse<T> {
-
-
- /**
- * status : ok
- * ch : market.ethusdt.trade.detail
- * ts : 1502448925216
- * data : [{"id":31459998,"ts":1502448920106,"data":[{"id":17592256642623,"amount":0.04,"price":1997,"direction":"buy","ts":1502448920106}]}]
- */
-
- private String status;
- private String ch;
- private long ts;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradess.java b/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradess.java
deleted file mode 100644
index 56eb132..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/HistoryTradess.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class HistoryTradess {
- /**
- * id : 31459998
- * ts : 1502448920106
- * data : [{"id":17592256642623,"amount":0.04,"price":1997,"direction":"buy","ts":1502448920106}]
- */
-
- private long id;
- private long ts;
- private HistoryTrade data;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public HistoryTrade getData() {
- return data;
- }
-
- public void setData(HistoryTrade data) {
- this.data = data;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetail.java b/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetail.java
deleted file mode 100644
index 7eeb618..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetail.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * @Author ISME
- * @Date 2018/1/14
- * @Time 19:20
- */
-
-public class IntrustDetail {
-
- /**
- * id : 59378
- * symbol : ethusdt
- * account-id : 100009
- * amount : 10.1000000000
- * price : 100.1000000000
- * created-at : 1494901162595
- * type : buy-limit
- * field-amount : 10.1000000000
- * field-cash-amount : 1011.0100000000
- * field-fees : 0.0202000000
- * finished-at : 1494901400468
- * user-id : 1000
- * source : api
- * state : filled
- * canceled-at : 0
- * exchange : huobi
- * batch :
- */
-
- private long id;
- private String symbol;
- @SerializedName("account-id")
- private int accountid;
- private String amount;
- private String price;
- @SerializedName("created-at")
- private long createdat;
- private String type;
- @SerializedName("field-amount")
- private String fieldamount;
- @SerializedName("field-cash-amount")
- private String fieldcashamount;
- @SerializedName("field-fees")
- private String fieldfees;
- @SerializedName("finished-at")
- private long finishedat;
- @SerializedName("user-id")
- private int userid;
- private String source;
- private String state;
- @SerializedName("canceled-at")
- private int canceledat;
- private String exchange;
- private String batch;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- public int getAccountid() {
- return accountid;
- }
-
- public void setAccountid(int accountid) {
- this.accountid = accountid;
- }
-
- public String getAmount() {
- return amount;
- }
-
- public void setAmount(String amount) {
- this.amount = amount;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
- public long getCreatedat() {
- return createdat;
- }
-
- public void setCreatedat(long createdat) {
- this.createdat = createdat;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getFieldamount() {
- return fieldamount;
- }
-
- public void setFieldamount(String fieldamount) {
- this.fieldamount = fieldamount;
- }
-
- public String getFieldcashamount() {
- return fieldcashamount;
- }
-
- public void setFieldcashamount(String fieldcashamount) {
- this.fieldcashamount = fieldcashamount;
- }
-
- public String getFieldfees() {
- return fieldfees;
- }
-
- public void setFieldfees(String fieldfees) {
- this.fieldfees = fieldfees;
- }
-
- public long getFinishedat() {
- return finishedat;
- }
-
- public void setFinishedat(long finishedat) {
- this.finishedat = finishedat;
- }
-
- public int getUserid() {
- return userid;
- }
-
- public void setUserid(int userid) {
- this.userid = userid;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public int getCanceledat() {
- return canceledat;
- }
-
- public void setCanceledat(int canceledat) {
- this.canceledat = canceledat;
- }
-
- public String getExchange() {
- return exchange;
- }
-
- public void setExchange(String exchange) {
- this.exchange = exchange;
- }
-
- public String getBatch() {
- return batch;
- }
-
- public void setBatch(String batch) {
- this.batch = batch;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetailResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetailResponse.java
deleted file mode 100644
index 90aabe5..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/IntrustDetailResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class IntrustDetailResponse<T> {
-
-
- /**
- * status : ok
- * data : [{"id":59378,"symbol":"ethusdt","account-id":100009,"amount":"10.1000000000","price":"100.1000000000","created-at":1494901162595,"type":"buy-limit","field-amount":"10.1000000000","field-cash-amount":"1011.0100000000","field-fees":"0.0202000000","finished-at":1494901400468,"user-id":1000,"source":"api","state":"filled","canceled-at":0,"exchange":"huobi","batch":""}]
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Kline.java b/src/main/java/com/xcong/excoin/utils/api/response/Kline.java
deleted file mode 100644
index 5df66f8..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Kline.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-public class Kline {
-
-
- private long id;
- private float amount;
- private int count;
- private float open;
- private float close;
- private float low;
- private float high;
- private float vol;
- public long getId() {
- return id;
- }
- public void setId(long id) {
- this.id = id;
- }
- public float getAmount() {
- return amount;
- }
- public void setAmount(float amount) {
- this.amount = amount;
- }
- public int getCount() {
- return count;
- }
- public void setCount(int count) {
- this.count = count;
- }
- public float getOpen() {
- return open;
- }
- public void setOpen(float open) {
- this.open = open;
- }
- public float getClose() {
- return close;
- }
- public void setClose(float close) {
- this.close = close;
- }
- public float getLow() {
- return low;
- }
- public void setLow(float low) {
- this.low = low;
- }
- public float getHigh() {
- return high;
- }
- public void setHigh(float high) {
- this.high = high;
- }
- public float getVol() {
- return vol;
- }
- public void setVol(float vol) {
- this.vol = vol;
- }
- @Override
- public String toString() {
- return "Kline [id=" + id + ", amount=" + amount + ", count=" + count + ", open=" + open + ", close=" + close
- + ", low=" + low + ", high=" + high + ", vol=" + vol + "]";
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/KlineResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/KlineResponse.java
deleted file mode 100644
index 91b2a4e..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/KlineResponse.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-import com.xcong.excoin.utils.api.ApiException;
-
-public class KlineResponse<T> {
-
- private String status;
- /**
- * 接口名
- */
- private String ch;
- /**
- * 时间格式
- */
- private String ts;
- public String errCode;
- public String errMsg;
- /**
- * 数据
- */
- public T data;
-
- public T checkAndReturn() {
- if ("ok".equals(status)) {
- return data;
- }
- throw new ApiException(errCode, errMsg);
- }
-
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public String getTs() {
- return ts;
- }
-
- public void setTs(String ts) {
- this.ts = ts;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/KlineReturn.java b/src/main/java/com/xcong/excoin/utils/api/response/KlineReturn.java
deleted file mode 100644
index efea294..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/KlineReturn.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-public class KlineReturn {
-
-
- private long time;
- private float open;
- private float high;
- private float low;
- private float close;
- private float volume;
-
- private float amount;
-// private int count;
-
-
- public float getOpen() {
- return open;
- }
- public void setOpen(float open) {
- this.open = open;
- }
- public float getClose() {
- return close;
- }
- public void setClose(float close) {
- this.close = close;
- }
- public float getLow() {
- return low;
- }
- public void setLow(float low) {
- this.low = low;
- }
- public float getHigh() {
- return high;
- }
- public void setHigh(float high) {
- this.high = high;
- }
- public long getTime() {
- return time;
- }
- public void setTime(long time) {
- this.time = time;
- }
- public float getVolume() {
- return volume;
- }
- public void setVolume(float volume) {
- this.volume = volume;
- }
- public float getAmount() {
- return amount;
- }
- public void setAmount(float amount) {
- this.amount = amount;
- }
- @Override
- public String toString() {
- return "KlineReturn [time=" + time + ", open=" + open + ", high=" + high + ", low=" + low + ", close=" + close
- + ", volume=" + volume + "]";
- }
-
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetail.java b/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetail.java
deleted file mode 100644
index 6985876..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetail.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class MatchresultsOrdersDetail {
- /**
- * id : 29553
- * order-id : 59378
- * match-id : 59335
- * symbol : ethusdt
- * type : buy-limit
- * source : api
- * price : 100.1000000000
- * filled-amount : 9.1155000000
- * filled-fees : 0.0182310000
- * created-at : 1494901400435
- */
-
- private long id;
- @com.google.gson.annotations.SerializedName("order-id")
- private long orderid;
- @com.google.gson.annotations.SerializedName("match-id")
- private long matchid;
- private String symbol;
- private String type;
- private String source;
- private String price;
- @com.google.gson.annotations.SerializedName("filled-amount")
- private String filledamount;
- @com.google.gson.annotations.SerializedName("filled-fees")
- private String filledfees;
- @com.google.gson.annotations.SerializedName("created-at")
- private long createdat;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public long getOrderid() {
- return orderid;
- }
-
- public void setOrderid(long orderid) {
- this.orderid = orderid;
- }
-
- public long getMatchid() {
- return matchid;
- }
-
- public void setMatchid(long matchid) {
- this.matchid = matchid;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
- public String getFilledamount() {
- return filledamount;
- }
-
- public void setFilledamount(String filledamount) {
- this.filledamount = filledamount;
- }
-
- public String getFilledfees() {
- return filledfees;
- }
-
- public void setFilledfees(String filledfees) {
- this.filledfees = filledfees;
- }
-
- public long getCreatedat() {
- return createdat;
- }
-
- public void setCreatedat(long createdat) {
- this.createdat = createdat;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetailResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetailResponse.java
deleted file mode 100644
index f968c0c..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/MatchresultsOrdersDetailResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class MatchresultsOrdersDetailResponse<T> {
-
-
- /**
- * status : ok
- * data : [{"id":29553,"order-id":59378,"match-id":59335,"symbol":"ethusdt","type":"buy-limit","source":"api","price":"100.1000000000","filled-amount":"9.1155000000","filled-fees":"0.0182310000","created-at":1494901400435}]
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Merged.java b/src/main/java/com/xcong/excoin/utils/api/response/Merged.java
deleted file mode 100644
index 3682ed9..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Merged.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-import java.util.List;
-
-
-public class Merged {
-
- /**
- * id : 1499225271
- * ts : 1499225271000
- * close : 1885
- * open : 1960
- * high : 1985
- * low : 1856
- * amount : 81486.2926
- * count : 42122
- * vol : 1.57052744857082E8
- * ask : [1885,21.8804]
- * bid : [1884,1.6702]
- */
-
- private long id;
- private long ts;
- private int close;
- private int open;
- private int high;
- private int low;
- private double amount;
- private int count;
- private double vol;
- private List<Integer> ask;
- private List<Integer> bid;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public int getClose() {
- return close;
- }
-
- public void setClose(int close) {
- this.close = close;
- }
-
- public int getOpen() {
- return open;
- }
-
- public void setOpen(int open) {
- this.open = open;
- }
-
- public int getHigh() {
- return high;
- }
-
- public void setHigh(int high) {
- this.high = high;
- }
-
- public int getLow() {
- return low;
- }
-
- public void setLow(int low) {
- this.low = low;
- }
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public double getVol() {
- return vol;
- }
-
- public void setVol(double vol) {
- this.vol = vol;
- }
-
- public List<Integer> getAsk() {
- return ask;
- }
-
- public void setAsk(List<Integer> ask) {
- this.ask = ask;
- }
-
- public List<Integer> getBid() {
- return bid;
- }
-
- public void setBid(List<Integer> bid) {
- this.bid = bid;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/MergedResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/MergedResponse.java
deleted file mode 100644
index c30306a..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/MergedResponse.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-
-import com.xcong.excoin.utils.api.ApiException;
-
-public class MergedResponse<T> {
-
- /**
- * status : ok
- * ch : market.ethusdt.detail.merged
- * ts : 1499225276950
- * tick : {"id":1499225271,"ts":1499225271000,"close":1885,"open":1960,"high":1985,"low":1856,"amount":81486.2926,"count":42122,"vol":1.57052744857082E8,"ask":[1885,21.8804],"bid":[1884,1.6702]}
- */
-
- private String status;
- private String ch;
- private long ts;
- public String errCode;
- public String errMsg;
- public Object tick;
-
- public Object checkAndReturn() {
- if ("ok".equals(status)) {
- return tick;
- }
- throw new ApiException(errCode, errMsg);
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- public Object getTick() {
- return tick;
- }
-
- public void setTick(Object tick) {
- this.tick = tick;
- }
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetail.java b/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetail.java
deleted file mode 100644
index 226da84..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetail.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class OrdersDetail {
-
- /**
- * id : 59378
- * symbol : ethusdt
- * account-id : 100009
- * amount : 10.1000000000
- * price : 100.1000000000
- * created-at : 1494901162595
- * type : buy-limit
- * field-amount : 10.1000000000
- * field-cash-amount : 1011.0100000000
- * field-fees : 0.0202000000
- * finished-at : 1494901400468
- * user-id : 1000
- * source : api
- * state : filled
- * canceled-at : 0
- * exchange : huobi
- * batch :
- */
-
- private long id;
- private String symbol;
- private int accountid;
- private String amount;
- private String price;
- private long createdat;
- private String type;
- private String fieldamount;
- private String fieldcashamount;
- private String fieldfees;
- private long finishedat;
- private int userid;
- private String source;
- private String state;
- private long canceledat;
- private String exchange;
- private String batch;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- public int getAccountid() {
- return accountid;
- }
-
- public void setAccountid(int accountid) {
- this.accountid = accountid;
- }
-
- public String getAmount() {
- return amount;
- }
-
- public void setAmount(String amount) {
- this.amount = amount;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
- public long getCreatedat() {
- return createdat;
- }
-
- public void setCreatedat(long createdat) {
- this.createdat = createdat;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getFieldamount() {
- return fieldamount;
- }
-
- public void setFieldamount(String fieldamount) {
- this.fieldamount = fieldamount;
- }
-
- public String getFieldcashamount() {
- return fieldcashamount;
- }
-
- public void setFieldcashamount(String fieldcashamount) {
- this.fieldcashamount = fieldcashamount;
- }
-
- public String getFieldfees() {
- return fieldfees;
- }
-
- public void setFieldfees(String fieldfees) {
- this.fieldfees = fieldfees;
- }
-
- public long getFinishedat() {
- return finishedat;
- }
-
- public void setFinishedat(long finishedat) {
- this.finishedat = finishedat;
- }
-
- public int getUserid() {
- return userid;
- }
-
- public void setUserid(int userid) {
- this.userid = userid;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public long getCanceledat() {
- return canceledat;
- }
-
- public void setCanceledat(long canceledat) {
- this.canceledat = canceledat;
- }
-
- public String getExchange() {
- return exchange;
- }
-
- public void setExchange(String exchange) {
- this.exchange = exchange;
- }
-
- public String getBatch() {
- return batch;
- }
-
- public void setBatch(String batch) {
- this.batch = batch;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetailResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetailResponse.java
deleted file mode 100644
index 585601e..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/OrdersDetailResponse.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class OrdersDetailResponse<T> {
-
- /**
- * status : ok
- * data : {"id":59378,"symbol":"ethusdt","account-id":100009,"amount":"10.1000000000","price":"100.1000000000","created-at":1494901162595,"type":"buy-limit","field-amount":"10.1000000000","field-cash-amount":"1011.0100000000","field-fees":"0.0202000000","finished-at":1494901400468,"user-id":1000,"source":"api","state":"filled","canceled-at":0,"exchange":"huobi","batch":""}
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private T data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public static class DataBean {
-
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Place.java b/src/main/java/com/xcong/excoin/utils/api/response/Place.java
deleted file mode 100644
index be261e7..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Place.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Place {
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/SubmitcancelResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/SubmitcancelResponse.java
deleted file mode 100644
index 9036e4c..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/SubmitcancelResponse.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class SubmitcancelResponse {
-
-
- /**
- * status : ok
- * data : 59378
- */
-
- private String status;
- public String errCode;
- public String errMsg;
- private String data;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Symbol.java b/src/main/java/com/xcong/excoin/utils/api/response/Symbol.java
deleted file mode 100644
index 7f98dba..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Symbol.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Symbol {
-
- public String baseCurrency;
- public String quoteCurrency;
- public String symbol;
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Symbols.java b/src/main/java/com/xcong/excoin/utils/api/response/Symbols.java
deleted file mode 100644
index fc6004d..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Symbols.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Symbols {
-
- /**
- * amount : 4316.4346
- * open : 8090.54
- * close : 7962.62
- * high : 8119
- * ts : 1489464451000
- * id : 1489464451
- * count : 9595
- * low : 7875
- * vol : 3.449727690576E7
- */
-
- private double amount;
- private double open;
- private double close;
- private int high;
- private long ts;
- private long id;
- private int count;
- private int low;
- private double vol;
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public double getOpen() {
- return open;
- }
-
- public void setOpen(double open) {
- this.open = open;
- }
-
- public double getClose() {
- return close;
- }
-
- public void setClose(double close) {
- this.close = close;
- }
-
- public int getHigh() {
- return high;
- }
-
- public void setHigh(int high) {
- this.high = high;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public int getLow() {
- return low;
- }
-
- public void setLow(int low) {
- this.low = low;
- }
-
- public double getVol() {
- return vol;
- }
-
- public void setVol(double vol) {
- this.vol = vol;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/SymbolsResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/SymbolsResponse.java
deleted file mode 100644
index 3488aa3..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/SymbolsResponse.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class SymbolsResponse<T> {
-
-
- /**
- * status : ok
- * ch : market.btcusdt.detail
- * ts : 1489473538996
- * tick : {"amount":4316.4346,"open":8090.54,"close":7962.62,"high":8119,"ts":1489464451000,"id":1489464451,"count":9595,"low":7875,"vol":3.449727690576E7}
- */
-
- private String status;
- private String ch;
- private long ts;
- public String errCode;
- public String errMsg;
- private T tick;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- public T getTick() {
- return tick;
- }
-
- public void setTick(T tick) {
- this.tick = tick;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/TimestampResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/TimestampResponse.java
deleted file mode 100644
index bb1d71c..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/TimestampResponse.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * @Author ISME
- * @Date 2018/1/14
- * @Time 15:53
- */
-
-public class TimestampResponse {
-
- /**
- * status : ok
- * data : 1494900087029
- */
-
- private String status;
- private long data;
- @SuppressWarnings("unused")
- private String dateTime;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public long getData() {
- return data;
- }
-
- public void setData(long data) {
- this.data = data;
- }
-
- public String getDateTime() {
- SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");
- Date date = new Date(data);
- return sdf.format(date);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/Trade.java b/src/main/java/com/xcong/excoin/utils/api/response/Trade.java
deleted file mode 100644
index ecb844e..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/Trade.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class Trade<T> {
-
- /**
- * id : 600848670
- * ts : 1489464451000
- * data : [{"id":600848670,"price":7962.62,"amount":0.0122,"direction":"buy","ts":1489464451000}]
- */
-
- private long id;
- private long ts;
- private T data;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public T getData() {
- return data;
- }
-
- public void setData(T data) {
- this.data = data;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/TradeBean.java b/src/main/java/com/xcong/excoin/utils/api/response/TradeBean.java
deleted file mode 100644
index 1dc6bfb..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/TradeBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class TradeBean {
-
- /**
- * id : 600848670
- * price : 7962.62
- * amount : 0.0122
- * direction : buy
- * ts : 1489464451000
- */
-
- private long id;
- private double price;
- private double amount;
- private String direction;
- private long ts;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPrice(double price) {
- this.price = price;
- }
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(double amount) {
- this.amount = amount;
- }
-
- public String getDirection() {
- return direction;
- }
-
- public void setDirection(String direction) {
- this.direction = direction;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
-
-}
diff --git a/src/main/java/com/xcong/excoin/utils/api/response/TradeResponse.java b/src/main/java/com/xcong/excoin/utils/api/response/TradeResponse.java
deleted file mode 100644
index 21a09ce..0000000
--- a/src/main/java/com/xcong/excoin/utils/api/response/TradeResponse.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.xcong.excoin.utils.api.response;
-
-public class TradeResponse {
-
-
- /**
- * status : ok
- * ch : market.btcusdt.trade.detail
- * ts : 1489473346905
- * tick : {"id":600848670,"ts":1489464451000,"data":[{"id":600848670,"price":7962.62,"amount":0.0122,"direction":"buy","ts":1489464451000}]}
- */
-
- private String status;
- private String ch;
- private long ts;
- public String errCode;
- public String errMsg;
- @SuppressWarnings("rawtypes")
- private Trade tick;
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getCh() {
- return ch;
- }
-
- public void setCh(String ch) {
- this.ch = ch;
- }
-
- public long getTs() {
- return ts;
- }
-
- public void setTs(long ts) {
- this.ts = ts;
- }
-
- public String getErrCode() {
- return errCode;
- }
-
- public void setErrCode(String errCode) {
- this.errCode = errCode;
- }
-
- public String getErrMsg() {
- return errMsg;
- }
-
- public void setErrMsg(String errMsg) {
- this.errMsg = errMsg;
- }
-
- @SuppressWarnings("rawtypes")
- public Trade getTick() {
- return tick;
- }
-
- @SuppressWarnings("rawtypes")
- public void setTick(Trade tick) {
- this.tick = tick;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/mail/RequestEncoder.java b/src/main/java/com/xcong/excoin/utils/mail/RequestEncoder.java
deleted file mode 100644
index 16318f4..0000000
--- a/src/main/java/com/xcong/excoin/utils/mail/RequestEncoder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.xcong.excoin.utils.mail;
-
-import java.security.MessageDigest;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 处理请求数据
- * @author submail
- *
- */
-public class RequestEncoder {
-
- private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5',
- '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- public static final String MD5 = "MD5";
- public static final String SHA1 = "SHA1";
- /**
- * 编码的字符串
- *
- * @param algorithm
- * @param str
- * @return String
- */
- public static String encode(String algorithm, String str) {
- if (str == null) {
- return null;
- }
- try {
- MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
- messageDigest.update(str.getBytes("UTF-8"));
- return getFormattedText(messageDigest.digest());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-
- /**
- *获取原始字节并将其格式化。
- * @param bytes
- * the raw bytes from the digest.
- * @return the formatted bytes.
- */
- private static String getFormattedText(byte[] bytes) {
- int len = bytes.length;
- StringBuilder buf = new StringBuilder(len * 2);
- for (int j = 0; j < len; j++) { buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
- buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
- }
- return buf.toString();
- }
-
- public static String formatRequest(Map<String, Object> data){
- Set<String> keySet = data.keySet();
- Iterator<String> it = keySet.iterator();
- StringBuffer sb = new StringBuffer();
- while(it.hasNext()){
- String key = it.next();
- Object value = data.get(key);
- if(value instanceof String){
- sb.append(key + "=" + value + "&");
- }
- }
- if(sb.length() != 0){
- return sb.substring(0, sb.length() - 1);
- }
- return null;
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java b/src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java
deleted file mode 100644
index 8685a35..0000000
--- a/src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.xcong.excoin.utils.mail;
-
-import cn.hutool.core.date.DatePattern;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.core.util.XmlUtil;
-import cn.hutool.http.HttpUtil;
-import com.xcong.excoin.common.exception.GlobalException;
-import lombok.extern.slf4j.Slf4j;
-
-import java.util.Date;
-import java.util.HashMap;
-
-/**
- * @author wzy
- * @date 2020-07-14
- **/
-@Slf4j
-public class Sms106Send {
-
- private static final String URL = "http://www.qf106.com/sms.aspx";
- private static final String ID = "16580";
- private static final String ACCOUNT = "Biue";
- private static final String PASSWORD = "123456";
-
-
- /**
- * @param phone 手机号
- * @param code 验证码
- * @param time 失效时间
- * @return
- */
- public static boolean sendVerifyCode(String phone, String code, int time) {
- String msg = "您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。";
- String content = StrUtil.format(msg, code, time);
- return request(phone, content, "验证码");
- }
-
- public static boolean sendRechargeMsg(String phone, String time, String orderNo) {
- String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,如有疑问请联系客服,订单编号为{}";
- String content = StrUtil.format(msg, time, orderNo);
- return request(phone, content, "充值");
- }
-
- public static boolean sendWithdrawalMsg(String phone, String time, String orderNo) {
- String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,如有疑问请联系客服,订单编号为{}";
- String content = StrUtil.format(msg, time, orderNo);
- return request(phone, content, "提现");
- }
-
- private static boolean request(String phone, String content, String tagName) {
- HashMap<String, Object> param = new HashMap<>();
- param.put("userid", ID);
- param.put("account", ACCOUNT);
- param.put("password", PASSWORD);
- param.put("mobile", phone);
- param.put("content", content);
- param.put("sendTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
- param.put("action", "send");
- param.put("checkcontent", 0);
- param.put("taskName", tagName);
- param.put("countnumber", 1);
- param.put("mobilenumber", 1);
- param.put("telephonenumber", 0);
-
- String response = HttpUtil.post(URL, param);
- log.info("短信发送:{}, {}", tagName, response);
- if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) {
- return true;
- } else {
- throw new GlobalException((String) XmlUtil.xmlToMap(response).get("message"));
- }
- }
-
- public static void main(String[] args) {
- System.out.println(sendVerifyCode("15773002834", "123456", 2));
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java b/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java
deleted file mode 100644
index e2e8ed2..0000000
--- a/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package com.xcong.excoin.utils.mail;
-
-import cn.hutool.core.date.DateUtil;
-import net.sf.json.JSONObject;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * @author wzy
- * @date 2020-06-17
- **/
-public class SmsSend {
- /**
- * 时间戳接口配置
- */
- public static final String TIMESTAMP = "https://api.mysubmail.com/service/timestamp";
-
- public static final String TYPE_MD5 = "md5";
- public static final String TYPE_SHA1 = "sha1";
-
- private static final String APP_ID = "51258";
- private static final String APP_KEY = "a9b6e0758dc40d3c346887fc0e154642";
- private static final String SIGN_TYPE = "";
- /**
- * API 请求接口配置
- */
- private static final String URL = "https://api.mysubmail.com/message/xsend";
-
-
- /**
- * 发送验证码
- *
- * @param telphone 手机号
- * @param code 验证码
- * @param time 超时时间
- * @return
- */
- public static boolean sendVerifyCode(String telphone, String code, int time) {
- TreeMap<String, Object> requestData = new TreeMap<String, Object>();
- JSONObject vars = new JSONObject();
-
- String project = "2CHnV3";
- vars.put("code", code);
- vars.put("time", time);
-
- requestData.put("appid", APP_ID);
- requestData.put("project", project);
- requestData.put("to", telphone);
- if (!vars.isEmpty()) {
- requestData.put("vars", vars.toString());
- }
- return requestSend(requestData);
- }
-
- /**
- * 发送充值成功消息
- *
- * @param phone 手机号
- * @param time 充值时间
- * @param amount 金额
- * @param orderNo 订单号
- */
- public static void sendRechargeMsg(String phone, String time, String amount, String orderNo) {
- TreeMap<String, Object> requestData = new TreeMap<String, Object>();
- JSONObject vars = new JSONObject();
- vars.put("time", time);
- vars.put("price", amount);
- vars.put("orderNo", orderNo);
- String project = "Cqky91";
- requestData.put("appid", APP_ID);
- requestData.put("project", project);
- requestData.put("to", phone);
- if (!vars.isEmpty()) {
- requestData.put("vars", vars.toString());
- }
-
- requestSend(requestData);
- }
-
-
- private static boolean requestSend(TreeMap<String, Object> requestData) {
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- @SuppressWarnings("deprecation")
- ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
- for (Map.Entry<String, Object> entry : requestData.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof String) {
- builder.addTextBody(key, String.valueOf(value), contentType);
- }
- }
- if (SIGN_TYPE.equals(TYPE_MD5) || SIGN_TYPE.equals(TYPE_SHA1)) {
- String timestamp = getTimestamp();
- requestData.put("timestamp", timestamp);
- requestData.put("sign_type", SIGN_TYPE);
- String signStr = APP_ID + APP_KEY + RequestEncoder.formatRequest(requestData) + APP_ID + APP_KEY;
-
- builder.addTextBody("timestamp", timestamp);
- builder.addTextBody("sign_type", SIGN_TYPE);
- builder.addTextBody("signature", RequestEncoder.encode(SIGN_TYPE, signStr), contentType);
- } else {
- builder.addTextBody("signature", APP_KEY, contentType);
- }
-
- HttpPost httpPost = new HttpPost(URL);
- httpPost.addHeader("charset", "UTF-8");
- httpPost.setEntity(builder.build());
- try {
- CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
- HttpResponse response = closeableHttpClient.execute(httpPost);
- HttpEntity httpEntity = response.getEntity();
- if (httpEntity != null) {
- String jsonStr = EntityUtils.toString(httpEntity, "UTF-8");
- System.out.println(jsonStr);
- if ("success".equals(JSONObject.fromObject(jsonStr).getString("status"))) {
- return true;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
-
- /**
- * 获取时间戳
- */
- private static String getTimestamp() {
- CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
- HttpGet httpget = new HttpGet(TIMESTAMP);
- try {
- HttpResponse response = closeableHttpClient.execute(httpget);
- HttpEntity httpEntity = response.getEntity();
- String jsonStr = EntityUtils.toString(httpEntity, "UTF-8");
- if (jsonStr != null) {
- JSONObject json = JSONObject.fromObject(jsonStr);
- return json.getString("timestamp");
- }
- closeableHttpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- public static void main(String[] args) {
-// sendVerifyCode("15773002834", "123456", 2);
- }
-}
diff --git a/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java b/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java
deleted file mode 100644
index 4663a48..0000000
--- a/src/main/java/com/xcong/excoin/utils/mail/SubMailSend.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.xcong.excoin.utils.mail;
-
-
-import cn.hutool.core.date.DatePattern;
-import cn.hutool.core.date.DateUtil;
-import net.sf.json.JSONObject;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * 邮件发送
- *
- * @author wzy
- * @date 2020-05-27
- **/
-public class SubMailSend {
-
- /**
- * 时间戳接口配置
- */
- public static final String TIMESTAMP = "https://api.mysubmail.com/service/timestamp";
- /**
- * API 请求接口配置
- */
- private static final String URL = "https://api.mysubmail.com/mail/xsend";
-
- public static final String TYPE_MD5 = "md5";
- public static final String TYPE_SHA1 = "sha1";
-
- private static final String APP_ID = "16082";
- private static final String APP_KEY = "f34c792a1112c16c190ed7190d386c4f";
- private static final String FROM = "biue@submail.biue.me";
- private static final String SIGN_TYPE = "";
-
- /**
- * 发送验证码邮件
- *
- * @param to 对象
- * @param code 验证码
- * @return true or false
- */
- public static boolean sendMail(String to, String code) {
- JSONObject vars = new JSONObject();
- vars.put("code", code);
-
- String project = "zoKVB";
- return request(vars, project, to);
- }
-
- /**
- * 发送充值成功邮件
- *
- * @param to 对象
- * @param time 成功时间
- * @param orderNo 订单编号
- * @return true or false
- */
- public static boolean sendRechargeMail(String to, String time, String orderNo) {
- JSONObject vars = new JSONObject();
- vars.put("time", time);
- vars.put("orderNo", orderNo);
- String project = "x820C2";
- return request(vars, project, to);
- }
-
- public static boolean sendWithdrawalMail(String to, String time) {
- JSONObject vars = new JSONObject();
- vars.put("time", time);
- String project = "e3BO91";
- return request(vars, project, to);
- }
-
-
- private static boolean request(JSONObject vars, String project, String to) {
- TreeMap<String, Object> requestData = new TreeMap<String, Object>();
- requestData.put("appid", APP_ID);
- requestData.put("project", project);
- requestData.put("to", to);
- requestData.put("from", FROM);
- if (!vars.isEmpty()) {
- requestData.put("vars", vars.toString());
- }
-
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- @SuppressWarnings("deprecation")
- ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
- for (Map.Entry<String, Object> entry : requestData.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof String) {
- builder.addTextBody(key, String.valueOf(value), contentType);
- }
- }
- if (SIGN_TYPE.equals(TYPE_MD5) || SIGN_TYPE.equals(TYPE_SHA1)) {
- String timestamp = getTimestamp();
- requestData.put("timestamp", timestamp);
- requestData.put("sign_type", SIGN_TYPE);
- String signStr = APP_ID + APP_KEY + RequestEncoder.formatRequest(requestData) + APP_ID + APP_KEY;
-
- builder.addTextBody("timestamp", timestamp);
- builder.addTextBody("sign_type", SIGN_TYPE);
- builder.addTextBody("signature", RequestEncoder.encode(SIGN_TYPE, signStr), contentType);
- } else {
- builder.addTextBody("signature", APP_KEY, contentType);
- }
-
- HttpPost httpPost = new HttpPost(URL);
- httpPost.addHeader("charset", "UTF-8");
- httpPost.setEntity(builder.build());
- try {
- CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
- HttpResponse response = closeableHttpClient.execute(httpPost);
- HttpEntity httpEntity = response.getEntity();
- if (httpEntity != null) {
- String jsonStr = EntityUtils.toString(httpEntity, "UTF-8");
- if ("success".equals(JSONObject.fromObject(jsonStr).getString("status"))) {
- return true;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
-
-
- /**
- * 获取时间戳
- *
- * @return
- */
- private static String getTimestamp() {
- CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
- HttpGet httpget = new HttpGet(TIMESTAMP);
- try {
- HttpResponse response = closeableHttpClient.execute(httpget);
- HttpEntity httpEntity = response.getEntity();
- String jsonStr = EntityUtils.toString(httpEntity, "UTF-8");
- if (jsonStr != null) {
- JSONObject json = JSONObject.fromObject(jsonStr);
- return json.getString("timestamp");
- }
- closeableHttpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- public static void main(String[] args) {
-// System.out.println(sendMail("546766039@qq.com", "123456"));
-
- System.out.println(sendRechargeMail("546766039@qq.com", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN), "123456"));
- }
-}
diff --git a/src/main/resources/application-app.yml b/src/main/resources/application-app.yml
deleted file mode 100644
index ff8f05a..0000000
--- a/src/main/resources/application-app.yml
+++ /dev/null
@@ -1,116 +0,0 @@
-server:
- port: 8888
- servlet:
- context-path: /
-
-spring:
- profiles:
- active: app
- datasource:
- url: jdbc:mysql://127.0.0.1:3306/db_base?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
- username: db_base
- password: P@ssw0rd!123
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- # Redis数据库索引(默认为 0)
- database: 13
- # Redis服务器地址
- host: 127.0.0.1
- # Redis服务器连接端口
- port: 6379
- # Redis 密码
- password: lianghua1!qaz2@WSX
- lettuce:
- pool:
- # 连接池中的最小空闲连接
- min-idle: 8
- # 连接池中的最大空闲连接
- max-idle: 500
- # 连接池最大连接数(使用负值表示没有限制)
- max-active: 2000
- # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-wait: 10000
- # 连接超时时间(毫秒)
- timeout: 500000
-
- rabbitmq:
- host: 127.0.0.1
- port: 5672
- username: lianghua20210816
- password: lianghua20210816
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- # k线更新任务控制
- kline-update-job: false
- #最新价任务控制
- newest-price-update-job: false
- #日线 该任务不能与最新价处于同一个服务器
- day-line: false
- #其他任务控制
- other-job: false
- loop-job: false
- rabbit-consumer: false
- block-job: false
- websocket: false
- quant: true
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
diff --git a/src/main/resources/application-dayline.yml b/src/main/resources/application-dayline.yml
deleted file mode 100644
index 416ae8d..0000000
--- a/src/main/resources/application-dayline.yml
+++ /dev/null
@@ -1,114 +0,0 @@
-server:
- port: 8888
- servlet:
- context-path: /
-
-spring:
- profiles:
- active: dayline
- 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
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- ## Redis数据库索引(默认为0)
- database: 2
- ## Redis服务器地址
- host: 47.114.114.219
- ## Redis服务器连接端口
- port: 6379
- ## Redis服务器连接密码(默认为空)
- password: biyi123
- jedis:
- pool:
- ## 连接池最大连接数(使用负值表示没有限制)
- #spring.redis.pool.max-active=8
- max-active: 300
- ## 连接池最大阻塞等待时间(使用负值表示没有限制)
- #spring.redis.pool.max-wait=-1
- max-wait: -1
- ## 连接池中的最大空闲连接
- #spring.redis.pool.max-idle=8
- max-idle: 100
- ## 连接池中的最小空闲连接
- #spring.redis.pool.min-idle=0
- min-idle: 8
- ## 连接超时时间(毫秒)
- timeout: 30000
- rabbitmq:
- host: 120.55.86.146
- port: 5672
- username: biyict
- password: biyict123
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- kline-update-job: false
- newest-price-update-job: false
- #日线 该任务不能与最新价处于同一个服务器
- day-line: true
- other-job: false
- loop-job: false
- rabbit-consumer: true
- block-job: false
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
diff --git a/src/main/resources/application-loop.yml b/src/main/resources/application-loop.yml
deleted file mode 100644
index a79046c..0000000
--- a/src/main/resources/application-loop.yml
+++ /dev/null
@@ -1,114 +0,0 @@
-server:
- port: 8888
- servlet:
- context-path: /
-
-spring:
- profiles:
- active: loop
- 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
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- ## Redis数据库索引(默认为0)
- database: 2
- ## Redis服务器地址
- host: 47.114.114.219
- ## Redis服务器连接端口
- port: 6379
- ## Redis服务器连接密码(默认为空)
- password: biyi123
- jedis:
- pool:
- ## 连接池最大连接数(使用负值表示没有限制)
- #spring.redis.pool.max-active=8
- max-active: 300
- ## 连接池最大阻塞等待时间(使用负值表示没有限制)
- #spring.redis.pool.max-wait=-1
- max-wait: -1
- ## 连接池中的最大空闲连接
- #spring.redis.pool.max-idle=8
- max-idle: 100
- ## 连接池中的最小空闲连接
- #spring.redis.pool.min-idle=0
- min-idle: 8
- ## 连接超时时间(毫秒)
- timeout: 30000
- rabbitmq:
- host: 120.55.86.146
- port: 5672
- username: biyict
- password: biyict123
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- kline-update-job: false
- newest-price-update-job: false
- #日线 该任务不能与最新价处于同一个服务器
- day-line: false
- other-job: true
- loop-job: true
- rabbit-consumer: true
- block-job: true
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
diff --git a/src/main/resources/application-newprice.yml b/src/main/resources/application-newprice.yml
deleted file mode 100644
index a363e34..0000000
--- a/src/main/resources/application-newprice.yml
+++ /dev/null
@@ -1,114 +0,0 @@
-server:
- port: 8888
- servlet:
- context-path: /
-
-spring:
- profiles:
- active: newprice
- 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
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- ## Redis数据库索引(默认为0)
- database: 2
- ## Redis服务器地址
- host: 47.114.114.219
- ## Redis服务器连接端口
- port: 6379
- ## Redis服务器连接密码(默认为空)
- password: biyi123
- jedis:
- pool:
- ## 连接池最大连接数(使用负值表示没有限制)
- #spring.redis.pool.max-active=8
- max-active: 300
- ## 连接池最大阻塞等待时间(使用负值表示没有限制)
- #spring.redis.pool.max-wait=-1
- max-wait: -1
- ## 连接池中的最大空闲连接
- #spring.redis.pool.max-idle=8
- max-idle: 100
- ## 连接池中的最小空闲连接
- #spring.redis.pool.min-idle=0
- min-idle: 8
- ## 连接超时时间(毫秒)
- timeout: 30000
- rabbitmq:
- host: 120.55.86.146
- port: 5672
- username: biyict
- password: biyict123
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- kline-update-job: false
- newest-price-update-job: true
- #日线 该任务不能与最新价处于同一个服务器
- day-line: false
- other-job: false
- loop-job: false
- rabbit-consumer: true
- block-job: false
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml
deleted file mode 100644
index 21cd98d..0000000
--- a/src/main/resources/application-test.yml
+++ /dev/null
@@ -1,116 +0,0 @@
-server:
- port: 8888
- servlet:
- context-path: /
-
-spring:
- profiles:
- active: app
- datasource:
- url: jdbc:mysql://120.27.238.55:3406/db_base?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
- username: ct_test
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- # Redis数据库索引(默认为 0)
- database: 8
- # Redis服务器地址
- host: 120.27.238.55
- # Redis服务器连接端口
- port: 6479
- # Redis 密码
- password: d3y6dsdl;f.327
- lettuce:
- pool:
- # 连接池中的最小空闲连接
- min-idle: 8
- # 连接池中的最大空闲连接
- max-idle: 500
- # 连接池最大连接数(使用负值表示没有限制)
- max-active: 2000
- # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-wait: 10000
- # 连接超时时间(毫秒)
- timeout: 500000
-
- rabbitmq:
- host: 120.27.238.55
- port: 5672
- username: ct_rabbit
- password: 123456
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- # k线更新任务控制
- kline-update-job: false
- #最新价任务控制
- newest-price-update-job: false
- #日线 该任务不能与最新价处于同一个服务器
- day-line: false
- #其他任务控制
- other-job: false
- loop-job: false
- rabbit-consumer: false
- block-job: false
- websocket: false
- quant: false
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index e7c31eb..009bc4d 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -4,113 +4,10 @@
context-path: /
spring:
- OKEX:
- baseurl: https://www.okex.com
- profiles:
- active: test
- datasource:
- url: jdbc:mysql://120.27.238.55:3406/db_base?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
- username: ct_test
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- type: com.alibaba.druid.pool.DruidDataSource
- druid:
- initial-size: ${spring_datasource_druid_initial_size:10}
- max-active: ${spring_datasource_druid_max_active:20}
- min-idle: ${spring_datasource_druid_min_idle:3}
- #配置获取连接等待超时的时间
- max-wait: 60000
- pool-prepared-statements: true
- max-pool-prepared-statement-per-connection-size: 20
- validation-query: SELECT 'x'
- test-on-borrow: true
- test-on-return: true
- test-while-idle: true
- #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
- time-between-eviction-runs-millis: 60000
- #配置一个连接在池中最小生存的时间,单位是毫秒
- min-evictable-idle-time-millis: 300000
- #spring.datasource.druid.max-evguide.ftlictable-idle-time-millis=
- filters: stat,wall
- stat-view-servlet:
- # 默认true 内置监控页面首页/druid/index.html
- enabled: true
- url-pattern: /druid/*
- # 允许清空统计数据
- reset-enable: true
- login-username: root
- login-password: 123456
- # IP白名单 多个逗号分隔
- allow: ${spring_datasource_stat_view_servlet_allow:}
- # IP黑名单
- deny: ${spring_datasource_stat_view_servlet_deny:}
- ## 国际化配置
- messages:
- basename: i18n/messages
- ## redis配置
- redis:
- # Redis数据库索引(默认为 0)
- database: 13
- # Redis服务器地址
- host: 120.27.238.55
- # Redis服务器连接端口
- port: 6479
- # Redis 密码
- password: d3y6dsdl;f.327
- lettuce:
- pool:
- # 连接池中的最小空闲连接
- min-idle: 8
- # 连接池中的最大空闲连接
- max-idle: 500
- # 连接池最大连接数(使用负值表示没有限制)
- max-active: 2000
- # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-wait: 10000
- # 连接超时时间(毫秒)
- timeout: 500000
+ devtools:
+ restart:
+ enabled: false
- rabbitmq:
- host: 120.27.238.55
- port: 5672
- username: ct_rabbit
- password: 123456
- publisher-confirm-type: correlated
-
-
-#custom:
-# rabbitmq:
-# host: 120.27.238.55
-# port: 5672
-# username: ct_rabbit
-# password: 123456
-
-mybatis-plus:
- mapper-locations: classpath:mapper/**/*.xml
-
-
-app:
- debug: false
- redis_expire: 3000
- # k线更新任务控制
- kline-update-job: false
- #最新价任务控制
- newest-price-update-job: false
- #日线 该任务不能与最新价处于同一个服务器
- day-line: false
- #其他任务控制
- other-job: false
- loop-job: false
- rabbit-consumer: false
- block-job: false
-
-aliyun:
- oss:
- end-point: https://oss-cn-hangzhou.aliyuncs.com
- bucket-name: https://excoin.oss-cn-hangzhou.aliyuncs.com
- access-key-id: LTAI4GBuydqbJ5bTsDP97Lpd
- access-key-secret: vbCjQtPxABWjqtUlQfzjlA0qAY96fh
-
-rsa:
- public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
- private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIJ/xQVkrngCIrg9G7u0135nypnvuj9BcKeTbkNGbKBWk4S7mYY1IC9+daYqnakRXZGWN5erdGJ3/4tCSidp5swl5cpIXTLEv9WDJ5PwlpDmA1s6t192Vz6YWRcnLPIm3xiS8CkR09E1JTYQ0GfuaBF8PQFg8zi9nr+u/517fwUnAgMBAAECgYBhPt9NvpI4wbanvnndLczr2GJkxfzvSE+vwLCJF4C5FusFHVsxZINggQcg1V75bwRgCiXRMyYefreCSdrCditS43PzTOmE4RRrpxLlm8oubJc0C98LQ2qlN9AsUqL5IHpVGgbHDyWAwjc1GBID6nwXKpxq1/VodFqhahG9D5EZsQJBALnkb+5VTxQbiyQI4Uc9NIvAyVcNY1OisbvY6tvNgdBbJkADgAb78M1HWxxYjUqsvzggNHc7cWqWBHMgpnJaqm8CQQCztze4D7uAk7OC9MJHY5eE980J8Kk+GEZKxz4LahzU6V6dcb9GFac3wEtgilj/tOAn9y0/Q8sm9vvCIbMDzgzJAkEAqRYcqhF26LdVDOX25DHMBgLKISDQZFbsjA13M4/usHL4i+mjHrc0BcUOHu59NpuDI65HitzLAUSLr5zXSdUmiQJAW77wOg4GCejdXsB3IhzMsHwU97sdm26nC+vVV9xvJZ6Rx8zW+f9543NOx9U5BCmhuaVtOvvwDU9PTVcI3atmSQJAXAIJ5gGdtXx0DXiX4VvzNFHqgaqHMGvXyjNVkU2FYQbSAd2A6app4uRO+BkZu9dSjh14m+oXMnV2HzAN2rRnjA==
+logging:
+ level:
+ com.xcong.excoin.modules.okxApi: INFO
diff --git a/src/main/resources/i18n/messages.properties b/src/main/resources/i18n/messages.properties
deleted file mode 100644
index e69de29..0000000
--- a/src/main/resources/i18n/messages.properties
+++ /dev/null
diff --git a/src/main/resources/i18n/messages_en_US.properties b/src/main/resources/i18n/messages_en_US.properties
deleted file mode 100644
index fc356e7..0000000
--- a/src/main/resources/i18n/messages_en_US.properties
+++ /dev/null
@@ -1,243 +0,0 @@
-test=test
-
-blockchain_service_0001=Invalid login information
-blockchain_service_0002=User does not exist
-
-member_controller_0001=Please conduct real name authentication
-member_controller_0002=Please configure the transaction password first
-member_controller_0003=Please enter the transaction password
-member_controller_0004=Please enter the correct transaction password
-member_controller_0005=The system is busy. Please try again later
-member_controller_0006=Please pay in time if the purchase is successful
-member_controller_0007=Confirm success
-member_controller_0008=Login information has expired
-member_controller_0009=Please go to the Security Center for real name authentication
-member_controller_0010=Please go to the security center to configure the transaction password
-
-member_controller_0011=Please enter the transaction password
-member_controller_0012=Please enter the correct transaction password
-member_controller_0013=Your current available usdt quota is not enough
-member_controller_0014=Please enter the withdrawal amount
-member_controller_0015=Your current available usdt quota is not enough
-member_controller_0016=Please configure the collection method
-member_controller_0017=Insufficient available usdt balance
-member_controller_0018=checkout success
-member_controller_0019=Login user is invalid
-member_controller_0020=Undo successful
-
-member_controller_0021=Confirm success
-member_controller_0022=This type of collection is not supported
-member_controller_0023=Login user is invalid
-member_controller_0024=Undo successful
-
-member_service_0001=Wallet address does not exist
-member_service_0002=Invalid login information
-member_service_0003=User does not exist
-member_service_0004=Transfer amount cannot be less than 0
-member_service_0005=Insufficient available balance of currency account
-member_service_0006=Transfer succeeded
-member_service_0007=The available balance of contract account usdt is insufficient
-member_service_0008=Insufficient available balance of agent account usdt
-member_service_0009=Mobile number cannot be empty
-member_service_0010=Sent successfully
-
-member_service_0011=Fail in send
-member_service_0012=The verification code has expired, please request again
-member_service_0013=Wrong verification code
-member_service_0014=Binding succeeded
-member_service_1400=Binding fail
-member_service_0015=Submit failed
-member_service_0016=Mailbox cannot be empty
-member_service_0017=Verification code cannot be empty
-member_service_0018=Binding succeeded
-member_service_0019=Binding failed
-member_service_0020=Get failed
-
-member_service_0021=Please enter the address of withdrawal
-member_service_0022=Please enter notes
-member_service_0023=Please select currency
-member_service_0024=Submitted successfully
-member_service_0025=Get failed
-member_service_0026=Set successfully
-member_service_0027=Setting failed
-member_service_0028=Set successfully
-member_service_0029=Setting failed
-member_service_0030=Delete succeeded
-
-member_service_0031=Delete failed
-member_service_0032=User failure
-member_service_0033=Successfully added
-member_service_0034=Delete succeeded
-member_service_0035=Delete failed
-member_service_0036=Update successful
-member_service_0037=Update failed
-member_service_0038=Verification code is invalid
-member_service_0039=Verification code error
-member_service_0040=Modification succeeded
-member_service_4000=Information auditing
-
-member_service_0041=Modification failed
-member_service_0042=Please enter your mobile number
-member_service_0043=Please enter the verification code
-member_service_0044=Please input a password
-member_service_0045=Verification code is invalid, please resend
-member_service_0046=The verification code entered is wrong, please re-enter
-member_service_0047=please register and log in
-member_service_0048=Modification succeeded, please log in
-member_service_0049=Verification code is invalid
-member_service_0050=Verification code error
-
-member_service_0051=Reset successful
-member_service_0052=Modification failed
-member_service_0053=Sent successfully
-member_service_0054=fail in send
-member_service_0055=Submitted, pending review
-member_service_0056=Audit passed
-member_service_0057=Please enter country
-member_service_0058=Last name cannot be blank, please enter
-member_service_0059=The name cannot be empty. Please enter
-member_service_0060=Card has been used
-
-member_service_0061=Image missing, please upload
-member_service_0062=Submitted successfully
-member_service_0063=Failed to submit, please resubmit
-member_service_0064=The transaction password is wrong, please check and re-enter
-member_service_0065=Verification code is invalid
-member_service_0066=Wrong verification code
-member_service_0067=Submit failed
-member_service_0068=Transaction password set successfully
-member_service_0069=Transaction password modified successfully
-member_service_0070=User does not exist
-
-member_service_0071=Exit successful
-member_service_0072=Exit failed
-member_service_0073=Get failed
-member_service_0074=Failure of user login information
-member_service_0075=User does not exist
-member_service_0076=Get failed
-member_service_0077=No real name authentication
-member_service_0078=Submitted successfully
-member_service_0079=Submit failed
-member_service_0080=No real name authentication
-
-member_service_0081=Transaction password not set
-member_service_0082=Wrong transaction password entered
-member_service_0083=Cell phone number is empty
-member_service_0084=Verification code error
-member_service_0085=Insufficient available balance
-member_service_0086=Submitted successfully, waiting for approval
-member_service_0087=Wallet does not exist
-member_service_0088=User login is invalid
-member_service_0089=Network exception
-member_service_0090=Already logged in
-
-member_service_0091=Not logged in
-member_service_0092=The account has been restricted
-member_service_0093=The user does not exist. Please register and log in again
-member_service_0094=Insufficient available balance of contract usdt account
-member_service_0095=Insufficient available balance of agent usdt account
-member_service_0096=Transfer fail
-member_service_0097=Payment method already exists
-
-order_service_0001=Wrong parameter value
-order_service_0002=Not logged in
-order_service_0003=Submit failed
-order_service_0004=Parameter error
-order_service_0005=Invalid login information
-order_service_0006=User does not exist
-order_service_0007=No real name authentication, please go to the Security Center for real name authentication
-order_service_0008=Wrong parameter
-order_service_0009=Server exception
-order_service_0010=Insufficient amount available
-
-order_service_0011=Submitted successfully
-order_service_0012=Do not repeat cancellation
-order_service_0013=Cancellation successful
-order_service_0014=Please log in
-order_service_0015=Add self selection succeeded
-order_service_0016=Delete self selection succeeded
-order_service_0017=No wallet account
-order_service_0018=User does not exist
-order_service_0019=Wrong parameter
-order_service_0020=User wallet does not exist
-
-order_service_0021=Parameter error
-order_service_0022=The entrusted open price cannot be higher than the market price
-order_service_0023=The entrusted open price cannot be lower than the market price
-order_service_0024=The available amount is insufficient, please recharge before purchasing
-order_service_0025=Submitted successfully
-order_service_0026=User not logged in
-order_service_0027=Order does not exist
-order_service_0028=The order has been closed
-order_service_0029=Margin adjustment failed
-order_service_0030=Margin adjusted
-
-order_service_0031=User login failed
-order_service_0032=Do not repeat cancellation
-order_service_0033=Cancellation successful
-order_service_0034=Closed position
-order_service_0035=Get failed
-order_service_0036=Failure of user login information
-order_service_0037=Operation successful
-order_service_0038=Server exception
-order_service_0039=Frequent operation, please try again later
-order_service_0040=Insufficient available balance
-
-order_service_0041=Set successfully
-order_service_0042=Setting failed
-order_service_0043=Cancellation failed
-order_service_0044=Successful closing
-order_service_0045=This order cannot be closed temporarily
-order_service_0046=No open order
-
-symbols_controller_0001=Success
-
-symbols_service_0001=Details obtained successfully
-symbols_service_0002=Failed to get data
-symbols_service_0003=Load failed
-
-home_controller_0001=Number registered
-home_controller_0002=Number registration available
-home_controller_0003=Correct number
-home_controller_0004=Number not registered
-home_controller_0005=Sent successfully
-home_controller_0006=Failed to send, please resend
-home_controller_0007=The verification code is invalid, please resend!
-home_controller_0008=Verification code error
-home_controller_0009=Verification code succeeded
-
-home_service_0001=Please enter your mobile number
-home_service_0002=Please input a password
-home_service_0003=The user does not exist. Please register and log in again
-home_service_0004=The account has been restricted
-home_service_0005=Wrong password
-home_service_0006=Wrong format of mobile number entered
-home_service_0007=The mobile number has been registered. Please log in
-home_service_0008=login has failed
-home_service_0009=Registration succeeded, please log in
-home_service_0010=Verification code is invalid, please resend
-
-home_service_0011=The verification code entered is wrong, please re-enter
-home_service_0012=Please enter the verification code
-home_service_0013=Modification succeeded, please log in
-home_service_0014=The mobile number does not exist, please register and log in
-
-uploadFile_controller_0001=Upload failed
-
-result_success_msg=Operation success
-result_fail_msg=Operation failed
-
-common_verify_code=Code Error Or Invalided
-common_verify_code_exist=Code existed
-
-illegal_symbol=Illegal Symbol
-illegal_type=Illegal Type
-
-entrust_price_judge_more=The entrusted open price cannot be higher than the market price
-entrust_price_judge_less=The entrusted open price cannot be lower than the market price
-entrust_order_not_exist=Order does not exist
-cancellation_success=Cancellation Success
-cancellation_fail=Cancellation Fail
-
-submit_repeat=Do not repeat submission
-
diff --git a/src/main/resources/i18n/messages_zh_CN.properties b/src/main/resources/i18n/messages_zh_CN.properties
deleted file mode 100644
index 0fdc300..0000000
--- a/src/main/resources/i18n/messages_zh_CN.properties
+++ /dev/null
@@ -1,242 +0,0 @@
-test=测�
-
-blockchain_service_0001=登录信息失效
-blockchain_service_0002=用户不存在
-
-member_controller_0001=请先实名认证
-member_controller_0002=请先配置交易密码
-member_controller_0003=请输入交易密码
-member_controller_0004=请输入正确的交易密码
-member_controller_0005=系统繁忙,请稍后再试
-member_controller_0006=购买成功,请及时付款
-member_controller_0007=确认成功
-member_controller_0008=登录信息已失效
-member_controller_0009=请前往安全中心进行实名认证
-member_controller_0010=请前往安全中心配置交易密码
-
-member_controller_0011=请输入交易密码
-member_controller_0012=请输入正确的交易密码
-member_controller_0013=您当前可用USDT额度不够
-member_controller_0014=请输入提币量
-member_controller_0015=您当前可用USDT额度不够
-member_controller_0016=请配置收款方式
-member_controller_0017=可用USDT余额不足
-member_controller_0018=下单成功
-member_controller_0019=登录用户已失效
-member_controller_0020=撤销成功
-
-member_controller_0021=确认成功
-member_controller_0022=不支持此类收款
-member_controller_0023=登录用户已失效
-member_controller_0024=撤销成功
-
-member_service_0001=钱包地址不存在
-member_service_0002=用户登录信息失效
-member_service_0003=用户不存在
-member_service_0004=转账金额不能小于0
-member_service_0005=币币账户可用余额不足
-member_service_0006=划转成功
-member_service_0007=合约账户USDT可用余额不足
-member_service_0008=代理账户USDT可用余额不足
-member_service_0009=手机号不能为空
-member_service_0010=发送成功
-
-member_service_0011=发送失败
-member_service_0012=验证码已失效,请重新请求
-member_service_0013=验证码有误
-member_service_0014=绑定成功
-member_service_1400=绑定失败
-member_service_0015=提交失败
-member_service_0016=邮箱不能为空
-member_service_0017=验证码不能为空
-member_service_0018=绑定成功
-member_service_0019=绑定失败
-member_service_0020=获取失败
-
-member_service_0021=请输入提币地址
-member_service_0022=请输入备注信息
-member_service_0023=请选择币种
-member_service_0024=提交成功
-member_service_0025=获取失败
-member_service_0026=设置成功
-member_service_0027=设置失败
-member_service_0028=获取成功
-member_service_0029=获取失败
-member_service_0030=删除成功
-
-member_service_0031=删除失败
-member_service_0032=用户失效
-member_service_0033=添加成功
-member_service_0034=删除成功
-member_service_0035=删除失败
-member_service_0036=更新成功
-member_service_0037=更新失败
-member_service_0038=验证码已失效
-member_service_0039=验证码错误
-member_service_0040=修改成功
-member_service_4000=信息审核中
-
-member_service_0041=修改失败
-member_service_0042=请输入手机号码
-member_service_0043=请输入验证码
-member_service_0044=请输入密码
-member_service_0045=验证码已失效,请重新发送
-member_service_0046=输入的验证码有误,请重新输入
-member_service_0047=请进行注册登录
-member_service_0048=修改成功,请登录
-member_service_0049=验证码已失效
-member_service_0050=验证码错误
-
-member_service_0051=重置成功
-member_service_0052=修改失败
-member_service_0053=发送成功
-member_service_0054=发送失败
-member_service_0055=已提交,等待审核
-member_service_0056=审核已通过
-member_service_0057=请输入国家
-member_service_0058=姓不能为空,请输入
-member_service_0059=名不能为空,请输入
-member_service_0060=证件号码已被使用
-
-member_service_0061=缺少图片,请上传
-member_service_0062=提交成功
-member_service_0063=提交失败,请重新提交
-member_service_0064=输入交易密码有误,请检查重新输入
-member_service_0065=验证码已失效
-member_service_0066=验证码有误
-member_service_0067=提交失败
-member_service_0068=交易密码设置成功
-member_service_0069=交易密码修改成功
-member_service_0070=用户不存在
-
-member_service_0071=退出成功
-member_service_0072=退出失败
-member_service_0073=获取失败
-member_service_0074=用户登录信息失效
-member_service_0075=用户不存在
-member_service_0076=获取失败
-member_service_0077=未实名认证
-member_service_0078=提交成功
-member_service_0079=提交失败
-member_service_0080=未实名认证
-
-member_service_0081=未设置交易密码
-member_service_0082=输入的交易密码有误
-member_service_0083=手机号为空
-member_service_0084=验证码错误
-member_service_0085=可用余额不足
-member_service_0086=提交成功,等待审核
-member_service_0087=钱包不存在
-member_service_0088=用户登陆已失效
-member_service_0089=网络异常
-member_service_0090=已经登陆
-
-member_service_0091=未登录
-member_service_0092=该账户已限制登录
-member_service_0093=用户不存在,请注册后再登录
-member_service_0094=合约USDT账户可用余额不足
-member_service_0095=代理USDT账户可用余额不足
-member_service_0096=划转失败
-member_service_0097=支付方式已存在
-
-order_service_0001=参值有误
-order_service_0002=未登录
-order_service_0003=提交失败
-order_service_0004=参数错误
-order_service_0005=登录信息失效
-order_service_0006=用户不存在
-order_service_0007=未实名认证,请去安全中心里进行实名认证
-order_service_0008=参数有误
-order_service_0009=服务器异常
-order_service_0010=可用金额不足
-
-order_service_0011=提交成功
-order_service_0012=请勿重复撤单
-order_service_0013=撤单成功
-order_service_0014=请登录
-order_service_0015=添加自选成功
-order_service_0016=删除自选成功
-order_service_0017=无钱包账号
-order_service_0018=用户不存在
-order_service_0019=参数有误
-order_service_0020=用户钱包不存在
-
-order_service_0021=参数错误
-order_service_0022=委托开多价不能高于市场价
-order_service_0023=委托开多价不能低于市场价
-order_service_0024=可用金额不足,请充值后再购买
-order_service_0025=提交成功
-order_service_0026=用户未登录
-order_service_0027=订单不存在
-order_service_0028=该订单已平仓
-order_service_0029=保证金调整失败
-order_service_0030=保证金已调整
-
-order_service_0031=用户登录已失效
-order_service_0032=请勿重复撤单
-order_service_0033=撤单成功
-order_service_0034=已平仓
-order_service_0035=获取失败
-order_service_0036=用户登录信息失效
-order_service_0037=操作成功
-order_service_0038=服务器异常
-order_service_0039=操作频繁,请稍后再试
-order_service_0040=可用余额不足
-
-order_service_0041=设置成功
-order_service_0042=设置失败
-order_service_0043=撤单失败
-order_service_0044=平仓成功
-order_service_0045=该订单暂不能平仓
-order_service_0046=没有可平仓的订单
-
-symbols_controller_0001=成功
-
-symbols_service_0001=获取详情成功
-symbols_service_0002=获取数据失败
-symbols_service_0003=加载失败
-
-home_controller_0001=号码已注册
-home_controller_0002=号码可用注册
-home_controller_0003=号码正确
-home_controller_0004=号码没注册
-home_controller_0005=发送成功
-home_controller_0006=发送失败,请重新发送
-home_controller_0007=验证码已失效,请重新发送!
-home_controller_0008=验证码错误
-home_controller_0009=验证码成功
-
-home_service_0001=请输入手机号码
-home_service_0002=请输入密码
-home_service_0003=用户不存在,请注册后再登录
-home_service_0004=该账户已限制登录
-home_service_0005=密码有误
-home_service_0006=输入的手机号码格式有误
-home_service_0007=该手机号码已被注册,请去登录
-home_service_0008=注册失败
-home_service_0009=注册成功,请去登录
-home_service_0010=验证码已失效,请重新发送
-
-home_service_0011=输入的验证码有误,请重新输入
-home_service_0012=请输入验证码
-home_service_0013=修改成功,请登录
-home_service_0014=不存在该手机号码,请进行注册登录
-
-uploadFile_controller_0001=上传失败
-
-result_success_msg=操作成功
-result_fail_msg=操作失败
-
-common_verify_code=验证码错误或已失效
-common_verify_code_exist=验证码已发送,请勿重复发送
-
-illegal_symbol=非法币种
-illegal_type=非法类型
-
-entrust_price_judge_more=委托价不能大于当前价
-entrust_price_judge_less=委托价不能小于当前价
-entrust_order_not_exist=委托单不存在
-cancellation_success=撤销成功
-cancellation_fail=撤销失败
-
-submit_repeat=请勿重复提交
diff --git a/src/main/resources/mapper/TestUserDao.xml b/src/main/resources/mapper/TestUserDao.xml
deleted file mode 100644
index a52f9b5..0000000
--- a/src/main/resources/mapper/TestUserDao.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?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.test.dao.TestUserDao">
-
- <select id="selectAll" resultType="com.xcong.excoin.modules.test.entity.TestUserEntity">
- select * from test_user
- </select>
-
- <select id="selectInPage" resultType="com.xcong.excoin.modules.test.entity.TestUserEntity">
- select * from test_user
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml b/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml
deleted file mode 100644
index 0ba1be1..0000000
--- a/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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.contract.dao.ContractEntrustOrderDao">
-
- <select id="selectEntrustOrderByIdAndMemberId" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity">
- select * from contract_entrust_order
- where id=#{id} and member_id=#{memberId}
- </select>
-
- <select id="selectEntrustOrderListByMemberId" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity">
- select * from contract_entrust_order
- where member_id=#{memberId}
- </select>
-
- <select id="selectEntrustOrderListByMemberIdAndSymbol" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity">
- select * from contract_entrust_order
- where member_id=#{memberId}
- <if test="symbol != null and symbol !=''">
- and symbol=#{symbol}
- </if>
- order by create_time desc
- </select>
- <select id="selectEntrustOrderListByIds" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity">
- select * from contract_entrust_order
- where id in
- <foreach collection="list" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- </select>
-
- <select id="selectAllEntrustOrder" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity">
- select * from contract_entrust_order
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/contract/ContractHoldOrderDao.xml b/src/main/resources/mapper/contract/ContractHoldOrderDao.xml
deleted file mode 100644
index 3572e89..0000000
--- a/src/main/resources/mapper/contract/ContractHoldOrderDao.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?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.contract.dao.ContractHoldOrderDao">
-
- <update id="updateContractHoldOrderCanNotClosingByIds" parameterType="map">
- UPDATE contract_hold_order set is_can_closing = 0,batch_no=#{batchNo}
- where is_can_closing=1
- and id in
- <foreach collection="list" close=")" item="item" open="(" separator=",">
- #{item.orderId}
- </foreach>
- </update>
-
- <select id="selectContractHoldOrderByBatchNo" parameterType="string" resultType="com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity">
- select * from contract_hold_order where batch_no=#{batchNo}
- </select>
-
- <update id="updateOrderIsCanClosingAndBatchNoById" parameterType="long">
- update contract_hold_order set is_can_closing = 1 ,batch_no=null
- where id=#{id}
- </update>
-
- <select id="selectHoldOrderListByMemberId" resultType="com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity">
- select * from contract_hold_order where member_id=#{memberId} and is_can_closing=1 order by create_time desc
- </select>
-
- <select id="selectHoldOrderListByMemberIdAndSymbol" resultType="com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity">
- select * from contract_hold_order where member_id=#{memberId}
- <if test="symbol!=null and symbol!=''">
- and symbol=#{symbol}
- </if>
- and is_can_closing=1
- order by create_time desc
- </select>
-
- <select id="selectHoldOrderByMemberIdAndId" resultType="com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity">
- select * from contract_hold_order where member_id=#{memberId} and id=#{id}
- </select>
-
- <update id="updateHoldOrderIsCanClosingById">
- update contract_hold_order set is_can_closing=#{isCanClosing}
- where id=#{id}
- </update>
-
- <select id="selectAllHoldOrder" resultType="com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity">
- select * from contract_hold_order
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/contract/ContractOrderDao.xml b/src/main/resources/mapper/contract/ContractOrderDao.xml
deleted file mode 100644
index a9b11dd..0000000
--- a/src/main/resources/mapper/contract/ContractOrderDao.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?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.contract.dao.ContractOrderDao">
-
-
- <select id="selectContractOrderInPage" resultType="com.xcong.excoin.modules.contract.entity.ContractOrderEntity">
- select
- create_time,
- id,
- member_id,
- order_no,
- position_type,
- trade_type,
- order_type,
- order_status,
- entrust_opening_price,
- entrust_time,
- symbol,
- symbol_cnt,
- symbol_sku,
- closing_price,
- closing_time,
- closing_fee_amount*(select fee_spread_ratio from platform_trade_setting) closing_fee_amount,
- closing_type,
- lever_ratio,
- stop_loss_price,
- stop_profit_price,
- reward_amount,
- reward_ratio,
- opening_price,
- opening_time,
- pre_payment_amount,
- bond_amount,
- mark_price,
- force_closing_price,
- hold_amount,
- opening_fee_amount*(select fee_spread_ratio from platform_trade_setting) opening_fee_amount
- from contract_order
- <if test="record != null">
- <where>
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- <if test="record.symbol != null and record.symbol != ''">
- and symbol = #{record.symbol}
- </if>
- </where>
- </if>
- order by create_time desc, id desc
- </select>
-
- <select id="selectOrderDetailByIdAndMemberId" resultType="com.xcong.excoin.modules.contract.entity.ContractOrderEntity">
- select * from contract_order where id=#{id} and member_id=#{memberId}
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml b/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
deleted file mode 100644
index 050c21a..0000000
--- a/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?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.home.dao.MemberQuickBuySaleDao">
-
- <select id="selectByIdAndMemberId" resultType="com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity">
- SELECT a.* FROM member_quick_buy_sale a WHERE a.id = #{id} AND a.member_id = #{memberId}
- </select>
-
- <update id="updateQuickBuySaleTimeOut">
- update member_quick_buy_sale
- set order_status = 5
- where order_type = 'B' and order_status=1
- and timestampdiff(MINUTE, create_time, now()) > 30
- </update>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/AgentReturnDao.xml b/src/main/resources/mapper/member/AgentReturnDao.xml
deleted file mode 100644
index 0c7d266..0000000
--- a/src/main/resources/mapper/member/AgentReturnDao.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?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.dao.AgentReturnDao">
-
- <select id="selectAllNeedMoneyReturn" resultType="com.xcong.excoin.modules.member.entity.AgentReturnEntity">
- select
- referer_id,
- sum(return_amount) return_amount
- from agent_return where is_return=0
- group by referer_id
- </select>
-
- <update id="updateAgentReturnStatusByRefererId">
- update agent_return
- set is_return=#{isReturn}
- where referer_id=#{refererId}
- </update>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/AppVersionDao.xml b/src/main/resources/mapper/member/AppVersionDao.xml
deleted file mode 100644
index 23a92c5..0000000
--- a/src/main/resources/mapper/member/AppVersionDao.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?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.dao.AppVersionDao">
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberAccountFlowEntityDao.xml b/src/main/resources/mapper/member/MemberAccountFlowEntityDao.xml
deleted file mode 100644
index 2918668..0000000
--- a/src/main/resources/mapper/member/MemberAccountFlowEntityDao.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?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.coin.dao.MemberAccountFlowEntityDao">
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberAccountMoneyChangeDao.xml b/src/main/resources/mapper/member/MemberAccountMoneyChangeDao.xml
deleted file mode 100644
index 1c47b40..0000000
--- a/src/main/resources/mapper/member/MemberAccountMoneyChangeDao.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?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.coin.dao.MemberAccountMoneyChangeDao">
-
- <select id="selectWalletCoinRecordsByMemIdTypeSymbol" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change where type = 1 and member_id = #{memberId} order by id desc
- </select>
-
- <select id="selectWalletContractRecordsByMemIdTypeSymbol" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change where type = 2 and member_id = #{memberId} order by id desc
- </select>
-
- <select id="selectWalletAgentRecordByMemIdTypeSymbol" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change where type = 3 and member_id = #{memberId} order by id desc
- </select>
-
- <select id="selectWalletCoinRecordsInPage" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change
- <if test="record != null">
- <where>
- type = 1
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- </where>
- </if>
- order by id desc
- </select>
-
- <select id="selectWalletContractRecordsInPage" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change <if test="record != null">
- <where>
- type = 2
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- </where>
- </if>
- order by id desc
- </select>
-
- <select id="selectWalletAgentRecordsInPage" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change <if test="record != null">
- <where>
- type = 3
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- </where>
- </if>
- order by id desc
- </select>
-
- <select id="selectWalletAgentIntoRecordsByMemIdTypeSymbol" resultType="com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange">
- select * from member_account_money_change <if test="record != null">
- <where>
- type = 3
- and content like '%佣金到账%'
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- </where>
- </if>
- order by id desc
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberAuthenticationDao.xml b/src/main/resources/mapper/member/MemberAuthenticationDao.xml
deleted file mode 100644
index 8959e65..0000000
--- a/src/main/resources/mapper/member/MemberAuthenticationDao.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?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.dao.MemberAuthenticationDao">
-
- <select id="findMemberbyIdCardNoCount" resultType="int">
- select count(*) from member_authentication where idcard_No = #{idCardNo}
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberCoinAddressDao.xml b/src/main/resources/mapper/member/MemberCoinAddressDao.xml
deleted file mode 100644
index 4a3237a..0000000
--- a/src/main/resources/mapper/member/MemberCoinAddressDao.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?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.dao.MemberCoinAddressDao">
-
- <select id="selectAddressByMemberIdAndSymbol" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select * from member_coin_address where member_id=#{memberId} and symbol = #{symbol}
- </select>
-
- <select id="selectBlockAddressWithTag" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select *
- from member_coin_address
- <where>
- is_biyict = 1
- <if test="memberId != null and memberId != ''">
- and member_id = #{memberId}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- <if test="tag != null and tag != ''">
- and tag = #{tag}
- </if>
- </where>
- </select>
-
- <select id="selectBlockAddress" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select *
- from member_coin_address
- <where>
- is_biyict = 1
- <if test="memberId != null and memberId != ''">
- and member_id = #{memberId}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- </where>
- </select>
-
- <select id="selectCoinAddressListByMap" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select * from member_coin_address
- <where>
- is_biyict = 2
- and symbolscoin_id IS NOT NULL
- <if test="memberId != null and memberId != ''">
- and member_id = #{memberId}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- </where>
- </select>
-
-
- <select id="selectAllBlockAddressBySymbolAndTag" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select * from member_coin_address
- where is_biyict = 1
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- <if test="tag != null and tag != ''">
- and tag = #{tag}
- </if>
- </select>
-
- <select id="selectAllBlockAddressBySymbol" resultType="com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity">
- select * from member_coin_address
- where symbol=#{symbol}
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberCoinChargeDao.xml b/src/main/resources/mapper/member/MemberCoinChargeDao.xml
deleted file mode 100644
index e875705..0000000
--- a/src/main/resources/mapper/member/MemberCoinChargeDao.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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.dao.MemberCoinChargeDao">
-
- <select id="selectNewestChargeRecord" resultType="com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity">
- select * from member_coin_charge
- where member_id=#{memberId}
- and symbol=#{symbol}
- <if test="tag !=null and tag != ''">
- and tag = #{tag}
- </if>
- order by create_time desc limit 1
- </select>
-
- <select id="selectAllBySymbolAndTag" resultType="com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity">
- select * from member_coin_charge
- where symbol=#{symbol}
- <if test="tag !=null and tag != ''">
- and tag = #{tag}
- </if>
- <if test="status !=null and status != ''">
- and status = #{status}
- </if>
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberDao.xml b/src/main/resources/mapper/member/MemberDao.xml
deleted file mode 100644
index 7debfd9..0000000
--- a/src/main/resources/mapper/member/MemberDao.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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.dao.MemberDao">
-
- <select id="selectMemberInfoByAccount" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
- select * from member where phone=#{account} or email=#{account}
- </select>
-
- <select id="selectMemberInfoByInviteId" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
- select * from member where invite_id=#{inviteId}
- </select>
-
- <select id="selectFriendRelationUserByMemberId" parameterType="long" resultType="com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo">
- SELECT
- t1.id memberId,
- t1.invite_id inviteId,
- t2.referer_id referenceId,
- t2.return_ratio returnRatio,
- t2.level_id levelId,
- t2.fee_is_self feeIsSelf
- FROM
- member t1
- INNER JOIN agent_friend_relation t2 ON t1.id = t2.member_id
- WHERE
- t1.id = #{memberId}
- AND t2.referer_id IS NOT NULL
- </select>
-
- <select id="selectAllNeedMoneyMember" parameterType="map" resultType="com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo">
- SELECT
- t1.id memberId,
- t1.invite_id inviteId,
- t2.referer_id referenceId,
- t2.return_ratio returnRatio,
- t2.level_id levelId,
- t2.fee_is_self feeIsSelf
- FROM
- member t1
- INNER JOIN agent_friend_relation t2 ON t1.id = t2.member_id
- WHERE
- t2.referer_id IS NOT NULL
- AND t1.invite_id IN
- <foreach collection = "list" item = "item" separator="," open = "(" close = ")" >
- #{item}
- </foreach >
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberLevelRateDao.xml b/src/main/resources/mapper/member/MemberLevelRateDao.xml
deleted file mode 100644
index 2f79547..0000000
--- a/src/main/resources/mapper/member/MemberLevelRateDao.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?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.dao.MemberLevelRateDao">
-
- <select id="selectLeverRateByMemberIdAndSymbol" resultType="com.xcong.excoin.modules.member.entity.MemberLevelRateEntity">
- select * from member_level_rate where member_id=#{memberId} and symbol=#{symbol}
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberPaymentMethodDao.xml b/src/main/resources/mapper/member/MemberPaymentMethodDao.xml
deleted file mode 100644
index 84a4214..0000000
--- a/src/main/resources/mapper/member/MemberPaymentMethodDao.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?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.dao.MemberPaymentMethodDao">
-
- <select id="selectByMemberId" resultType="com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity">
- SELECT a.* FROM member_payment_method a WHERE a.member_id = #{memberId}
- </select>
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml b/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml
deleted file mode 100644
index a649376..0000000
--- a/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?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.coin.dao.MemberSelectSymbolsDao">
-
- <select id="selectSymbolByMemIdAndSymbol" resultType="com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity">
- select id id,symbol symbol,member_id memberId from member_select_symbols where member_id = #{memberId} and symbol = #{symbol}
- </select>
-
- <select id="selectSymbolByMemId" resultType="com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity">
- select id id,symbol symbol,member_id memberId from member_select_symbols where member_id = #{memberId} GROUP BY symbol
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberSettingDao.xml b/src/main/resources/mapper/member/MemberSettingDao.xml
deleted file mode 100644
index 2a56bce..0000000
--- a/src/main/resources/mapper/member/MemberSettingDao.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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.dao.MemberSettingDao">
-
- <select id="selectMemberSettingByMemberId" resultType="com.xcong.excoin.modules.member.entity.MemberSettingEntity">
- select * from member_setting where member_id=#{memberId}
- </select>
-
- <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
- insert into member_setting (
- create_by,
- create_time,
- update_by,
- update_time,
- version,
- id,
- member_id,
- force_param,
- spread,
- closing_spread
- ) values
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.createBy},
- now(),
- #{item.updateBy},
- now(),
- #{item.version},
- #{item.id},
- #{item.memberId},
- #{item.forceParam},
- #{item.spread},
- #{item.closingSpread}
- )
- </foreach>
- </insert>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberWalletAgentDao.xml b/src/main/resources/mapper/member/MemberWalletAgentDao.xml
deleted file mode 100644
index a6415ff..0000000
--- a/src/main/resources/mapper/member/MemberWalletAgentDao.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?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.dao.MemberWalletAgentDao">
-
- <select id="selectWalletAgentBymIdAndCode" resultType="com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity">
- select * from member_wallet_agent where member_id = #{memberId} and wallet_code = #{walletCode}
- </select>
-
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberWalletCoinDao.xml b/src/main/resources/mapper/member/MemberWalletCoinDao.xml
deleted file mode 100644
index 79979c5..0000000
--- a/src/main/resources/mapper/member/MemberWalletCoinDao.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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.dao.MemberWalletCoinDao">
-
- <select id="selectMemberWalletCoinsByMemberId" resultType="com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity">
- select * from member_wallet_coin where member_id = #{memberId}
- </select>
-
- <select id="selectWalletCoinBymIdAndCode" resultType="com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity">
- select * from member_wallet_coin where member_id = #{memberId} and wallet_code = #{walletCode}
- </select>
-
- <update id="updateFrozenBalance" parameterType="map">
- UPDATE member_wallet_coin
- SET available_balance = available_balance - #{amount},
- frozen_balance = frozen_balance + #{amount}
- WHERE
- id = #{id}
- AND member_id = #{memberId}
- </update>
-
- <update id="subFrozenBalance" parameterType="map">
- UPDATE member_wallet_coin
- SET available_balance = available_balance + #{amount},
- frozen_balance = frozen_balance - #{amount}
- WHERE
- id = #{id}
- AND member_id = #{memberId}
- </update>
-
-
- <update id="updateBlockBalance">
- update member_wallet_coin
- set
- available_balance = IFNULL(available_balance, 0) + #{availableBalance},
- total_balance = IFNULL(total_balance, 0) + #{availableBalance},
- early_balance = IFNULL(early_balance, 0) + #{earlyBalance},
- block_number = IFNULL(block_number, 0) + #{blockNumber}
- where id=#{id}
- </update>
-
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberWalletContractDao.xml b/src/main/resources/mapper/member/MemberWalletContractDao.xml
deleted file mode 100644
index 878b221..0000000
--- a/src/main/resources/mapper/member/MemberWalletContractDao.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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.dao.MemberWalletContractDao">
- <select id="findWalletContractByMemberIdAndSymbol" resultType="com.xcong.excoin.modules.member.entity.MemberWalletContractEntity">
- select *
- from member_wallet_contract
- where member_id = #{memberId}
- <if test = "symbol != null and symbol !=''">
- and wallet_code = #{symbol}
- </if>
- </select>
-
- <update id="increaseWalletContractBalanceById" parameterType="map" >
- update member_wallet_contract
- <set>
- <if test="availableBalance!=null">
- available_balance = available_balance + #{availableBalance},
- </if>
- <if test="totalBalance!=null">
- total_balance =total_balance + #{totalBalance},
- </if>
- <if test="frozenBalance!=null">
- frozen_balance = frozen_balance + #{frozenBalance},
- </if>
- </set>
- where id =#{id}
- </update>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/member/MemberWalletContractSimulateDao.xml b/src/main/resources/mapper/member/MemberWalletContractSimulateDao.xml
deleted file mode 100644
index e54a1af..0000000
--- a/src/main/resources/mapper/member/MemberWalletContractSimulateDao.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?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.dao.MemberWalletContractSimulateDao">
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/platform/PlatformCnyUsdtExchangeDao.xml b/src/main/resources/mapper/platform/PlatformCnyUsdtExchangeDao.xml
deleted file mode 100644
index 30bcdb1..0000000
--- a/src/main/resources/mapper/platform/PlatformCnyUsdtExchangeDao.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?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.platform.dao.PlatformCnyUsdtExchangeDao">
-
- <select id="getCNYAndUSDTOne" resultType="com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity">
- select * from platform_cny_usdt_exchange limit 1
- </select>
-
- <update id="updateUsdt">
- update platform_cny_usdt_exchange set value = #{value}
- </update>
-
-</mapper>
diff --git a/src/main/resources/mapper/platform/PlatformFeeSettingDao.xml b/src/main/resources/mapper/platform/PlatformFeeSettingDao.xml
deleted file mode 100644
index 8e31d89..0000000
--- a/src/main/resources/mapper/platform/PlatformFeeSettingDao.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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.platform.dao.PlatformFeeSettingDao">
-
- <select id="getFeeSettingByTypeAndSymbolLable" resultType="com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity">
- select * from platform_fee_setting
- <where>
- <if test="type != null and type != ''">
- type = #{type}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- <if test="lable != null and lable != ''">
- and lable = #{lable}
- </if>
- </where>
- </select>
-
- <select id="getFeeSettingByTypeAndSymbol" resultType="com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity">
- select * from platform_fee_setting where type = #{type} and symbol = #{symbol}
- </select>
-
- <select id="getFeeSettingsByTypeAndSymbol" resultType="com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity">
- select * from platform_fee_setting
- <where>
- <if test="type != null and type != ''">
- type = #{type}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- </where>
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/platform/PlatformSymbolsCoinDao.xml b/src/main/resources/mapper/platform/PlatformSymbolsCoinDao.xml
deleted file mode 100644
index dc1328b..0000000
--- a/src/main/resources/mapper/platform/PlatformSymbolsCoinDao.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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.platform.dao.PlatformSymbolsCoinDao">
-
- <select id="selectCoinAddressCount" resultType="com.xcong.excoin.modules.member.parameter.vo.MemberCoinAddressCountVo">
- SELECT
- a.id,
- a. NAME,
- count(b.id) count
- FROM
- platform_symbols_coin a
- LEFT JOIN member_coin_address b ON a.id = b.symbolscoin_id
- AND member_id = #{memberId}
- GROUP BY
- a.id,
- a. NAME
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/platform/PlatformSymbolsContractDao.xml b/src/main/resources/mapper/platform/PlatformSymbolsContractDao.xml
deleted file mode 100644
index 7013470..0000000
--- a/src/main/resources/mapper/platform/PlatformSymbolsContractDao.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?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.symbols.dao.PlatformSymbolsContractDao">
-
- <select id="selectAllContractSymbols" resultType="com.xcong.excoin.modules.symbols.entity.PlatformSymbolsContractEntity">
- select * from platform_symbols_contract
- </select>
-
-</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/platform/PlatformSymbolsSkuDao.xml b/src/main/resources/mapper/platform/PlatformSymbolsSkuDao.xml
deleted file mode 100644
index a01084d..0000000
--- a/src/main/resources/mapper/platform/PlatformSymbolsSkuDao.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?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.platform.dao.PlatformSymbolsSkuDao">
-
- <select id="findSymbolSkuByName" parameterType="string" resultType="com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity">
- SELECT * FROM platform_symbols_sku where name = #{name}
- </select>
-</mapper>
diff --git a/src/main/resources/mapper/platform/TradeSettingDao.xml b/src/main/resources/mapper/platform/TradeSettingDao.xml
deleted file mode 100644
index 7537a80..0000000
--- a/src/main/resources/mapper/platform/TradeSettingDao.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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.platform.dao.TradeSettingDao">
-
- <select id="findTradeSetting" resultType="com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity">
- SELECT * FROM platform_trade_setting
- </select>
-
- <select id="findSymbolSkubySymbol" resultType="com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity">
- select * from platform_symbols_sku
- <where>
- <if test="symbol!=null and symbol!=''">
- name = #{symbol}
- </if>
- </where>
- </select>
-
- <select id="findAllSymbolSkubySymbol" resultType="com.xcong.excoin.modules.platform.entity.PlatformSymbolsSkuEntity">
- select * from platform_symbols_sku
- </select>
-
- <select id="findLeverageSetting" resultType="com.xcong.excoin.modules.platform.entity.PlatformLeverageSettingEntity">
- select * from platform_leverage_setting order by value ASC
- </select>
-
-</mapper>
diff --git a/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml b/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
deleted file mode 100644
index 03a89ae..0000000
--- a/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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.coin.dao.OrderCoinDealDao">
-
- <select id="selectAllWalletCoinOrder" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity">
- select * from coins_order_deal
- <where>
- <if test="memberId != null and memberId != ''">
- and member_id = #{memberId}
- </if>
- </where>
- order by create_time desc
- </select>
- <select id="selectAllWalletCoinOrderBySymbol" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity">
- select * from coins_order_deal
- <where>
- <if test="memberId != null and memberId != ''">
- and member_id = #{memberId}
- </if>
- <if test="symbol != null and symbol != ''">
- and symbol = #{symbol}
- </if>
- </where>
- order by create_time desc
- </select>
-
- <select id="selectWalletCoinOrder" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity">
- select * from coins_order_deal where order_id= #{orderId} and member_id = #{memberId}
- </select>
-
- <select id="findAllWalletCoinOrderInPage" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity">
- select * from coins_order_deal
- <if test="record != null">
- <where>
- <if test="record.memberId != null" >
- and member_id=#{record.memberId}
- </if>
- <if test="record.symbol != null and record.symbol != ''">
- and symbol = #{record.symbol}
- </if>
- </where>
- </if>
- order by create_time desc
- </select>
-
-</mapper>
diff --git a/src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml b/src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml
deleted file mode 100644
index b844a93..0000000
--- a/src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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.coin.dao.OrderCoinsDao">
-
- <select id="getOrderCountByToday" resultType="long">
- <![CDATA[ SELECT COUNT(*) from coins_order WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= DATE_FORMAT(#{now}, '%Y-%m-%d')
- and DATE_FORMAT(create_time, '%Y-%m-%d') < DATE_FORMAT(#{tomorrow}, '%Y-%m-%d') ]]>
- </select>
-
- <select id="findCoinOrderListByMemberIdAndSysmbol" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity">
- SELECT * FROM coins_order a where a.member_id= #{memberId} and a.order_status = #{status}
- <if test="symbol != null and symbol !=''">
- and a.symbol = #{symbol}
- </if>
- order by create_time desc
- </select>
-
- <select id="findWalletCoinOrderByOrderNo" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity">
-
- SELECT * FROM coins_order a where a.order_no= #{orderNo}
- </select>
-
-
- <select id="selectAllEntrustingCoinOrderList" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity">
- select *
- from coins_order
- where order_status=1
- </select>
-</mapper>
--
Gitblit v1.9.1