package com.yami.trading.admin.controller; import com.yami.trading.admin.dto.HomeViewDto; import com.yami.trading.admin.dto.WaitCountDto; import com.yami.trading.bean.user.dto.UserBenefitsDto; import com.yami.trading.common.domain.Result; import com.yami.trading.common.util.DateUtil; import com.yami.trading.service.*; import com.yami.trading.service.user.UserDataService; import com.yami.trading.service.user.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Date; @RestController @RequestMapping("home") @Api(tags = "首页") @Slf4j public class HomeController { @Autowired UserService userService; @Autowired UserDataService userDataService; @Autowired WalletService walletService; @Autowired RealNameAuthRecordService realNameAuthRecordService; @Autowired HighLevelAuthRecordService highLevelAuthRecordService; @Autowired RechargeBlockchainOrderService rechargeBlockchainOrderService; @Autowired WithdrawService withdrawService; @ApiOperation(value = "今日数据统计") @PostMapping("view") public Result view(){ HomeViewDto homeViewDto=new HomeViewDto(); homeViewDto.setAllUserCount(userService.count()); homeViewDto.setTodayUserCount(userService.countToDay()); Date date=new Date(); log.info(DateUtil.formatDate(date,"yyyy-MM-dd HH:mm:ss")); log.info(DateUtil.formatDate(DateUtil.minDate(date),"yyyy-MM-dd HH:mm:ss")); log.info(DateUtil.formatDate(DateUtil.maxDate(date),"yyyy-MM-dd HH:mm:ss")); UserBenefitsDto userBenefitsDto= userDataService.daySumData(DateUtil.minDate(date),DateUtil.maxDate(date),null); homeViewDto.setSumUsdtAmount(walletService.sumMoney()); homeViewDto.setTodayRechargeUserCount(userDataService.countTodayRechargeUser()); if (userBenefitsDto!=null){ homeViewDto.setRecharge(userBenefitsDto.getRechargeUsdt()); homeViewDto.setWithdraw(userBenefitsDto.getWithdraw()); homeViewDto.setBalanceAmount(userBenefitsDto.getWithdraw().subtract(userBenefitsDto.getRechargeUsdt())); homeViewDto.setTotleIncome(userBenefitsDto.getTotleIncome()); } return Result.ok(homeViewDto); } @ApiOperation(value = "待处理统计数据") @PostMapping("waitCount") public Result waitCount(){ WaitCountDto waitCountDto=new WaitCountDto(); waitCountDto.setHighLevelAuthCount(highLevelAuthRecordService.waitCount()); waitCountDto.setRealNameAuthCount(realNameAuthRecordService.waitCount()); waitCountDto.setWithdrawCount(withdrawService.waitCount()); waitCountDto.setRechargeCount(rechargeBlockchainOrderService.waitCount()); return Result.ok(waitCountDto); } }