From 6ac527e204fbcf9bc62f280eb925cddab291fe5b Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 25 May 2020 11:01:07 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin

---
 src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java         |   81 ++++
 src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDao.java                            |    8 
 src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java                              |   10 
 src/main/java/com/xcong/excoin/modules/coin/dao/MemberSelectSymbolsDao.java                  |   14 
 pom.xml                                                                                      |   14 
 src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java                 |   19 +
 src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java |   32 +
 src/main/resources/mapper/platform/TradeSettingDao.xml                                       |   35 ++
 src/main/java/com/xcong/excoin/modules/coin/entity/PlatformLeverageSettingEntity.java        |   41 ++
 src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java                     |   75 ++++
 src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java                    |   16 
 src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java                   |   21 +
 src/main/java/com/xcong/excoin/modules/coin/dao/platform/TradeSettingDao.java                |   22 +
 src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java             |   12 
 src/main/java/com/xcong/excoin/utils/SpringContextHolder.java                                |    2 
 src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java           |  287 ++++++++++++++++
 src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java                |   45 +
 src/main/java/com/xcong/excoin/modules/coin/entity/PlatformSymbolsSku.java                   |   32 +
 src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java                        |    8 
 src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java                |   27 +
 src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java          |   29 +
 /dev/null                                                                                    |   39 --
 src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java                   |    9 
 src/main/resources/mapper/member/MemberSelectSymbolsDao.xml                                  |    9 
 src/main/java/com/xcong/excoin/modules/coin/entity/PlatformTradeSettingEntity.java           |   59 +++
 src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java              |   61 +++
 26 files changed, 921 insertions(+), 86 deletions(-)

diff --git a/lib/huobi-client-1.0.8-SNAPSHOT.jar b/lib/huobi-client-1.0.8-SNAPSHOT.jar
deleted file mode 100644
index 6422e71..0000000
--- a/lib/huobi-client-1.0.8-SNAPSHOT.jar
+++ /dev/null
Binary files differ
diff --git a/pom.xml b/pom.xml
index 0a9f0d4..20f2f96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -175,20 +175,6 @@
             <artifactId>netty-all</artifactId>
             <version>4.1.33.Final</version>
         </dependency>
-
-        <dependency>
-            <groupId>com.squareup.okhttp3</groupId>
-            <artifactId>okhttp</artifactId>
-            <version>3.6.0</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.huobi.sdk</groupId>
-            <artifactId>huobi-client</artifactId>
-            <version>1.0.8-SNAPSHOT</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/huobi-client-1.0.8-SNAPSHOT.jar</systemPath>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java b/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
index 20d6648..3a286be 100644
--- a/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
+++ b/src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
@@ -18,8 +18,27 @@
 	
 	CONTENTFROMAGENT("0005","由代理账户转入"),
 	
-	WALLETCOINCODE("USDT", "USDT")
+	WALLETCOINCODE("USDT", "USDT"),
+	
+	SUBMITSALESWALLETCOINORDER_SERVICERATE("ServiceRate","0.002"),
+	SUBMITSALESWALLETCOINORDER_TYPE("type","1"),
+	
+	
+	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;
diff --git a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java b/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
index 289c874..cc8e77b 100644
--- a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
+++ b/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
@@ -37,9 +37,9 @@
                 .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                 .allowCredentials(true).maxAge(3600);
     }
-//
-//    @Bean
-//    public SpringContextHolder springContextHolder() {
-//        return new SpringContextHolder();
-//    }
+
+    @Bean
+    public SpringContextHolder springContextHolder() {
+        return new SpringContextHolder();
+    }
 }
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
index 40a6556..e069762 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -18,12 +18,15 @@
 import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceDto;
 import com.xcong.excoin.modules.coin.service.CoinService;
 
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
 @Api(value = "会员资产接口", tags = "会员资产接口")
 @RestController
-@RequestMapping(value = "/api/coin")
+@RequestMapping(value = "/api/walletCoin")
 public class CoinController {
 	
 	@Resource
@@ -77,7 +80,7 @@
 	 */
 	@ApiOperation(value="查询币币账户里面的可用资产余额", notes="查询币币账户里面的可用资产余额")
 	@GetMapping(value="/findWalletCoinBySymbol")
-	public Result findWalletCoinBysymbol(String symbol) {
+	public Result findWalletCoinBysymbol(@ApiParam(name="symbol",value="币种",required=true)String symbol) {
 		return coinService.findWalletCoinBySymbol(symbol);
 	}
 	
@@ -107,7 +110,7 @@
 	 */
 	@ApiOperation(value="获取合约资产交易记录", notes="获取合约资产交易记录")
 	@GetMapping(value="/getWalletContractRecords")
-	public Result getWalletContractRecords(String symbol) {
+	public Result getWalletContractRecords(@ApiParam(name="symbol",value="币种",required=true)String symbol) {
 		return coinService.getWalletContractRecords(symbol);
 	}
 	
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
new file mode 100644
index 0000000..b5b0b20
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
@@ -0,0 +1,61 @@
+package com.xcong.excoin.modules.coin.controller;
+
+import java.math.BigDecimal;
+
+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.coin.parameter.dto.SubmitSalesWalletCoinOrderDto;
+import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceDto;
+import com.xcong.excoin.modules.coin.service.OrderCoinService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Api(value = "币币交易接口", tags = "币币交易接口")
+@RestController
+@RequestMapping(value = "/api/orderCoin")
+public class OrderCoinController {
+	
+	@Resource
+	OrderCoinService orderCoinService;
+	
+	/**
+	 * 进入交易页面
+	 * @return
+	 */
+	@ApiOperation(value = "进入交易页面", notes = "进入交易页面")
+    @GetMapping(value = "/enterTransactionPageOfWalletCoin")
+	public Result enterTransactionPageOfWalletCoin(		@ApiParam(name="symbol",value="币种",required=true)String symbol,
+														@ApiParam(name="type",value="买入卖出类型",required=true)String type) {
+		return orderCoinService.enterTransactionPageOfWalletCoin(symbol,type);
+	}
+	
+	/**
+	 *	提交买卖订单
+	 * @param buySymbolTradeVo
+	 * @param token
+	 * @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);
+	}
+
+}
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
new file mode 100644
index 0000000..0de89ee
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberSelectSymbolsDao.java
@@ -0,0 +1,14 @@
+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);
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDao.java
new file mode 100644
index 0000000..dfc8a98
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDao.java
@@ -0,0 +1,8 @@
+package com.xcong.excoin.modules.coin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.coin.entity.OrderCoinEntity;
+
+public interface OrderCoinDao extends BaseMapper<OrderCoinEntity>{
+
+}
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
new file mode 100644
index 0000000..d3c80b4
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
@@ -0,0 +1,8 @@
+package com.xcong.excoin.modules.coin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.coin.entity.OrderCoinDealEntity;
+
+public interface OrderCoinDealDao  extends BaseMapper<OrderCoinDealEntity>{
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/platform/TradeSettingDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/platform/TradeSettingDao.java
new file mode 100644
index 0000000..f68b080
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/platform/TradeSettingDao.java
@@ -0,0 +1,22 @@
+package com.xcong.excoin.modules.coin.dao.platform;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.coin.entity.PlatformLeverageSettingEntity;
+import com.xcong.excoin.modules.coin.entity.PlatformSymbolsSku;
+import com.xcong.excoin.modules.coin.entity.PlatformTradeSettingEntity;
+
+public interface TradeSettingDao extends BaseMapper<PlatformTradeSettingEntity> {
+
+	PlatformTradeSettingEntity findTradeSetting();
+
+	PlatformSymbolsSku findSymbolSkubySymbol(@Param("symbol") String symbol);
+	
+	List<PlatformSymbolsSku> findAllSymbolSkubySymbol();
+
+	List<PlatformLeverageSettingEntity> findLeverageSetting();
+
+}
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
new file mode 100644
index 0000000..02b24ad
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsDealEntity.java
@@ -0,0 +1,19 @@
+package com.xcong.excoin.modules.coin.entity;
+
+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;
+
+}
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
new file mode 100644
index 0000000..a99e77e
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/OrderCoinsEntity.java
@@ -0,0 +1,75 @@
+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("coins_order")
+public class OrderCoinsEntity extends BaseEntity{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	/**
+	 * 会员ID
+	 */
+	private Long memberId;
+	/**
+	 * 订单编号
+	 */
+	private String orderNo;
+	/**
+	 * 订单类型 1、买入2、卖出
+	 */
+	private int orderType;
+	/**
+	 * 币种
+	 */
+	private String symbol;
+	/**
+	 * 市场价
+	 */
+	private BigDecimal markPrice;
+	/**
+	 * 委托量
+	 */
+	private BigDecimal entrustCnt;
+	/**
+	 * 委托价
+	 */
+	private BigDecimal entrustPrice;
+	/**
+	 * 成交量
+	 */
+	private BigDecimal dealCnt;
+	/**
+	 * 成交价
+	 */
+	private Double dealPrice;
+	/**
+	 * 成交金额
+	 */
+	private BigDecimal dealAmount;
+	/**
+	 * 状态 1:委托中2:撤单3:已成交
+	 */
+	private Integer orderStatus;
+	/**
+	 * 交易类型 1:市价2:限价
+	 */
+	private Integer tradeType;
+	/**
+	 * 手续费
+	 */
+	private String feeAmount;
+	
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformLeverageSettingEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformLeverageSettingEntity.java
new file mode 100644
index 0000000..ac907da
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformLeverageSettingEntity.java
@@ -0,0 +1,41 @@
+package com.xcong.excoin.modules.coin.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/coin/entity/PlatformSymbolsSku.java b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformSymbolsSku.java
new file mode 100644
index 0000000..268f301
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformSymbolsSku.java
@@ -0,0 +1,32 @@
+package com.xcong.excoin.modules.coin.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_sku")
+public class PlatformSymbolsSku implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	@TableId(value = "id",type = IdType.AUTO)
+    private Long id;
+	/**
+	 * 币种名称
+	 */
+	private String name;
+	/**
+	 * 规格
+	 */
+	private String sku;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformTradeSettingEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformTradeSettingEntity.java
new file mode 100644
index 0000000..1eae490
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/PlatformTradeSettingEntity.java
@@ -0,0 +1,59 @@
+package com.xcong.excoin.modules.coin.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 agentReturnRatio;
+    /**
+     * 持仓系数
+     */
+    private BigDecimal doingRatio;
+    /**
+     * 预估强平价系数
+     */
+    private BigDecimal forceParam;
+
+    /**
+     *盈亏难度系数
+     */
+    private BigDecimal profitParam;
+}
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
new file mode 100644
index 0000000..b69daf2
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
@@ -0,0 +1,27 @@
+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 = "进入交易页面参数接收类", 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/SubmitSalesWalletCoinOrderDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
new file mode 100644
index 0000000..bdff678
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
@@ -0,0 +1,32 @@
+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 = "提交买卖订单接收类", description = "提交买卖订单接收类")
+public class SubmitSalesWalletCoinOrderDto {
+	
+    @ApiModelProperty(value = "币种", example = "BTC")
+	private String symbol;
+
+	@NotNull(message = "币种不能为空")
+    @ApiModelProperty(value = "币种", example = "USDT")
+    private Integer type;
+	
+	@NotNull(message = "账户类型不能为空")
+    @ApiModelProperty(value = "账户类型", example = "1")
+	private Integer tradeType;
+	
+	@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/vo/MemberWalletCoinInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
new file mode 100644
index 0000000..3c1884b
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
@@ -0,0 +1,81 @@
+package com.xcong.excoin.modules.coin.parameter.vo;
+
+import java.math.BigDecimal;
+
+import io.swagger.annotations.ApiModelProperty;
+
+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;
+    
+	public String getWalletCode() {
+		return walletCode;
+	}
+
+	public void setWalletCode(String walletCode) {
+		this.walletCode = walletCode;
+	}
+
+	public Long getMemberId() {
+		return memberId;
+	}
+
+	public void setMemberId(Long memberId) {
+		this.memberId = memberId;
+	}
+
+	public BigDecimal getAvailableBalance() {
+		return availableBalance;
+	}
+
+	public void setAvailableBalance(BigDecimal availableBalance) {
+		this.availableBalance = availableBalance;
+	}
+
+	public BigDecimal getTotalBalance() {
+		return totalBalance;
+	}
+
+	public void setTotalBalance(BigDecimal totalBalance) {
+		this.totalBalance = totalBalance;
+	}
+
+	public BigDecimal getFrozenBalance() {
+		return frozenBalance;
+	}
+
+	public void setFrozenBalance(BigDecimal frozenBalance) {
+		this.frozenBalance = 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
index 1fa46a3..54f5d65 100644
--- 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
@@ -3,8 +3,6 @@
 import java.math.BigDecimal;
 import java.util.List;
 
-import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -23,7 +21,7 @@
 	private BigDecimal totalCny;
 	
 	@ApiModelProperty(value = "币种详情")
-	private List<MemberWalletCoinEntity> walletCoinEntities;
+	private List<MemberWalletCoinInfoVo> memberWalletCoinInfoVo;
 	
 	public BigDecimal getTotalUsdt() {
 		return totalUsdt;
@@ -37,11 +35,11 @@
 	public void setTotalCny(BigDecimal totalCny) {
 		this.totalCny = totalCny;
 	}
-	public List<MemberWalletCoinEntity> getWalletCoinEntities() {
-		return walletCoinEntities;
+	public List<MemberWalletCoinInfoVo> getMemberWalletCoinInfoVo() {
+		return memberWalletCoinInfoVo;
 	}
-	public void setWalletCoinEntities(List<MemberWalletCoinEntity> walletCoinEntities) {
-		this.walletCoinEntities = walletCoinEntities;
+	public void setMemberWalletCoinInfoVo(List<MemberWalletCoinInfoVo> memberWalletCoinInfoVo) {
+		this.memberWalletCoinInfoVo = memberWalletCoinInfoVo;
 	}
 
 }
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
new file mode 100644
index 0000000..cedd8bb
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
@@ -0,0 +1,16 @@
+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.OrderCoinEntity;
+
+public interface OrderCoinService extends IService<OrderCoinEntity>{
+
+	Result enterTransactionPageOfWalletCoin(String symbol, String type);
+
+	Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
+			BigDecimal amount);
+
+}
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
index 1a392da..b24e3ef 100644
--- 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
@@ -18,6 +18,7 @@
 import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
 import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange;
 import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
 import com.xcong.excoin.modules.coin.service.CoinService;
 import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
@@ -60,10 +61,23 @@
 			
 			if(!StrUtil.isEmpty(memberId.toString())) {
 				
-				List<MemberWalletCoinEntity> MemberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
+				List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
 				
-				if(CollUtil.isNotEmpty(MemberWalletCoinlist)) {
-					for(MemberWalletCoinEntity walletCoin : MemberWalletCoinlist) {
+				List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
+				MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
+				if(ObjectUtil.isNotEmpty(memberWalletCoinlist)) {
+					for(MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
+						memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance());
+						memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance());
+						memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
+						memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance());
+						memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
+					}
+				}
+				
+				
+				if(CollUtil.isNotEmpty(memberWalletCoinlist)) {
+					for(MemberWalletCoinEntity walletCoin : memberWalletCoinlist) {
 						if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {	
 							totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
 							BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
@@ -80,34 +94,35 @@
 				MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
 				memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN));
 				memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-				memberWalletCoinVo.setWalletCoinEntities(MemberWalletCoinlist);
+				memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist);
 				return Result.ok(memberWalletCoinVo);
 			}else {
-				List<MemberWalletCoinEntity> MemberWalletCoinlist = new ArrayList<MemberWalletCoinEntity>();
-				MemberWalletCoinEntity coin = new MemberWalletCoinEntity();
+				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);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.ETH.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.LTC.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.BCH.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.USDT.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.EOS.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.XRP.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
 				coin.setWalletCode(CoinTypeEnum.ETC.toString());
-				MemberWalletCoinlist.add(coin);
+				memberWalletCoinlist.add(coin);
+				
 				MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
 				memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN));
 				memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-				memberWalletCoinVo.setWalletCoinEntities(MemberWalletCoinlist);
+				memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinlist);;
 				return Result.ok(memberWalletCoinVo);
 			}
 		} catch (Exception e) {
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
new file mode 100644
index 0000000..b4543ee
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -0,0 +1,287 @@
+package com.xcong.excoin.modules.coin.service.impl;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kebex.app.entity.member.Member;
+import com.kebex.app.entity.member.MemberAccountFlowRecord;
+import com.kebex.app.entity.member.WalletCoin;
+import com.kebex.app.entity.order.CoinOrderMain;
+import com.kebex.app.entity.order.CoinsOrderDetail;
+import com.kebex.app.entity.trade.TradeSetting;
+import com.kebex.common.huobiapi.CoinTypeConConvert;
+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.MemberSelectSymbolsDao;
+import com.xcong.excoin.modules.coin.dao.OrderCoinDao;
+import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
+import com.xcong.excoin.modules.coin.dao.platform.TradeSettingDao;
+import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange;
+import com.xcong.excoin.modules.coin.entity.OrderCoinEntity;
+import com.xcong.excoin.modules.coin.entity.PlatformTradeSettingEntity;
+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.utils.MessageSourceUtils;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+
+@Service
+public class OrderCoinServiceImpl extends ServiceImpl<OrderCoinDao, OrderCoinEntity> implements OrderCoinService{
+	
+	@Resource
+	TradeSettingDao platformTradeSettingDao;
+	@Resource
+	MemberWalletCoinDao memberWalletCoinDao;
+	@Resource
+	MemberSelectSymbolsDao memberSelectSymbolsDao;
+	@Resource
+	CnyUsdtExchangeDao cnyUsdtExchangeDao;
+
+	@Override
+	public Result enterTransactionPageOfWalletCoin(String symbol, String type) {
+		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 (tradeSetting == null) {
+			return Result.fail(MessageSourceUtils.getString("order_service_0003"));
+		}
+		//获取USDT的币币账户信息
+		MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, 
+															MemberWalletCoinEnum.WALLETCOINCODE.getValue());
+		/**
+		 * todo
+		 */
+		//获取某个币种的收盘价
+		//Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(symbol+"/USDT");
+		BigDecimal closePrice = new BigDecimal("100.0000");
+		
+		List<MemberSelectSymbolsEntity> memSymbols = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol);
+		
+		CnyUsdtExchange cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+		BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+		
+		Map<String, Object> map = new HashMap<String, Object>();
+		if(CollUtil.isEmpty(memSymbols)) {
+			map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO.getName(),
+					MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_NO.getValue());//是否已经自选该币种
+		}else {
+			map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_YES.getName(),
+					MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_ISCOLLECT_YES.getValue());//是否已经自选该币种
+		}
+		if (ObjectUtil.isEmpty(walletCoin))
+			return Result.fail(MessageSourceUtils.getString("order_service_0003"));
+		
+		map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_SPREAD.getValue(), tradeSetting.getSpread());// 点差
+		map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CLOSINGRATIO.getValue(), tradeSetting.getFeeRatio());// 手续费用率
+		if(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_BUY.getValue().equals(type)) {//买入
+			map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_MEMBERMONEY.getValue(), walletCoinUsdt.getAvailableBalance());// 用户可用金额
+		}else {
+			map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_MEMBERMONEY.getValue(), walletCoin.getAvailableBalance());// 用户可用金额
+		}
+		
+		map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICE.getValue(), closePrice);//当前价
+		map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CNYUSDT.getValue(), cnyUsdt);//比例
+		map.put(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_CURRENTPRICECNY.getValue(), cnyUsdt.multiply(closePrice));//换算成人民币的币种价格
+		return Result.ok(map);
+}
+
+	@Override
+	@Transactional
+	public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
+			BigDecimal amount) {
+		try {
+			//获取用户ID
+			Long memberId = LoginUserUtils.getAppLoginUser().getId();
+			
+			String[] symbols = symbol.split("/");
+			if (symbols.length <= 0) {
+				return Result.fail(MessageSourceUtils.getString("order_service_0008"));
+			}
+			/**
+			 * todo
+			 */
+			//查询当前价
+			//BigDecimal nowPrice = new BigDecimal(redisUtil.getString(CoinTypeConConvert.convertToKey(symbol+"/USDT")));
+			BigDecimal nowPrice = new BigDecimal("100.0000");
+			
+			// 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
+			symbol = symbol.toUpperCase();
+			MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbols[0]);
+			MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, 
+																		MemberWalletCoinEnum.WALLETCOINCODE.getValue());
+			if (ObjectUtil.isEmpty(walletCoin) || ObjectUtil.isEmpty(walletCoinUsdt) ) {
+				return Result.fail(MessageSourceUtils.getString("order_service_0003"));
+			}
+			// 查询交易设置
+			PlatformTradeSettingEntity tradeSetting = platformTradeSettingDao.findTradeSetting();
+			if(ObjectUtil.isEmpty(tradeSetting)) {
+				return Result.fail(MessageSourceUtils.getString("order_service_0009"));
+			}
+			//手续费率
+			BigDecimal ServiceRate = new BigDecimal(MemberWalletCoinEnum.SUBMITSALESWALLETCOINORDER_SERVICERATE.getValue());
+			// 手续费用(手续费=建仓价X数量X手续费率)
+			BigDecimal closingPrice = price.multiply(amount).multiply(ServiceRate).setScale(4, BigDecimal.ROUND_DOWN);
+			//总费用 = 成交价*数量+手续费
+			BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice).setScale(4, BigDecimal.ROUND_DOWN);
+			if(MemberWalletCoinEnum.SUBMITSALESWALLETCOINORDER_TYPE.getValue().equals(type.toString())) {
+				//买入,所需总费用跟用户USDT金额进行比较
+				if (totalPayPrice.compareTo(walletCoinUsdt.getAvailableBalance()) > 0) {
+					return Result.fail(MessageSourceUtils.getString("order_service_0010"));
+				}
+			}else {
+				//卖出,所需总费用跟用户所对应的币种金额进行比较
+				if (amount.compareTo(walletCoin.getAvailableBalance()) > 0) {
+					return Result.fail(MessageSourceUtils.getString("order_service_0010"));
+				}
+			}
+			
+			CoinOrderMain order = new CoinOrderMain();
+			
+			// 创建订单
+			if (tradeType == 2) {// 如果是限价交易直接插入主表数据
+				order.setStatus(1);
+				order.setMemId(member.getmId());
+				order.setOpenPrice(price.doubleValue());
+				order.setOpenTime(new Date());
+				order.setOrderNo(generateSimpleSerialno(member.getmId() + ""));
+				order.setOrderType(type);
+				order.setRewardRatio(price
+						.multiply(amount).doubleValue());
+				order.setForceSetPrice(nowPrice.doubleValue());
+//				order.setStatus(3);
+				order.setSysbol(symbol);
+				order.setSysbolNumber(amount);
+				order.setSysbolFlatNumber(amount);
+				order.setTradeType(tradeType);
+				order.setVersion(1);
+				order.setClosingPrice(closingPrice);
+				orderMapper.addCoinMainOrder(order);
+				
+				//更新用户钱包信息
+				//冻结相应的资产
+				if(type == 1) {//如果是买入,所对应的币种增加,USDT账户减少金额
+					// 更新用户的可用金额,冻结金额
+					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance()-totalPayPrice.doubleValue());
+					walletCoinUsdt.setFrozenBalance(walletCoinUsdt.getFrozenBalance()+totalPayPrice.doubleValue());
+					walletCoinDao.updateByModel(walletCoinUsdt);
+				}else {
+					//如果是卖出,币种减少,USDT增加
+					BigDecimal availableBalance = new BigDecimal(walletCoin.getAvailableBalance()).subtract(amount).setScale(8, BigDecimal.ROUND_HALF_UP);
+					walletCoin.setAvailableBalance(availableBalance.doubleValue());
+					walletCoin.setFrozenBalance(walletCoin.getFrozenBalance()+amount.doubleValue());
+					walletCoinDao.updateByModel(walletCoin);
+				} 
+			} else {
+				//如果是市价交易,主表和附表都需要插入数据
+				order.setStatus(3);
+				order.setMemId(member.getmId());
+				order.setForceSetPrice(nowPrice.doubleValue());
+				order.setOpenPrice(nowPrice.doubleValue());
+				order.setOpenTime(new Date());
+				order.setOrderNo(generateSimpleSerialno(member.getmId() + ""));
+				order.setOrderType(type);
+				order.setRewardRatio(nowPrice
+						.multiply(amount).doubleValue());
+//				order.setStatus(3);
+				order.setSysbol(symbol);
+				order.setSysbolNumber(amount);
+				order.setSysbolFlatNumber(amount);
+				order.setTradeType(tradeType);
+				order.setVersion(1);
+				order.setClosingPrice(closingPrice);
+				orderMapper.addCoinMainOrder(order);
+				//
+				CoinsOrderDetail detail = new CoinsOrderDetail();
+				detail.setClosingPrice(closingPrice.doubleValue());
+				detail.setCreateTime(new Date());
+				detail.setEntrustStatus(1);
+				detail.setEntrustType(type);
+				detail.setExitPrice(price.doubleValue());
+				detail.setExitType(1);
+				detail.setMainId(order.getId());
+				detail.setMemberId(member.getmId());
+				detail.setMemberPhone(member.getPhone());
+				detail.setPrePrice(price
+						.multiply(amount).doubleValue());
+				detail.setRewardRatio(0.0);
+				detail.setSerialno(generateSimpleSerialno(member.getmId() + ""));
+				detail.setSymbol(symbol);
+				detail.setSymbolSku(amount);
+				detail.setSymbolSkuNumber(amount);
+				detail.setTradePrice(price.doubleValue());
+				detail.setTradeType(tradeType);
+				detail.setVersion(1);
+				coinOrderDetailMapper.insert(detail);
+				
+				if(type == 1) {//如果是买入,所对应的币种增加,USDT账户减少金额
+					// 更新用户的可用金额
+					BigDecimal availableBalance = new BigDecimal(walletCoin.getAvailableBalance()).add(amount).setScale(8, BigDecimal.ROUND_HALF_UP);
+					walletCoin.setAvailableBalance(availableBalance.doubleValue());
+					walletCoinDao.updateByModel(walletCoin);
+					
+					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance()-totalPayPrice.doubleValue());
+					walletCoinDao.updateByModel(walletCoinUsdt);
+				}else {
+					//如果是卖出,币种减少,USDT增加
+					BigDecimal availableBalance = new BigDecimal(walletCoin.getAvailableBalance()).subtract(amount).setScale(8, BigDecimal.ROUND_HALF_UP);
+					walletCoin.setAvailableBalance(availableBalance.doubleValue());
+					walletCoinDao.updateByModel(walletCoin);
+					
+					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance()+totalPayPrice.doubleValue());
+					walletCoinDao.updateByModel(walletCoinUsdt);
+				}
+				
+				//返佣
+//				calYj(member.getmId(), closingPrice, order);
+//				String reference = member.getReference();
+				//返佣
+//				agentReturn(reference,closingPrice.doubleValue(),detail);
+				
+			}
+			// 流水记录
+			MemberAccountFlowRecord record = new MemberAccountFlowRecord();
+			record.setCreateTime(new Date());
+			if (type == 1) {
+				record.setDirectionSource("币币买入"+symbol);
+				record.setRemark("买入"+symbol+":"+amount);
+				record.setPrice(totalPayPrice.doubleValue());
+			} else {
+				record.setDirectionSource("币币卖出"+symbol);
+				record.setRemark("卖出"+symbol+":"+amount);
+				record.setPrice(-totalPayPrice.doubleValue());
+			}
+			record.setMemberBalance(walletCoinUsdt.getAvailableBalance());
+			record.setMemberid(member.getmId());
+			record.setSymbolName(symbol);
+			record.setMemberName(member.getRealName());
+			record.setMemberPhone(member.getPhone());
+			
+			memberMapper.addFlowRecord(record);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return Result.success(MessageSourceUtils.getString("order_service_0011"));
+	}
+
+}
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
new file mode 100644
index 0000000..82c98db
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberSelectSymbolsEntity.java
@@ -0,0 +1,29 @@
+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
+public class MemberSelectSymbolsEntity extends BaseEntity{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 会员ID
+	 */
+	private BigDecimal memberId;
+	/**
+	 * 币种
+	 */
+	private BigDecimal symbol;
+
+}
diff --git a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java b/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
index 02b56c9..7dbf951 100644
--- a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
+++ b/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
@@ -5,7 +5,6 @@
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
 
 /**
  * @Author wzy
@@ -14,7 +13,6 @@
  * @Version V1.0
  **/
 @Slf4j
-@Component
 public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
 
     private static ApplicationContext applicationContext = null;
diff --git a/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml b/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml
new file mode 100644
index 0000000..c5780d1
--- /dev/null
+++ b/src/main/resources/mapper/member/MemberSelectSymbolsDao.xml
@@ -0,0 +1,9 @@
+<?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 memId from member_select_symbols where member_id = #{memberId} and symbol = #{symbol}
+	</select>
+	
+</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/platform/TradeSettingDao.xml b/src/main/resources/mapper/platform/TradeSettingDao.xml
new file mode 100644
index 0000000..4d4461d
--- /dev/null
+++ b/src/main/resources/mapper/platform/TradeSettingDao.xml
@@ -0,0 +1,35 @@
+<?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.platform.TradeSettingDao">	
+	
+	<select id="findTradeSetting" resultType="com.xcong.excoin.modules.coin.entity.PlatformTradeSettingEntity">
+		SELECT
+			id id,
+			spread spread,
+			leverageratio leverageRatio,
+			outstock outStock,
+			closingratio closingRatio,
+			agent_return agent_return,
+			doing_rate doingRate
+		FROM
+			platform_trade_setting
+	</select>
+	
+	<select id="findSymbolSkubySymbol" resultType="com.xcong.excoin.modules.coin.entity.PlatformSymbolsSku">
+		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.coin.entity.PlatformSymbolsSku">
+		select * from platform_symbols_sku
+	</select>
+	
+	<select id="findLeverageSetting" resultType="com.xcong.excoin.modules.coin.entity.PlatformLeverageSettingEntity">
+		select * from platform_leverage_setting order by value ASC
+	</select>
+	
+</mapper>
diff --git a/src/test/java/com/xcong/excoin/HuobiTest.java b/src/test/java/com/xcong/excoin/HuobiTest.java
deleted file mode 100644
index 763f2f7..0000000
--- a/src/test/java/com/xcong/excoin/HuobiTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.xcong.excoin;
-
-import com.alibaba.fastjson.JSONObject;
-import com.huobi.client.SubscriptionClient;
-import com.huobi.client.SubscriptionOptions;
-import com.huobi.client.model.Candlestick;
-import com.huobi.client.model.enums.CandlestickInterval;
-import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-/**
- * @author wzy
- * @date 2020-05-22
- **/
-@Slf4j
-@SpringBootTest
-public class HuobiTest {
-
-    @Test
-    public void websocketTest() {
-    }
-
-    public static void main(String[] args) {
-        System.out.println("========价格更新开启=======");
-        SubscriptionOptions subscriptionOptions = new SubscriptionOptions();
-        //3秒重试
-        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 -> {
-            log.info("#------>>>>>{}#", JSONObject.toJSONString(tradeEvent));
-        });
-
-        subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> {
-            log.info("#-------<<<<<{}#", JSONObject.toJSONString(candlestickEvent));
-        });
-    }
-}

--
Gitblit v1.9.1