| | |
| | | import com.yami.trading.admin.model.AdjustProfitsModel; |
| | | import com.yami.trading.bean.contract.domain.ContractApplyOrder; |
| | | import com.yami.trading.bean.data.domain.Realtime; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.BusinessException; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | |
| | | |
| | | import com.yami.trading.common.util.ThreadUtils; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired(required = false) |
| | | @Qualifier("dataService") |
| | | private DataService dataService; |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | /** |
| | | * 非按金额订单列表数据 |
| | |
| | | public Result<IPage<ContractOrderDTO>> list(ContractOrderQuery contractOrderQuery, Page<ContractOrder> page) throws Exception { |
| | | IPage<ContractOrderDTO> result = contractOrderService.listRecord(page, contractOrderQuery); |
| | | result.getRecords().forEach(d -> { |
| | | String symbol = d.getSymbol(); |
| | | User user = userService.cacheUserBy(d.getPartyId()); |
| | | d.setUserName(user.getUserName()); |
| | | String symbol = d.getSymbol(); |
| | | List<Realtime> realtimes = dataService.realtime(symbol); |
| | | if (CollectionUtil.isEmpty(realtimes)) { |
| | | d.setMark_price(BigDecimal.ZERO); |
| | |
| | | // 获取合约账户(contract) |
| | | Wallet wallet = walletService.saveWalletByPartyId(partyId); |
| | | // 获取资金账户(capital) |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | List<WalletExtend> walletExtends = walletExtendService.findByUserId(partyId); |
| | | AtomicReference<BigDecimal> walletExtendMoneyRef = new AtomicReference<>(BigDecimal.ZERO); |
| | | walletExtends.forEach(f -> { |
| | |
| | | Map<String, BigDecimal> assets = new HashMap<>(); |
| | | |
| | | assets.put("contract",wallet.getMoney().setScale(2,RoundingMode.DOWN)); |
| | | assets.put("capital",capitaltWallet.getMoney().add(walletExtendMoney).setScale(2,RoundingMode.DOWN)); |
| | | assets.put("capitalUSDT",capitaltWallet.getMoney());//划转专用 |
| | | // assets.put("capital",capitaltWallet.getMoney().add(walletExtendMoney).setScale(2,RoundingMode.DOWN)); |
| | | // assets.put("capitalUSDT",capitaltWallet.getMoney());//划转专用 |
| | | return Result.succeed(assets); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty("角色名称") |
| | | private String roleName; |
| | | |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | |
| | | */ |
| | | @ApiModelProperty("用户名") |
| | | private String userName; |
| | | /** |
| | | * UID |
| | | */ |
| | | @ApiModelProperty("userCode") |
| | | private String userCode; |
| | | |
| | | |
| | | /** |
| | | * 手机号码 |
| | |
| | | |
| | | private String userMobile; |
| | | /** |
| | | * UID |
| | | */ |
| | | @ApiModelProperty("userCode") |
| | | private String userCode; |
| | | |
| | | /** |
| | | * USDT账户余额 |
| | | */ |
| | | @ApiModelProperty("USDT账户余额") |
| | |
| | | f.setTradeAvgPrice((f.getTradeAvgPrice().add(realtime.getClose())).divide(new BigDecimal(2)).setScale(4, RoundingMode.DOWN)); |
| | | |
| | | BigDecimal fee = BigDecimal.ZERO; |
| | | if (f.getLeverRate() != null) { |
| | | |
| | | fee = applyOrder.getDeposit().multiply(f.getLeverRate()).multiply(item.getUnitFee()); |
| | | fee = fee.setScale(4, RoundingMode.DOWN); // 保留两位小数 |
| | | f.setFee(f.getFee().add(fee)); |
| | | } |
| | | // if (f.getLeverRate() != null) { |
| | | // |
| | | // fee = applyOrder.getDeposit().multiply(f.getLeverRate()).multiply(item.getUnitFee()); |
| | | // fee = fee.setScale(4, RoundingMode.DOWN); // 保留两位小数 |
| | | // f.setFee(f.getFee().add(fee)); |
| | | // } |
| | | fee = applyOrder.getFee(); |
| | | f.setFee(applyOrder.getFee()); |
| | | double number = strongLevelCalculationService.countSheets(f.getDepositOpen().doubleValue(), applyOrder.getLeverRate().intValue(), 0.01, realtime.getClose().doubleValue()); |
| | | f.setVolumeOpen(new BigDecimal(number)); |
| | | f.setVolume(new BigDecimal(number)); |
| | |
| | | |
| | | @Override |
| | | public User cacheUserBy(String userId) { |
| | | return null; |
| | | return getById(userId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | party.setUserLevel(userLevel); |
| | | party.setSafePassword(this.passwordEncoder.encode(safeword)); |
| | | party.setRoleName(Constants.SECURITY_ROLE_MEMBER); |
| | | party.setLoginPassword(passwordEncoder.encode(password)); |
| | | party.setUserMobile(phone); |
| | | save(party); |
| | | // if (reg.getUsername().indexOf("@") == -1) { |
| | |
| | | walletExtendMoneyRef.updateAndGet(current -> current.add(money)); |
| | | }); |
| | | BigDecimal walletExtendMoney = walletExtendMoneyRef.get(); |
| | | CapitaltWallet userIdWallet = capitaltWalletMapper.selectOne(new LambdaQueryWrapper<CapitaltWallet>() |
| | | .eq(CapitaltWallet::getUserId,partyId.toString())); |
| | | // CapitaltWallet userIdWallet = capitaltWalletMapper.selectOne(new LambdaQueryWrapper<CapitaltWallet>() |
| | | // .eq(CapitaltWallet::getUserId,partyId.toString())); |
| | | moneys_contract.put("money_wallet", wallet.getMoney().doubleValue());//可用余额 |
| | | moneys_contract.put("money_contract", userIdWallet.getMoney().doubleValue()+wallet.getMoney().doubleValue()+money_contract+walletExtendMoney.doubleValue()); |
| | | // moneys_contract.put("money_contract", userIdWallet.getMoney().doubleValue()+wallet.getMoney().doubleValue()+money_contract+walletExtendMoney.doubleValue()); |
| | | moneys_contract.put("money_contract", wallet.getMoney().doubleValue()+money_contract+walletExtendMoney.doubleValue()); |
| | | return moneys_contract; |
| | | } |
| | | |
| | |
| | | wallet = saveWalletByPartyId(partyId.toString()); |
| | | } |
| | | //资金账户 |
| | | CapitaltWallet capitaltWallet = capitaltWalletMapper.selectOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletMapper.selectOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | money = wallet.getMoney().doubleValue(); |
| | | // 钱包USDT |
| | | money_wallet = wallet.getMoney().doubleValue(); |
| | | // 币余额 |
| | | money_coin = this.getMoneyCoin(partyId, realtime_all, list_symbol)+capitaltWallet.getMoney().doubleValue(); |
| | | money_coin = this.getMoneyCoin(partyId, realtime_all, list_symbol); |
| | | money = money + money_coin; |
| | | // 钱包USDT+币余额 |
| | | money_all_coin = money; |