package com.gear.admin.Biz.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.gear.admin.Biz.SwxStatisticsBiz; import com.gear.common.constant.SwxConstons; import com.gear.swx.domain.*; import com.gear.swx.service.*; import com.gear.swx.service.impl.SwxUserServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Queue; @Component public class SwxStatisticsBizImpl implements SwxStatisticsBiz { @Autowired private ISwxRechargeRecordService swxRechargeRecordService; @Autowired private ISwxWithdrawalRecordService swxWithdrawalRecordService; @Autowired private ISwxLoanRecordService swxLoanRecordService; @Autowired private ISwxOptionsOrderService swxOptionsOrderService; @Autowired private ISwxSmartOrderService swxSmartOrderService; @Autowired private ISwxNftService swxNftService; @Autowired private ISwxIdentificationService swxIdentificationService; @Autowired private ISwxUserService swxUserService; @Override public Map getTop() { Map result = new HashMap<>(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateNow = simpleDateFormat.format(new Date()); //获取今天开始时间 String startTime = dateNow + " 00:00:00"; //获取今天结束时间 String endTime = dateNow + " 23:59:59"; //今日充值 QueryWrapper swxRechargeRecordQueryWrapper = new QueryWrapper<>(); swxRechargeRecordQueryWrapper.lambda().ge(SwxRechargeRecord::getCreateTime,startTime); swxRechargeRecordQueryWrapper.lambda().le(SwxRechargeRecord::getCreateTime,endTime); swxRechargeRecordQueryWrapper.lambda().eq(SwxRechargeRecord::getStatus, SwxConstons.SWX_EXAMINE_STATUS_REVIEW); Long rechargeCount = swxRechargeRecordService.count(swxRechargeRecordQueryWrapper); result.put("rechargeCount",rechargeCount); //今日提现 QueryWrapper swxWithdrawalRecordQueryWrapper = new QueryWrapper<>(); swxWithdrawalRecordQueryWrapper.lambda().ge(SwxWithdrawalRecord::getCreateTime,startTime); swxWithdrawalRecordQueryWrapper.lambda().le(SwxWithdrawalRecord::getCreateTime,endTime); swxWithdrawalRecordQueryWrapper.lambda().eq(SwxWithdrawalRecord::getStatus, SwxConstons.SWX_EXAMINE_STATUS_REVIEW); Long withdrawalCount = swxWithdrawalRecordService.count(swxWithdrawalRecordQueryWrapper); result.put("withdrawalCount",withdrawalCount); //今日贷款 QueryWrapper swxLoanRecordQueryWrapper = new QueryWrapper<>(); swxLoanRecordQueryWrapper.lambda().ge(SwxLoanRecord::getCreateTime,startTime); swxLoanRecordQueryWrapper.lambda().le(SwxLoanRecord::getCreateTime,endTime); swxLoanRecordQueryWrapper.lambda().eq(SwxLoanRecord::getStatus, SwxConstons.SWX_EXAMINE_STATUS_REVIEW); Long loanCount = swxLoanRecordService.count(swxLoanRecordQueryWrapper); result.put("loanCount",loanCount); //今日期权 QueryWrapper swxOptionsOrderQueryWrapper = new QueryWrapper<>(); swxOptionsOrderQueryWrapper.lambda().ge(SwxOptionsOrder::getCreateTime,startTime); swxOptionsOrderQueryWrapper.lambda().le(SwxOptionsOrder::getCreateTime,endTime); Long optionsCount = swxOptionsOrderService.count(swxOptionsOrderQueryWrapper); result.put("optionsCount",optionsCount); //今日实名 QueryWrapper swxIdentificationQueryWrapper = new QueryWrapper<>(); swxIdentificationQueryWrapper.lambda().ge(SwxIdentification::getCreateTime,startTime); swxIdentificationQueryWrapper.lambda().le(SwxIdentification::getCreateTime,endTime); Long identification = swxIdentificationService.count(swxIdentificationQueryWrapper); result.put("identificationCount",identification); return result; } @Override public Map getIndexTop() { Map result = new HashMap<>(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateNow = simpleDateFormat.format(new Date()); //获取今天开始时间 String startTime = dateNow + " 00:00:00"; //获取今天结束时间 String endTime = dateNow + " 23:59:59"; //查询累计充值 QueryWrapper swxRechargeRecordQueryWrapper = Wrappers.query(); swxRechargeRecordQueryWrapper.select("SUM(amount) AS total"); swxRechargeRecordQueryWrapper.lambda().eq(SwxRechargeRecord::getStatus,1); Map allRechargeMap = swxRechargeRecordService.getMap(swxRechargeRecordQueryWrapper); result.put("allRecharge",allRechargeMap == null ? 0:allRechargeMap.get("total")); //查询累计提现 QueryWrapper swxWithdrawalRecordQueryWrapper = new QueryWrapper<>(); swxWithdrawalRecordQueryWrapper.select("SUM(amount) AS total"); swxWithdrawalRecordQueryWrapper.lambda().eq(SwxWithdrawalRecord::getStatus,1); Map allWithdrawalMap = swxWithdrawalRecordService.getMap(swxWithdrawalRecordQueryWrapper); result.put("allWithdrawal",allWithdrawalMap == null ? 0:allWithdrawalMap.get("total")); //查询今日充值 swxRechargeRecordQueryWrapper.lambda().ge(SwxRechargeRecord::getCreateTime,startTime); swxRechargeRecordQueryWrapper.lambda().le(SwxRechargeRecord::getCreateTime,endTime); Map todayRechargeMap = swxRechargeRecordService.getMap(swxRechargeRecordQueryWrapper); result.put("todayRecharge",todayRechargeMap == null ? 0:todayRechargeMap.get("total")); //查询今日提现 swxWithdrawalRecordQueryWrapper.lambda().ge(SwxWithdrawalRecord::getCreateTime,startTime); swxWithdrawalRecordQueryWrapper.lambda().le(SwxWithdrawalRecord::getCreateTime,endTime); Map todayWithdarwalMap = swxWithdrawalRecordService.getMap(swxWithdrawalRecordQueryWrapper); result.put("todayWithdarwal",todayWithdarwalMap == null ? 0:todayWithdarwalMap.get("total")); //查询贷款总额 QueryWrapper swxLoanRecordQueryWrapper = new QueryWrapper<>(); swxLoanRecordQueryWrapper.select("SUM(amount) AS total"); swxLoanRecordQueryWrapper.lambda().ge(SwxLoanRecord::getStatus,1); Map allLoanMap = swxLoanRecordService.getMap(swxLoanRecordQueryWrapper); result.put("allLoan",allLoanMap == null ? 0 : allLoanMap.get("total")); //获取总期权交易 QueryWrapper swxOptionsOrderQueryWrapper = new QueryWrapper<>(); swxOptionsOrderQueryWrapper.select("SUM(amount) as total"); swxOptionsOrderQueryWrapper.lambda().eq(SwxOptionsOrder::getStatus,1); Map allOptions = swxOptionsOrderService.getMap(swxOptionsOrderQueryWrapper); result.put("allOptions",allOptions == null ? 0 : allOptions.get("total")); //获取总用户数 result.put("allUser",swxUserService.count()); //获取总合约数 result.put("allContracts",0); return result; } }