From 13603d06c6740ceb1238ae0c6c9bc6d1b810703f Mon Sep 17 00:00:00 2001 From: huangyawei Date: Sat, 10 Aug 2024 11:43:43 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E6=8A=BD=E5=A5=96=E8=AF=A6=E6=83=85?= =?UTF-8?q?(PC)=20=E6=8A=BD=E5=A5=96=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8(P?= =?UTF-8?q?C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/controller/PointController.java | 631 +++++++++--------- .../com/luoo/user/service/LotteryService.java | 111 ++- .../luoo/user/vo/point/LotteryDetailPCVO.java | 105 +++ .../user/vo/point/LotteryUserDetailPCVO.java | 41 ++ 4 files changed, 580 insertions(+), 308 deletions(-) create mode 100644 luoo_user/src/main/java/com/luoo/user/vo/point/LotteryDetailPCVO.java create mode 100644 luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserDetailPCVO.java diff --git a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java index f34b4ef..270a268 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java @@ -9,9 +9,7 @@ import com.luoo.user.service.DrawLotteryService; import com.luoo.user.service.LotteryService; import com.luoo.user.service.TaskPointService; import com.luoo.user.service.UserPointLogService; -import com.luoo.user.vo.point.LotteryAPPVO; -import com.luoo.user.vo.point.LotteryPCVO; -import com.luoo.user.vo.point.UserPointLogVO; +import com.luoo.user.vo.point.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -49,120 +47,120 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = "积分模块") public class PointController { - @Autowired - private TaskPointService taskPointService; - - @Autowired - private UserPointLogService userPointLogService; - - @Autowired - private LotteryService lotteryService; - - @Autowired - private DrawLotteryService drawLotteryService; - - - @ApiOperation(value = "1.1.新增任务积分配置(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/task/add") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "taskPoint", value = "任务积分配置", required = true, dataType = "TaskPoint", paramType = "body"), - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header")}) - public Result add( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody TaskPointDto taskPointDto) { - TaskPoint taskPoint = new TaskPoint(); - BeanUtils.copyProperties(taskPointDto, taskPoint); - taskPointService.add(taskPoint, authorization); - return Result.success(); - } - - @ApiOperation(value = "1.2.修改任务积分配置(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/task/update") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "taskPoint", value = "任务积分配置", required = true, dataType = "TaskPoint", paramType = "body"), - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header")} - ) - public Result update( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody TaskPointDto taskPointDto) { - TaskPoint taskPoint = new TaskPoint(); - BeanUtils.copyProperties(taskPointDto, taskPoint); - taskPointService.update(taskPoint, authorization); - return Result.success(); - } - - @ApiOperation(value = "1.3.批量修改任务积分配置(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/task/batch/update") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "taskPoints", value = "任务积分配置", required = true, dataType = "List", paramType = "body")} - ) - public Result batchUpdate( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody List taskPoints) { - taskPointService.batchUpdate(taskPoints, authorization); - return Result.success(); - } - - @ApiOperation(value = "1.4.批量禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/task/batch/disable") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "ids", value = "任务积分配置id", required = true, dataType = "List", paramType = "body"), - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "valid", value = "是否生效 1-生效 2-不生效", required = true, dataType = "Integer", paramType = "query") - } - ) - public Result batchDisable( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody List ids, - @RequestParam Integer valid) { - taskPointService.batchDisable(ids, authorization, valid); - return Result.success(); - } - - @ApiOperation(value = "1.5.禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/task/disable") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "任务积分配置id", required = true, dataType = "String", paramType = "body"), - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "valid", value = "是否生效 1-生效 2-不生效", required = true, dataType = "Integer", paramType = "query") - }) - public Result disable( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestParam String id, - @RequestParam Integer valid) { - taskPointService.disable(id, authorization, valid); - return Result.success(); - } - - @ApiOperation(value = "1.6. 任务积分列表(PC)", notes = "任务积分列表") - @GetMapping("/task/list/{page}/{size}") - @GlobalInterceptor(checkAdminLogin = true) - public Result> getUnApproveList( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success(taskPointService.getTaskPointList(page, size)); - } - - @ApiOperation(value = "1.7. 任务积分列表(APP)", notes = "任务积分列表") - @GetMapping("/task/list/app") - @GlobalInterceptor(checkAppUserLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "type", value = "任务类型 1-新手任务 2-日常任务", required = true, dataType = "Integer", paramType = "query") - }) - public Result> getUnApproveListApp( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "任务类型 1-新手任务 2-日常任务", required = true) Integer type - ) { - return Result.success(taskPointService.getTaskPointListForApp(token, type)); - } + @Autowired + private TaskPointService taskPointService; + + @Autowired + private UserPointLogService userPointLogService; + + @Autowired + private LotteryService lotteryService; + + @Autowired + private DrawLotteryService drawLotteryService; + + + @ApiOperation(value = "1.1.新增任务积分配置(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/task/add") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "taskPoint", value = "任务积分配置", required = true, dataType = "TaskPoint", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header")}) + public Result add( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestBody TaskPointDto taskPointDto) { + TaskPoint taskPoint = new TaskPoint(); + BeanUtils.copyProperties(taskPointDto, taskPoint); + taskPointService.add(taskPoint, authorization); + return Result.success(); + } + + @ApiOperation(value = "1.2.修改任务积分配置(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/task/update") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "taskPoint", value = "任务积分配置", required = true, dataType = "TaskPoint", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header")} + ) + public Result update( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestBody TaskPointDto taskPointDto) { + TaskPoint taskPoint = new TaskPoint(); + BeanUtils.copyProperties(taskPointDto, taskPoint); + taskPointService.update(taskPoint, authorization); + return Result.success(); + } + + @ApiOperation(value = "1.3.批量修改任务积分配置(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/task/batch/update") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "taskPoints", value = "任务积分配置", required = true, dataType = "List", paramType = "body")} + ) + public Result batchUpdate( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestBody List taskPoints) { + taskPointService.batchUpdate(taskPoints, authorization); + return Result.success(); + } + + @ApiOperation(value = "1.4.批量禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/task/batch/disable") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "任务积分配置id", required = true, dataType = "List", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "valid", value = "是否生效 1-生效 2-不生效", required = true, dataType = "Integer", paramType = "query") + } + ) + public Result batchDisable( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestBody List ids, + @RequestParam Integer valid) { + taskPointService.batchDisable(ids, authorization, valid); + return Result.success(); + } + + @ApiOperation(value = "1.5.禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/task/disable") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "任务积分配置id", required = true, dataType = "String", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "valid", value = "是否生效 1-生效 2-不生效", required = true, dataType = "Integer", paramType = "query") + }) + public Result disable( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestParam String id, + @RequestParam Integer valid) { + taskPointService.disable(id, authorization, valid); + return Result.success(); + } + + @ApiOperation(value = "1.6. 任务积分列表(PC)", notes = "任务积分列表") + @GetMapping("/task/list/{page}/{size}") + @GlobalInterceptor(checkAdminLogin = true) + public Result> getUnApproveList( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success(taskPointService.getTaskPointList(page, size)); + } + + @ApiOperation(value = "1.7. 任务积分列表(APP)", notes = "任务积分列表") + @GetMapping("/task/list/app") + @GlobalInterceptor(checkAppUserLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "type", value = "任务类型 1-新手任务 2-日常任务", required = true, dataType = "Integer", paramType = "query") + }) + public Result> getUnApproveListApp( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "任务类型 1-新手任务 2-日常任务", required = true) Integer type + ) { + return Result.success(taskPointService.getTaskPointListForApp(token, type)); + } // @ApiOperation(value = "2.1. 用户根据新手任务获取积分", notes = "仅限app用户调用") // @PostMapping("/log/earn/task/new") @@ -192,195 +190,216 @@ public class PointController { // return Result.success(); // } - @ApiOperation(value = "2.2.用户积分日志列表APP", notes = "用户积分日志列表") - @PostMapping("/admin/log/list/{page}/{size}") - @GlobalInterceptor(checkAdminLogin = true) - public Result> getUserPointLogListForAdmin( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "查询对象") @RequestBody UserPointLogSearchDto userPointLogSearchDto, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success( - userPointLogService.getUserPointLogList(token, userPointLogSearchDto, page, size)); - } - - @ApiOperation(value = "2.3.用户积分日志列表PC", notes = "用户积分日志列表") - @PostMapping("/app/log/list/{page}/{size}") - @GlobalInterceptor(checkAppUserLogin = true) - public Result> getUserPointLogListForApp( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "查询对象") @RequestBody UserPointLogSearchDto userPointLogSearchDto, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success( - userPointLogService.getUserPointLogList(token, userPointLogSearchDto, page, size)); - } - - @ApiOperation(value = "2.4.每日签到(APP)", notes = "仅限app用户调用") - @PostMapping("/log/earn/sign") - @GlobalInterceptor(checkAppUserLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header") - }) - public Result addLogSign( - @RequestHeader(value = "Authorization", required = true) String authorization) { - userPointLogService.dailySign(authorization); - return Result.success(); - } - - @ApiOperation(value = "2.5.分享期刊(APP)", notes = "仅限app用户调用") - @PostMapping("/log/share/journal") - @GlobalInterceptor(checkAppUserLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "journalId", value = "期刊id", required = true, dataType = "String", paramType = "query") - }) - public Result addLogShareJournal( - @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestParam String journalId) { - userPointLogService.shareJournal(authorization); - return Result.success(); - } - - - @ApiOperation(value = "3.1.添加抽奖(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/lottery/add") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "lotteryAddDto", value = "抽奖信息", required = true, dataType = "LotteryAddDto", paramType = "body") - }) - public Result addLottery(@RequestHeader("Authorization") String token, - @Validated @RequestBody LotteryAddDto lotteryAddDto) { - Lottery lottery = new Lottery(); - BeanUtils.copyProperties(lotteryAddDto, lottery); - - lotteryService.add(lottery, token); - return Result.success(); - } - - @ApiOperation(value = "3.2.抽奖列表页(PC)", notes = "admin") - @PostMapping("/lottery/list/{page}/{size}") - @GlobalInterceptor(checkAdminLogin = true) - public Result> lotteryList( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success(lotteryService.lotteryPageResult(page, size, lotterySearchDto)); - } - - @ApiOperation(value = "3.3.根据抽奖id获取地区列表(APP)", notes = "仅限app权限用户调用") - @PostMapping("/lottery/region/list") - @GlobalInterceptor(checkAppUserLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "lotteryId", value = "抽奖id", required = true, dataType = "String", paramType = "query") - }) - public Result> getLotteryRegionList( - @RequestHeader("Authorization") String token, - @RequestParam String lotteryId) { - return Result.success(lotteryService.getLotteryRegionList(lotteryId)); - } - - @ApiOperation(value = "3.4.编辑抽奖(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/lottery/edit") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "lotteryUpdateDto", value = "抽奖信息", required = true, dataType = "LotteryUpdateDto", paramType = "body") - }) - public Result editLottery(@RequestHeader("Authorization") String token, - @Validated @RequestBody LotteryUpdateDto lotteryUpdateDto) { - Lottery lottery = new Lottery(); - BeanUtils.copyProperties(lotteryUpdateDto, lottery); - lotteryService.edit(lottery, token); - return Result.success(); - } - - @ApiOperation(value = "3.5.发布抽奖(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/lottery/publish") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query") - }) - public Result publishLottery(@RequestHeader("Authorization") String token, - @RequestParam String id) { - lotteryService.publish(id, token); - return Result.success(); - } - - @ApiOperation(value = "3.6.停止抽奖(PC)", notes = "仅限admin权限用户调用") - @PostMapping("/lottery/stop") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "stopReason", value = "停止原因", required = true, dataType = "String", paramType = "body") - }) - public Result stopLottery(@RequestHeader("Authorization") String token, - @NotNull String id, @RequestBody @NotNull String stopReason) { - lotteryService.stop(id, token, stopReason); - return Result.success(); - } - - @ApiOperation(value = "3.7.参与抽奖(APP)") - @PostMapping("/lottery/participate") - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataType = "Integer", paramType = "query") - }) - public Result participate(@RequestHeader("Authorization") String token, @NotNull String id, - @NotNull Integer regionId) { - lotteryService.participate(id, token, regionId); - return Result.success(); - } - - @ApiOperation(value = "3.8.自动抽奖结果(PC)", notes = "用这个方法主动触发自动抽奖结果") - @PostMapping("/lottery/auto") - @GlobalInterceptor(checkAdminLogin = true) - @ApiImplicitParams({ - @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), - @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query") - }) - public Result auto(@RequestHeader("Authorization") String token, @NotNull String id) { - drawLotteryService.auto(id, token); - return Result.success(); - } - - @ApiOperation(value = "3.9.抽奖列表页,以及本人是否已参加(APP)", notes = "APP") - @PostMapping("/lottery/list/user/{page}/{size}") - @GlobalInterceptor(checkAppUserLogin = true) - public Result> findLotteryListForApp( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success( - lotteryService.findLotteryListForApp(page, size, lotterySearchDto, token)); - } - - @ApiOperation(value = "3.10.已参与抽奖的人(APP)", notes = "APP") - @PostMapping("/lottery/participated/{page}/{size}") - @GlobalInterceptor(checkAppUserLogin = true) - public Result> findParticipatedLotteryUserList( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "抽奖id") String lotteryId, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success(lotteryService.findPageByLotteryId(page, size, lotteryId)); - } - - @ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP") - @PostMapping("/lottery/result/{id}") - @GlobalInterceptor(checkAppUserLogin = true) - public Result findLotteryResult( - @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "抽奖id", required = true) @PathVariable String id) { - return Result.success(lotteryService.getLotteryUserResult(id, token)); - } + @ApiOperation(value = "2.2.用户积分日志列表APP", notes = "用户积分日志列表") + @PostMapping("/admin/log/list/{page}/{size}") + @GlobalInterceptor(checkAdminLogin = true) + public Result> getUserPointLogListForAdmin( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "查询对象") @RequestBody UserPointLogSearchDto userPointLogSearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success( + userPointLogService.getUserPointLogList(token, userPointLogSearchDto, page, size)); + } + + @ApiOperation(value = "2.3.用户积分日志列表PC", notes = "用户积分日志列表") + @PostMapping("/app/log/list/{page}/{size}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result> getUserPointLogListForApp( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "查询对象") @RequestBody UserPointLogSearchDto userPointLogSearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success( + userPointLogService.getUserPointLogList(token, userPointLogSearchDto, page, size)); + } + + @ApiOperation(value = "2.4.每日签到(APP)", notes = "仅限app用户调用") + @PostMapping("/log/earn/sign") + @GlobalInterceptor(checkAppUserLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header") + }) + public Result addLogSign( + @RequestHeader(value = "Authorization", required = true) String authorization) { + userPointLogService.dailySign(authorization); + return Result.success(); + } + + @ApiOperation(value = "2.5.分享期刊(APP)", notes = "仅限app用户调用") + @PostMapping("/log/share/journal") + @GlobalInterceptor(checkAppUserLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "journalId", value = "期刊id", required = true, dataType = "String", paramType = "query") + }) + public Result addLogShareJournal( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestParam String journalId) { + userPointLogService.shareJournal(authorization); + return Result.success(); + } + + + @ApiOperation(value = "3.1.添加抽奖(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/lottery/add") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "lotteryAddDto", value = "抽奖信息", required = true, dataType = "LotteryAddDto", paramType = "body") + }) + public Result addLottery(@RequestHeader("Authorization") String token, + @Validated @RequestBody LotteryAddDto lotteryAddDto) { + Lottery lottery = new Lottery(); + BeanUtils.copyProperties(lotteryAddDto, lottery); + + lotteryService.add(lottery, token); + return Result.success(); + } + + @ApiOperation(value = "3.2.抽奖列表页(PC)", notes = "admin") + @PostMapping("/lottery/list/{page}/{size}") + @GlobalInterceptor(checkAdminLogin = true) + public Result> lotteryList( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success(lotteryService.lotteryPageResult(page, size, lotterySearchDto)); + } + + @ApiOperation(value = "3.3.根据抽奖id获取地区列表(APP)", notes = "仅限app权限用户调用") + @PostMapping("/lottery/region/list") + @GlobalInterceptor(checkAppUserLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "lotteryId", value = "抽奖id", required = true, dataType = "String", paramType = "query") + }) + public Result> getLotteryRegionList( + @RequestHeader("Authorization") String token, + @RequestParam String lotteryId) { + return Result.success(lotteryService.getLotteryRegionList(lotteryId)); + } + + @ApiOperation(value = "3.4.编辑抽奖(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/lottery/edit") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "lotteryUpdateDto", value = "抽奖信息", required = true, dataType = "LotteryUpdateDto", paramType = "body") + }) + public Result editLottery(@RequestHeader("Authorization") String token, + @Validated @RequestBody LotteryUpdateDto lotteryUpdateDto) { + Lottery lottery = new Lottery(); + BeanUtils.copyProperties(lotteryUpdateDto, lottery); + lotteryService.edit(lottery, token); + return Result.success(); + } + + @ApiOperation(value = "3.5.发布抽奖(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/lottery/publish") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query") + }) + public Result publishLottery(@RequestHeader("Authorization") String token, + @RequestParam String id) { + lotteryService.publish(id, token); + return Result.success(); + } + + @ApiOperation(value = "3.6.停止抽奖(PC)", notes = "仅限admin权限用户调用") + @PostMapping("/lottery/stop") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "stopReason", value = "停止原因", required = true, dataType = "String", paramType = "body") + }) + public Result stopLottery(@RequestHeader("Authorization") String token, + @NotNull String id, @RequestBody @NotNull String stopReason) { + lotteryService.stop(id, token, stopReason); + return Result.success(); + } + + @ApiOperation(value = "3.7.参与抽奖(APP)") + @PostMapping("/lottery/participate") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataType = "Integer", paramType = "query") + }) + public Result participate(@RequestHeader("Authorization") String token, @NotNull String id, + @NotNull Integer regionId) { + lotteryService.participate(id, token, regionId); + return Result.success(); + } + + @ApiOperation(value = "3.8.自动抽奖结果(PC)", notes = "用这个方法主动触发自动抽奖结果") + @PostMapping("/lottery/auto") + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "id", value = "抽奖id", required = true, dataType = "String", paramType = "query") + }) + public Result auto(@RequestHeader("Authorization") String token, @NotNull String id) { + drawLotteryService.auto(id, token); + return Result.success(); + } + + @ApiOperation(value = "3.9.抽奖列表页,以及本人是否已参加(APP)", notes = "APP") + @PostMapping("/lottery/list/user/{page}/{size}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result> findLotteryListForApp( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success( + lotteryService.findLotteryListForApp(page, size, lotterySearchDto, token)); + } + + @ApiOperation(value = "3.10.已参与抽奖的人(APP)", notes = "APP") + @GetMapping("/lottery/participated/{page}/{size}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result> findParticipatedLotteryUserList( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "抽奖id") String lotteryId, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success(lotteryService.findPageByLotteryId(page, size, lotteryId)); + } + + @ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP") + @GetMapping("/lottery/result/{id}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result findLotteryResult( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "抽奖id", required = true) @PathVariable String id) { + return Result.success(lotteryService.getLotteryUserResult(id, token)); + } + + @ApiOperation(value = "3.12.抽奖详情(PC)", notes = "PC") + @GetMapping("/lottery/detail/{id}") + @GlobalInterceptor(checkAdminLogin = true) + public Result findLotteryDetailPCVO( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "抽奖id", required = true) @PathVariable String id) { + return Result.success(lotteryService.getLotteryDetailPCVO(id)); + } + + @ApiOperation(value = "3.13.抽奖用户列表(PC)", notes = "PC") + @GetMapping("/lottery/user/{page}/{size}") + @GlobalInterceptor(checkAdminLogin = true) + public Result> findLotteryUserList( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "抽奖id") String lotteryId, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size, + @ApiParam(value = "用户类型") Integer userType) { + return Result.success(lotteryService.getLotteryUserList(page, size, lotteryId, userType)); + } } diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index f9a40a3..5ad941a 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -9,7 +9,9 @@ import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dto.point.LotterySearchDto; import com.luoo.user.pojo.*; import com.luoo.user.vo.point.LotteryAPPVO; +import com.luoo.user.vo.point.LotteryDetailPCVO; import com.luoo.user.vo.point.LotteryPCVO; +import com.luoo.user.vo.point.LotteryUserDetailPCVO; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -31,8 +33,6 @@ import javax.persistence.criteria.Root; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -570,4 +570,111 @@ public class LotteryService { return lotteryUser.getResult(); } + /** + * 抽奖详情 + * + * @param lotteryId 抽奖id + * @return 抽奖详情 + */ + public LotteryDetailPCVO getLotteryDetailPCVO(String lotteryId) { + QLottery qLottery = QLottery.lottery; + LotteryDetailPCVO lotteryDetailPCVO = jpaQueryFactory + .select(Projections.bean(LotteryDetailPCVO.class, + qLottery.id, + qLottery.code, + qLottery.title, + qLottery.type, + qLottery.num, + qLottery.participant, + qLottery.point, + qLottery.applyStartTime, + qLottery.applyEndTime, + qLottery.drawTime, + qLottery.way, + qLottery.image, + qLottery.description, + qLottery.status, + qLottery.createTime, + qLottery.stopReason + )) + .from(qLottery) + .where(qLottery.id.eq(lotteryId)) + .fetchOne(); + + QLotteryRegion qLotteryRegion = QLotteryRegion.lotteryRegion; + List lotteryRegionList = jpaQueryFactory + .select(Projections.bean(LotteryRegion.class, + qLotteryRegion.id, + qLotteryRegion.regionId, + qLotteryRegion.lotteryId + )) + .from(qLotteryRegion) + .where(qLotteryRegion.lotteryId.eq(lotteryId)) + .fetch(); + + + + assert lotteryDetailPCVO != null; + lotteryDetailPCVO.setLotteryRegionList(lotteryRegionList); + return lotteryDetailPCVO; + } + + /** + * 根据抽奖id,用户类型获取抽奖用户列表 + * + * @param page 页数 + * @param size 每页大小 + * @param lotteryId 抽奖id + * @param userType null- 全部用户,1- 中奖用户 + * @return 用户列表 + */ + public PageResult getLotteryUserList(Integer page, Integer size, String lotteryId, Integer userType) { + + QLotteryUser qLotteryUser = QLotteryUser.lotteryUser; + QUserInfo qUserInfo = QUserInfo.userInfo; + QRegion qRegion = QRegion.region; + + BooleanBuilder booleanBuilder = new BooleanBuilder(); + checkLotteryUserCondition(booleanBuilder,qLotteryUser, lotteryId, userType); + Pageable pageable = PageRequest.of(page - 1, size); + List lotteryUserList = jpaQueryFactory + .select(Projections.bean(LotteryUserDetailPCVO.class, + qLotteryUser.lotteryId.as("lotteryId"), + qLotteryUser.userId.as("userId"), + qLotteryUser.regionId.as("regionId"), + qRegion.name.as("regionName"), + qUserInfo.mobile.as("mobile"), + qUserInfo.nickName.as("nickName"), + qUserInfo.point.as("point") + )) + .from(qLotteryUser) + .leftJoin(qRegion) + .on(qLotteryUser.regionId.eq(qRegion.id)) + .leftJoin(qUserInfo) + .on(qLotteryUser.userId.eq(qUserInfo.id)) + .where(booleanBuilder) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + long total = jpaQueryFactory + .select(qLotteryUser.count()) + .from(qLotteryUser) + .leftJoin(qRegion) + .on(qLotteryUser.regionId.eq(qRegion.id)) + .leftJoin(qUserInfo) + .on(qLotteryUser.userId.eq(qUserInfo.id)) + .where(booleanBuilder) + .fetchCount(); + return new PageResult<>(total, lotteryUserList); + + } + + private void checkLotteryUserCondition(BooleanBuilder booleanBuilder, QLotteryUser qLotteryUser, String lotteryId, Integer userType) { + booleanBuilder.and(qLotteryUser.lotteryId.eq(lotteryId)); + if (Objects.nonNull(userType)) { + booleanBuilder.and(qLotteryUser.result.eq(userType)); + } + } + } diff --git a/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryDetailPCVO.java b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryDetailPCVO.java new file mode 100644 index 0000000..ac0119e --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryDetailPCVO.java @@ -0,0 +1,105 @@ +package com.luoo.user.vo.point; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.luoo.user.pojo.LotteryRegion; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDateTime; +import java.util.List; + +import lombok.Data; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @program: luoo + * @description: PC端抽奖详情页 + * @author: yawei.huang + * @create: 2024-08-10 10:48 + **/ +@Data +public class LotteryDetailPCVO { + + + @ApiModelProperty(value = "主键") + private String id; + + @ApiModelProperty(value = "抽奖编码") + private String code; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "抽奖类型 1-门票抽奖 2-实物抽奖") + private Integer type; + + @ApiModelProperty(value = "奖品总数量") + private Integer num; + + @ApiModelProperty(value = "可参加人员 1-全部 2-全部会员 3-永久会员 4-贡献者") + private Integer participant; + + @ApiModelProperty(value = "积分") + private Integer point; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "报名开始时间") + private LocalDateTime applyStartTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "报名结束时间") + private LocalDateTime applyEndTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "抽奖时间") + private LocalDateTime drawTime; + + @ApiModelProperty(value = "抽奖方式 1-自动抽奖 2-手动抽奖") + private Integer way; + + @ApiModelProperty(value = "抽奖封面url") + private String image; + + @ApiModelProperty(value = "抽奖描述") + private String description; + + @ApiModelProperty(value = "抽奖状态 0-编辑中 1-报名中 2-已抽奖 3-已停止") + private Integer status; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + @CreatedDate + private LocalDateTime createTime; + + @ApiModelProperty(value = "停止原因") + private String stopReason; + + @ApiModelProperty(value = "抽奖区域列表") + List lotteryRegionList; + + public LotteryDetailPCVO() { + } + + public LotteryDetailPCVO(String id, String code, String title, Integer type, Integer num, Integer participant, Integer point, LocalDateTime applyStartTime, LocalDateTime applyEndTime, LocalDateTime drawTime, Integer way, String image, String description, Integer status, LocalDateTime createTime, String stopReason) { + this.id = id; + this.code = code; + this.title = title; + this.type = type; + this.num = num; + this.participant = participant; + this.point = point; + this.applyStartTime = applyStartTime; + this.applyEndTime = applyEndTime; + this.drawTime = drawTime; + this.way = way; + this.image = image; + this.description = description; + this.status = status; + this.createTime = createTime; + this.stopReason = stopReason; + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserDetailPCVO.java b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserDetailPCVO.java new file mode 100644 index 0000000..ef0d14e --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserDetailPCVO.java @@ -0,0 +1,41 @@ +package com.luoo.user.vo.point; + +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +import lombok.Data; + +/** + * @program: luoo + * @description: 抽奖用户详情 + * @author: yawei.huang + * @create: 2024-08-10 10:49 + **/ +@Data +public class LotteryUserDetailPCVO implements Serializable { + + @ApiModelProperty(value = "抽奖id") + private String lotteryId; + + @ApiModelProperty(value = "用户id") + private String userId; + + @ApiModelProperty(value = "区域id") + private Integer regionId; + + @ApiModelProperty(value = "区域名称") + private String regionName; + + @ApiModelProperty(value = "手机号") + private String mobile; + + @ApiModelProperty(value = "昵称") + private String nickName; + + @ApiModelProperty(value = "用户积分") + private Integer point; + + @ApiModelProperty(value = "用户等级") + private String level; +}