| | |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | |
| | | userPendingorder.setTargetPrice(preMarketPrice); |
| | | userPendingorder.setAddTime(new Date()); |
| | | userPendingorder.setStatus(0); |
| | | userPendingorder.setBuyAmt(buyAmt); |
| | | userPendingorder.setBuyAmt(preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever))); |
| | | int ret = userPendingorderMapper.insert(userPendingorder); |
| | | buyAmt = userPendingorder.getBuyAmt(); |
| | | orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | }else { |
| | | userPosition.setPositionType(user.getAccountType()); |
| | | userPosition.setPositionSn(KeyUtils.getUniqueKey()); |
| | |
| | | userPosition.setStockSpell(stock.getStockSpell()); |
| | | userPosition.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setBuyOrderTime(new Date()); |
| | | userPosition.setBuyOrderPrice(nowPrice); |
| | | // userPosition.setBuyOrderPrice(null == preMarketPrice ? nowPrice : preMarketPrice); |
| | | if(null == preMarketPrice){ |
| | | userPosition.setBuyOrderPrice(nowPrice); |
| | | }else { |
| | | userPosition.setBuyOrderPrice(preMarketPrice); |
| | | buyAmt = preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | } |
| | | userPosition.setOrderDirection((buyType.intValue() == 0) ? "买涨" : "买跌"); |
| | | userPosition.setOrderNum(buyNum); |
| | | if (stock.getStockPlate() != null) { |
| | |
| | | userPosition.setOrderLever(lever); |
| | | userPosition.setOrderTotalPrice(buyAmt); |
| | | // 手续费 |
| | | |
| | | userPosition.setOrderFee(orderFree); |
| | | userPosition.setOrderSpread(BigDecimal.ZERO); |
| | | userPosition.setSpreadRatePrice(BigDecimal.ZERO); |