|
@@ -59,178 +59,91 @@ public class StockCoinServiceImpl implements IStockCoinService {
|
|
|
|
|
|
|
|
|
private CoinAdminListVO assembleCoinAdminListVO(StockCoin stockCoin) {
|
|
|
-
|
|
|
CoinAdminListVO coinAdminListVO = new CoinAdminListVO();
|
|
|
-
|
|
|
coinAdminListVO.setId(stockCoin.getId());
|
|
|
-
|
|
|
coinAdminListVO.setCoinName(stockCoin.getCoinName());
|
|
|
-
|
|
|
coinAdminListVO.setCoinCode(stockCoin.getCoinCode());
|
|
|
-
|
|
|
coinAdminListVO.setCoinGid(stockCoin.getCoinGid());
|
|
|
-
|
|
|
coinAdminListVO.setDynamicRate(stockCoin.getDynamicRate());
|
|
|
-
|
|
|
coinAdminListVO.setDefaultRate(stockCoin.getDefaultRate());
|
|
|
-
|
|
|
coinAdminListVO.setIsUse(stockCoin.getIsUse());
|
|
|
-
|
|
|
coinAdminListVO.setAddTime(stockCoin.getAddTime());
|
|
|
-
|
|
|
coinAdminListVO.setTDesc(stockCoin.gettDesc());
|
|
|
-
|
|
|
coinAdminListVO.setServiceCharge(stockCoin.getServiceCharge());
|
|
|
-
|
|
|
String nowPrice = "";
|
|
|
-
|
|
|
ExchangeVO exchangeVO = null;
|
|
|
-
|
|
|
-
|
|
|
ServerResponse serverResponse = this.iStockFuturesService.queryExchangeVO(stockCoin.getCoinCode());
|
|
|
-
|
|
|
if (serverResponse.isSuccess()) {
|
|
|
-
|
|
|
exchangeVO = (ExchangeVO) serverResponse.getData();
|
|
|
-
|
|
|
if (exchangeVO != null) {
|
|
|
-
|
|
|
nowPrice = exchangeVO.getNowPrice();
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
coinAdminListVO.setNowPrice(nowPrice);
|
|
|
-
|
|
|
-
|
|
|
return coinAdminListVO;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
public ServerResponse add(StockCoin stockCoin) {
|
|
|
-
|
|
|
if (StringUtils.isBlank(stockCoin.getCoinName()) ||
|
|
|
-
|
|
|
StringUtils.isBlank(stockCoin.getCoinCode()) ||
|
|
|
-
|
|
|
StringUtils.isBlank(stockCoin.getCoinGid())) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("参数不能为空");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
StockCoin coinName = this.stockCoinMapper.selectCoinByName(stockCoin.getCoinName());
|
|
|
-
|
|
|
if (coinName != null) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("名称不能重复");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
StockCoin coinCode = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinCode());
|
|
|
-
|
|
|
if (coinCode != null) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("代码不能重复");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
StockCoin coinGid = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinGid());
|
|
|
-
|
|
|
if (coinGid != null) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("gid不能重复");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
stockCoin.setAddTime(new Date());
|
|
|
-
|
|
|
-
|
|
|
int insertCount = this.stockCoinMapper.insert(stockCoin);
|
|
|
-
|
|
|
if (insertCount > 0) {
|
|
|
-
|
|
|
return ServerResponse.createBySuccessMsg("添加成功");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("添加失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public ServerResponse update(StockCoin stockCoin) {
|
|
|
-
|
|
|
if (stockCoin.getId() == null) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("修改id不能为空");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
StockCoin dbCoin = this.stockCoinMapper.selectByPrimaryKey(stockCoin.getId());
|
|
|
-
|
|
|
if (dbCoin == null) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("基币不存在");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if (stockCoin.getCoinName() != null) {
|
|
|
-
|
|
|
StockCoin coinName = this.stockCoinMapper.selectCoinByName(stockCoin.getCoinName());
|
|
|
-
|
|
|
if (coinName != null && coinName.getId() != dbCoin.getId()) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("名称已存在");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
if (stockCoin.getCoinCode() != null) {
|
|
|
-
|
|
|
StockCoin coinCode = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinCode());
|
|
|
-
|
|
|
if (coinCode != null && coinCode.getId() != dbCoin.getId()) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("代码已存在");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
if (stockCoin.getCoinGid() != null) {
|
|
|
-
|
|
|
StockCoin coinGid = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinGid());
|
|
|
-
|
|
|
if (coinGid != null && coinGid.getId() != dbCoin.getId()) {
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("gid已存在");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
int updateCount = this.stockCoinMapper.updateByPrimaryKeySelective(stockCoin);
|
|
|
-
|
|
|
if (updateCount > 0) {
|
|
|
-
|
|
|
return ServerResponse.createBySuccessMsg("修改成功");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return ServerResponse.createByErrorMsg("修改失败");
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
public StockCoin selectCoinByCode(String coinCode) {
|
|
|
return this.stockCoinMapper.selectCoinByCode(coinCode);
|
|
|
}
|