xiaoyong931011
2021-05-17 7572b8dbd4c41ca9b6437a032da2aa1a0fdd5444
src/main/java/com/xcong/excoin/modules/yunding/service/impl/BasicSettingServiceImpl.java
@@ -1,21 +1,29 @@
package com.xcong.excoin.modules.yunding.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.entity.FebsResponse;
import com.xcong.excoin.common.entity.QueryRequest;
import com.xcong.excoin.modules.member.entity.MemberAccountMoneyChangeEntity;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.member.mapper.MemberMapper;
import com.xcong.excoin.modules.member.mapper.MemberWalletCoinMapper;
import com.xcong.excoin.modules.yunding.entity.BasicSettingEntity;
import com.xcong.excoin.modules.yunding.entity.YdOrderEntity;
import com.xcong.excoin.modules.yunding.entity.YdProductEntity;
import com.xcong.excoin.modules.yunding.mapper.BasicSettingMapper;
import com.xcong.excoin.modules.yunding.mapper.YdProductMapper;
import com.xcong.excoin.modules.yunding.service.IBasicSettingService;
import com.xcong.excoin.modules.yunding.vo.YdAgentOrderVo;
import com.xcong.excoin.modules.yunding.vo.YdMemberVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -30,10 +38,14 @@
    private BasicSettingMapper basicSettingMapper;
    @Resource
    private MemberWalletCoinMapper memberWalletCoinMapper;
    @Resource
    private MemberMapper memberMapper;
    @Resource
    private YdProductMapper ydProductMapper;
    @Override
    public IPage<YdOrderEntity> getOrderList(YdOrderEntity ydOrderEntity, QueryRequest request) {
        log.info("订单列表");
        log.info("产品订单列表");
        Page<YdOrderEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<YdOrderEntity> ydOrderEntitys = basicSettingMapper.getOrderList(page, ydOrderEntity);
        return ydOrderEntitys;
@@ -62,16 +74,118 @@
                ydMemberVo.setQuantityWork(quantityWork);
                int quantityEnd = basicSettingMapper.selectPowerByMemberIdAndState(memberId,YdOrderEntity.ORDER_STATE_END);
                ydMemberVo.setQuantityEnd(quantityEnd);
                BigDecimal totalUsed = basicSettingMapper.selectAmountByMemberId(memberId);
                ydMemberVo.setTotalUsed(totalUsed);
                BigDecimal totalUsed = basicSettingMapper.selectAmountByMemberId(memberId,1);
                ydMemberVo.setTotalUsed(totalUsed == null ? BigDecimal.ZERO : totalUsed);
                BigDecimal agentUsed = basicSettingMapper.selectAmountByMemberId(memberId,2);
                ydMemberVo.setAgentUsed(agentUsed == null ? BigDecimal.ZERO : agentUsed);
                MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(memberId, "USDT");
                ydMemberVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance());
                if(ObjectUtil.isNotEmpty(memberWalletCoinEntity)){
                    ydMemberVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance() == null ? BigDecimal.ZERO : memberWalletCoinEntity.getAvailableBalance());
                }else{
                    ydMemberVo.setAvailableBalance(BigDecimal.ZERO);
                }
                BigDecimal inBalance = basicSettingMapper.selectChargeAmountByMemberIdAndStatus(memberId,1);
                ydMemberVo.setInBalance(inBalance);
                ydMemberVo.setInBalance(inBalance == null ? BigDecimal.ZERO : inBalance);
                BigDecimal outBalance = basicSettingMapper.selectWithdrawAmountByMemberIdAndStatusAndIsInside(memberId,2,"N");
                ydMemberVo.setOutBalance(outBalance);
                ydMemberVo.setOutBalance(outBalance  == null ? BigDecimal.ZERO : outBalance);
                BigDecimal returnAgent = basicSettingMapper.selectAgentReturnByMemberId(memberId);
                ydMemberVo.setReturnAgent(returnAgent == null ? BigDecimal.ZERO : returnAgent);
                BigDecimal totalProfit = basicSettingMapper.selectTotalProfitByMemberIdAndType(memberId,1);
                ydMemberVo.setTotalProfit(totalProfit);
            }
        }
        return ydMemberVos;
    }
    @Override
    public IPage<YdAgentOrderVo> getAgentOrderList(YdOrderEntity ydOrderEntity, QueryRequest request) {
        log.info("代理订单列表");
        Page<YdOrderEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<YdAgentOrderVo> ydOrderEntitys = basicSettingMapper.getAgentOrderList(page, ydOrderEntity);
        return ydOrderEntitys;
    }
    @Override
    public IPage<MemberAccountMoneyChangeEntity> seeAgentReturn(QueryRequest request, MemberEntity memberEntity) {
        log.info("会员算力查询---返利详情");
        Page<MemberAccountMoneyChangeEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MemberAccountMoneyChangeEntity> memberAccountMoneyChangeEntitys = basicSettingMapper.seeAgentReturn(page, memberEntity);
        return memberAccountMoneyChangeEntitys;
    }
    @Override
    public IPage<MemberAccountMoneyChangeEntity> seeReturn(QueryRequest request, MemberEntity memberEntity) {
        log.info("会员算力查询---挖矿详情");
        Page<MemberAccountMoneyChangeEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MemberAccountMoneyChangeEntity> memberAccountMoneyChangeEntitys = basicSettingMapper.seeReturn(page, memberEntity);
        return memberAccountMoneyChangeEntitys;
    }
    @Override
    public IPage<YdOrderEntity> seeOrder(QueryRequest request, MemberEntity memberEntity) {
        log.info("会员算力查询---订单详情");
        Page<YdOrderEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<YdOrderEntity> ydOrderEntitys = basicSettingMapper.seeOrder(page, memberEntity);
        return ydOrderEntitys;
    }
    @Override
    @Transactional
    public FebsResponse addIsTraderOn(Long id) {
        MemberEntity memberEntity = memberMapper.selectById(id);
        if(ObjectUtil.isEmpty(memberEntity)) {
            return new FebsResponse().fail().message("会员信息不存在");
        }
        memberEntity.setIsTrader(MemberEntity.ISTRADER_Y);
        memberMapper.updateById(memberEntity);
        return new FebsResponse().success();
    }
    @Override
    @Transactional
    public FebsResponse delIsTraderOn(Long id) {
        MemberEntity memberEntity = memberMapper.selectById(id);
        if(ObjectUtil.isEmpty(memberEntity)) {
            return new FebsResponse().fail().message("会员信息不存在");
        }
        memberEntity.setIsTrader(MemberEntity.ISTRADER_N);
        memberMapper.updateById(memberEntity);
        return new FebsResponse().success();
    }
    @Override
    public YdProductEntity getydProductUpdateById(long id) {
        return basicSettingMapper.getydProductById(id);
    }
    @Override
    @Transactional
    public FebsResponse ydProductUpdateOn(YdProductEntity ydProductEntity) {
        Long id = ydProductEntity.getId();
        YdProductEntity ydProductEntityOld = ydProductMapper.selectById(id);
        String name = ydProductEntity.getName();
        ydProductEntityOld.setName(name);
        BigDecimal totalT = ydProductEntity.getTotalT();
        ydProductEntityOld.setTotalT(totalT);
        BigDecimal surplusT = ydProductEntity.getSurplusT();
        ydProductEntityOld.setSurplusT(surplusT);
        BigDecimal salePrice = ydProductEntity.getSalePrice();
        ydProductEntityOld.setSalePrice(salePrice);
        Integer proCycle = ydProductEntity.getProCycle();
        ydProductEntityOld.setProCycle(proCycle);
        BigDecimal manageExpense = ydProductEntity.getManageExpense();
        ydProductEntityOld.setManageExpense(manageExpense);
        Integer shelvesDays = ydProductEntity.getShelvesDays();
        ydProductEntityOld.setShelvesDays(shelvesDays);
        Integer limitedNum = ydProductEntity.getLimitedNum();
        ydProductEntityOld.setLimitedNum(limitedNum);
        Integer status = ydProductEntity.getStatus();
        ydProductEntityOld.setStatus(status);
        ydProductMapper.updateById(ydProductEntityOld);
        return new FebsResponse().success();
    }
}