| | |
| | | @ResponseBody |
| | | public ServerResponse transfer(@RequestParam("fromType") String fromType, @RequestParam("toType") String toType, |
| | | @RequestParam("amt") String amt, HttpServletRequest request) { |
| | | try { |
| | | if (fromType.equals(toType)) { |
| | | return ServerResponse.createByErrorMsg("货币类型不能相同", request); |
| | | } |
| | | return iUserService.transfer(fromType, toType, amt,request); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | ServerResponse getMoney(Integer userId); |
| | | |
| | | ServerResponse transfer(String fromType,String toType,String amt,HttpServletRequest paramHttpServletRequest); |
| | | ServerResponse transfer(String fromType,String toType,String amt,HttpServletRequest paramHttpServletRequest) throws Exception; |
| | | |
| | | void ForceSellTask(); |
| | | void ForceSellOneStockTask(); |
| | |
| | | |
| | | @Override |
| | | public BigDecimal exchangeAmountByRate(String fromType, String toType, BigDecimal amount) throws Exception { |
| | | EStockType stockType = EStockType.getEStockTypeBySymbol(fromType); |
| | | EStockType toStockType = EStockType.getEStockTypeBySymbol(toType); |
| | | EStockType stockType = EStockType.getEStockTypeByCode(fromType); |
| | | EStockType toStockType = EStockType.getEStockTypeByCode(toType); |
| | | ExchangeRate exchangeRate = exchangeRateRepository.findExchangeRateByCurrencyAndConversionCurrency( |
| | | stockType.getSymbol(), toStockType.getSymbol()).orElse(null); |
| | | if (exchangeRate != null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse transfer(String fromType, String toType, String amt,HttpServletRequest request) { |
| | | try { |
| | | @Transactional |
| | | public ServerResponse transfer(String fromType, String toType, String amt,HttpServletRequest request) throws Exception { |
| | | User user = userService.getCurrentUser(request); |
| | | UserAssets formAssets = userAssetsServices.assetsByTypeAndUserId(fromType,user.getId()); |
| | | BigDecimal amtBig = new BigDecimal(amt).abs(); |
| | |
| | | userAssetsServices.availablebalanceChange(toType,user.getId(), EUserAssets.TRANSFER, amtBig.setScale(5,RoundingMode.HALF_DOWN),fromType+"/"+toType,""); |
| | | |
| | | return ServerResponse.createBySuccess("操作成功", request); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |