| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yami.trading.bean.constans.WalletConstants; |
| | | import com.yami.trading.bean.data.domain.Realtime; |
| | | import com.yami.trading.bean.finance.Finance; |
| | | import com.yami.trading.bean.finance.FinanceOrder; |
| | | import com.yami.trading.bean.model.MoneyLog; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.model.UserRecom; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.bean.model.*; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.exception.BusinessException; |
| | | import com.yami.trading.common.util.Arith; |
| | |
| | | import com.yami.trading.dao.finance.FinanceOrderMapper; |
| | | import com.yami.trading.service.MoneyLogService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.finance.service.FinanceOrderService; |
| | | import com.yami.trading.service.finance.service.FinanceService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | |
| | | protected UserDataService userDataService; |
| | | @Autowired |
| | | protected UserRecomService userRecomService; |
| | | @Autowired |
| | | protected DataService dataService; |
| | | |
| | | public void saveCreate(FinanceOrder entity) { |
| | | |
| | |
| | | } |
| | | |
| | | if (get_amount > 0) { |
| | | Wallet wallet = this.walletService.saveWalletByPartyId((String) entity.getPartyId()); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | // wallet.setMoney(Arith.add(wallet.getMoney(), get_amount)); |
| | | // this.walletService.update(wallet); |
| | | this.walletService.update(wallet.getUserId(), get_amount); |
| | | String symbol = entity.getBuyCurrency().toLowerCase(); |
| | | double amount_before; |
| | | double amount_after; |
| | | double amount; |
| | | if (symbol.equals("usdt")) { |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId()); |
| | | amount_before = wallet.getMoney().doubleValue(); |
| | | amount_after = Arith.add(amount_before, get_amount); |
| | | amount = get_amount; |
| | | this.walletService.update(wallet.getUserId(), get_amount); |
| | | } else { |
| | | //USDT转对应symbol |
| | | Realtime realtime = this.dataService.realtime(symbol).get(0); |
| | | amount = Arith.div(get_amount, realtime.getClose(), 8); |
| | | |
| | | WalletExtend walletExtend = walletService.saveExtendByPara(entity.getPartyId(), symbol); |
| | | amount_before = walletExtend.getAmount(); |
| | | amount_after = Arith.add(amount_before, get_amount); |
| | | this.walletService.updateExtend(walletExtend.getPartyId(), walletExtend.getWallettype(), amount); |
| | | } |
| | | |
| | | /** |
| | | * 保存资金日志 |
| | | */ |
| | | MoneyLog moneylog = new MoneyLog(); |
| | | moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE); |
| | | moneylog.setAmountBefore(BigDecimal.valueOf(amount_before)); |
| | | moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, get_amount))); |
| | | moneylog.setAmountAfter(BigDecimal.valueOf(Arith.add(amount_before, get_amount))); |
| | | moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, amount))); |
| | | moneylog.setAmountAfter(BigDecimal.valueOf(amount_after)); |
| | | moneylog.setLog("赎回理财产品,订单号[" + entity.getOrderNo() + "]"); |
| | | moneylog.setUserId((String) entity.getPartyId()); |
| | | moneylog.setWalletType(Constants.WALLET); |
| | | moneylog.setUserId(entity.getPartyId()); |
| | | moneylog.setWalletType(symbol.toUpperCase()); |
| | | moneylog.setContentType(WalletConstants.MONEYLOG_CONTENT_FINANCE_BACK); |
| | | moneylog.setCreateTime(systemTime != null ? systemTime : new Date()); |
| | | moneylog.setCreateTime(new Date()); |
| | | |
| | | moneyLogService.save(moneylog); |
| | | |
| | | entity.setVolume(amount); |
| | | } |
| | | |
| | | entity.setCloseTime(new Date());// 赎回时间 |
| | |
| | | } |
| | | |
| | | if (get_amount > 0) { |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId().toString()); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | // wallet.setMoney(Arith.add(wallet.getMoney(), get_amount)); |
| | | // this.walletService.update(wallet); |
| | | this.walletService.update(wallet.getUserId(), get_amount); |
| | | String symbol = entity.getBuyCurrency().toLowerCase(); |
| | | double amount_before; |
| | | double amount_after; |
| | | double amount; |
| | | if (symbol.equals("usdt")) { |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId()); |
| | | amount_before = wallet.getMoney().doubleValue(); |
| | | amount_after = Arith.add(amount_before, get_amount); |
| | | amount = get_amount; |
| | | this.walletService.update(wallet.getUserId(), get_amount); |
| | | } else { |
| | | //USDT转对应symbol |
| | | Realtime realtime = this.dataService.realtime(symbol).get(0); |
| | | amount = Arith.div(get_amount, realtime.getClose(), 8); |
| | | |
| | | WalletExtend walletExtend = walletService.saveExtendByPara(entity.getPartyId(), symbol); |
| | | amount_before = walletExtend.getAmount(); |
| | | amount_after = Arith.add(amount_before, amount); |
| | | this.walletService.updateExtend(walletExtend.getPartyId(), walletExtend.getWallettype(), amount); |
| | | } |
| | | |
| | | /** |
| | | * 保存资金日志 |
| | | */ |
| | | MoneyLog moneylog = new MoneyLog(); |
| | | moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE); |
| | | moneylog.setAmountBefore(BigDecimal.valueOf(amount_before)); |
| | | moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, get_amount))); |
| | | moneylog.setAmountAfter(BigDecimal.valueOf(Arith.add(wallet.getMoney().doubleValue(), get_amount))); |
| | | moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, amount))); |
| | | moneylog.setAmountAfter(BigDecimal.valueOf(amount_after)); |
| | | moneylog.setLog("赎回理财产品,订单号[" + entity.getOrderNo() + "]"); |
| | | moneylog.setUserId(entity.getPartyId().toString()); |
| | | moneylog.setWalletType(Constants.WALLET); |
| | | moneylog.setUserId(entity.getPartyId()); |
| | | moneylog.setWalletType(symbol.toUpperCase()); |
| | | moneylog.setContentType(WalletConstants.MONEYLOG_CONTENT_FINANCE_BACK); |
| | | moneylog.setCreateTime(new Date()); |
| | | |
| | | moneyLogService.save(moneylog); |
| | | |
| | | entity.setVolume(amount); |
| | | } |
| | | |
| | | entity.setCloseTime(new Date());// 赎回时间 |
| | |
| | | if (get_amount > 0) { |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId().toString()); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | // wallet.setMoney(Arith.add(wallet.getMoney(), get_amount)); |
| | | // this.walletService.update(wallet); |
| | | this.walletService.update(wallet.getUserId().toString(), get_amount); |
| | | /** |
| | | * 保存资金日志 |