| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
| | | import com.xcong.excoin.common.LoginUserUtils;
|
| | | import com.xcong.excoin.common.enumerates.CoinTypeEnum;
|
| | | import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
|
| | | import com.xcong.excoin.common.exception.GlobalException;
|
| | | import com.xcong.excoin.common.response.Result;
|
| | | import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
|
| | | import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
|
| | |
| | | import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
|
| | | import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
|
| | | import com.xcong.excoin.utils.MessageSourceUtils;
|
| | |
|
| | | import cn.hutool.core.collection.CollUtil;
|
| | | import cn.hutool.core.util.ObjectUtil;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | |
|
| | | @Service
|
| | |
| | | @Override
|
| | | public Result getWalletContractById() {
|
| | |
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0002"));
|
| | | |
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | |
| | | CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
|
| | | BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
|
| | | |
| | | String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
|
| | | MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
|
| | | if(ObjectUtil.isEmpty(walletContract)) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0001"));
|
| | | }
|
| | | /**
|
| | | * todo
|
| | | */
|
| | | //获取当前的合约持仓
|
| | | //获取实时盈亏
|
| | | BigDecimal profitAndLoss = new BigDecimal("50.000");
|
| | | //获取总付款
|
| | | BigDecimal totalPayment = new BigDecimal("50.000");
|
| | | |
| | | walletContract.setFrozenBalance(totalPayment.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | |
| | | BigDecimal lastTotalBalance = new BigDecimal("0");
|
| | | BigDecimal totalBalance = walletContract.getTotalBalance();
|
| | | lastTotalBalance = totalBalance.add(profitAndLoss);
|
| | | if(lastTotalBalance.compareTo(BigDecimal.ZERO) < 0) {
|
| | | lastTotalBalance = new BigDecimal("0");
|
| | | }
|
| | | |
| | | walletContract.setAvailableBalance(walletContract.getAvailableBalance());
|
| | | walletContract.setTotalBalance(lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | |
| | | Map<String,Object> map = new HashMap<String, Object>();
|
| | | map.put(MemberWalletCoinEnum.WALLETCOINUSDT.getValue(), lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | map.put(MemberWalletCoinEnum.WALLETCONTRACT.getValue(), walletContract);
|
| | | map.put(MemberWalletCoinEnum.WALLETCOINCNY.getValue(), lastTotalBalance.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | return Result.ok(map);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public Result findWalletContractBySymbol(String symbol) {
|
| | | /**
|
| | | * ---todo
|
| | | */
|
| | | return null;
|
| | | public Result findWalletContractBySymbol() {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
|
| | | MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
|
| | | |
| | | return Result.ok(walletContract);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | walletAgent.setAvailableBalance(availableBalance);
|
| | | Map<String,Object> map = new HashMap<String, Object>();
|
| | | map.put(MemberWalletCoinEnum.WALLETCOINUSDT.getValue(), availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | map.put(MemberWalletCoinEnum.WALLETAGENTCNY.getValue(), walletAgent);
|
| | | map.put(MemberWalletCoinEnum.WALLETAGENT.getValue(), walletAgent);
|
| | | map.put(MemberWalletCoinEnum.WALLETCOINCNY.getValue(), multiply.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | return Result.ok(map);
|
| | | }
|