src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java | ●●●●● patch | view | raw | blame | history |
src/main/java/com/xcong/excoin/modules/platform/controller/PlatformController.java
File was renamed from src/main/java/com/xcong/excoin/modules/platform/controller/PlatformCnyUsdtExchangeController.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; src/main/java/com/xcong/excoin/modules/platform/dao/PlatformPaymentMethodDao.java
New file @@ -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> { } src/main/java/com/xcong/excoin/modules/platform/entity/PlatformPaymentMethodEntity.java
New file @@ -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; } src/main/java/com/xcong/excoin/modules/platform/service/PlatformPaymentMethodService.java
New file @@ -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); } src/main/java/com/xcong/excoin/modules/platform/service/impl/PlatformPaymentMethodServiceImpl.java
New file @@ -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); } }