Helius
2020-08-14 9e8a8a68126721ac336b1bbc77e1f11d85a538cb
Merge branch 'master' into whole
1 files added
4 files modified
109 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/AllWalletCoinVo.java 28 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java 64 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -5,6 +5,7 @@
import javax.annotation.Resource;
import javax.validation.Valid;
import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberAgentIntoInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
@@ -37,6 +38,16 @@
    private CoinService coinService;
    
    /**
     *  获取我的总资产
     * @return
     */
    @ApiOperation(value = "获取我的总资产", notes = "获取我的总资产")
    @ApiResponses({@ApiResponse( code = 200, message = "success", response = AllWalletCoinVo.class)})
    @GetMapping(value = "/getAllWalletCoin")
    public Result getAllWalletCoin() {
        return coinService.getAllWalletCoin();
    }
    /**
     *  获取我的币币资产信息
     * @return
     */
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/AllWalletCoinVo.java
New file
@@ -0,0 +1,28 @@
package com.xcong.excoin.modules.coin.parameter.vo;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "AllWalletCoinVo", description = "信息返回")
public class AllWalletCoinVo {
    @ApiModelProperty(value = "账户总USDT")
    private BigDecimal totalUsdt;
    @ApiModelProperty(value = "账户总RMB")
    private BigDecimal totalCny;
    @ApiModelProperty(value = "币币USDT")
    private BigDecimal walletUsdt;
    @ApiModelProperty(value = "合约USDT")
    private BigDecimal contractUsdt;
    @ApiModelProperty(value = "代理USDT")
    private BigDecimal agentUsdt;
}
src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java
@@ -37,4 +37,6 @@
    public Result getWalletAgentRecords(@Valid RecordsPageDto recordsPageDto);
    public Result getAllWalletCoin();
}
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -22,6 +22,7 @@
import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
import com.xcong.excoin.modules.coin.mapper.MemberAccountMoneyChangeMapper;
import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberAgentIntoInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
@@ -510,4 +511,67 @@
            return Result.ok(pageEntityToPageVo);
    }
    @Override
    public Result getAllWalletCoin() {
        //获取【币币】
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
        BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
        AllWalletCoinVo allWalletCoinVo = new AllWalletCoinVo();
        BigDecimal totalUsdts = BigDecimal.ZERO;
        if (!StrUtil.isEmpty(memberId.toString())) {
            List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
            List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
            if (CollUtil.isNotEmpty(memberWalletCoinlist)) {
                for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
                    MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
                    memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
                    memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
                    memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
                    memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
                    memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
                    memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
                }
            }
            if (CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) {
                for (MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) {
                    if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
                        BigDecimal totalUsdt = BigDecimal.ZERO;
                        totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
                        totalUsdts = totalUsdts.add(totalUsdt);
                    } else {
                        BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
                        // 获取最新价
                        BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
                        BigDecimal totalUsdt = BigDecimal.ZERO;
                        totalUsdt = totalUsdt.add(amount.multiply(closePrice));
                        totalUsdts = totalUsdts.add(totalUsdt);
                    }
                }
            }
        }
        allWalletCoinVo.setWalletUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
        //获取【合约】
        String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
        if (ObjectUtil.isEmpty(walletContract)) {
            return Result.fail(MessageSourceUtils.getString("member_service_0001"));
        }
        allWalletCoinVo.setContractUsdt(walletContract.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
        totalUsdts = totalUsdts.add(walletContract.getTotalBalance());
        //获取【代理】
        MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
        BigDecimal availableBalance = walletAgent.getAvailableBalance();
        allWalletCoinVo.setAgentUsdt(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
        totalUsdts = totalUsdts.add(availableBalance);
        allWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
        allWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
        return Result.ok(allWalletCoinVo);
    }
}
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -160,8 +160,8 @@
        MemberSettingEntity memberSettingEntity = new MemberSettingEntity();
        memberSettingEntity.setSpread(BigDecimal.ONE);
        memberSettingEntity.setClosingSpread(BigDecimal.ONE);
        memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0015));
        memberSettingEntity.setClosingSpread(BigDecimal.valueOf(5));
        memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0030));
        memberSettingEntity.setMemberId(member.getId());
        memberSettingDao.insert(memberSettingEntity);