From 9da52c963fcbee66a3b299bb687c1efbbafe93a7 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 05 Jun 2020 11:59:04 +0800
Subject: [PATCH] finish all contract interface
---
src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java | 3 +
src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderListVo.java | 3 +
src/main/resources/mapper/contract/ContractOrderDao.xml | 4 +
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java | 17 ++++-
src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java | 81 +++++++++++++++++++++++++++
src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java | 8 ++
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java | 3 +
src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java | 2
8 files changed, 116 insertions(+), 5 deletions(-)
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
index 75b6fbe..0be9cc1 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/controller/ContractOrderController.java
@@ -95,9 +95,15 @@
}
@ApiOperation(value = "调整杠杆")
- @GetMapping(value = "/changeLeverRate")
+ @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/ContractOrderDao.java b/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
index 4a1bd7d..f3ac561 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
+import org.apache.ibatis.annotations.Param;
/**
* @author helius
@@ -11,4 +12,6 @@
public interface ContractOrderDao extends BaseMapper<ContractOrderEntity> {
public IPage<ContractOrderEntity> selectContractOrderInPage(Page<ContractOrderEntity> page, Long memberId);
+
+ public ContractOrderEntity selectOrderDetailByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);
}
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
index d77d2ab..b2e3ee2 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/mapper/ContractOrderEntityMapper.java
@@ -3,6 +3,7 @@
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;
@@ -22,4 +23,6 @@
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/vo/OrderDetailVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java
new file mode 100644
index 0000000..53db2fe
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/OrderDetailVo.java
@@ -0,0 +1,81 @@
+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 stopLosePrice;
+
+ @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;
+
+}
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
index 573d040..6ae45fe 100644
--- 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
@@ -16,6 +16,9 @@
@ApiModel(value = "OrderListVo", description = "历史委托订单接口返回参数类")
public class OrderListVo {
+ @ApiModelProperty("订单ID")
+ private Long id;
+
@ApiModelProperty("订单类型 -1撤单,1开多,2开空,3平多,4平空")
private int orderType;
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
index 5498034..9294a72 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java
@@ -40,4 +40,6 @@
public Result findOrderList(OrderListDto orderListDto);
+ public Result findOrderDetailById(Long id);
+
}
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
index 796710d..613d6f0 100644
--- 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
@@ -20,10 +20,7 @@
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.ContractMoneyInfoVo;
-import com.xcong.excoin.modules.contract.parameter.vo.HoldOrderDetailVo;
-import com.xcong.excoin.modules.contract.parameter.vo.HoldOrderListVo;
-import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
+import com.xcong.excoin.modules.contract.parameter.vo.*;
import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
import com.xcong.excoin.modules.member.dao.MemberLevelRateDao;
import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
@@ -550,4 +547,16 @@
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);
+ return Result.ok(orderDetailVo);
+ }
}
diff --git a/src/main/resources/mapper/contract/ContractOrderDao.xml b/src/main/resources/mapper/contract/ContractOrderDao.xml
index d98a8d3..4ad5cbc 100644
--- a/src/main/resources/mapper/contract/ContractOrderDao.xml
+++ b/src/main/resources/mapper/contract/ContractOrderDao.xml
@@ -8,4 +8,8 @@
order by create_time 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
--
Gitblit v1.9.1