From 8b69c02da0657625068c039b6996d80ed6c15783 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 02 Jun 2020 19:59:26 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java | 44 ++++++++++-----------
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/TransactionPageOfWalletCoinVo.java | 10 ++++-
src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java | 14 ++++---
src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java | 4 +-
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/OrderWalletCoinDealVo.java | 6 +++
src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java | 2 +
src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml | 12 ++++++
7 files changed, 59 insertions(+), 33 deletions(-)
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
index 006490e..4202ea9 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/OrderCoinController.java
@@ -48,12 +48,11 @@
@ApiOperation(value = "进入交易页面", notes = "进入交易页面")
@ApiResponses({@ApiResponse( code = 200, message = "success", response = TransactionPageOfWalletCoinVo.class)})
@ApiImplicitParams({
- @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query"),
- @ApiImplicitParam(name = "type", value = "买入卖出类型1:买入,2:卖出", required = true, dataType = "String", paramType="query")
+ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
})
@GetMapping(value = "/enterTransactionPageOfWalletCoin")
- public Result enterTransactionPageOfWalletCoin(String symbol,String type) {
- return orderCoinService.enterTransactionPageOfWalletCoin(symbol,type);
+ public Result enterTransactionPageOfWalletCoin(String symbol) {
+ return orderCoinService.enterTransactionPageOfWalletCoin(symbol);
}
/**
@@ -103,9 +102,12 @@
*/
@ApiOperation(value = "获取币币交易历史订单信息", notes = "获取币币交易历史订单信息")
@ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealListVo.class)})
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "symbol", value = "币种", required = true, dataType = "String", paramType="query")
+ })
@GetMapping(value = "/findAllWalletCoinOrder")
- public Result findAllWalletCoinOrder() {
- return orderCoinService.findAllWalletCoinOrder();
+ public Result findAllWalletCoinOrder(String symbol) {
+ return orderCoinService.findAllWalletCoinOrder(symbol);
}
/**
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
index 1d3f4d8..9d4ec60 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/OrderCoinDealDao.java
@@ -11,6 +11,8 @@
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);
}
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
index 649f2a5..0b5d4a7 100644
--- 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
@@ -63,6 +63,12 @@
@ApiModelProperty(value = "成交金额")
private BigDecimal dealAmount;
/**
+ * 状态 2:撤单3:已成交
+ */
+ @ApiModelProperty(value = "状态 2:撤单3:已成交")
+ private Integer orderStatus;
+
+ /**
* 手续费
*/
@ApiModelProperty(value = "手续费")
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
index aeb2a2c..e37cac9 100644
--- 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
@@ -39,8 +39,14 @@
/**
* 用户可用金额
*/
- @ApiModelProperty(value = "用户可用金额")
- private BigDecimal availableBalance;
+ @ApiModelProperty(value = "买入用户可用金额")
+ private BigDecimal availableBalanceBuy;
+
+ /**
+ * 用户可用金额
+ */
+ @ApiModelProperty(value = "卖出用户可用金额")
+ private BigDecimal availableBalanceSell;
/**
* 当前价
*/
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
index f824d5b..9ca2106 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/OrderCoinService.java
@@ -10,7 +10,7 @@
public String generateSimpleSerialno(String userId);
- Result enterTransactionPageOfWalletCoin(String symbol, String type);
+ Result enterTransactionPageOfWalletCoin(String symbol);
Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
BigDecimal amount);
@@ -19,7 +19,7 @@
public Result cancelEntrustWalletCoinOrder(String orderId);
- public Result findAllWalletCoinOrder();
+ public Result findAllWalletCoinOrder(String symbol);
public Result findWalletCoinOrder(Long orderId);
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
index 5d4ebf0..a2e194c 100644
--- 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
@@ -98,7 +98,7 @@
}
@Override
- public Result enterTransactionPageOfWalletCoin(String symbol, String type) {
+ public Result enterTransactionPageOfWalletCoin(String symbol) {
if (StrUtil.isBlank(symbol)) {
return Result.fail(MessageSourceUtils.getString("order_service_0001"));
}
@@ -135,11 +135,8 @@
// 手续费用率
transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
// 用户可用金额
- if(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_BUY.getValue().equals(type)) {//买入
- transactionPageOfWalletCoinVo.setAvailableBalance(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
- }else {
- transactionPageOfWalletCoinVo.setAvailableBalance(walletCoin.getAvailableBalance().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));
//比例
@@ -148,7 +145,6 @@
transactionPageOfWalletCoinVo.setCurrentPriceCny(cnyUsdt.multiply(closePrice).setScale(4, BigDecimal.ROUND_DOWN));
transactionPageOfWalletCoinVo.setSymbol(symbol);
- transactionPageOfWalletCoinVo.setType(type);
return Result.ok(transactionPageOfWalletCoinVo);
}
@@ -258,6 +254,7 @@
detail.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
detail.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
detail.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN));
+ detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
orderCoinDealDao.insert(detail);
if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
@@ -331,6 +328,21 @@
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().setScale(4, BigDecimal.ROUND_DOWN));
+ detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
+ detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
+ detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
+ orderCoinDealDao.insert(detail);
+
if(OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
//如果是限价买入,撤单将USDT账户冻结金额返回
String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
@@ -376,33 +388,19 @@
return Result.ok(MessageSourceUtils.getString("order_service_0013"));
}
}
- 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().setScale(4, BigDecimal.ROUND_DOWN));
- detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
- detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
- detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
- orderCoinDealDao.insert(detail);
}
return Result.fail(MessageSourceUtils.getString("order_service_0043"));
}
@Override
- public Result findAllWalletCoinOrder() {
+ public Result findAllWalletCoinOrder(String symbol) {
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
OrderWalletCoinDealListVo orderWalletCoinDealListVo = new OrderWalletCoinDealListVo();
List<OrderWalletCoinDealVo> arrayList = new ArrayList<OrderWalletCoinDealVo>();
- List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrder(memberId);
+ List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrderBySymbol(memberId,symbol);
if(CollUtil.isNotEmpty(selectAllWalletCoinOrder)) {
for(OrderCoinsDealEntity orderCoinsDealEntity: selectAllWalletCoinOrder) {
OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(orderCoinsDealEntity);
diff --git a/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml b/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
index 998f72d..f498ab6 100644
--- a/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
+++ b/src/main/resources/mapper/walletCoinOrder/OrderCoinDealDao.xml
@@ -11,6 +11,18 @@
</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}
--
Gitblit v1.9.1