From 8976ce27dfbd978dbae3a3b89b9dae8af067fde6 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 20 Oct 2025 10:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=88=9D=E6=AD=A5=E8=B0=83=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/LotteryActivityQueryClientApi.java | 3 +- .../activity/api/LotteryRecordClientApi.java | 2 +- .../api/LotteryRecordManageClientApi.java | 2 +- .../cmd/activity/LotteryActivitySaveCmd.java | 11 +- .../cmd/activity/LotteryPrizeSaveCmd.java | 6 +- .../cmd/activity/LotteryRecordQryCmd.java | 4 +- .../cmd/activity/LotteryTicketGrantCmd.java | 5 +- .../dto/activity/LotteryActivityDTO.java | 10 +- .../model/dto/activity/LotteryPrizeDTO.java | 2 +- .../LotteryActivityBackRestController.java | 2 +- .../LotteryActivityBackServiceImpl.java | 4 +- .../LotteryActivityRestController.java | 29 +-- .../activity/LotteryActivityDetailQryExe.java | 17 +- .../activity/LotteryActivityListQryExe.java | 10 +- .../app/command/activity/LotteryDrawExe.java | 236 +++++++++++------- .../command/activity/LotteryRecordQryExe.java | 23 +- .../activity/LotteryTicketCountQryExe.java | 2 +- .../command/activity/LotteryTicketQryExe.java | 13 +- ...va => LotteryActivityRestServiceImpl.java} | 2 +- .../service/activity/LotteryServiceImpl.java | 11 +- .../activity/LotteryActivityCO.java | 6 +- .../activity/LotteryDrawResultCO.java | 4 +- .../clientobject/activity/LotteryPrizeCO.java | 2 +- .../activity/LotteryRecordCO.java | 4 +- .../activity/LotteryTicketCO.java | 4 +- .../app/dto/cmd/activity/LotteryDrawCmd.java | 8 +- ...e.java => LotteryActivityRestService.java} | 2 +- .../app/service/activity/LotteryService.java | 5 - .../dao/activity/LotteryActivityMapper.java | 6 +- .../rds/dao/activity/LotteryPrizeMapper.java | 6 +- .../rds/dao/activity/LotteryRecordMapper.java | 6 +- .../rds/dao/activity/LotteryTicketMapper.java | 6 +- .../activity/LotteryTicketRecordMapper.java | 6 +- .../dao/activity/LotteryUserCountMapper.java | 6 +- .../rds/entity/activity/LotteryActivity.java | 14 +- .../rds/entity/activity/LotteryPrize.java | 13 +- .../rds/entity/activity/LotteryRecord.java | 14 +- .../rds/entity/activity/LotteryTicket.java | 10 +- .../entity/activity/LotteryTicketRecord.java | 7 +- .../rds/entity/activity/LotteryUserCount.java | 10 +- .../activity/LotteryActivityService.java | 4 +- .../service/activity/LotteryPrizeService.java | 4 +- .../activity/LotteryRecordService.java | 4 +- .../activity/LotteryTicketRecordService.java | 4 +- .../activity/LotteryTicketService.java | 4 +- .../activity/LotteryUserCountService.java | 4 +- .../impl/LotteryActivityServiceImpl.java | 4 +- .../impl/LotteryPrizeServiceImpl.java | 4 +- .../impl/LotteryRecordServiceImpl.java | 4 +- .../impl/LotteryTicketRecordServiceImpl.java | 4 +- .../impl/LotteryTicketServiceImpl.java | 4 +- .../impl/LotteryUserCountServiceImpl.java | 4 +- .../dao/activity/LotteryActivityMapper.xml | 7 + .../dao/activity/LotteryPrizeMapper.xml | 7 + .../dao/activity/LotteryRecordMapper.xml | 7 + .../dao/activity/LotteryTicketMapper.xml | 7 + .../activity/LotteryTicketRecordMapper.xml | 6 + .../dao/activity/LotteryUserCountMapper.xml | 6 + .../LotteryActivityClientEndpoint.java | 6 +- .../LotteryActivityManageClientEndpoint.java | 55 +++- .../LotteryActivityQueryClientEndpoint.java | 5 +- .../activity/LotteryPrizeClientEndpoint.java | 13 +- .../LotteryPrizeManageClientEndpoint.java | 8 +- .../activity/LotteryRecordClientEndpoint.java | 10 +- .../LotteryRecordManageClientEndpoint.java | 23 +- .../activity/LotteryTicketClientEndpoint.java | 13 +- .../LotteryTicketManageClientEndpoint.java | 23 +- .../LotteryUserCountClientEndpoint.java | 12 +- 68 files changed, 476 insertions(+), 313 deletions(-) rename rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/{LotteryActivityServiceImpl.java => LotteryActivityRestServiceImpl.java} (96%) rename rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/{LotteryActivityService.java => LotteryActivityRestService.java} (96%) create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryActivityMapper.xml create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryPrizeMapper.xml create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryRecordMapper.xml create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketMapper.xml create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketRecordMapper.xml create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryUserCountMapper.xml diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryActivityQueryClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryActivityQueryClientApi.java index b4d29950..b4050001 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryActivityQueryClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryActivityQueryClientApi.java @@ -5,6 +5,7 @@ import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.inner.model.cmd.activity.LotteryActivityQryCmd; import com.red.circle.other.inner.model.dto.activity.LotteryActivityDTO; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; /** @@ -20,7 +21,7 @@ public interface LotteryActivityQueryClientApi { /** * 分页查询活动列表. */ - @GetMapping("/listActivities") + @PostMapping("/listActivities") ResultResponse> listActivities(@RequestBody LotteryActivityQryCmd cmd); } diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordClientApi.java index 3d04ee7f..6796f0b2 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordClientApi.java @@ -26,7 +26,7 @@ public interface LotteryRecordClientApi { @RequestParam("activityId") Long activityId, @RequestParam(value = "prizeId", required = false) Long prizeId, @RequestParam(value = "prizeName", required = false) String prizeName, - @RequestParam(value = "prizeType", required = false) Integer prizeType, + @RequestParam(value = "prizeType", required = false) String prizeType, @RequestParam("isWin") Integer isWin ); diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordManageClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordManageClientApi.java index 7fc3fcae..40581cef 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordManageClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/LotteryRecordManageClientApi.java @@ -22,7 +22,7 @@ public interface LotteryRecordManageClientApi { /** * 分页查询中奖记录. */ - @GetMapping("/listRecords") + @PostMapping("/listRecords") ResultResponse> listRecords(@RequestBody LotteryRecordQryCmd cmd); /** diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryActivitySaveCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryActivitySaveCmd.java index df62b3a7..4cc44db1 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryActivitySaveCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryActivitySaveCmd.java @@ -1,13 +1,12 @@ package com.red.circle.other.inner.model.cmd.activity; -import com.red.circle.framework.dto.Command; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; import lombok.Data; import lombok.EqualsAndHashCode; +import java.sql.Timestamp; + /** * 创建/更新活动命令. * @@ -16,7 +15,7 @@ import lombok.EqualsAndHashCode; */ @Data @EqualsAndHashCode(callSuper = false) -public class LotteryActivitySaveCmd extends Command { +public class LotteryActivitySaveCmd { /** * 活动ID(更新时需要). @@ -44,13 +43,13 @@ public class LotteryActivitySaveCmd extends Command { * 开始时间. */ @NotNull(message = "开始时间不能为空") - private LocalDateTime startTime; + private Timestamp startTime; /** * 结束时间. */ @NotNull(message = "结束时间不能为空") - private LocalDateTime endTime; + private Timestamp endTime; /** * 抽奖次数限制. diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryPrizeSaveCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryPrizeSaveCmd.java index 591638ce..3273f642 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryPrizeSaveCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryPrizeSaveCmd.java @@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode; */ @Data @EqualsAndHashCode(callSuper = false) -public class LotteryPrizeSaveCmd extends Command { +public class LotteryPrizeSaveCmd { /** * 奖品ID(更新时需要). @@ -43,8 +43,8 @@ public class LotteryPrizeSaveCmd extends Command { /** * 奖品类型. */ - @NotNull(message = "奖品类型不能为空") - private Integer prizeType; + @NotBlank(message = "奖品类型不能为空") + private String prizeType; /** * 奖品价值. diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryRecordQryCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryRecordQryCmd.java index 4599216e..c9648a3e 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryRecordQryCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryRecordQryCmd.java @@ -53,11 +53,11 @@ public class LotteryRecordQryCmd extends Command { /** * 页码. */ - private Integer pageNo; + private Integer pageNo = 1; /** * 页大小. */ - private Integer pageSize; + private Integer pageSize = 20; } diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryTicketGrantCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryTicketGrantCmd.java index 0be986e1..71025e7f 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryTicketGrantCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/activity/LotteryTicketGrantCmd.java @@ -2,7 +2,8 @@ package com.red.circle.other.inner.model.cmd.activity; import com.red.circle.framework.dto.Command; import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; + +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; @@ -41,7 +42,7 @@ public class LotteryTicketGrantCmd extends Command { /** * 过期时间. */ - private LocalDateTime expireTime; + private Timestamp expireTime; /** * 备注. diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryActivityDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryActivityDTO.java index e367fa69..b7ac8ef3 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryActivityDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryActivityDTO.java @@ -3,7 +3,7 @@ package com.red.circle.other.inner.model.dto.activity; import java.io.Serial; import java.io.Serializable; import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.sql.Timestamp; import lombok.Data; /** @@ -41,12 +41,12 @@ public class LotteryActivityDTO implements Serializable { /** * 开始时间. */ - private LocalDateTime startTime; + private Timestamp startTime; /** * 结束时间. */ - private LocalDateTime endTime; + private Timestamp endTime; /** * 状态. @@ -91,11 +91,11 @@ public class LotteryActivityDTO implements Serializable { /** * 创建时间. */ - private LocalDateTime createdAt; + private Timestamp createdAt; /** * 更新时间. */ - private LocalDateTime updatedAt; + private Timestamp updatedAt; } diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryPrizeDTO.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryPrizeDTO.java index ada4222a..d47bde01 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryPrizeDTO.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/dto/activity/LotteryPrizeDTO.java @@ -41,7 +41,7 @@ public class LotteryPrizeDTO implements Serializable { /** * 奖品类型. */ - private Integer prizeType; + private String prizeType; /** * 奖品价值. diff --git a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/activity/LotteryActivityBackRestController.java b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/activity/LotteryActivityBackRestController.java index c285b661..badd063a 100644 --- a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/activity/LotteryActivityBackRestController.java +++ b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/activity/LotteryActivityBackRestController.java @@ -48,7 +48,7 @@ public class LotteryActivityBackRestController extends BaseController { * 更新活动. */ @PutMapping("/update") - public void updateActivity(@RequestBody @Validated LotteryActivitySaveCmd cmd) { + public void updateActivity(@RequestBody LotteryActivitySaveCmd cmd) { lotteryActivityBackService.updateActivity(cmd); } diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/LotteryActivityBackServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/LotteryActivityBackServiceImpl.java index a88eb3e9..978fe666 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/LotteryActivityBackServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/activity/LotteryActivityBackServiceImpl.java @@ -1,6 +1,7 @@ package com.red.circle.console.app.service.app.activity; import com.red.circle.framework.dto.PageResult; +import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.inner.endpoint.activity.LotteryActivityManageClient; import com.red.circle.other.inner.endpoint.activity.LotteryActivityQueryClient; import com.red.circle.other.inner.endpoint.activity.LotteryPrizeManageClient; @@ -46,7 +47,8 @@ public class LotteryActivityBackServiceImpl implements LotteryActivityBackServic @Override public PageResult listActivities(LotteryActivityQryCmd cmd) { - return lotteryActivityQueryClient.listActivities(cmd).getBody(); + ResultResponse> response = lotteryActivityQueryClient.listActivities(cmd); + return response.getBody(); } @Override diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/LotteryActivityRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/LotteryActivityRestController.java index 84731339..91286ef9 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/LotteryActivityRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/LotteryActivityRestController.java @@ -10,7 +10,8 @@ import com.red.circle.other.app.dto.clientobject.activity.LotteryRecordCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryTicketCO; import com.red.circle.other.app.dto.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRecordQryCmd; -import com.red.circle.other.app.service.activity.LotteryActivityService; +import com.red.circle.other.app.service.activity.LotteryActivityRestService; + import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -40,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController; @RequiredArgsConstructor public class LotteryActivityRestController extends BaseController { - private final LotteryActivityService lotteryActivityService; + private final LotteryActivityRestService lotteryActivityRestService; /** * 获取有效活动列表. @@ -52,7 +53,7 @@ public class LotteryActivityRestController extends BaseController { */ @GetMapping("/list") public List listValidActivities(AppExtCommand cmd) { - return lotteryActivityService.listValidActivities(cmd); + return lotteryActivityRestService.listValidActivities(cmd); } /** @@ -65,7 +66,7 @@ public class LotteryActivityRestController extends BaseController { */ @GetMapping("/detail/{activityCode}") public LotteryActivityDetailCO getActivityDetail(@PathVariable String activityCode, AppExtCommand cmd) { - return lotteryActivityService.getActivityDetail(activityCode, cmd); + return lotteryActivityRestService.getActivityDetail(activityCode, cmd); } /** @@ -78,7 +79,7 @@ public class LotteryActivityRestController extends BaseController { */ @PostMapping("/draw") public LotteryDrawResultCO draw(@RequestBody @Validated LotteryDrawCmd cmd) { - return lotteryActivityService.draw(cmd); + return lotteryActivityRestService.draw(cmd); } /** @@ -91,33 +92,33 @@ public class LotteryActivityRestController extends BaseController { */ @GetMapping("/my-records") public PageResult listMyRecords(LotteryRecordQryCmd cmd) { - return lotteryActivityService.listMyRecords(cmd); + return lotteryActivityRestService.listMyRecords(cmd); } /** - * 查询我的抽奖券. + * 查询我的抽奖券列表(详细信息). * - * @eo.name 查询我的抽奖券. + * @eo.name 查询我的抽奖券列表. * @eo.url /my-tickets * @eo.method get * @eo.request-type formdata */ @GetMapping("/my-tickets") public List listMyTickets(AppExtCommand cmd) { - return lotteryActivityService.listMyTickets(cmd); + return lotteryActivityRestService.listMyTickets(cmd); } /** - * 获取抽奖券总数. + * 获取我的剩余抽奖券数量. * - * @eo.name 获取抽奖券总数. - * @eo.url /ticket-count + * @eo.name 获取我的剩余抽奖券数量. + * @eo.url /my-ticket-count * @eo.method get * @eo.request-type formdata */ - @GetMapping("/ticket-count") + @GetMapping("/my-ticket-count") public Integer getMyTicketCount(AppExtCommand cmd) { - return lotteryActivityService.getMyTicketCount(cmd); + return lotteryActivityRestService.getMyTicketCount(cmd); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java index d4e8b2fa..6d462221 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java @@ -13,6 +13,7 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryActivityS import com.red.circle.other.infra.database.rds.service.activity.LotteryPrizeService; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService; import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService; +import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; @@ -39,22 +40,22 @@ public class LotteryActivityDetailQryExe { Long userId = cmd.requiredReqUserId(); // 查询活动 - LotteryActivity activity = lotteryActivityService.lambdaQuery() + LotteryActivity activity = lotteryActivityService.query() .eq(LotteryActivity::getActivityCode, activityCode) - .one(); - ResponseAssert.isTrue(activity != null, "活动不存在"); + .getOne(); + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_NOT_FOUND, activity != null); // 查询奖品列表 - List prizes = lotteryPrizeService.lambdaQuery() + List prizes = lotteryPrizeService.query() .eq(LotteryPrize::getActivityId, activity.getId()) .eq(LotteryPrize::getIsDisplay, 1) .orderByAsc(LotteryPrize::getSortOrder) .list(); // 查询用户抽奖券数量 - Integer ticketCount = 0; + int ticketCount = 0; if (activity.getNeedTicket() == 1) { - ticketCount = lotteryTicketService.lambdaQuery() + ticketCount = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) @@ -67,11 +68,11 @@ public class LotteryActivityDetailQryExe { // 查询用户今日抽奖次数 Integer usedCount = 0; if (activity.getDrawCountLimit() != null && activity.getDrawCountLimit() > 0) { - LotteryUserCount userCount = lotteryUserCountService.lambdaQuery() + LotteryUserCount userCount = lotteryUserCountService.query() .eq(LotteryUserCount::getUserId, userId) .eq(LotteryUserCount::getActivityId, activity.getId()) .eq(LotteryUserCount::getDrawDate, LocalDate.now()) - .one(); + .getOne(); if (userCount != null) { usedCount = userCount.getDrawCount(); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityListQryExe.java index 18949cf1..bdb47e80 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityListQryExe.java @@ -6,11 +6,15 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryActivity; import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserCount; import com.red.circle.other.infra.database.rds.service.activity.LotteryActivityService; import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService; + +import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + +import com.red.circle.tool.core.date.TimestampUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -29,10 +33,10 @@ public class LotteryActivityListQryExe { public List execute(AppExtCommand cmd) { Long userId = cmd.requiredReqUserId(); - LocalDateTime now = LocalDateTime.now(); + Timestamp now = TimestampUtils.now(); // 查询进行中的活动 - List activities = lotteryActivityService.lambdaQuery() + List activities = lotteryActivityService.query() .eq(LotteryActivity::getStatus, 1) .le(LotteryActivity::getStartTime, now) .ge(LotteryActivity::getEndTime, now) @@ -48,7 +52,7 @@ public class LotteryActivityListQryExe { .map(LotteryActivity::getId) .collect(Collectors.toList()); - Map userDrawCountMap = lotteryUserCountService.lambdaQuery() + Map userDrawCountMap = lotteryUserCountService.query() .eq(LotteryUserCount::getUserId, userId) .in(LotteryUserCount::getActivityId, activityIds) .eq(LotteryUserCount::getDrawDate, LocalDate.now()) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java index 83f5ab0c..b496f665 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java @@ -16,12 +16,16 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryRecordSer import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketRecordService; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService; import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService; +import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; +import com.red.circle.tool.core.date.TimestampUtils; import java.math.BigDecimal; +import java.sql.Timestamp; import java.time.LocalDate; -import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -45,95 +49,99 @@ public class LotteryDrawExe { private final LotteryTicketRecordService lotteryTicketRecordService; private final LotteryUserCountService lotteryUserCountService; - private final Random random = new Random(); - @Transactional(rollbackFor = Exception.class) public LotteryDrawResultCO execute(LotteryDrawCmd cmd) { Long userId = cmd.requiredReqUserId(); - String activityCode = cmd.getActivityCode(); + Long activityId = cmd.getActivityId(); + Timestamp now = TimestampUtils.now(); // 1. 校验活动 - LotteryActivity activity = lotteryActivityService.lambdaQuery() - .eq(LotteryActivity::getActivityCode, activityCode) - .one(); - ResponseAssert.isTrue(activity != null, "活动不存在"); - ResponseAssert.isTrue(activity.getStatus() == 1, "活动未开始或已结束"); + LotteryActivity activity = validateActivity(activityId, now); - LocalDateTime now = LocalDateTime.now(); - ResponseAssert.isTrue(now.isAfter(activity.getStartTime()) && now.isBefore(activity.getEndTime()), - "不在活动时间内"); + // 2. 校验抽奖次数限制 + validateDrawCount(userId, activityId, activity); - // 2. 校验抽奖次数 - if (activity.getDrawCountLimit() != null && activity.getDrawCountLimit() > 0) { - LotteryUserCount userCount = lotteryUserCountService.lambdaQuery() - .eq(LotteryUserCount::getUserId, userId) - .eq(LotteryUserCount::getActivityId, activity.getId()) - .eq(LotteryUserCount::getDrawDate, LocalDate.now()) - .one(); - - int drawCount = userCount != null ? userCount.getDrawCount() : 0; - ResponseAssert.isTrue(drawCount < activity.getDrawCountLimit(), "今日抽奖次数已用完"); - } - - // 3. 校验并扣除抽奖券 - if (activity.getNeedTicket() == 1) { - deductTicket(userId, activity.getTicketCost()); - } + // 3. 校验并扣除抽奖券(写死消耗1次) + Integer needTicket = 1; + deductTicket(userId, needTicket); // 4. 执行抽奖算法 - LotteryPrize prize = drawPrize(activity.getId()); - - // 5. 保存抽奖记录 - String recordNo = generateRecordNo(); - LotteryRecord record = new LotteryRecord(); - record.setRecordNo(recordNo); - record.setUserId(userId); - record.setActivityId(activity.getId()); - record.setDrawTime(now); + LotteryPrize prize = drawPrize(activityId); + // 5. 扣减奖品库存(使用悲观锁防止超卖) if (prize != null) { - record.setPrizeId(prize.getId()); - record.setPrizeName(prize.getPrizeName()); - record.setPrizeType(prize.getPrizeType()); - record.setIsWin(1); - record.setPrizeStatus(0); // 待发放 - - // 扣减库存 - lotteryPrizeService.lambdaUpdate() - .eq(LotteryPrize::getId, prize.getId()) - .gt(LotteryPrize::getRemainingStock, 0) - .setSql("remaining_stock = remaining_stock - 1") - .update(); - } else { - record.setIsWin(0); + boolean deductSuccess = deductPrizeStock(prize.getId()); + if (!deductSuccess) { + // 库存扣减失败,视为未中奖 + log.warn("Prize stock deduction failed, prizeId: {}", prize.getId()); + prize = null; + } } - lotteryRecordService.save(record); + // 6. 保存抽奖记录 + LotteryRecord record = saveDrawRecord(userId, activityId, prize, now); - // 6. 更新用户抽奖次数 - updateUserDrawCount(userId, activity.getId()); + // 7. 更新用户抽奖次数 + updateUserDrawCount(userId, activityId); - // 7. 组装返回结果 + // 8. 组装返回结果 return convertToResultCO(record, prize); } /** - * 扣除抽奖券. + * 校验活动状态和时间. + */ + private LotteryActivity validateActivity(Long activityId, Timestamp now) { + LotteryActivity activity = lotteryActivityService.getById(activityId); + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_NOT_FOUND, activity != null); + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_CLOSED, activity.getStatus() == 1); + ResponseAssert.isTrue(LotteryErrorCode.NOT_IN_ACTIVITY_TIME, + now.after(activity.getStartTime()) && now.before(activity.getEndTime())); + + return activity; + } + + /** + * 校验抽奖次数限制. + */ + private void validateDrawCount(Long userId, Long activityId, LotteryActivity activity) { + if (activity.getDrawCountLimit() == null || activity.getDrawCountLimit() <= 0) { + return; // 无限制 + } + + LotteryUserCount userCount = lotteryUserCountService.query() + .eq(LotteryUserCount::getUserId, userId) + .eq(LotteryUserCount::getActivityId, activityId) + .eq(LotteryUserCount::getDrawDate, LocalDate.now()) + .getOne(); + + int drawCount = userCount != null ? userCount.getDrawCount() : 0; + ResponseAssert.isTrue(LotteryErrorCode.DRAW_COUNT_EXHAUSTED, + drawCount < activity.getDrawCountLimit()); + } + + /** + * 扣除抽奖券(优化:使用批量处理,减少数据库交互). */ private void deductTicket(Long userId, Integer ticketCost) { - List tickets = lotteryTicketService.lambdaQuery() + // 查询可用抽奖券(按过期时间排序,先用快过期的) + List tickets = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) .orderByAsc(LotteryTicket::getExpireTime) .list(); + // 校验总数量 int totalRemaining = tickets.stream() .mapToInt(LotteryTicket::getRemainingCount) .sum(); - ResponseAssert.isTrue(totalRemaining >= ticketCost, "抽奖券不足"); + ResponseAssert.isTrue(LotteryErrorCode.INSUFFICIENT_TICKETS, totalRemaining >= ticketCost); + // 批量扣减 + List records = new ArrayList<>(); int remaining = ticketCost; + for (LotteryTicket ticket : tickets) { if (remaining <= 0) { break; @@ -141,33 +149,43 @@ public class LotteryDrawExe { int deduct = Math.min(remaining, ticket.getRemainingCount()); - lotteryTicketService.lambdaUpdate() + // 使用乐观锁更新(防止并发问题) + boolean updateSuccess = lotteryTicketService.update() .eq(LotteryTicket::getId, ticket.getId()) + .eq(LotteryTicket::getRemainingCount, ticket.getRemainingCount()) // 乐观锁 .setSql("used_count = used_count + " + deduct) .setSql("remaining_count = remaining_count - " + deduct) - .update(); + .execute(); - // 记录使用 + ResponseAssert.isTrue(LotteryErrorCode.INSUFFICIENT_TICKETS, updateSuccess); + + // 记录使用日志 LotteryTicketRecord ticketRecord = new LotteryTicketRecord(); ticketRecord.setUserId(userId); ticketRecord.setTicketId(ticket.getId()); ticketRecord.setChangeCount(-deduct); ticketRecord.setChangeType(2); // 消耗 ticketRecord.setRemark("抽奖消耗"); - lotteryTicketRecordService.save(ticketRecord); + records.add(ticketRecord); remaining -= deduct; } + + // 批量插入日志 + if (!records.isEmpty()) { + lotteryTicketRecordService.saveBatch(records); + } } /** - * 抽奖算法 - 权重随机. + * 抽奖算法 - 权重随机(优化:使用ThreadLocalRandom). */ private LotteryPrize drawPrize(Long activityId) { // 查询所有可用奖品 - List prizes = lotteryPrizeService.lambdaQuery() + List prizes = lotteryPrizeService.query() .eq(LotteryPrize::getActivityId, activityId) .gt(LotteryPrize::getRemainingStock, 0) + .orderByAsc(LotteryPrize::getSortOrder) .list(); if (prizes.isEmpty()) { @@ -179,8 +197,7 @@ public class LotteryDrawExe { .map(LotteryPrize::getProbability) .reduce(BigDecimal.ZERO, BigDecimal::add); - // 生成随机数 - double randomValue = random.nextDouble() * totalProbability.doubleValue(); + double randomValue = ThreadLocalRandom.current().nextDouble() * totalProbability.doubleValue(); double cumulative = 0.0; // 根据概率选择奖品 @@ -195,35 +212,86 @@ public class LotteryDrawExe { } /** - * 更新用户抽奖次数. + * 扣减奖品库存(使用悲观锁防止超卖). + */ + private boolean deductPrizeStock(Long prizeId) { + // 使用数据库级别的原子操作 + int affected = lotteryPrizeService.update() + .eq(LotteryPrize::getId, prizeId) + .gt(LotteryPrize::getRemainingStock, 0) // 必须有库存 + .setSql("remaining_stock = remaining_stock - 1") + .execute() + ? 1 : 0; + + return affected > 0; + } + + /** + * 保存抽奖记录. + */ + private LotteryRecord saveDrawRecord(Long userId, Long activityId, LotteryPrize prize, Timestamp now) { + String recordNo = generateRecordNo(); + LotteryRecord record = new LotteryRecord(); + record.setRecordNo(recordNo); + record.setUserId(userId); + record.setActivityId(activityId); + record.setDrawTime(now); + + if (prize != null) { + record.setPrizeId(prize.getId()); + record.setPrizeName(prize.getPrizeName()); + record.setPrizeType(prize.getPrizeType()); + record.setIsWin(1); + record.setPrizeStatus(0); // 待发放 + } else { + record.setIsWin(0); + } + + lotteryRecordService.save(record); + return record; + } + + /** + * 更新用户抽奖次数(优化:减少查询). */ private void updateUserDrawCount(Long userId, Long activityId) { - LotteryUserCount userCount = lotteryUserCountService.lambdaQuery() + LocalDate today = LocalDate.now(); + + // 先尝试直接更新 + boolean updated = lotteryUserCountService.update() .eq(LotteryUserCount::getUserId, userId) .eq(LotteryUserCount::getActivityId, activityId) - .eq(LotteryUserCount::getDrawDate, LocalDate.now()) - .one(); + .eq(LotteryUserCount::getDrawDate, today) + .setSql("draw_count = draw_count + 1") + .execute(); - if (userCount == null) { - userCount = new LotteryUserCount(); - userCount.setUserId(userId); - userCount.setActivityId(activityId); - userCount.setDrawDate(LocalDate.now()); - userCount.setDrawCount(1); - lotteryUserCountService.save(userCount); - } else { - lotteryUserCountService.lambdaUpdate() - .eq(LotteryUserCount::getId, userCount.getId()) - .setSql("draw_count = draw_count + 1") - .update(); + // 如果更新失败(记录不存在),则插入 + if (!updated) { + try { + LotteryUserCount userCount = new LotteryUserCount(); + userCount.setUserId(userId); + userCount.setActivityId(activityId); + userCount.setDrawDate(today); + userCount.setDrawCount(1); + lotteryUserCountService.save(userCount); + } catch (Exception e) { + // 并发情况下可能插入失败,再次更新 + lotteryUserCountService.update() + .eq(LotteryUserCount::getUserId, userId) + .eq(LotteryUserCount::getActivityId, activityId) + .eq(LotteryUserCount::getDrawDate, today) + .setSql("draw_count = draw_count + 1") + .execute(); + } } } /** - * 生成记录编号. + * 生成记录编号(优化:使用更高效的方式). */ private String generateRecordNo() { - return "LT" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 8); + return "LT" + System.currentTimeMillis() + + String.format("%06d", ThreadLocalRandom.current().nextInt(1000000)); } /** diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryRecordQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryRecordQryExe.java index 90875937..66177038 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryRecordQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryRecordQryExe.java @@ -1,5 +1,6 @@ package com.red.circle.other.app.command.activity; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.dto.PageResult; import com.red.circle.other.app.dto.clientobject.activity.LotteryPrizeCO; @@ -37,14 +38,14 @@ public class LotteryRecordQryExe { Integer pageSize = cmd.getPageSize() != null ? cmd.getPageSize() : 20; // 构建查询条件 - Page page = new Page<>(pageNo, pageSize); - var query = lotteryRecordService.lambdaQuery() + IPage page = new Page<>(pageNo, pageSize); + var query = lotteryRecordService.query() .eq(LotteryRecord::getUserId, userId); if (cmd.getActivityCode() != null) { - LotteryActivity activity = lotteryActivityService.lambdaQuery() + LotteryActivity activity = lotteryActivityService.query() .eq(LotteryActivity::getActivityCode, cmd.getActivityCode()) - .one(); + .getOne(); if (activity != null) { query.eq(LotteryRecord::getActivityId, activity.getId()); } @@ -54,7 +55,7 @@ public class LotteryRecordQryExe { query.eq(LotteryRecord::getIsWin, 1); } - Page recordPage = query.orderByDesc(LotteryRecord::getDrawTime).page(page); + IPage recordPage = query.orderByDesc(LotteryRecord::getDrawTime).page(page); // 查询关联数据 List activityIds = recordPage.getRecords().stream() @@ -68,13 +69,13 @@ public class LotteryRecordQryExe { .distinct() .collect(Collectors.toList()); - Map activityMap = lotteryActivityService.lambdaQuery() + Map activityMap = lotteryActivityService.query() .in(LotteryActivity::getId, activityIds) .list() .stream() .collect(Collectors.toMap(LotteryActivity::getId, a -> a)); - Map prizeMap = lotteryPrizeService.lambdaQuery() + Map prizeMap = lotteryPrizeService.query() .in(LotteryPrize::getId, prizeIds) .list() .stream() @@ -85,7 +86,13 @@ public class LotteryRecordQryExe { .map(record -> convertToCO(record, activityMap, prizeMap)) .collect(Collectors.toList()); - return PageResult.of(records, recordPage.getTotal(), pageNo, pageSize); + PageResult result = new PageResult<>(); + result.setRecords(records); + result.setTotal(recordPage.getTotal()); + result.setCurrent(recordPage.getCurrent()); + result.setSize(recordPage.getSize()); + + return result; } private LotteryRecordCO convertToCO(LotteryRecord record, diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketCountQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketCountQryExe.java index 28c163cc..16ef276b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketCountQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketCountQryExe.java @@ -22,7 +22,7 @@ public class LotteryTicketCountQryExe { public Integer execute(AppExtCommand cmd) { Long userId = cmd.requiredReqUserId(); - List tickets = lotteryTicketService.lambdaQuery() + List tickets = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketQryExe.java index a5ef4498..fbd6faf4 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryTicketQryExe.java @@ -7,10 +7,11 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketSer import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; /** - * 查询我的抽奖券. + * 查询我的抽奖券列表. * * @author system * @since 2025-10-18 @@ -24,7 +25,7 @@ public class LotteryTicketQryExe { public List execute(AppExtCommand cmd) { Long userId = cmd.requiredReqUserId(); - List tickets = lotteryTicketService.lambdaQuery() + List tickets = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) @@ -38,13 +39,7 @@ public class LotteryTicketQryExe { private LotteryTicketCO convertToCO(LotteryTicket ticket) { LotteryTicketCO co = new LotteryTicketCO(); - co.setId(ticket.getId()); - co.setTicketSource(ticket.getTicketSource()); - co.setTotalCount(ticket.getTotalCount()); - co.setUsedCount(ticket.getUsedCount()); - co.setRemainingCount(ticket.getRemainingCount()); - co.setExpireTime(ticket.getExpireTime()); - co.setStatus(ticket.getStatus()); + BeanUtils.copyProperties(ticket, co); return co; } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java similarity index 96% rename from rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityServiceImpl.java rename to rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java index 2d8372af..40cce94e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java @@ -27,7 +27,7 @@ import org.springframework.stereotype.Service; */ @Service @RequiredArgsConstructor -public class LotteryActivityServiceImpl implements LotteryActivityService { +public class LotteryActivityRestServiceImpl implements LotteryActivityRestService { private final LotteryActivityListQryExe lotteryActivityListQryExe; private final LotteryActivityDetailQryExe lotteryActivityDetailQryExe; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryServiceImpl.java index cff72413..f9f8f522 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryServiceImpl.java @@ -1,11 +1,7 @@ package com.red.circle.other.app.service.activity; import com.red.circle.common.business.dto.cmd.AppExtCommand; -import com.red.circle.other.app.command.activity.LotteryDrawExe; -import com.red.circle.other.app.command.activity.query.LotteryActivityDetailQryExe; -import com.red.circle.other.app.command.activity.query.LotteryActivityListQryExe; -import com.red.circle.other.app.command.activity.query.LotteryRecordQryExe; -import com.red.circle.other.app.command.activity.query.LotteryTicketQryExe; +import com.red.circle.other.app.command.activity.*; import com.red.circle.other.app.dto.clientobject.activity.LotteryActivityCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryActivityDetailCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryDrawResultCO; @@ -48,11 +44,6 @@ public class LotteryServiceImpl implements LotteryService { return lotteryDrawExe.execute(cmd); } - @Override - public List listMyRecords(LotteryRecordQryCmd cmd) { - return lotteryRecordQryExe.execute(cmd); - } - @Override public List listMyTickets(AppExtCommand cmd) { return lotteryTicketQryExe.execute(cmd); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryActivityCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryActivityCO.java index a8234b9c..90d717ee 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryActivityCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryActivityCO.java @@ -1,7 +1,7 @@ package com.red.circle.other.app.dto.clientobject.activity; import com.red.circle.framework.dto.ClientObject; -import java.time.LocalDateTime; +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -40,12 +40,12 @@ public class LotteryActivityCO extends ClientObject { /** * 开始时间. */ - private LocalDateTime startTime; + private Timestamp startTime; /** * 结束时间. */ - private LocalDateTime endTime; + private Timestamp endTime; /** * 状态:0-未开始,1-进行中,2-已结束,3-已关闭. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryDrawResultCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryDrawResultCO.java index c1ff5a79..ebc6951f 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryDrawResultCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryDrawResultCO.java @@ -1,7 +1,7 @@ package com.red.circle.other.app.dto.clientobject.activity; import com.red.circle.framework.dto.ClientObject; -import java.time.LocalDateTime; +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -35,6 +35,6 @@ public class LotteryDrawResultCO extends ClientObject { /** * 抽奖时间. */ - private LocalDateTime drawTime; + private Timestamp drawTime; } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryPrizeCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryPrizeCO.java index 667eb2ce..8c88df34 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryPrizeCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryPrizeCO.java @@ -35,7 +35,7 @@ public class LotteryPrizeCO extends ClientObject { /** * 奖品类型. */ - private Integer prizeType; + private String prizeType; /** * 奖品价值. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryRecordCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryRecordCO.java index 4aecd9c2..860c2c01 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryRecordCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryRecordCO.java @@ -1,7 +1,7 @@ package com.red.circle.other.app.dto.clientobject.activity; import com.red.circle.framework.dto.ClientObject; -import java.time.LocalDateTime; +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -40,7 +40,7 @@ public class LotteryRecordCO extends ClientObject { /** * 抽奖时间. */ - private LocalDateTime drawTime; + private Timestamp drawTime; /** * 奖品状态:0-待发放,1-已发放,2-发放失败. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryTicketCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryTicketCO.java index e43c54a9..7c1d7d69 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryTicketCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryTicketCO.java @@ -1,7 +1,7 @@ package com.red.circle.other.app.dto.clientobject.activity; import com.red.circle.framework.dto.ClientObject; -import java.time.LocalDateTime; +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -45,7 +45,7 @@ public class LotteryTicketCO extends ClientObject { /** * 过期时间. */ - private LocalDateTime expireTime; + private Timestamp expireTime; /** * 状态. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryDrawCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryDrawCmd.java index 88e5e679..c7a350b6 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryDrawCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryDrawCmd.java @@ -1,7 +1,7 @@ package com.red.circle.other.app.dto.cmd.activity; import com.red.circle.common.business.dto.cmd.AppExtCommand; -import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,11 +16,11 @@ import lombok.EqualsAndHashCode; public class LotteryDrawCmd extends AppExtCommand { /** - * 活动编码. + * 活动ID. * * @eo.required */ - @NotBlank(message = "activityCode required.") - private String activityCode; + @NotNull(message = "activityId required.") + private Long activityId; } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java similarity index 96% rename from rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityService.java rename to rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java index 7ef198b3..c4be0c39 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java @@ -17,7 +17,7 @@ import java.util.List; * @author system * @since 2025-10-18 */ -public interface LotteryActivityService { +public interface LotteryActivityRestService { /** * 获取有效活动列表. diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryService.java index c978b16e..ac456394 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryService.java @@ -33,11 +33,6 @@ public interface LotteryService { */ LotteryDrawResultCO draw(LotteryDrawCmd cmd); - /** - * 查询用户抽奖记录. - */ - List listMyRecords(LotteryRecordQryCmd cmd); - /** * 查询用户抽奖券. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryActivityMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryActivityMapper.java index add7d526..15a7583a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryActivityMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryActivityMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryActivity; -import org.apache.ibatis.annotations.Mapper; /** * 抽奖活动Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryActivityMapper extends BaseMapper { +public interface LotteryActivityMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryPrizeMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryPrizeMapper.java index 4e7d0815..938a5725 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryPrizeMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryPrizeMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryPrize; -import org.apache.ibatis.annotations.Mapper; /** * 奖品配置Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryPrizeMapper extends BaseMapper { +public interface LotteryPrizeMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryRecordMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryRecordMapper.java index 483a80cb..53535279 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryRecordMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryRecordMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryRecord; -import org.apache.ibatis.annotations.Mapper; /** * 中奖记录Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryRecordMapper extends BaseMapper { +public interface LotteryRecordMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketMapper.java index 34b04817..6f49e2f5 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; -import org.apache.ibatis.annotations.Mapper; /** * 抽奖券Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryTicketMapper extends BaseMapper { +public interface LotteryTicketMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketRecordMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketRecordMapper.java index 3488fa10..c3f0bf85 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketRecordMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryTicketRecordMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketRecord; -import org.apache.ibatis.annotations.Mapper; /** * 抽奖券使用记录Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryTicketRecordMapper extends BaseMapper { +public interface LotteryTicketRecordMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryUserCountMapper.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryUserCountMapper.java index 7ae2fffc..e5a36a20 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryUserCountMapper.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryUserCountMapper.java @@ -1,8 +1,7 @@ package com.red.circle.other.infra.database.rds.dao.activity; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserCount; -import org.apache.ibatis.annotations.Mapper; /** * 用户抽奖次数统计Mapper. @@ -10,7 +9,6 @@ import org.apache.ibatis.annotations.Mapper; * @author system * @since 2025-10-18 */ -@Mapper -public interface LotteryUserCountMapper extends BaseMapper { +public interface LotteryUserCountMapper extends BaseDAO { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryActivity.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryActivity.java index 089209b3..f532eefa 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryActivity.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryActivity.java @@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; -import java.time.LocalDateTime; +import java.io.Serializable; +import java.sql.Timestamp; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -19,10 +20,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_activity") -public class LotteryActivity extends TimestampBaseEntity { +public class LotteryActivity implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -55,13 +55,13 @@ public class LotteryActivity extends TimestampBaseEntity { * 开始时间. */ @TableField("start_time") - private LocalDateTime startTime; + private Timestamp startTime; /** * 结束时间. */ @TableField("end_time") - private LocalDateTime endTime; + private Timestamp endTime; /** * 状态:0-未开始,1-进行中,2-已结束,3-已关闭. @@ -111,4 +111,8 @@ public class LotteryActivity extends TimestampBaseEntity { @TableField("sort_order") private Integer sortOrder; + private Timestamp createTime; + + private Timestamp updateTime; + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryPrize.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryPrize.java index e1add975..522f0947 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryPrize.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryPrize.java @@ -3,9 +3,11 @@ package com.red.circle.other.infra.database.rds.entity.activity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; +import java.io.Serializable; import java.math.BigDecimal; +import java.sql.Timestamp; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -19,10 +21,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_prize") -public class LotteryPrize extends TimestampBaseEntity { +public class LotteryPrize implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -55,7 +56,7 @@ public class LotteryPrize extends TimestampBaseEntity { * 奖品类型:1-实物,2-虚拟币,3-优惠券,4-积分,5-谢谢参与. */ @TableField("prize_type") - private Integer prizeType; + private String prizeType; /** * 奖品价值/数量. @@ -111,4 +112,8 @@ public class LotteryPrize extends TimestampBaseEntity { @TableField("is_display") private Integer isDisplay; + private Timestamp createTime; + + private Timestamp updateTime; + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryRecord.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryRecord.java index 8c992ad0..578d5475 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryRecord.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryRecord.java @@ -3,11 +3,10 @@ package com.red.circle.other.infra.database.rds.entity.activity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; -import java.time.LocalDateTime; +import java.io.Serializable; +import java.sql.Timestamp; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** @@ -19,10 +18,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_record") -public class LotteryRecord extends TimestampBaseEntity { +public class LotteryRecord implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -67,7 +65,7 @@ public class LotteryRecord extends TimestampBaseEntity { * 奖品类型快照. */ @TableField("prize_type") - private Integer prizeType; + private String prizeType; /** * 是否中奖:0-未中奖,1-中奖. @@ -79,7 +77,7 @@ public class LotteryRecord extends TimestampBaseEntity { * 抽奖时间. */ @TableField("draw_time") - private LocalDateTime drawTime; + private Timestamp drawTime; /** * 奖品状态:0-待发放,1-已发放,2-发放失败. @@ -91,7 +89,7 @@ public class LotteryRecord extends TimestampBaseEntity { * 发放时间. */ @TableField("deliver_time") - private LocalDateTime deliverTime; + private Timestamp deliverTime; /** * 备注. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicket.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicket.java index 94030abf..b0681985 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicket.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicket.java @@ -3,11 +3,10 @@ package com.red.circle.other.infra.database.rds.entity.activity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; -import java.time.LocalDateTime; +import java.io.Serializable; +import java.sql.Timestamp; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** @@ -19,10 +18,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_ticket") -public class LotteryTicket extends TimestampBaseEntity { +public class LotteryTicket implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -73,7 +71,7 @@ public class LotteryTicket extends TimestampBaseEntity { * 过期时间. */ @TableField("expire_time") - private LocalDateTime expireTime; + private Timestamp expireTime; /** * 状态:0-已失效,1-正常. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicketRecord.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicketRecord.java index 11ba7e2e..dbda9180 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicketRecord.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryTicketRecord.java @@ -3,10 +3,10 @@ package com.red.circle.other.infra.database.rds.entity.activity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; +import java.io.Serializable; + import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** @@ -18,10 +18,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_ticket_record") -public class LotteryTicketRecord extends TimestampBaseEntity { +public class LotteryTicketRecord implements Serializable { @Serial private static final long serialVersionUID = 1L; diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryUserCount.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryUserCount.java index 48e6ecbd..c9d87d44 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryUserCount.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryUserCount.java @@ -3,9 +3,11 @@ package com.red.circle.other.infra.database.rds.entity.activity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import java.io.Serial; +import java.io.Serializable; +import java.sql.Timestamp; import java.time.LocalDate; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -19,10 +21,9 @@ import lombok.experimental.Accessors; * @since 2025-10-18 */ @Data -@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName("lottery_user_count") -public class LotteryUserCount extends TimestampBaseEntity { +public class LotteryUserCount implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -57,4 +58,7 @@ public class LotteryUserCount extends TimestampBaseEntity { @TableField("draw_count") private Integer drawCount; + private Timestamp createTime; + + private Timestamp updateTime; } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryActivityService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryActivityService.java index f786327a..259b3736 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryActivityService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryActivityService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryActivity; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryActivity; * @author system * @since 2025-10-18 */ -public interface LotteryActivityService extends IService { +public interface LotteryActivityService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryPrizeService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryPrizeService.java index 0fbc3242..f0abe1a9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryPrizeService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryPrizeService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryPrize; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryPrize; * @author system * @since 2025-10-18 */ -public interface LotteryPrizeService extends IService { +public interface LotteryPrizeService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryRecordService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryRecordService.java index f0cf47bf..4a1668b0 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryRecordService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryRecordService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryRecord; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryRecord; * @author system * @since 2025-10-18 */ -public interface LotteryRecordService extends IService { +public interface LotteryRecordService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketRecordService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketRecordService.java index 2cb629c0..b7c8e71d 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketRecordService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketRecordService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketRecord; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketReco * @author system * @since 2025-10-18 */ -public interface LotteryTicketRecordService extends IService { +public interface LotteryTicketRecordService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketService.java index 5c203a82..938615e3 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryTicketService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; * @author system * @since 2025-10-18 */ -public interface LotteryTicketService extends IService { +public interface LotteryTicketService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryUserCountService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryUserCountService.java index 001f0a69..53e3693b 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryUserCountService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryUserCountService.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity; -import com.baomidou.mybatisplus.extension.service.IService; +import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserCount; /** @@ -9,6 +9,6 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserCount; * @author system * @since 2025-10-18 */ -public interface LotteryUserCountService extends IService { +public interface LotteryUserCountService extends BaseService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryActivityServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryActivityServiceImpl.java index c6e3f48d..7a637950 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryActivityServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryActivityServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryActivity; import com.red.circle.other.infra.database.rds.dao.activity.LotteryActivityMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryActivityService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryActivityServiceImpl extends ServiceImpl +public class LotteryActivityServiceImpl extends BaseServiceImpl implements LotteryActivityService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryPrizeServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryPrizeServiceImpl.java index d73f38e6..7da8d43a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryPrizeServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryPrizeServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryPrize; import com.red.circle.other.infra.database.rds.dao.activity.LotteryPrizeMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryPrizeService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryPrizeServiceImpl extends ServiceImpl +public class LotteryPrizeServiceImpl extends BaseServiceImpl implements LotteryPrizeService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryRecordServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryRecordServiceImpl.java index e170e215..0bc8624b 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryRecordServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryRecordServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryRecord; import com.red.circle.other.infra.database.rds.dao.activity.LotteryRecordMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryRecordService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryRecordServiceImpl extends ServiceImpl +public class LotteryRecordServiceImpl extends BaseServiceImpl implements LotteryRecordService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketRecordServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketRecordServiceImpl.java index 44bf4eb0..df7e2c22 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketRecordServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketRecordServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketRecord; import com.red.circle.other.infra.database.rds.dao.activity.LotteryTicketRecordMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketRecordService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryTicketRecordServiceImpl extends ServiceImpl +public class LotteryTicketRecordServiceImpl extends BaseServiceImpl implements LotteryTicketRecordService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketServiceImpl.java index 8bce3b76..fe80e9bf 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryTicketServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; import com.red.circle.other.infra.database.rds.dao.activity.LotteryTicketMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryTicketServiceImpl extends ServiceImpl +public class LotteryTicketServiceImpl extends BaseServiceImpl implements LotteryTicketService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryUserCountServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryUserCountServiceImpl.java index 576be188..e16c9282 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryUserCountServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryUserCountServiceImpl.java @@ -1,6 +1,6 @@ package com.red.circle.other.infra.database.rds.service.activity.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserCount; import com.red.circle.other.infra.database.rds.dao.activity.LotteryUserCountMapper; import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; * @since 2025-10-18 */ @Service -public class LotteryUserCountServiceImpl extends ServiceImpl +public class LotteryUserCountServiceImpl extends BaseServiceImpl implements LotteryUserCountService { } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryActivityMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryActivityMapper.xml new file mode 100644 index 00000000..35f70e29 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryActivityMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryPrizeMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryPrizeMapper.xml new file mode 100644 index 00000000..d63264c5 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryPrizeMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryRecordMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryRecordMapper.xml new file mode 100644 index 00000000..b7d84788 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryRecordMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketMapper.xml new file mode 100644 index 00000000..87a62bde --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketRecordMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketRecordMapper.xml new file mode 100644 index 00000000..e6a85942 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryTicketRecordMapper.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryUserCountMapper.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryUserCountMapper.xml new file mode 100644 index 00000000..33bbe407 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/activity/LotteryUserCountMapper.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityClientEndpoint.java index ab746c36..5159c3b2 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityClientEndpoint.java @@ -30,9 +30,9 @@ public class LotteryActivityClientEndpoint implements LotteryActivityClientApi { @Override public ResultResponse getByActivityCode(String activityCode) { - LotteryActivity activity = lotteryActivityService.lambdaQuery() + LotteryActivity activity = lotteryActivityService.query() .eq(LotteryActivity::getActivityCode, activityCode) - .one(); + .getOne(); if (activity == null) { return ResultResponse.success(null); @@ -54,7 +54,7 @@ public class LotteryActivityClientEndpoint implements LotteryActivityClientApi { @Override public ResultResponse> listActivities() { - List activities = lotteryActivityService.lambdaQuery() + List activities = lotteryActivityService.query() .eq(LotteryActivity::getStatus, 1) .orderByDesc(LotteryActivity::getCreateTime) .list(); diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityManageClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityManageClientEndpoint.java index 999b7300..229032c0 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityManageClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityManageClientEndpoint.java @@ -8,6 +8,10 @@ import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; import com.red.circle.other.inner.endpoint.activity.api.LotteryActivityManageClientApi; import com.red.circle.other.inner.model.cmd.activity.LotteryActivitySaveCmd; import com.red.circle.other.inner.model.dto.activity.LotteryActivityDTO; +import java.sql.Timestamp; + +import com.red.circle.tool.core.date.TimestampUtils; +import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.http.MediaType; @@ -34,9 +38,9 @@ public class LotteryActivityManageClientEndpoint implements LotteryActivityManag @Transactional(rollbackFor = Exception.class) public ResultResponse createActivity(LotteryActivitySaveCmd cmd) { // 校验活动编码唯一性 - LotteryActivity exists = lotteryActivityService.lambdaQuery() + LotteryActivity exists = lotteryActivityService.query() .eq(LotteryActivity::getActivityCode, cmd.getActivityCode()) - .one(); + .getOne(); ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_CODE_EXISTS, exists == null); LotteryActivity activity = new LotteryActivity(); @@ -58,15 +62,8 @@ public class LotteryActivityManageClientEndpoint implements LotteryActivityManag LotteryActivity activity = lotteryActivityService.getById(cmd.getId()); ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_NOT_FOUND, activity != null); - // 校验活动编码唯一性 - LotteryActivity exists = lotteryActivityService.lambdaQuery() - .eq(LotteryActivity::getActivityCode, cmd.getActivityCode()) - .ne(LotteryActivity::getId, cmd.getId()) - .one(); - ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_CODE_EXISTS, exists == null); - BeanUtils.copyProperties(cmd, activity); - lotteryActivityService.updateById(activity); + lotteryActivityService.updateSelectiveById(activity); return ResultResponse.success(); } @@ -77,8 +74,44 @@ public class LotteryActivityManageClientEndpoint implements LotteryActivityManag LotteryActivity activity = lotteryActivityService.getById(id); ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_NOT_FOUND, activity != null); + Integer currentStatus = activity.getStatus(); + Timestamp now = TimestampUtils.now(); + + // 状态校验规则:0-未开始,1-进行中,2-已结束,3-已关闭 + // 1. 未开始(0) -> 可以转换为:进行中(1)、已关闭(3) + // 2. 进行中(1) -> 可以转换为:已结束(2)、已关闭(3) + // 3. 已结束(2) -> 可以转换为:已关闭(3) + // 4. 已关闭(3) -> 不可再转换 + + // 校验:已关闭的活动不能再修改状态 + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_STATUS_NOT_ALLOW_UPDATE, + currentStatus != 3); + + // 校验状态转换的合法性 + if (currentStatus == 0) { + // 未开始 -> 只能转换为 进行中(1) 或 已关闭(3) + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_STATUS_NOT_ALLOW_UPDATE, + status == 1 || status == 3); + + // 转换为进行中时,需要校验时间 + if (status == 1) { + ResponseAssert.isTrue(LotteryErrorCode.NOT_IN_ACTIVITY_TIME, + now.after(activity.getStartTime()) || now.equals(activity.getStartTime())); + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_ENDED, + now.before(activity.getEndTime())); + } + } else if (currentStatus == 1) { + // 进行中 -> 只能转换为 已结束(2) 或 已关闭(3) + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_STATUS_NOT_ALLOW_UPDATE, + status == 2 || status == 3); + } else if (currentStatus == 2) { + // 已结束 -> 只能转换为 已关闭(3) + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_STATUS_NOT_ALLOW_UPDATE, + status == 3); + } + activity.setStatus(status); - lotteryActivityService.updateById(activity); + lotteryActivityService.updateSelectiveById(activity); return ResultResponse.success(); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityQueryClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityQueryClientEndpoint.java index 2389517e..592871a3 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityQueryClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryActivityQueryClientEndpoint.java @@ -1,5 +1,6 @@ package com.red.circle.other.app.inner.endpoint.activity; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.ResultResponse; @@ -37,7 +38,7 @@ public class LotteryActivityQueryClientEndpoint implements LotteryActivityQueryC Integer pageSize = cmd.getPageSize() != null ? cmd.getPageSize() : 20; Page page = new Page<>(pageNo, pageSize); - var query = lotteryActivityService.lambdaQuery(); + var query = lotteryActivityService.query(); if (cmd.getActivityName() != null) { query.like(LotteryActivity::getActivityName, cmd.getActivityName()); @@ -55,7 +56,7 @@ public class LotteryActivityQueryClientEndpoint implements LotteryActivityQueryC query.le(LotteryActivity::getStartTime, cmd.getStartTimeEnd()); } - Page result = query.orderByDesc(LotteryActivity::getCreateTime).page(page); + IPage result = query.orderByDesc(LotteryActivity::getCreateTime).page(page); List dtoList = result.getRecords().stream() .map(activity -> { diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeClientEndpoint.java index 9253b630..10096b51 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeClientEndpoint.java @@ -1,6 +1,9 @@ package com.red.circle.other.app.inner.endpoint.activity; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.red.circle.framework.dto.ResultResponse; +import com.red.circle.framework.mybatis.mybatisplus.LambdaQueryWrapperChain; import com.red.circle.other.infra.database.rds.entity.activity.LotteryPrize; import com.red.circle.other.infra.database.rds.service.activity.LotteryPrizeService; import com.red.circle.other.inner.endpoint.activity.api.LotteryPrizeClientApi; @@ -30,7 +33,7 @@ public class LotteryPrizeClientEndpoint implements LotteryPrizeClientApi { @Override public ResultResponse> listByActivityId(Long activityId) { - List prizes = lotteryPrizeService.lambdaQuery() + List prizes = lotteryPrizeService.query() .eq(LotteryPrize::getActivityId, activityId) .orderByAsc(LotteryPrize::getSortOrder) .list(); @@ -55,12 +58,10 @@ public class LotteryPrizeClientEndpoint implements LotteryPrizeClientApi { @Override public ResultResponse deductStock(Long id, Integer count) { - boolean success = lotteryPrizeService.lambdaUpdate() - .eq(LotteryPrize::getId, id) + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper().eq(LotteryPrize::getId, id) .gt(LotteryPrize::getRemainingStock, 0) - .setSql("remaining_stock = remaining_stock - " + count) - .update(); - + .setSql("remaining_stock = remaining_stock - " + count); + boolean success = lotteryPrizeService.update(wrapper); return ResultResponse.success(success); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeManageClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeManageClientEndpoint.java index b48155a4..2bb36da2 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeManageClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryPrizeManageClientEndpoint.java @@ -65,7 +65,7 @@ public class LotteryPrizeManageClientEndpoint implements LotteryPrizeManageClien @Override public ResultResponse> listByActivityId(Long activityId) { - List prizes = lotteryPrizeService.lambdaQuery() + List prizes = lotteryPrizeService.query() .eq(LotteryPrize::getActivityId, activityId) .orderByAsc(LotteryPrize::getSortOrder) .list(); @@ -107,7 +107,7 @@ public class LotteryPrizeManageClientEndpoint implements LotteryPrizeManageClien * 更新活动总库存(内部方法). */ private void updateActivityStockInternal(Long activityId) { - List prizes = lotteryPrizeService.lambdaQuery() + List prizes = lotteryPrizeService.query() .eq(LotteryPrize::getActivityId, activityId) .list(); @@ -119,11 +119,11 @@ public class LotteryPrizeManageClientEndpoint implements LotteryPrizeManageClien .mapToInt(LotteryPrize::getRemainingStock) .sum(); - lotteryActivityService.lambdaUpdate() + lotteryActivityService.update() .eq(LotteryActivity::getId, activityId) .set(LotteryActivity::getTotalStock, totalStock) .set(LotteryActivity::getConsumedStock, totalStock - remainingStock) - .update(); + .execute(); } } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordClientEndpoint.java index 0a8377c9..41b05015 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordClientEndpoint.java @@ -6,6 +6,8 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryRecordSer import com.red.circle.other.inner.endpoint.activity.api.LotteryRecordClientApi; import com.red.circle.other.inner.model.dto.activity.LotteryRecordDTO; import java.time.LocalDateTime; + +import com.red.circle.tool.core.date.TimestampUtils; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.http.MediaType; @@ -29,7 +31,7 @@ public class LotteryRecordClientEndpoint implements LotteryRecordClientApi { @Override public ResultResponse saveRecord(String recordNo, Long userId, Long activityId, - Long prizeId, String prizeName, Integer prizeType, + Long prizeId, String prizeName, String prizeType, Integer isWin) { LotteryRecord record = new LotteryRecord(); record.setRecordNo(recordNo); @@ -39,7 +41,7 @@ public class LotteryRecordClientEndpoint implements LotteryRecordClientApi { record.setPrizeName(prizeName); record.setPrizeType(prizeType); record.setIsWin(isWin); - record.setDrawTime(LocalDateTime.now()); + record.setDrawTime(TimestampUtils.now()); record.setPrizeStatus(isWin == 1 ? 0 : null); lotteryRecordService.save(record); @@ -49,9 +51,9 @@ public class LotteryRecordClientEndpoint implements LotteryRecordClientApi { @Override public ResultResponse getByRecordNo(String recordNo) { - LotteryRecord record = lotteryRecordService.lambdaQuery() + LotteryRecord record = lotteryRecordService.query() .eq(LotteryRecord::getRecordNo, recordNo) - .one(); + .getOne(); if (record == null) { return ResultResponse.success(null); diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordManageClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordManageClientEndpoint.java index f94c2e11..0f57bb66 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordManageClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryRecordManageClientEndpoint.java @@ -1,5 +1,6 @@ package com.red.circle.other.app.inner.endpoint.activity; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.dto.PageResult; @@ -13,10 +14,14 @@ import com.red.circle.other.inner.endpoint.activity.api.LotteryRecordManageClien import com.red.circle.other.inner.model.cmd.activity.LotteryRecordQryCmd; import com.red.circle.other.inner.model.dto.activity.LotteryActivityDTO; import com.red.circle.other.inner.model.dto.activity.LotteryRecordDTO; + +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + +import com.red.circle.tool.core.date.TimestampUtils; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.http.MediaType; @@ -46,7 +51,7 @@ public class LotteryRecordManageClientEndpoint implements LotteryRecordManageCli Integer pageSize = cmd.getPageSize() != null ? cmd.getPageSize() : 20; Page page = new Page<>(pageNo, pageSize); - var query = lotteryRecordService.lambdaQuery(); + var query = lotteryRecordService.query(); if (cmd.getUserId() != null) { query.eq(LotteryRecord::getUserId, cmd.getUserId()); @@ -55,9 +60,9 @@ public class LotteryRecordManageClientEndpoint implements LotteryRecordManageCli query.eq(LotteryRecord::getActivityId, cmd.getActivityId()); } if (cmd.getActivityCode() != null) { - LotteryActivity activity = lotteryActivityService.lambdaQuery() + LotteryActivity activity = lotteryActivityService.query() .eq(LotteryActivity::getActivityCode, cmd.getActivityCode()) - .one(); + .getOne(); if (activity != null) { query.eq(LotteryRecord::getActivityId, activity.getId()); } @@ -75,7 +80,7 @@ public class LotteryRecordManageClientEndpoint implements LotteryRecordManageCli query.le(LotteryRecord::getDrawTime, cmd.getDrawTimeEnd()); } - Page result = query.orderByDesc(LotteryRecord::getDrawTime).page(page); + IPage result = query.orderByDesc(LotteryRecord::getDrawTime).page(page); // 查询活动信息 List activityIds = result.getRecords().stream() @@ -83,7 +88,11 @@ public class LotteryRecordManageClientEndpoint implements LotteryRecordManageCli .distinct() .collect(Collectors.toList()); - Map activityMap = lotteryActivityService.lambdaQuery() + if (activityIds.isEmpty()) { + return ResultResponse.success(PageResult.newPageResult(cmd.getPageSize())); + } + + Map activityMap = lotteryActivityService.query() .in(LotteryActivity::getId, activityIds) .list() .stream() @@ -126,8 +135,8 @@ public class LotteryRecordManageClientEndpoint implements LotteryRecordManageCli // 4-积分:调用积分服务 record.setPrizeStatus(1); // 已发放 - record.setDeliverTime(LocalDateTime.now()); - lotteryRecordService.updateById(record); + record.setDeliverTime(TimestampUtils.now()); + lotteryRecordService.updateSelectiveById(record); return ResultResponse.success(); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketClientEndpoint.java index 0f14f253..62927556 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketClientEndpoint.java @@ -1,5 +1,6 @@ package com.red.circle.other.app.inner.endpoint.activity; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketRecord; @@ -31,7 +32,7 @@ public class LotteryTicketClientEndpoint implements LotteryTicketClientApi { @Override public ResultResponse getUserTicketCount(Long userId) { - List tickets = lotteryTicketService.lambdaQuery() + List tickets = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) @@ -47,7 +48,7 @@ public class LotteryTicketClientEndpoint implements LotteryTicketClientApi { @Override @Transactional(rollbackFor = Exception.class) public ResultResponse deductTicket(Long userId, Integer count) { - List tickets = lotteryTicketService.lambdaQuery() + List tickets = lotteryTicketService.query() .eq(LotteryTicket::getUserId, userId) .eq(LotteryTicket::getStatus, 1) .gt(LotteryTicket::getRemainingCount, 0) @@ -69,12 +70,12 @@ public class LotteryTicketClientEndpoint implements LotteryTicketClientApi { } int deduct = Math.min(remaining, ticket.getRemainingCount()); - - lotteryTicketService.lambdaUpdate() + + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .eq(LotteryTicket::getId, ticket.getId()) .setSql("used_count = used_count + " + deduct) - .setSql("remaining_count = remaining_count - " + deduct) - .update(); + .setSql("remaining_count = remaining_count - " + deduct); + lotteryTicketService.update(updateWrapper); // 记录使用 LotteryTicketRecord ticketRecord = new LotteryTicketRecord(); diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketManageClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketManageClientEndpoint.java index 3146aa54..754145c5 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketManageClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryTicketManageClientEndpoint.java @@ -1,12 +1,15 @@ package com.red.circle.other.app.inner.endpoint.activity; +import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicketRecord; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketRecordService; import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService; +import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; import com.red.circle.other.inner.endpoint.activity.api.LotteryTicketManageClientApi; import com.red.circle.other.inner.model.cmd.activity.LotteryTicketGrantCmd; +import java.sql.Timestamp; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; @@ -32,9 +35,21 @@ public class LotteryTicketManageClientEndpoint implements LotteryTicketManageCli @Override @Transactional(rollbackFor = Exception.class) public ResultResponse grantTickets(LotteryTicketGrantCmd cmd) { + // 校验必填参数 + ResponseAssert.isTrue(LotteryErrorCode.USER_ID_REQUIRED, + cmd.getUserIds() != null && !cmd.getUserIds().isEmpty()); + ResponseAssert.isTrue(LotteryErrorCode.GRANT_COUNT_INVALID, + cmd.getCount() != null && cmd.getCount() > 0); + + // 来源ID必填 - 用于追踪抽奖券的发放来源 + ResponseAssert.isTrue(LotteryErrorCode.ACTIVITY_ID_REQUIRED, + cmd.getSourceId() != null && !cmd.getSourceId().isEmpty()); + String ticketSource = cmd.getTicketSource() != null ? cmd.getTicketSource() : "SYSTEM"; + Timestamp now = new Timestamp(System.currentTimeMillis()); for (Long userId : cmd.getUserIds()) { + // 创建抽奖券记录 LotteryTicket ticket = new LotteryTicket(); ticket.setUserId(userId); ticket.setTicketSource(ticketSource); @@ -43,16 +58,16 @@ public class LotteryTicketManageClientEndpoint implements LotteryTicketManageCli ticket.setUsedCount(0); ticket.setRemainingCount(cmd.getCount()); ticket.setExpireTime(cmd.getExpireTime()); - ticket.setStatus(1); + ticket.setStatus(1); // 正常状态 lotteryTicketService.save(ticket); - // 记录发放 + // 记录发放日志 LotteryTicketRecord ticketRecord = new LotteryTicketRecord(); ticketRecord.setUserId(userId); ticketRecord.setTicketId(ticket.getId()); ticketRecord.setChangeCount(cmd.getCount()); - ticketRecord.setChangeType(1); // 发放 - ticketRecord.setRemark(cmd.getRemark()); + ticketRecord.setChangeType(1); // 1-发放 + ticketRecord.setRemark(cmd.getRemark() != null ? cmd.getRemark() : "系统发放抽奖券"); lotteryTicketRecordService.save(ticketRecord); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryUserCountClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryUserCountClientEndpoint.java index 8a6fdc9d..7f512cfc 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryUserCountClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/activity/LotteryUserCountClientEndpoint.java @@ -27,11 +27,11 @@ public class LotteryUserCountClientEndpoint implements LotteryUserCountClientApi @Override public ResultResponse getTodayCount(Long userId, Long activityId) { - LotteryUserCount userCount = lotteryUserCountService.lambdaQuery() + LotteryUserCount userCount = lotteryUserCountService.query() .eq(LotteryUserCount::getUserId, userId) .eq(LotteryUserCount::getActivityId, activityId) .eq(LotteryUserCount::getDrawDate, LocalDate.now()) - .one(); + .getOne(); int count = userCount != null ? userCount.getDrawCount() : 0; @@ -40,11 +40,11 @@ public class LotteryUserCountClientEndpoint implements LotteryUserCountClientApi @Override public ResultResponse incrDrawCount(Long userId, Long activityId) { - LotteryUserCount userCount = lotteryUserCountService.lambdaQuery() + LotteryUserCount userCount = lotteryUserCountService.query() .eq(LotteryUserCount::getUserId, userId) .eq(LotteryUserCount::getActivityId, activityId) .eq(LotteryUserCount::getDrawDate, LocalDate.now()) - .one(); + .getOne(); if (userCount == null) { userCount = new LotteryUserCount(); @@ -54,10 +54,10 @@ public class LotteryUserCountClientEndpoint implements LotteryUserCountClientApi userCount.setDrawCount(1); lotteryUserCountService.save(userCount); } else { - lotteryUserCountService.lambdaUpdate() + lotteryUserCountService.update() .eq(LotteryUserCount::getId, userCount.getId()) .setSql("draw_count = draw_count + 1") - .update(); + .execute(); } return ResultResponse.success();