| | |
| | | import com.google.common.collect.Lists; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.*; |
| | | import com.nq.enums.EConfigKey; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.*; |
| | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | @Autowired |
| | | IStockConfigServices iStockConfigServices; |
| | | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) { |
| | | if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) || |
| | |
| | | if (user.getIsLogin().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | //默认资产 |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.getDefault().getCode(),user.getId()); |
| | | //新增账号资产 |
| | | userAssetsServices.addUserAssetsListByUserId(user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | RUserAssets rUserAssets = new RUserAssets(); |
| | | /*RUserAssets rUserAssets = new RUserAssets(); |
| | | rUserAssets.setAccectType("ALL"); |
| | | rUserAssets.setProfitAndLoss(AllProfitAndLose.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setProfitAndLossUSD(AllProfitAndLose.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | |
| | | rUserAssets.setFreezeMoneyUSD(allFreeMoney.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setSymbol("$"); |
| | | rUserAssets.setSymbolCode("USD"); |
| | | rUserAssetsList.add(rUserAssets); |
| | | rUserAssetsList.add(rUserAssets);*/ |
| | | |
| | | return ServerResponse.createBySuccess(rUserAssetsList); |
| | | } |
| | |
| | | try { |
| | | User user = userService.getCurrentUser(request); |
| | | UserAssets formAssets = userAssetsServices.assetsByTypeAndUserId(fromType,user.getId()); |
| | | BigDecimal amtBig = new BigDecimal(amt); |
| | | if(formAssets.getAvailableBalance().compareTo(amtBig)<0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | BigDecimal amtBig = new BigDecimal(amt).abs(); |
| | | |
| | | // 转换手续费率 |
| | | BigDecimal siteSettingBuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.EXCHANGE_HANDLING_CHARGE.getCode()).getCValue()) ; |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(amtBig); |
| | | //资金校验 |
| | | BigDecimal needAmt = amtBig.add(orderFree); |
| | | if(formAssets.getAvailableBalance().compareTo(needAmt)<0){ |
| | | return ServerResponse.createByErrorMsg("余额不足", request); |
| | | } |
| | | userAssetsServices.availablebalanceChange(fromType,user.getId(), EUserAssets.TRANSFER,amtBig.negate(),fromType+"/"+toType,""); |
| | | amtBig = rateServices.currencyRate(EStockType.getEStockTypeByCode(fromType),EStockType.getEStockTypeByCode(toType)).multiply(amtBig); |
| | | userAssetsServices.availablebalanceChange(toType,user.getId(),EUserAssets.TRANSFER,amtBig.setScale(5,RoundingMode.HALF_DOWN),fromType+"/"+toType,""); |
| | | return ServerResponse.createBySuccess(); |
| | | |
| | | userAssetsServices.availablebalanceChange(fromType, user.getId(), EUserAssets.HANDLING_CHARGE, orderFree, "", ""); |
| | | userAssetsServices.availablebalanceChange(fromType, user.getId(), EUserAssets.TRANSFER, amtBig.negate(),fromType+"/"+toType,""); |
| | | //转换金额 |
| | | amtBig = userAssetsServices.exchangeAmountByRate(fromType, toType, amtBig); |
| | | 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()); |
| | | } |