| | |
| | | return ServerResponse.createBySuccess(buy_fee_amt); |
| | | } |
| | | |
| | | /** T+0:可用资金变动时同步调整可取资金 */ |
| | | private void applyEnableAndWithdrawChange(User user, BigDecimal enableBefore, BigDecimal enableAfter) { |
| | | UserFundUtil.applyEnableDelta(user, enableBefore, enableAfter); |
| | | } |
| | | |
| | | /** 下单从两融可用资金扣除:保证金 + 买入手续费 */ |
| | | private void deductUserEnableOnBuy(User user, BigDecimal buyDebit, BigDecimal margin, BigDecimal fee, |
| | | UserPosition position) throws Exception { |
| | |
| | | |
| | | log.info("用戶平倉後的總資金 = {} , 可用資金 = {}", reckon_all, reckon_enable); |
| | | user.setUserAmt(reckon_all); |
| | | user.setEnableAmt(reckon_enable); |
| | | applyEnableAndWithdrawChange(user, user_enable_amt, reckon_enable); |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | if (updateUserCount > 0) { |
| | | log.info("【用戶平倉】修改用戶金額成功"); |
| | |
| | | ucd.setUserName(user.getRealName()); |
| | | ucd.setDeType("总盈亏"); |
| | | ucd.setDeAmt(all_profit); |
| | | ucd.setDeSummary("卖出股票," + userPosition.getStockCode() + "/" + userPosition.getStockName() + ",占用本金:" + freez_amt + ",总手续费:" + all_fee_amt + ",盈亏:" + profitLoss + ",总盈亏:" + all_profit); |
| | | ucd.setDeSummary("卖出股票," + userPosition.getStockCode() + "/" + userPosition.getStockName() + ",占用本金:" + freez_amt + ",总手续费:" + order_fee_all + ",盈亏:" + profitLoss + ",总盈亏:" + all_profit); |
| | | |
| | | ucd.setAddTime(new Date()); |
| | | ucd.setIsRead(Integer.valueOf(0)); |
| | |
| | | |
| | | log.info("用戶平倉後的總資金 = {} , 可用資金 = {}", reckon_all, reckon_enable); |
| | | user.setUserAmt(reckon_all); |
| | | user.setEnableAmt(reckon_enable); |
| | | applyEnableAndWithdrawChange(user, user_enable_amt, reckon_enable); |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | if (updateUserCount > 0) { |
| | | log.info("【用戶平倉】修改用戶金額成功"); |
| | |
| | | ucd.setUserName(user.getRealName()); |
| | | ucd.setDeType("总盈亏"); |
| | | ucd.setDeAmt(all_profit); |
| | | ucd.setDeSummary("卖出股票," + userPositionNew.getStockCode() + "/" + userPositionNew.getStockName() + ",占用本金:" + freez_amt + ",总手续费:" + all_fee_amt + ",递延费:" + 0 + ",印花稅:" + orderSpread + ",盈亏:" + profitLoss + ",总盈亏:" + all_profit); |
| | | ucd.setDeSummary("卖出股票," + userPositionNew.getStockCode() + "/" + userPositionNew.getStockName() + ",占用本金:" + freez_amt + ",总手续费:" + order_fee_all + ",递延费:" + 0 + ",印花稅:" + orderSpread + ",盈亏:" + profitLoss + ",总盈亏:" + all_profit); |
| | | |
| | | ucd.setAddTime(new Date()); |
| | | ucd.setIsRead(Integer.valueOf(0)); |
| | |
| | | BigDecimal reckon_enable = user_enable_amt.subtract(marginAdd); |
| | | |
| | | log.info("用户追加保证金后的总资金 = {} , 可用资金 = {}", user_all_amt, reckon_enable); |
| | | user.setEnableAmt(reckon_enable); |
| | | applyEnableAndWithdrawChange(user, user_enable_amt, reckon_enable); |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | if (updateUserCount > 0) { |
| | | log.info("【用户平仓】修改用户金额成功"); |
| | |
| | | |
| | | adminPositionVO.setStockPlate(position.getStockPlate()); |
| | | |
| | | if (position.getStatus() != null && position.getStatus().intValue() == 2) { |
| | | adminPositionVO.setProfitAndLose(position.getProfitAndLose()); |
| | | adminPositionVO.setAllProfitAndLose(position.getAllProfitAndLose()); |
| | | if (position.getSellOrderPrice() != null) { |
| | | adminPositionVO.setNow_price(position.getSellOrderPrice().toPlainString()); |
| | | } |
| | | } else { |
| | | PositionProfitVO positionProfitVO = getPositionProfitVO(position); |
| | | adminPositionVO.setProfitAndLose(positionProfitVO.getProfitAndLose()); |
| | | adminPositionVO.setAllProfitAndLose(positionProfitVO.getAllProfitAndLose()); |
| | | adminPositionVO.setNow_price(positionProfitVO.getNowPrice()); |
| | | } |
| | | |
| | | |
| | | return adminPositionVO; |
| | |
| | | |
| | | agentPositionVO.setStockPlate(position.getStockPlate()); |
| | | |
| | | if (position.getStatus() != null && position.getStatus().intValue() == 2) { |
| | | agentPositionVO.setProfitAndLose(position.getProfitAndLose()); |
| | | agentPositionVO.setAllProfitAndLose(position.getAllProfitAndLose()); |
| | | if (position.getSellOrderPrice() != null) { |
| | | agentPositionVO.setNow_price(position.getSellOrderPrice().toPlainString()); |
| | | } |
| | | } else { |
| | | PositionProfitVO positionProfitVO = getPositionProfitVO(position); |
| | | agentPositionVO.setProfitAndLose(positionProfitVO.getProfitAndLose()); |
| | | agentPositionVO.setAllProfitAndLose(positionProfitVO.getAllProfitAndLose()); |
| | | agentPositionVO.setNow_price(positionProfitVO.getNowPrice()); |
| | | } |
| | | |
| | | |
| | | return agentPositionVO; |
| | |
| | | BigDecimal orderTotalPrice = position.getOrderTotalPrice(); |
| | | |
| | | if (position.getSellOrderId() != null) { |
| | | |
| | | if (Integer.valueOf(2).equals(position.getStatus()) |
| | | && position.getProfitAndLose() != null |
| | | && position.getAllProfitAndLose() != null) { |
| | | profitAndLose = position.getProfitAndLose(); |
| | | allProfitAndLose = position.getAllProfitAndLose(); |
| | | } else { |
| | | BigDecimal subPrice = position.getSellOrderPrice().subtract(position.getBuyOrderPrice()); |
| | | // profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4); |
| | | profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).setScale(2,4); |
| | | if ("买跌".equals(position.getOrderDirection())) { |
| | | profitAndLose = profitAndLose.negate(); |
| | | } |
| | | |
| | | |
| | | allProfitAndLose = profitAndLose.subtract(position.getOrderFee()).subtract(position.getOrderSpread()).subtract(position.getOrderStayFee()).subtract(position.getSpreadRatePrice()); |
| | | allProfitAndLose = profitAndLose.subtract(position.getOrderFee()).subtract(position.getOrderSpread()) |
| | | .subtract(position.getOrderStayFee()).subtract(position.getSpreadRatePrice()); |
| | | } |
| | | } else { |
| | | StockListVO stockListVO = new StockListVO(); |
| | | StockCoin stockCoin = new StockCoin(); |