From 75018b2f492444248d8b476d9703bb312d2befc3 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sat, 08 Feb 2025 16:51:19 +0800
Subject: [PATCH] 项目提交
---
trading-order-service/src/main/java/com/yami/trading/service/exchange/impl/ExchangeApplyOrderServiceImpl.java | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/trading-order-service/src/main/java/com/yami/trading/service/exchange/impl/ExchangeApplyOrderServiceImpl.java b/trading-order-service/src/main/java/com/yami/trading/service/exchange/impl/ExchangeApplyOrderServiceImpl.java
index 517bbe1..3cd3b94 100644
--- a/trading-order-service/src/main/java/com/yami/trading/service/exchange/impl/ExchangeApplyOrderServiceImpl.java
+++ b/trading-order-service/src/main/java/com/yami/trading/service/exchange/impl/ExchangeApplyOrderServiceImpl.java
@@ -13,6 +13,7 @@
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;
@@ -21,6 +22,7 @@
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;
@@ -58,6 +60,8 @@
MoneyLogService moneyLogService;
@Autowired
UserDataService userDataService;
+ @Autowired
+ CapitaltWalletService capitaltWalletService;
@Override
public List<ExchangeApplyOrder> findSubmitted() {
@@ -107,9 +111,12 @@
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);
+
/*
* 保存资金日志
*/
@@ -117,7 +124,7 @@
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);
@@ -607,11 +614,9 @@
// 可以买的数量
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()) {
@@ -632,12 +637,11 @@
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()));
/*
* 保存资金日志
*/
@@ -645,7 +649,7 @@
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);
--
Gitblit v1.9.3