xiaoyong931011
2022-03-04 2e2eeeb8291415706f4941e55270a0b23e76bf23
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -4,6 +4,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.date.DateUtil;
@@ -11,8 +12,11 @@
import com.xcong.excoin.modules.coin.dao.ZhiYaRecordDao;
import com.xcong.excoin.modules.coin.dao.ZhiyaRewardDao;
import com.xcong.excoin.modules.coin.entity.*;
import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto;
import com.xcong.excoin.modules.coin.parameter.dto.ZhiyaRewardRecordsPageDto;
import com.xcong.excoin.modules.coin.parameter.vo.*;
import com.xcong.excoin.modules.member.dao.*;
import com.xcong.excoin.modules.member.entity.*;
import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -28,12 +32,6 @@
import com.xcong.excoin.modules.coin.mapper.MemberAccountMoneyChangeMapper;
import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
import com.xcong.excoin.modules.coin.service.CoinService;
import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
import com.xcong.excoin.utils.CoinTypeConvert;
import com.xcong.excoin.utils.MessageSourceUtils;
@@ -62,6 +60,10 @@
    ZhiYaRecordDao zhiYaRecordDao;
    @Resource
    ZhiyaRewardDao zhiyaRewardDao;
    @Resource
    MemberCoinChargeDao memberCoinChargeDao;
    @Resource
    MemberCoinWithdrawDao memberCoinWithdrawDao;
    @Resource
    ZhiYaDao zhiYaDao;
    @Resource
@@ -150,7 +152,7 @@
            memberWalletCoinlist.add(coin);
//            coin.setWalletCode(CoinTypeEnum.GUSD.toString());
//            memberWalletCoinlist.add(coin);
            coin.setWalletCode(CoinTypeEnum.GOLDRICE.toString());
            coin.setWalletCode(CoinTypeEnum.GRICE.toString());
            memberWalletCoinlist.add(coin);
            MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
@@ -774,6 +776,9 @@
//            zhiYaRecord.setEffectDate(newDate);
//            zhiYaRecordDao.updateById(zhiYaRecord);
//        }
        //更新团队算力表
        //只计算直属团队的算力信息
        return Result.ok(MessageSourceUtils.getString("member_service_0024"));
    }
@@ -864,7 +869,7 @@
    @Override
    @Transactional
    public void grantZhiyaAmount() {
        //获取每日总奖励
        //获取每日总产出
        BigDecimal gusdReward = new BigDecimal(redisUtils.getString("GUSDREWARD"));
        //获取每日质押总数
        Long totalGusd = zhiYaRecordDao.selectTotalGusdByStatueAndTime(1,new Date());
@@ -884,6 +889,10 @@
                    zhiyaRewardEntity.setMemberId(zhiYaRecordEntity.getMemberId());
                    zhiyaRewardEntity.setRewardAmout(divide.multiply(zhiYaRecordEntity.getZhiyaCnt()));
                    zhiyaRewardDao.insert(zhiyaRewardEntity);
                    //给团队上级发送奖励goldrice
                    //给账户的冻结
                }
            }
        }
@@ -903,6 +912,124 @@
        return Result.ok(lists);
    }
    @Override
    public Result coinInList(@Valid CoinInListDto coinInListDto) {
        //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        int type = coinInListDto.getType();
        //充币记录
        if(type == 1) {
            Page<MemberCoinChargeEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            MemberCoinChargeEntity memberCoinChargeEntity = new MemberCoinChargeEntity();
            memberCoinChargeEntity.setMemberId(memberId);
            IPage<MemberCoinChargeEntity> memberCoinCharge = memberCoinChargeDao.findMemberCoinChargeInPage(page, memberCoinChargeEntity);
            List<MemberCoinChargeEntity> records = memberCoinCharge.getRecords();
            Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            if(CollUtil.isNotEmpty(records)) {
                ArrayList<CoinInListVo> arrayList = new ArrayList<>();
                for(MemberCoinChargeEntity memberCoinChargeEntitys : records) {
                    CoinInListVo coinInListVo = new CoinInListVo();
                    coinInListVo.setSymbol(memberCoinChargeEntitys.getSymbol());
                    coinInListVo.setAmount(memberCoinChargeEntitys.getAmount().toPlainString());
                    coinInListVo.setContent("充币");
                    coinInListVo.setStatus(memberCoinChargeEntitys.getStatus());
                    coinInListVo.setUpdateTime(memberCoinChargeEntitys.getUpdateTime());
                    arrayList.add(coinInListVo);
                }
                responsePage.setRecords(arrayList);
            }
            return Result.ok(responsePage);
        }
        //提币记录
        if(type == 2) {
            Page<MemberCoinWithdrawEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
            memberCoinWithdrawEntity.setMemberId(memberId);
            IPage<MemberCoinWithdrawEntity> memberCoinWithdraw = memberCoinWithdrawDao.findMemberCoinWithdrawInPage(page, memberCoinWithdrawEntity);
            List<MemberCoinWithdrawEntity> records = memberCoinWithdraw.getRecords();
            Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            if(CollUtil.isNotEmpty(records)) {
                ArrayList<CoinInListVo> arrayList = new ArrayList<>();
                for(MemberCoinWithdrawEntity memberCoinWithdrawEntitys : records) {
                    CoinInListVo coinInListVo = new CoinInListVo();
                    coinInListVo.setSymbol(memberCoinWithdrawEntitys.getSymbol());
                    coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount().toPlainString());
                    coinInListVo.setContent("提币");
                    int status = memberCoinWithdrawEntitys.getStatus();
                    int statusOut = 0;
                    if(status == 1) {
                        statusOut = 0;
                    }
                    if(status == 2) {
                        statusOut = 1;
                    }
                    if(status == 3) {
                        statusOut = 2;
                    }
                    coinInListVo.setStatus(statusOut);
                    coinInListVo.setUpdateTime(memberCoinWithdrawEntitys.getUpdateTime());
                    coinInListVo.setIsInside(memberCoinWithdrawEntitys.getIsInside());
                    arrayList.add(coinInListVo);
                }
                responsePage.setRecords(arrayList);
            }
            return Result.ok(responsePage);
        }
        //划转记录
        if(type == 3) {
            Page<MemberAccountMoneyChange> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
            memberAccountMoneyChange.setMemberId(memberId);
            IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.coinInList(page, memberAccountMoneyChange);
            List<MemberAccountMoneyChange> records = list.getRecords();
            Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            if(CollUtil.isNotEmpty(records)) {
                ArrayList<CoinInListVo> arrayList = new ArrayList<>();
                for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
                    CoinInListVo coinInListVo = new CoinInListVo();
                    coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
                    coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
                    coinInListVo.setContent(memberAccountMoneyChanges.getContent());
                    coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
                    coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
                    arrayList.add(coinInListVo);
                }
                responsePage.setRecords(arrayList);
            }
            return Result.ok(responsePage);
        }
        //其他记录
        if(type == 4) {
            Page<OrderCoinsDealEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
            memberAccountMoneyChange.setMemberId(memberId);
            IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(page, memberAccountMoneyChange);
            List<MemberAccountMoneyChange> records = list.getRecords();
            Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
            if(CollUtil.isNotEmpty(records)) {
                ArrayList<CoinInListVo> arrayList = new ArrayList<>();
                for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
                    CoinInListVo coinInListVo = new CoinInListVo();
                    coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
                    coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
                    coinInListVo.setContent(memberAccountMoneyChanges.getContent());
                    coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
                    coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
                    arrayList.add(coinInListVo);
                }
                responsePage.setRecords(arrayList);
            }
            return Result.ok(responsePage);
        }
        return Result.fail(MessageSourceUtils.getString("member_controller_0005"));
    }
    public String generateSimpleSerialno(String userId) {
        StringBuilder sb = new StringBuilder();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");