xiaoyong931011
2020-06-02 1e2725d0ab46e73cf21279f816f2320b626fbd3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
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.entity.PlatformCnyUsdtExchangeEntity;
import com.xcong.excoin.modules.platform.service.PlatformCnyUsdtExchangeService;
 
@Service
public class PlatformCnyUsdtExchangeServiceImpl 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);
    }
    
}