| | |
| | | import com.yami.trading.bean.exchange.dto.ExchangeSymbolDto; |
| | | import com.yami.trading.bean.exchange.dto.SumEtfDto; |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.bean.model.CapitaltWallet; |
| | | import com.yami.trading.bean.model.MoneyLog; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.bean.model.WalletExtend; |
| | |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.*; |
| | | import com.yami.trading.dao.exchange.ExchangeApplyOrderMapper; |
| | | import com.yami.trading.service.CapitaltWalletService; |
| | | import com.yami.trading.service.MoneyLogService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.data.DataService; |
| | |
| | | MoneyLogService moneyLogService; |
| | | @Autowired |
| | | UserDataService userDataService; |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | @Override |
| | | public List<ExchangeApplyOrder> findSubmitted() { |
| | |
| | | double amount = Arith.mul(sub, realtime.getClose().doubleValue()); |
| | | order.setCloseTime(new Date()); |
| | | order.setClosePrice(realtime.getClose().doubleValue()); |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | this.walletService.update(wallet.getUserId().toString(), amount); |
| | | // Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | double amount_before = capitaltWallet.getMoney().doubleValue(); |
| | | // this.walletService.update(userIdWallet.getUserId().toString(), amount); |
| | | this.capitaltWalletService.update(capitaltWallet, amount); |
| | | |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | |
| | | moneylog_deposit.setCategory(Constants.MONEYLOG_CATEGORY_EXCHANGE); |
| | | moneylog_deposit.setAmountBefore(new BigDecimal(amount_before)); |
| | | moneylog_deposit.setAmount(new BigDecimal(amount)); |
| | | moneylog_deposit.setAmountAfter(wallet.getMoney()); |
| | | moneylog_deposit.setAmountAfter(capitaltWallet.getMoney()); |
| | | moneylog_deposit.setLog("委托单,订单号[" + order.getOrderNo() + "]"); |
| | | moneylog_deposit.setUserId(order.getPartyId()); |
| | | moneylog_deposit.setWalletType(Constants.WALLET); |
| | |
| | | // 可以买的数量 |
| | | double amount = Arith.div(sub, order.getClosePrice(), 8); |
| | | order.setSymbolValue(amount); |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | WalletExtend walletExtend = walletService.saveExtendByPara(order.getPartyId(), order.getSymbol()); |
| | | // walletExtend.setAmount(Arith.add(walletExtend.getAmount(), amount)); |
| | | // this.walletService.update(walletExtend); |
| | | // Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | double amount_before = userIdWallet.getMoney().doubleValue(); |
| | | // 如果是计划委托,则先不扣钱 |
| | | if (order.isTriggerOrder()) { |
| | | |
| | |
| | | save(order); |
| | | } |
| | | if (!order.isTriggerOrder()) { |
| | | if (wallet.getMoney().doubleValue() < order.getVolume().doubleValue()) { |
| | | if (userIdWallet.getMoney().doubleValue() < order.getVolume().doubleValue()) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | } |
| | | this.walletService.update(wallet.getUserId().toString(), Arith.sub(0, order.getVolume())); |
| | | // this.walletService.updateExtend(walletExtend.getPartyId().toString(), walletExtend.getWallettype(), amount); |
| | | |
| | | // this.walletService.update(userIdWallet.getUserId().toString(), Arith.sub(0, order.getVolume())); |
| | | capitaltWalletService.update(userIdWallet, Arith.sub(0, order.getVolume())); |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | |
| | | moneylog_deposit.setCategory(Constants.MONEYLOG_CATEGORY_EXCHANGE); |
| | | moneylog_deposit.setAmountBefore(new BigDecimal(amount_before)); |
| | | moneylog_deposit.setAmount(new BigDecimal(Arith.sub(0, order.getVolume().doubleValue()))); |
| | | moneylog_deposit.setAmountAfter(new BigDecimal(Arith.sub(wallet.getMoney().doubleValue(), order.getVolume()))); |
| | | moneylog_deposit.setAmountAfter(new BigDecimal(Arith.sub(userIdWallet.getMoney().doubleValue(), order.getVolume()))); |
| | | moneylog_deposit.setLog("币币交易,订单号[" + order.getOrderNo() + "]"); |
| | | moneylog_deposit.setUserId(order.getPartyId()); |
| | | moneylog_deposit.setWalletType(Constants.WALLET); |