From c60a4d7b96f82677a20d8d83e4b8307461462fc7 Mon Sep 17 00:00:00 2001
From: gao <gaoleox@163>
Date: Tue, 26 May 2020 14:57:47 +0800
Subject: [PATCH] 平台系统设置类

---
 src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java                  |   12 ++++++
 src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java            |   26 +++++++++++++
 src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java          |   13 ++++++
 src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java                 |    4 +-
 src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java |   38 +++++++++++++++++++
 5 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformCnyUsdtExchangeController.java b/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
similarity index 89%
rename from src/main/java/com/xcong/excoin/modules/platform/controller/PlatformCnyUsdtExchangeController.java
rename to src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
index c10bd37..e8e2774 100644
--- a/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformCnyUsdtExchangeController.java
+++ b/src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
@@ -18,8 +18,8 @@
 @RestController
 @Slf4j
 @RequestMapping(value = "/api/exchange")
-@Api(value = "PlatformCnyUsdtExchangeController", tags = "平台Cny|Usdt兑换类")
-public class PlatformCnyUsdtExchangeController {
+@Api(value = "PlatformController", tags = "平台系统设置类")
+public class PlatformController {
 	
 	@Resource
 	PlatformCnyUsdtExchangeService platformCnyUsdtExchangeService;
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
new file mode 100644
index 0000000..8766698
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java
@@ -0,0 +1,12 @@
+package com.xcong.excoin.modules.platform.dao;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.home.entity.MemberPaymentMethodEntity;
+import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
+
+public interface PlatformPaymentMethodDao extends BaseMapper<PlatformCnyUsdtExchangeEntity> {
+
+	
+}
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
new file mode 100644
index 0000000..fbc3e0e
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java
@@ -0,0 +1,26 @@
+package com.xcong.excoin.modules.platform.entity;
+
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+
+import lombok.Data;
+@Data
+@TableName("platform_cny_usdt_exchange")
+public class PlatformPaymentMethodEntity extends BaseEntity{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 兑换比例
+	 */
+	private BigDecimal value;
+	/**
+	 * 增减偏量
+	 */
+	private BigDecimal diff;
+}
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
new file mode 100644
index 0000000..411b66f
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java
@@ -0,0 +1,13 @@
+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 PlatformPaymentMethodService extends IService<PlatformCnyUsdtExchangeEntity> {
+
+	public Result findUsdtCnyExchange(@RequestParam("type") String type);
+	
+}
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
new file mode 100644
index 0000000..2a5d998
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java
@@ -0,0 +1,38 @@
+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 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.dao.PlatformCnyUsdtExchangeDao;
+import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
+import com.xcong.excoin.modules.platform.service.PlatformCnyUsdtExchangeService;
+
+@Service
+public class PlatformPaymentMethodServiceImpl 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);
+	}
+	
+}

--
Gitblit v1.9.1