xiaoyong931011
2020-05-22 7b91ec6ba5b0ae35bdef5df4bd6b2e43ddbc2686
20200522   代码修改
4 files modified
83 ■■■■■ changed files
src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java 7 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java 15 ●●●●● 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 59 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/common/enumerates/MemberWalletCoinEnum.java
@@ -3,9 +3,12 @@
public enum MemberWalletCoinEnum {
    
    WALLETCOINUSDT("walletCoinUsdt", "usdt"),
    WALLETCOINLIST("walletCoinList", "walletList"),
    WALLETCOINCNY("walletCoinCny", "cny"),
    WALLETAGENTCNY("walletCoinCny", "wallet"),
    WALLETCOINLIST("walletCoinList", "walletList"),
    WALLETAGENT("walletCoin", "wallet"),
    WALLETCONTRACT("walletContract", "walletContract"),
    
    CONTENTTOCONTRACT("0001","转出至合约账户"),
    CONTENTFROMWALLETCOIN("0002","由币币账户转入"),
src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -8,9 +8,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -19,7 +17,6 @@
import com.xcong.excoin.modules.coin.service.CoinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -64,13 +61,13 @@
    }
    
    /**
     * 查询合约账户里面的资产余额
     * 查询合约账户里面的可用资产余额
     * @return
     */
    @ApiOperation(value="查询合约账户里面的资产余额", notes="查询合约账户里面的资产余额")
    @ApiOperation(value="查询合约账户里面的可用资产余额", notes="查询合约账户里面的可用资产余额")
    @GetMapping(value="/findWalletContractBySymbol")
    public Result findWalletContractBySymbol(String symbol) {
        return coinService.findWalletContractBySymbol(symbol);
    public Result findWalletContractBySymbol() {
        return coinService.findWalletContractBySymbol();
    }
    
    /**
@@ -87,7 +84,7 @@
     * 查询代理账户里面的资产余额
     * @return
     */
    @ApiOperation(value="查询代理账户里面的资产余额", notes="查询代理账户里面的资产余额")
    @ApiOperation(value="查询代理账户里面的可用资产余额", notes="查询代理账户里面的可用资产余额")
    @GetMapping(value="/findWalletAgentBySymbol")
    public Result findWalletAgentBySymbol() {
        return coinService.findWalletAgentBySymbol();
@@ -151,7 +148,7 @@
     * 代理账户划转到USDT账户
     * @return
     */
    @ApiOperation(value="代理账户划转到USDT账户", notes="代理账户划转到USDT账户")
    @ApiOperation(value="代理账户划转到合约或币币USDT账户()", notes="代理账户划转到合约或币币USDT账户")
    @PostMapping(value="/agentTransferToWalletCoin")
    public Result  agentTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceDto transferOfBalanceDto) {
        BigDecimal balance = transferOfBalanceDto.getBalance();
src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java
@@ -18,7 +18,7 @@
    public Result contractTransferToWalletCoin(BigDecimal balance, String symbol);
    public Result findWalletContractBySymbol(String symbol);
    public Result findWalletContractBySymbol();
    public Result findWalletCoinBySymbol(String symbol);
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -2,21 +2,17 @@
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;
@@ -31,8 +27,8 @@
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
@@ -151,8 +147,43 @@
    @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
@@ -276,11 +307,13 @@
    }
    @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
@@ -426,7 +459,7 @@
        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);
    }