From a8ecdb8fccf3805f3ba841bd493a0e6dccb0274d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 15 Jun 2021 10:43:52 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/coin/entity/GbzOrderEntity.java | 23 +++++++
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzListDto.java | 21 +++++++
src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java | 73 ++++++++++++++++++++++++
src/main/resources/mapper/walletCoinOrder/GbzOrderDao.xml | 9 +++
src/main/java/com/xcong/excoin/websocket/TradePlateSendWebSocket.java | 1
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzAddDto.java | 18 ++++++
src/main/java/com/xcong/excoin/modules/coin/dao/GbzOrderDao.java | 11 +++
7 files changed, 156 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java
new file mode 100644
index 0000000..e39fdd3
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java
@@ -0,0 +1,73 @@
+package com.xcong.excoin.modules.coin.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+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.coin.dao.GbzOrderDao;
+import com.xcong.excoin.modules.coin.entity.GbzOrderEntity;
+import com.xcong.excoin.modules.coin.parameter.dto.GbzAddDto;
+import com.xcong.excoin.modules.coin.parameter.dto.GbzListDto;
+import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping(value = "/api/gbz")
+@Api(value = "GbzOrderController", tags = "gbz订单接口类")
+public class GbzOrderController {
+
+ @Autowired
+ private GbzOrderDao gbzOrderDao;
+
+ @Autowired
+ private MemberWalletCoinDao memberWalletCoinDao;
+
+ @ApiOperation(value = "新增订单", notes = "新增订单")
+ @PostMapping(value = "/add")
+ public Result add(@RequestBody GbzAddDto gbzAddDto) {
+ MemberEntity loginUser = LoginUserUtils.getAppLoginUser();
+ BigDecimal price = new BigDecimal(66);
+ BigDecimal amount = BigDecimal.valueOf(gbzAddDto.getCount()).multiply(price);
+ GbzOrderEntity gbzOrder = new GbzOrderEntity();
+ gbzOrder.setPrice(price);
+ gbzOrder.setAmount(amount);
+ gbzOrder.setCnt(gbzAddDto.getCount());
+ gbzOrder.setMemberId(loginUser.getId());
+ gbzOrder.setSymbol(CoinTypeEnum.BZZ.name());
+
+ gbzOrderDao.insert(gbzOrder);
+
+ MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(loginUser.getId(), CoinTypeEnum.USDT.name());
+ memberWalletCoinDao.updateBlockBalance(wallet.getId(), amount.negate(), BigDecimal.ZERO, 0);
+ return Result.ok("购买成功");
+ }
+
+
+ @ApiOperation(value = "获取订单列表")
+ @PostMapping(value = "/findList")
+ public Result findList(@RequestBody GbzListDto gbzListDto) {
+ Page<GbzOrderEntity> page = new Page<>(gbzListDto.getPageNum(), gbzListDto.getPageSize());
+ IPage<GbzOrderEntity> result = gbzOrderDao.selectInPage(page);
+
+ return Result.ok(result.getRecords());
+ }
+
+ @ApiOperation(value = "获取最新价")
+ @GetMapping(value = "/findPrice")
+ public Result findPrice() {
+ return Result.ok(BigDecimal.valueOf(66));
+ }
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/GbzOrderDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/GbzOrderDao.java
new file mode 100644
index 0000000..caf955c
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/GbzOrderDao.java
@@ -0,0 +1,11 @@
+package com.xcong.excoin.modules.coin.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.coin.entity.GbzOrderEntity;
+
+public interface GbzOrderDao extends BaseMapper<GbzOrderEntity> {
+
+ IPage<GbzOrderEntity> selectInPage(Page<GbzOrderEntity> page);
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/GbzOrderEntity.java b/src/main/java/com/xcong/excoin/modules/coin/entity/GbzOrderEntity.java
new file mode 100644
index 0000000..e4c479a
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/GbzOrderEntity.java
@@ -0,0 +1,23 @@
+package com.xcong.excoin.modules.coin.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@TableName("gbz_order")
+public class GbzOrderEntity extends BaseEntity {
+
+ private BigDecimal price;
+
+ private BigDecimal amount;
+
+ private Integer cnt;
+
+ private Long memberId;
+
+ private String symbol;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzAddDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzAddDto.java
new file mode 100644
index 0000000..d29bbd5
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzAddDto.java
@@ -0,0 +1,18 @@
+package com.xcong.excoin.modules.coin.parameter.dto;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel(value = "GbzAddDto", description = "订单新增接口参数接受类")
+public class GbzAddDto {
+
+ @ApiModelProperty(value = "数量")
+ @NotNull(message = "数量不能为空")
+ private Integer count;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzListDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzListDto.java
new file mode 100644
index 0000000..edd0128
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/GbzListDto.java
@@ -0,0 +1,21 @@
+package com.xcong.excoin.modules.coin.parameter.dto;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel(value = "GbzListDto", description = "订单列表接口参数类")
+public class GbzListDto {
+
+ @NotNull(message = "参数错误")
+ @ApiModelProperty(value = "当前页", example = "1")
+ private Integer pageNum;
+
+ @NotNull(message = "参数错误")
+ @ApiModelProperty(value = "条数", example = "10")
+ private Integer pageSize;
+}
diff --git a/src/main/java/com/xcong/excoin/websocket/TradePlateSendWebSocket.java b/src/main/java/com/xcong/excoin/websocket/TradePlateSendWebSocket.java
index efab375..eb1a474 100644
--- a/src/main/java/com/xcong/excoin/websocket/TradePlateSendWebSocket.java
+++ b/src/main/java/com/xcong/excoin/websocket/TradePlateSendWebSocket.java
@@ -79,6 +79,7 @@
public void onMessage(String message, Session session) {
// 盘口订阅方法 {sub: 'market.btcusdt.depth.10,id: symbol}
JSONObject jsonObject = JSON.parseObject(message);
+ log.info("订阅参数:{}", jsonObject);
// 盘口的判断
if (jsonObject.containsKey("sub") && jsonObject.get("sub").toString().contains("depth")) {
diff --git a/src/main/resources/mapper/walletCoinOrder/GbzOrderDao.xml b/src/main/resources/mapper/walletCoinOrder/GbzOrderDao.xml
new file mode 100644
index 0000000..36a6b2b
--- /dev/null
+++ b/src/main/resources/mapper/walletCoinOrder/GbzOrderDao.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.GbzOrderDao">
+
+ <select id="selectInPage" resultType="com.xcong.excoin.modules.coin.entity.GbzOrderEntity">
+ select * from gbz_order
+ order by create_time desc
+ </select>
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.1