| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | 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 io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | 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; |
| | |
| | | private UserPointService userPointService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/transferPoint") |
| | | @ApiOperation("转赠积分") |
| | | public R<Void> transferPoint(@ApiParam("积分") BigDecimal point, @ApiParam("手机号") Long phone) { |
| | | AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getPhone, phone)); |
| | | if (null == appUser) { |
| | | return R.fail("用户不存在"); |
| | | } |
| | | public R<Void> transferPoint(@ApiParam("积分") @RequestParam BigDecimal point, @ApiParam("手机号") @RequestParam String phone) { |
| | | userPointService.transferPoint(point, phone); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | userPointService.save(userPoint); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 积分统计 |
| | | */ |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "积分统计", tags = "管理后台-财务统计-用户积分统计") |
| | | public R<UserPointStatistics> statistics(UserPoint userPoint) { |
| | | return R.ok(userPointService.getStatistics(userPoint)); |
| | | } |
| | | |
| | | /** |
| | | * 变更记录 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "积分变更记录", tags = "管理后台-财务统计-用户积分统计") |
| | | public R<IPage<UserPoint>> list(UserPoint userPoint) { |
| | | IPage<UserPoint> userPointPage = userPointService.getUserPointPage(Page.of(userPoint.getPageNum(), userPoint.getPageSize()), userPoint); |
| | | return R.ok(userPointPage); |
| | | } |
| | | |
| | | @GetMapping("/user/list") |
| | | @ApiOperation(value = "积分管理-用户积分明细(必传用户id)", tags = "后台") |
| | | public R<Page<UserPoint>> userlist(UserPoint userPoint) { |
| | | Page<UserPoint> page = userPointService.lambdaQuery().eq(UserPoint::getAppUserId, userPoint.getAppUserId()).orderByDesc(UserPoint::getCreateTime).page(Page.of(userPoint.getPageNum(), userPoint.getPageSize())); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | @GetMapping("/export") |
| | | @ApiOperation(value = "积分变更记录导出", tags = "管理后台-财务统计-用户积分统计") |
| | | public void export(HttpServletResponse response, UserPoint userPoint) { |
| | | IPage<UserPoint> userPointPage = userPointService.getUserPointPage(Page.of(1, Integer.MAX_VALUE), userPoint); |
| | | List<UserPoint> userPointList = userPointPage.getRecords(); |
| | | ExcelUtil<UserPoint> util = new ExcelUtil<>(UserPoint.class); |
| | | util.exportExcel(response, userPointList, "用户积分统计"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |