| | |
| | | @Autowired |
| | | StockMapper stockMapper; |
| | | @Autowired |
| | | AgentAgencyFeeMapper agentAgencyFeeMapper; |
| | | @Autowired |
| | | IAgentAgencyFeeService iAgentAgencyFeeService; |
| | | @Autowired |
| | | ISiteProductService iSiteProductService; |
| | | |
| | | @Autowired |
| | | FundsApplyMapper fundsApplyMapper; |
| | | @Autowired |
| | | UserStockSubscribeMapper userStockSubscribeMapper; |
| | | @Resource |
| | |
| | | @Resource |
| | | UserIndexPositionMapper userIndexPositionMapper; |
| | | |
| | | @Autowired |
| | | IStockFuturesService iStockFuturesService; |
| | | @Autowired |
| | | IStockCoinService iStockCoinService; |
| | | @Autowired |
| | | CurrencyUtils currencyUtils; |
| | | @Resource |
| | | StockDzMapper stockDzMapper; |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("报价0,请稍后再试", request); |
| | | } |
| | | |
| | | |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | BigDecimal finalBuyAmt = buyAmt; |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stock.getStockType().equals(EStockType.MX.getCode())) { |
| | | buyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt); |
| | | } |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | |
| | | BigDecimal fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100)); |
| | | BigDecimal fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100)); |
| | | BigDecimal availableBalance = fundratio.multiply(userAssets.getAvailableBalance()); |
| | | if (availableBalance.compareTo(buyAmt.add(orderFree)) < 0) { |
| | | return ServerResponse.createByErrorMsg("订单失败,配资不足", request); |
| | |
| | | } |
| | | userPosition.setIsLock(Integer.valueOf(0)); |
| | | userPosition.setOrderLever(lever); |
| | | userPosition.setOrderTotalPrice(buyAmt); |
| | | userPosition.setOrderTotalPrice(finalBuyAmt); |
| | | // 手续费 |
| | | |
| | | userPosition.setOrderFee(orderFree); |
| | |
| | | return ServerResponse.createByErrorMsg("订单失败,配资不足", request); |
| | | } |
| | | |
| | | BigDecimal newBuyAmt = buyAmt; |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stock.getStockType().equals(EStockType.MX.getCode())) { |
| | | newBuyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt); |
| | | } |
| | | if(newBuyAmt.compareTo(userAssets.getAvailableBalance()) > 0){ |
| | | return ServerResponse.createByErrorMsg("可用余额不足" + userAssets.getAvailableBalance(), request); |
| | | } |
| | | |
| | | //判断审核开关 |
| | | if(stockDz.getSwitchType() == 1) { |
| | | UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt); |
| | |
| | | // 创建UserPosition对象 |
| | | UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt); |
| | | userPositionMapper.insert(userPosition); |
| | | BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(buyAmt); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(stock.getStockType(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(newBuyAmt); |
| | | //已经转化 直接穿MEX类型 |
| | | userAssetsServices.availablebalanceChange(EStockType.MX.getCode(), user.getId(), EUserAssets.BUY, newBuyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.MX.getCode(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | return ServerResponse.createBySuccess("购买成功", request); |
| | | } |
| | | |
| | |
| | | userPositionCheckDzService.updateById(userPositionCheckDz); |
| | | return ServerResponse.createBySuccess("审核成功", request); |
| | | } |
| | | if (orderNum > userPositionCheckDz.getOrderNum()) { |
| | | return ServerResponse.createByErrorMsg("输入数量大于用户买入数量", request); |
| | | } |
| | | User user = userMapper.selectById(userPositionCheckDz.getUserId()); |
| | | |
| | | StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("id", userPositionCheckDz.getDzId())); |
| | |
| | | userPosition.setId(null); |
| | | userPosition.setDzId(stockDz.getId()); |
| | | userPositionMapper.insert(userPosition); |
| | | userAssetsServices.availablebalanceChange(userAssets.getAccectType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", ""); |
| | | userAssetsServices.availablebalanceChange(stockDz.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", ""); |
| | | return ServerResponse.createBySuccessMsg("审核成功,订单已转客户持仓", request); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg(e.getMessage()); |