| | |
| | | import com.yami.trading.common.util.RandomUtil; |
| | | import com.yami.trading.dao.dz.ExchangeApplyOrderDzMapper; |
| | | import com.yami.trading.dao.dz.StockDzMapper; |
| | | import com.yami.trading.service.MarketOpenChecker; |
| | | import com.yami.trading.service.MoneyLogService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.data.DataService; |
| | |
| | | } |
| | | |
| | | if(stockDz.getStartTime().getTime() > new Date().getTime() || stockDz.getEndTime().getTime() < new Date().getTime()){ |
| | | throw new YamiShopBindException("不在内幕交易时间之内"); |
| | | return Result.failed("不在内幕交易时间之内"); |
| | | } |
| | | BigDecimal nowPrice = stockDz.getNowPrice(); |
| | | |
| | |
| | | throw new YamiShopBindException("股票价格0,请重试"); |
| | | } |
| | | if (stockDz.getStockNum() > num) { |
| | | throw new YamiShopBindException("请购买最小数量"); |
| | | return Result.failed("请购买最小数量"); |
| | | } |
| | | boolean isOpen = MarketOpenChecker.isMarketOpenBuyDz(Item.US_STOCKS); |
| | | if (!isOpen) { |
| | | return Result.failed("当前股市休市"); |
| | | } |
| | | |
| | | |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(partyId); |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(num)); |
| | | //手续费比率 |
| | | Double feeRate = sysparaService.find("exchange_apply_order_buy_fee").getDouble(); |
| | | Double feeRate = sysparaService.find("exchange_apply_order_dz_buy_fee").getDouble(); |
| | | BigDecimal orderFree = buyAmt.multiply(BigDecimal.valueOf(feeRate)); |
| | | if (buyAmt.doubleValue() < 300) { |
| | | orderFree = BigDecimal.ONE; |
| | | } |
| | | BigDecimal orderAmt = buyAmt.add(orderFree); |
| | | if (wallet.getMoney().compareTo(orderAmt) < 0) { |
| | | return Result.failed("余额不足"); |
| | |
| | | //手续费比率 |
| | | Double feeRate = sysparaService.find("exchange_apply_order_dz_buy_fee").getDouble(); |
| | | BigDecimal orderFree = buyAmt.multiply(BigDecimal.valueOf(feeRate)); |
| | | if (buyAmt.doubleValue() < 300) { |
| | | orderFree = BigDecimal.ONE; |
| | | } |
| | | |
| | | |
| | | BigDecimal orderAmt = buyAmt.add(orderFree); |
| | | if (wallet.getMoney().compareTo(orderAmt) < 0) { |
| | | throw new YamiShopBindException("订单失败,资金不足"); |
| | |
| | | Date resultTime = calendar.getTime(); |
| | | |
| | | if(now.getTime() < resultTime.getTime()){ |
| | | throw new YamiShopBindException("未到平仓时间"); |
| | | return Result.failed("未到平仓时间"); |
| | | } |
| | | } |
| | | |
| | | boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(Item.US_STOCKS); |
| | | if (!isOpen) { |
| | | return Result.failed("当前股市休市"); |
| | | } |
| | | |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | |
| | | //手续费比率 |
| | | Double feeRate = sysparaService.find("exchange_apply_order_dz_sell_fee").getDouble(); |
| | | BigDecimal orderFree = sellAmt.multiply(BigDecimal.valueOf(feeRate)); |
| | | if (sellAmt.doubleValue() < 300) { |
| | | orderFree = BigDecimal.ONE; |
| | | } |
| | | |
| | | |
| | | String symbol = stockDz.getStockCode(); |
| | | Realtime realtime = this.dataService.realtime(symbol).get(0); |