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 c7efa5d1..8911d9b7 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 @@ -17,6 +17,7 @@ import com.red.circle.other.app.dto.clientobject.activity.ActivityRechargeRankCO import com.red.circle.other.app.dto.clientobject.activity.UserActivityRechargeCO; import com.red.circle.other.app.dto.clientobject.activity.ActivityRewardConfigCO; import com.red.circle.other.app.dto.clientobject.activity.ClaimRewardResultCO; +import com.red.circle.other.app.dto.clientobject.activity.MyTotalDrawCountCO; import com.red.circle.other.app.dto.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryMultiDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRankQryCmd; @@ -167,6 +168,19 @@ public class LotteryActivityRestController extends BaseController { return lotteryActivityRestService.getMyTicketCount(cmd); } + /** + * 获取我的总抽奖次数. + * + * @eo.name 获取我的总抽奖次数. + * @eo.url /my-total-draw-count + * @eo.method get + * @eo.request-type formdata + */ + @GetMapping("/my-total-draw-count") + public MyTotalDrawCountCO getMyTotalDrawCount(AppExtCommand cmd) { + return lotteryActivityRestService.getMyTotalDrawCount(cmd); + } + /** * 查询排行榜. * diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/MyTotalDrawCountQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/MyTotalDrawCountQryExe.java new file mode 100644 index 00000000..dce9aef9 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/MyTotalDrawCountQryExe.java @@ -0,0 +1,46 @@ +package com.red.circle.other.app.command.activity; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import com.red.circle.other.app.dto.clientobject.activity.MyTotalDrawCountCO; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryTicket; +import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 查询我的总抽奖次数 + */ +@Component +@RequiredArgsConstructor +public class MyTotalDrawCountQryExe { + + private final LotteryTicketService lotteryTicketService; + + public MyTotalDrawCountCO execute(AppExtCommand cmd) { + Long userId = cmd.requiredReqUserId(); + + List tickets = lotteryTicketService.query() + .eq(LotteryTicket::getUserId, userId) + .eq(LotteryTicket::getStatus, 1) + .list(); + + int totalCount = tickets.stream() + .mapToInt(LotteryTicket::getTotalCount) + .sum(); + + int usedCount = tickets.stream() + .mapToInt(LotteryTicket::getUsedCount) + .sum(); + + int remainingCount = tickets.stream() + .mapToInt(LotteryTicket::getRemainingCount) + .sum(); + + return new MyTotalDrawCountCO() + .setTotalCount(totalCount) + .setUsedCount(usedCount) + .setRemainingCount(remainingCount); + } +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java index 501f0b3d..2f35850e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestServiceImpl.java @@ -10,6 +10,7 @@ import com.red.circle.other.app.command.activity.LotteryRankQryExe; import com.red.circle.other.app.command.activity.LotteryRecordQryExe; import com.red.circle.other.app.command.activity.LotteryTicketCountQryExe; import com.red.circle.other.app.command.activity.LotteryTicketQryExe; +import com.red.circle.other.app.command.activity.MyTotalDrawCountQryExe; import com.red.circle.other.app.command.activity.LotteryWinnerHistoryQryExe; import com.red.circle.other.app.command.activity.LotteryWithdrawAmountQryExe; import com.red.circle.other.app.command.activity.LotteryWithdrawApplyExe; @@ -42,6 +43,7 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic private final LotteryRecordQryExe lotteryRecordQryExe; private final LotteryTicketQryExe lotteryTicketQryExe; private final LotteryTicketCountQryExe lotteryTicketCountQryExe; + private final MyTotalDrawCountQryExe myTotalDrawCountQryExe; private final LotteryRankQryExe lotteryRankQryExe; private final LotteryWinnerHistoryQryExe lotteryWinnerHistoryQryExe; private final LotteryWithdrawApplyExe lotteryWithdrawApplyExe; @@ -91,6 +93,11 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic return lotteryTicketCountQryExe.execute(cmd); } + @Override + public MyTotalDrawCountCO getMyTotalDrawCount(AppExtCommand cmd) { + return myTotalDrawCountQryExe.execute(cmd); + } + @Override public List getRankList(LotteryRankQryCmd cmd) { return lotteryRankQryExe.execute(cmd); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/MyTotalDrawCountCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/MyTotalDrawCountCO.java new file mode 100644 index 00000000..40636706 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/MyTotalDrawCountCO.java @@ -0,0 +1,29 @@ +package com.red.circle.other.app.dto.clientobject.activity; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 我的总抽奖次数CO + */ +@Data +@Accessors(chain = true) +public class MyTotalDrawCountCO implements Serializable { + + /** + * 总抽奖次数 + */ + private Integer totalCount; + + /** + * 已使用次数 + */ + private Integer usedCount; + + /** + * 剩余次数 + */ + private Integer remainingCount; +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java index f80c24ed..b221f5d2 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/activity/LotteryActivityRestService.java @@ -12,6 +12,7 @@ import com.red.circle.other.app.dto.clientobject.activity.LotteryTicketCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryWinnerHistoryCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawAmountCO; import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawCO; +import com.red.circle.other.app.dto.clientobject.activity.MyTotalDrawCountCO; import com.red.circle.other.app.dto.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryMultiDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRankQryCmd; @@ -66,6 +67,11 @@ public interface LotteryActivityRestService { */ Integer getMyTicketCount(AppExtCommand cmd); + /** + * 查询我的总抽奖次数. + */ + MyTotalDrawCountCO getMyTotalDrawCount(AppExtCommand cmd); + /** * 查询排行榜. */