| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.mapper.UserPointMapper; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.YearMonth; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private UserPointService userPointService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | /** |
| | |
| | | * 积分统计 |
| | | */ |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "积分统计", tags = "管理后台-财务统计-用户积分统计") |
| | | public R<UserPointStatistics> statistics(UserPoint userPoint) { |
| | | List<AppUser> appUserList = appUserService.list(); |
| | | Integer totalPoint = 0; |
| | | Integer consumePoint = 0; |
| | | Integer sharePoint = 0; |
| | | List<UserPoint> userPointList = userPointService.list(); |
| | | UserPointStatistics userPointStatistics = new UserPointStatistics(); |
| | | userPointStatistics.setTotalPoint(totalPoint); |
| | | userPointStatistics.setConsumePoint(consumePoint); |
| | | userPointStatistics.setSharePoint(sharePoint); |
| | | return null; |
| | | return R.ok(userPointService.getStatistics(userPoint)); |
| | | } |
| | | |
| | | /** |
| | | * 变更记录 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "积分变更记录", tags = "管理后台-财务统计-用户积分统计") |
| | | public R<Page<UserPoint>> list(@ApiParam("页码") @RequestParam Integer pageNum, @ApiParam("大小") Integer pageSize, UserPoint userPoint) { |
| | | List<String> userIds = appUserService.listObjs(new LambdaQueryWrapper<AppUser>() |
| | | .select(AppUser::getId) |
| | | .eq(AppUser::getPhone, userPoint.getPhone()) |
| | | .like(AppUser::getName, userPoint.getUserName()), String::valueOf); |
| | | |
| | | Page<UserPoint> page = userPointService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<UserPoint>() |
| | | .in(!CollectionUtils.isEmpty(userIds), UserPoint::getAppUserId, userIds) |
| | | .eq(UserPoint::getType, userPoint.getType()) |
| | | .between(UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime()) |
| | | .orderByDesc(UserPoint::getCreateTime)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | @GetMapping("/export") |
| | | @ApiOperation(value = "积分变更记录导出", tags = "管理后台-财务统计-用户积分统计") |
| | | public void export(HttpServletResponse response, UserPoint userPoint) { |
| | | List<String> userIds = appUserService.listObjs(new LambdaQueryWrapper<AppUser>() |
| | | .select(AppUser::getId) |
| | | .eq(AppUser::getPhone, userPoint.getPhone()) |
| | | .like(AppUser::getName, userPoint.getUserName()), String::valueOf); |
| | | |
| | | List<UserPoint> userPointList = userPointService.list(new LambdaQueryWrapper<UserPoint>() |
| | | .in(!CollectionUtils.isEmpty(userIds), UserPoint::getAppUserId, userIds) |
| | | .eq(UserPoint::getType, userPoint.getType()) |
| | | .between(UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime()) |
| | | .orderByDesc(UserPoint::getCreateTime)); |
| | | |
| | | ExcelUtil<UserPoint> util = new ExcelUtil<UserPoint>(UserPoint.class); |
| | | util.exportExcel(response, userPointList, "用户积分统计"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |