| | |
| | | import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
|
| | | import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinDealMapper;
|
| | | import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinMapper;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.FindCollectListVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealListVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo;
|
| | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
|
| | | BigDecimal amount) {
|
| | | public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,BigDecimal amount) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
|
| | |
| | | walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().subtract(amount).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletCoinDao.updateById(walletCoin);
|
| | |
|
| | | walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(totalPayPrice).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | BigDecimal subtract = totalPayPrice.subtract(closingPrice).subtract(closingPrice);
|
| | | walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(subtract).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletCoinDao.updateById(walletCoinUsdt);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | String symbol = orderCoinsEntity.getSymbol();
|
| | |
|
| | | if(orderCoinsEntity.getOrderType() == OrderCoinsEntity.TRADETYPE_FIXEDPRICE) {
|
| | | if(OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
|
| | | //如果是限价买入,撤单将USDT账户冻结金额返回
|
| | | String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
|
| | | MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
|
| | |
| | | if (ObjectUtil.isNotEmpty(walletCoin)) {
|
| | | //手续费 = 开仓价*数量*手续费率
|
| | | //返还金额=开仓价*未成交数量+手续费
|
| | | BigDecimal returnBalance = orderCoinsEntity.getDealAmount().add(orderCoinsEntity.getFeeAmount());
|
| | | BigDecimal returnBalance = orderCoinsEntity.getDealAmount();
|
| | |
|
| | | walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
|
| | |
| | | return Result.ok(memberSelectSymbolsVo);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Result findCollectList() {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | List<MemberSelectSymbolsEntity> selectByMap = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
|
| | | |
| | | FindCollectListVo findCollectListVo = new FindCollectListVo();
|
| | | List<MemberSelectSymbolsVo> arrayList = new ArrayList<>();
|
| | | if(CollUtil.isNotEmpty(selectByMap)) {
|
| | | for(MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectByMap) {
|
| | | MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
|
| | | memberSelectSymbolsVo.setSymbol(memberSelectSymbolsEntity.getSymbol());
|
| | | arrayList.add(memberSelectSymbolsVo);
|
| | | }
|
| | | }
|
| | | findCollectListVo.setMemberSelectSymbolsVo(arrayList);
|
| | | |
| | | return Result.ok(findCollectListVo);
|
| | | }
|
| | |
|
| | | }
|