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 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);
|
}
|
|
}
|