| | |
| | | package com.xcong.excoin.modules.yunding.service.Impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | for(YdProductVo ydProductVo : records){ |
| | | ydProductVo.setProfitT(prifitT); |
| | | |
| | | if(ydProductVo.getTotalT().compareTo(BigDecimal.ZERO) < 1) { |
| | | if(ydProductVo.getSurplusT().compareTo(BigDecimal.ZERO) < 1) { |
| | | ydProductVo.setStatus(2); |
| | | } |
| | | |
| | | Integer shelvesDays = ydProductVo.getShelvesDays(); |
| | | String proUnit = ydProductVo.getProUnit(); |
| | | if(shelvesDays == 0){ |
| | | ydProductVo.setShelvesDaysStr("待定"); |
| | | }else{ |
| | | ydProductVo.setShelvesDaysStr(proUnit+"+"+shelvesDays); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | *产出规则 |
| | | */ |
| | | Date date = DateUtil.date(); |
| | | ydProductVo.setNowTime(date); |
| | | //上架天数 |
| | | Integer shelvesDays = ydProductVo.getShelvesDays(); |
| | | String proUnit = ydProductVo.getProUnit(); |
| | | if(shelvesDays == 0){ |
| | | ydProductVo.setGetType(2); |
| | | ydProductVo.setShelvesDaysStr("待定"); |
| | | }else{ |
| | | ydProductVo.setGetType(1); |
| | | ydProductVo.setShelvesDaysStr(proUnit+"+"+shelvesDays); |
| | | } |
| | | |
| | | Date date = DateUtil.date(); |
| | | ydProductVo.setNowTime(date); |
| | | Date workTime = DateUtil.offsetDay(date, shelvesDays); |
| | | ydProductVo.setWorkTime(workTime); |
| | | //服务周期 |
| | |
| | | Date endTime = DateUtil.offsetDay(workTime, proCycle); |
| | | ydProductVo.setEndTime(endTime); |
| | | |
| | | if (ydProductVo.getTotalT().compareTo(BigDecimal.ZERO) < 1) { |
| | | if (ydProductVo.getSurplusT().compareTo(BigDecimal.ZERO) < 1) { |
| | | ydProductVo.setStatus(2); |
| | | } else { |
| | | ydProductVo.setStatus(1); |
| | | } |
| | | return Result.ok(ydProductVo); |
| | | } |
| | |
| | | "USDT", 1, 3, ydOrderEntity.getId()); |
| | | |
| | | yunDingProducter.sendYunDingUsdtProfit(ydOrderEntity.getId()); |
| | | yunDingProducter.sendYunDingAutoAgent(ydOrderEntity.getMemberId()); |
| | | return Result.ok("支付成功"); |
| | | } |
| | | |
| | |
| | | |
| | | MemberEntity memberEntity = LoginUserUtils.getAppLoginUser(); |
| | | Long memberId = memberEntity.getId(); |
| | | // Long memberId = 442L; |
| | | // Long memberId = 447L; |
| | | OrderAllInfoVo orderAllInfoVo = new OrderAllInfoVo(); |
| | | DecimalFormat decimalFormat = new DecimalFormat("0.0000#"); |
| | | //历史总收益 |
| | |
| | | if(CollUtil.isNotEmpty(PowerNowQuery)){ |
| | | for(YdOrderEntity order : PowerNowQuery){ |
| | | int quantity = order.getQuantity(); |
| | | powerNow = powerNow + quantity; |
| | | Long productId = order.getProductId(); |
| | | YdProductEntity ydProductEntity = ydProductDao.selectById(productId); |
| | | if("XCH".equals(ydProductEntity.getCoin())){ |
| | | Integer proNum = ydProductEntity.getProNum(); |
| | | powerNow = powerNow + quantity*proNum; |
| | | } |
| | | } |
| | | } |
| | | orderAllInfoVo.setPowerNow(powerNow); |
| | |
| | | if(CollUtil.isNotEmpty(powerReradyQuerys)){ |
| | | for(YdOrderEntity order : powerReradyQuerys){ |
| | | int quantity = order.getQuantity(); |
| | | powerReady = powerReady + quantity; |
| | | Long productId = order.getProductId(); |
| | | YdProductEntity ydProductEntity = ydProductDao.selectById(productId); |
| | | if("XCH".equals(ydProductEntity.getCoin())){ |
| | | Integer proNum = ydProductEntity.getProNum(); |
| | | powerReady = powerReady + quantity*proNum; |
| | | } |
| | | } |
| | | } |
| | | orderAllInfoVo.setPowerReady(powerReady); |
| | |
| | | MemberWalletCoinEntity xch = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, "XCH"); |
| | | BigDecimal totalBalance = xch.getTotalBalance(); |
| | | BigDecimal subtractTotalBalance = totalBalance.subtract(xchNum); |
| | | if(BigDecimal.ZERO.compareTo(subtractTotalBalance) >= 0){ |
| | | if(BigDecimal.ZERO.compareTo(subtractTotalBalance) > 0){ |
| | | return Result.fail("XCH数量不足"); |
| | | } |
| | | |
| | | BigDecimal availableBalance = xch.getAvailableBalance(); |
| | | BigDecimal subtractAvailableBalance = availableBalance.subtract(xchNum); |
| | | if(BigDecimal.ZERO.compareTo(subtractAvailableBalance) >= 0){ |
| | | if(BigDecimal.ZERO.compareTo(subtractAvailableBalance) > 0){ |
| | | return Result.fail("XCH数量不足"); |
| | | } |
| | | //xch减少 |
| | |
| | | |
| | | memberEntity.setAgentLevel(id.intValue()); |
| | | LoginUserUtils.resetAppLoginUser(memberEntity); |
| | | yunDingProducter.sendYunDingAutoAgent(memberId); |
| | | yunDingProducter.sendYunDingUsdtProfit(orderEntity.getId()); |
| | | return Result.ok("购买成功"); |
| | | } |
| | |
| | | return Result.ok(xchNewPrices); |
| | | } |
| | | |
| | | @Override |
| | | public Result getTeamList(TeamInfoDto teamInfoDto) { |
| | | log.info("获取团队信息"); |
| | | MemberEntity memberEntity = LoginUserUtils.getAppLoginUser(); |
| | | Long memberId = memberEntity.getId(); |
| | | // Long memberId = 444L; |
| | | // MemberEntity memberEntity = memberDao.selectById(memberId); |
| | | /** |
| | | * 获取团队总人数,总购买数 |
| | | * 详细列表 |
| | | * |
| | | */ |
| | | TeamVo teamVo = new TeamVo(); |
| | | //团队总人数 |
| | | int memberNum = 0; |
| | | String inviteId = memberEntity.getInviteId(); |
| | | List<MemberEntity> memberEntityList = ydOrderDao.selectMemberByInviteId(inviteId); |
| | | if(CollUtil.isNotEmpty(memberEntityList)){ |
| | | memberNum = memberEntityList.size(); |
| | | } |
| | | teamVo.setMemberNum(memberNum); |
| | | //购买总算力 |
| | | |
| | | int allPower =0; |
| | | List<YdOrderEntity> ydOrderEntitys = ydOrderDao.selectListByMemberIdAndElse(inviteId); |
| | | if(CollUtil.isNotEmpty(ydOrderEntitys)){ |
| | | for(YdOrderEntity ydOrderEntity : ydOrderEntitys){ |
| | | Long productId = ydOrderEntity.getProductId(); |
| | | YdProductEntity ydProductEntity = ydProductDao.selectById(productId); |
| | | if("XCH".equals(ydProductEntity.getCoin())){ |
| | | Integer proNum = ydProductEntity.getProNum(); |
| | | Integer quantity = ydOrderEntity.getQuantity(); |
| | | allPower = allPower + proNum*quantity; |
| | | } |
| | | } |
| | | } |
| | | teamVo.setAllPower(allPower); |
| | | //详细列表 |
| | | Page<TeamInfoVo> page = new Page<>(teamInfoDto.getPageNum(), teamInfoDto.getPageSize()); |
| | | IPage<TeamInfoVo> teamInfoVos = ydOrderDao.getTeamInfoList(page, memberEntity); |
| | | List<TeamInfoVo> records = teamInfoVos.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(TeamInfoVo teamInfoVo : records){ |
| | | String phone = teamInfoVo.getInvitephone(); |
| | | if(StrUtil.isNotEmpty(phone)){ |
| | | teamInfoVo.setInvitephone(StrUtil.subSufByLength(phone,4)); |
| | | } |
| | | //下属团队人数 |
| | | int memberNumInvite = 0; |
| | | List<MemberEntity> memberEntityInviteList = ydOrderDao.selectMemberByInviteId(phone); |
| | | if(CollUtil.isNotEmpty(memberEntityInviteList)){ |
| | | memberNumInvite = memberEntityInviteList.size(); |
| | | } |
| | | teamInfoVo.setMemberNum(memberNumInvite); |
| | | //下属团队总算力 |
| | | int powerNum =0; |
| | | List<YdOrderEntity> ydOrderEntityLevel = ydOrderDao.selectListByMemberIdAndElse(inviteId); |
| | | if(CollUtil.isNotEmpty(ydOrderEntityLevel)){ |
| | | for(YdOrderEntity ydOrderEntity : ydOrderEntityLevel){ |
| | | Long productId = ydOrderEntity.getProductId(); |
| | | YdProductEntity ydProductEntity = ydProductDao.selectById(productId); |
| | | if("XCH".equals(ydProductEntity.getCoin())){ |
| | | Integer proNum = ydProductEntity.getProNum(); |
| | | Integer quantity = ydOrderEntity.getQuantity(); |
| | | powerNum = powerNum + proNum*quantity; |
| | | } |
| | | } |
| | | } |
| | | teamInfoVo.setPowerNum(powerNum); |
| | | } |
| | | } |
| | | teamVo.setTeamInfoVos(records); |
| | | return Result.ok(teamVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 去加减币币账户余额,减少产品的剩余数目 |