From 388250159075c14cb274014b4b24f3b189a5a2b0 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 23 Oct 2025 14:33:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E6=96=B0=E5=A2=9E=E6=8A=BD?= =?UTF-8?q?=E5=A5=96=E6=B4=BB=E5=8A=A8=E6=8F=90=E7=8E=B0=E5=92=8C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asserts/lottery/LotteryErrorCode.java | 10 ++ .../LotteryActivityRestController.java | 43 ++++++ .../activity/LotteryWithdrawAmountQryExe.java | 88 ++++++++++++ .../activity/LotteryWithdrawApplyExe.java | 126 ++++++++++++++++++ .../activity/LotteryWithdrawQryExe.java | 57 ++++++++ .../LotteryActivityRestServiceImpl.java | 37 +++-- .../activity/LotteryWithdrawAmountCO.java | 40 ++++++ .../activity/LotteryWithdrawCO.java | 91 +++++++++++++ .../dto/cmd/activity/LotteryWithdrawCmd.java | 52 ++++++++ .../cmd/activity/LotteryWithdrawQryCmd.java | 38 ++++++ .../activity/LotteryActivityRestService.java | 19 +++ .../rds/dao/activity/LotteryWithdrawDAO.java | 16 +++ .../rds/entity/activity/LotteryWithdraw.java | 116 ++++++++++++++++ .../activity/LotteryWithdrawService.java | 14 ++ .../impl/LotteryWithdrawServiceImpl.java | 19 +++ 15 files changed, 753 insertions(+), 13 deletions(-) create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawAmountQryExe.java create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawApplyExe.java create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawQryExe.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawAmountCO.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawCO.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawCmd.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawQryCmd.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryWithdrawDAO.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryWithdraw.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryWithdrawService.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryWithdrawServiceImpl.java diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/lottery/LotteryErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/lottery/LotteryErrorCode.java index 0f7b3b9f..8caf905e 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/lottery/LotteryErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/lottery/LotteryErrorCode.java @@ -162,6 +162,16 @@ public enum LotteryErrorCode implements IResponseErrorCode { */ MULTI_DRAW_NOT_ENABLED(9730, "Multi-draw feature is not enabled for this activity"), + /** + * 没有可提现金额. + */ + NO_WITHDRAWAL_AMOUNT(9731, "No withdrawal amount available"), + + /** + * 可提现金额不足. + */ + INSUFFICIENT_WITHDRAWAL_AMOUNT(9732, "Insufficient withdrawal amount"), + ; private final Integer code; 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 b3ebe60d..b2bb6ce9 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 @@ -11,11 +11,15 @@ import com.red.circle.other.app.dto.clientobject.activity.LotteryRankCO; 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.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.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryMultiDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRankQryCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRecordQryCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryWinnerHistoryQryCmd; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawCmd; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawQryCmd; import com.red.circle.other.app.service.activity.LotteryActivityRestService; import java.util.List; @@ -180,4 +184,43 @@ public class LotteryActivityRestController extends BaseController { return lotteryActivityRestService.getWinnerHistory(cmd); } + /** + * 提交提现申请. + * + * @eo.name 提交提现申请. + * @eo.url /withdraw/apply + * @eo.method post + * @eo.request-type json + */ + @PostMapping("/withdraw/apply") + public void applyWithdraw(@RequestBody @Validated LotteryWithdrawCmd cmd) { + lotteryActivityRestService.applyWithdraw(cmd); + } + + /** + * 查询提现记录. + * + * @eo.name 查询提现记录. + * @eo.url /withdraw/records + * @eo.method get + * @eo.request-type formdata + */ + @GetMapping("/withdraw/records") + public PageResult listWithdrawRecords(LotteryWithdrawQryCmd cmd) { + return lotteryActivityRestService.listWithdrawRecords(cmd); + } + + /** + * 查询可提现金额. + * + * @eo.name 查询可提现金额. + * @eo.url /withdraw/amount + * @eo.method get + * @eo.request-type formdata + */ + @GetMapping("/withdraw/amount") + public LotteryWithdrawAmountCO getWithdrawAmount(AppExtCommand cmd, Long activityId) { + return lotteryActivityRestService.getWithdrawAmount(cmd, activityId); + } + } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawAmountQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawAmountQryExe.java new file mode 100644 index 00000000..dd0ed0da --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawAmountQryExe.java @@ -0,0 +1,88 @@ +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.LotteryWithdrawAmountCO; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserProgress; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; +import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService; +import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.temporal.WeekFields; +import java.util.Locale; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 查询可提现金额. + * + * @author system + * @since 2025-10-21 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class LotteryWithdrawAmountQryExe { + + private final LotteryUserProgressService lotteryUserProgressService; + private final LotteryWithdrawService lotteryWithdrawService; + + public LotteryWithdrawAmountCO execute(AppExtCommand cmd, Long activityId) { + Long userId = cmd.requiredReqUserId(); + + // 1. 获取用户本周累计金额 + String weekKey = getCurrentWeekKey(); + LotteryUserProgress progress = lotteryUserProgressService.query() + .eq(LotteryUserProgress::getUserId, userId) + .eq(activityId != null, LotteryUserProgress::getActivityId, activityId) + .eq(LotteryUserProgress::getWeekKey, weekKey) + .getOne(); + + BigDecimal totalAmount = progress != null && progress.getTotalAmount() != null + ? progress.getTotalAmount() + : BigDecimal.ZERO; + + // 2. 计算已提现金额 + BigDecimal withdrawnAmount = lotteryWithdrawService.query() + .eq(LotteryWithdraw::getUserId, userId) + .eq(activityId != null, LotteryWithdraw::getActivityId, activityId) + .in(LotteryWithdraw::getStatus, 1, 3) // 已通过、已完成 + .list() + .stream() + .map(LotteryWithdraw::getAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 3. 计算待审核金额 + BigDecimal pendingAmount = lotteryWithdrawService.query() + .eq(LotteryWithdraw::getUserId, userId) + .eq(activityId != null, LotteryWithdraw::getActivityId, activityId) + .eq(LotteryWithdraw::getStatus, 0) // 待审核 + .list() + .stream() + .map(LotteryWithdraw::getAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 4. 计算可提现金额 + BigDecimal availableAmount = totalAmount.subtract(withdrawnAmount).subtract(pendingAmount); + + LotteryWithdrawAmountCO amountCO = new LotteryWithdrawAmountCO(); + amountCO.setTotalAmount(totalAmount); + amountCO.setWithdrawnAmount(withdrawnAmount); + amountCO.setPendingAmount(pendingAmount); + amountCO.setAvailableAmount(availableAmount.compareTo(BigDecimal.ZERO) > 0 ? availableAmount : BigDecimal.ZERO); + + return amountCO; + } + + /** + * 获取当前周标识. + */ + private String getCurrentWeekKey() { + LocalDate now = LocalDate.now(); + int year = now.getYear(); + int weekOfYear = now.get(WeekFields.of(Locale.getDefault()).weekOfYear()); + return String.format("%dW%02d", year, weekOfYear); + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawApplyExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawApplyExe.java new file mode 100644 index 00000000..2d94b8d6 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawApplyExe.java @@ -0,0 +1,126 @@ +package com.red.circle.other.app.command.activity; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawCmd; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserProgress; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; +import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService; +import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService; +import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; +import com.red.circle.tool.core.date.TimestampUtils; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.temporal.WeekFields; +import java.util.Locale; +import java.util.concurrent.ThreadLocalRandom; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * 提交抽奖提现申请. + * + * @author system + * @since 2025-10-21 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class LotteryWithdrawApplyExe { + + private final LotteryUserProgressService lotteryUserProgressService; + private final LotteryWithdrawService lotteryWithdrawService; + + @Transactional(rollbackFor = Exception.class) + public void execute(LotteryWithdrawCmd cmd) { + Long userId = cmd.requiredReqUserId(); + BigDecimal amount = cmd.getAmount(); + + // 1. 获取用户本周累计金额 + String weekKey = getCurrentWeekKey(); + LotteryUserProgress progress = lotteryUserProgressService.query() + .eq(LotteryUserProgress::getUserId, userId) + .eq(cmd.getActivityId() != null, LotteryUserProgress::getActivityId, cmd.getActivityId()) + .eq(LotteryUserProgress::getWeekKey, weekKey) + .getOne(); + + ResponseAssert.notNull(LotteryErrorCode.NO_WITHDRAWAL_AMOUNT, progress); + ResponseAssert.isTrue(LotteryErrorCode.NO_WITHDRAWAL_AMOUNT, + progress.getTotalAmount() != null && progress.getTotalAmount().compareTo(BigDecimal.ZERO) > 0); + + // 2. 计算可提现金额(总金额 - 已提现金额 - 待审核金额) + BigDecimal withdrawnAmount = getWithdrawnAmount(userId, cmd.getActivityId()); + BigDecimal pendingAmount = getPendingAmount(userId, cmd.getActivityId()); + BigDecimal availableAmount = progress.getTotalAmount().subtract(withdrawnAmount).subtract(pendingAmount); + + // 3. 校验提现金额 + ResponseAssert.isTrue(LotteryErrorCode.INSUFFICIENT_WITHDRAWAL_AMOUNT, + amount.compareTo(availableAmount) <= 0); + + // 4. 创建提现申请 + LotteryWithdraw withdraw = new LotteryWithdraw(); + withdraw.setWithdrawNo(generateWithdrawNo()); + withdraw.setUserId(userId); + withdraw.setActivityId(cmd.getActivityId()); + withdraw.setAmount(amount); + withdraw.setContactNumber(cmd.getContactNumber()); + withdraw.setDescription(cmd.getDescription()); + withdraw.setCardImages(cmd.getCardImages()); + withdraw.setStatus(0); // 待审核 + withdraw.setCreateTime(TimestampUtils.now()); + withdraw.setUpdateTime(TimestampUtils.now()); + + lotteryWithdrawService.save(withdraw); + + log.info("Lottery withdraw application submitted, userId: {}, amount: {}, withdrawNo: {}", + userId, amount, withdraw.getWithdrawNo()); + } + + /** + * 获取已提现金额. + */ + private BigDecimal getWithdrawnAmount(Long userId, Long activityId) { + return lotteryWithdrawService.query() + .eq(LotteryWithdraw::getUserId, userId) + .eq(activityId != null, LotteryWithdraw::getActivityId, activityId) + .in(LotteryWithdraw::getStatus, 1, 3) // 已通过、已完成 + .list() + .stream() + .map(LotteryWithdraw::getAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + /** + * 获取待审核金额. + */ + private BigDecimal getPendingAmount(Long userId, Long activityId) { + return lotteryWithdrawService.query() + .eq(LotteryWithdraw::getUserId, userId) + .eq(activityId != null, LotteryWithdraw::getActivityId, activityId) + .eq(LotteryWithdraw::getStatus, 0) // 待审核 + .list() + .stream() + .map(LotteryWithdraw::getAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + /** + * 获取当前周标识. + */ + private String getCurrentWeekKey() { + LocalDate now = LocalDate.now(); + int year = now.getYear(); + int weekOfYear = now.get(WeekFields.of(Locale.getDefault()).weekOfYear()); + return String.format("%dW%02d", year, weekOfYear); + } + + /** + * 生成提现单号. + */ + private String generateWithdrawNo() { + return "WD" + 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/LotteryWithdrawQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawQryExe.java new file mode 100644 index 00000000..87c9b719 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryWithdrawQryExe.java @@ -0,0 +1,57 @@ +package com.red.circle.other.app.command.activity; + +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawCO; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawQryCmd; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; +import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Component; + +/** + * 查询抽奖提现记录. + * + * @author system + * @since 2025-10-21 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class LotteryWithdrawQryExe { + + private final LotteryWithdrawService lotteryWithdrawService; + + public PageResult execute(LotteryWithdrawQryCmd cmd) { + PageResult pageResult = lotteryWithdrawService.query() + .eq(cmd.getUserId() != null, LotteryWithdraw::getUserId, cmd.getUserId()) + .eq(cmd.getActivityId() != null, LotteryWithdraw::getActivityId, cmd.getActivityId()) + .eq(cmd.getStatus() != null, LotteryWithdraw::getStatus, cmd.getStatus()) + .orderByDesc(LotteryWithdraw::getCreateTime) + .page(cmd.getPageQuery()); + + return pageResult.convert(this::convertToCO); + } + + private LotteryWithdrawCO convertToCO(LotteryWithdraw withdraw) { + LotteryWithdrawCO co = new LotteryWithdrawCO(); + BeanUtils.copyProperties(withdraw, co); + co.setStatusText(getStatusText(withdraw.getStatus())); + return co; + } + + private String getStatusText(Integer status) { + if (status == null) { + return "未知"; + } + return switch (status) { + case 0 -> "待审核"; + case 1 -> "已通过"; + case 2 -> "已拒绝"; + case 3 -> "已完成"; + default -> "未知"; + }; + } + +} 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 55fe5066..e3d48c8e 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 @@ -11,19 +11,12 @@ 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.LotteryWinnerHistoryQryExe; -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; -import com.red.circle.other.app.dto.clientobject.activity.LotteryMultiDrawResultCO; -import com.red.circle.other.app.dto.clientobject.activity.LotteryRankCO; -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.clientobject.activity.LotteryWinnerHistoryCO; -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; -import com.red.circle.other.app.dto.cmd.activity.LotteryRecordQryCmd; -import com.red.circle.other.app.dto.cmd.activity.LotteryWinnerHistoryQryCmd; +import com.red.circle.other.app.command.activity.LotteryWithdrawAmountQryExe; +import com.red.circle.other.app.command.activity.LotteryWithdrawApplyExe; +import com.red.circle.other.app.command.activity.LotteryWithdrawQryExe; +import com.red.circle.other.app.dto.clientobject.activity.*; +import com.red.circle.other.app.dto.cmd.activity.*; + import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -47,6 +40,9 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic private final LotteryTicketCountQryExe lotteryTicketCountQryExe; private final LotteryRankQryExe lotteryRankQryExe; private final LotteryWinnerHistoryQryExe lotteryWinnerHistoryQryExe; + private final LotteryWithdrawApplyExe lotteryWithdrawApplyExe; + private final LotteryWithdrawQryExe lotteryWithdrawQryExe; + private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe; @Override public List listValidActivities(AppExtCommand cmd) { @@ -93,4 +89,19 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic return lotteryWinnerHistoryQryExe.execute(cmd); } + @Override + public void applyWithdraw(LotteryWithdrawCmd cmd) { + lotteryWithdrawApplyExe.execute(cmd); + } + + @Override + public PageResult listWithdrawRecords(LotteryWithdrawQryCmd cmd) { + return lotteryWithdrawQryExe.execute(cmd); + } + + @Override + public LotteryWithdrawAmountCO getWithdrawAmount(AppExtCommand cmd, Long activityId) { + return lotteryWithdrawAmountQryExe.execute(cmd, activityId); + } + } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawAmountCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawAmountCO.java new file mode 100644 index 00000000..9f1b470b --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawAmountCO.java @@ -0,0 +1,40 @@ +package com.red.circle.other.app.dto.clientobject.activity; + +import com.red.circle.framework.dto.ClientObject; +import java.math.BigDecimal; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 可提现金额CO. + * + * @author system + * @since 2025-10-21 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class LotteryWithdrawAmountCO extends ClientObject { + + /** + * 可提现金额. + */ + private BigDecimal availableAmount; + + /** + * 总中奖金额. + */ + private BigDecimal totalAmount; + + /** + * 已提现金额. + */ + private BigDecimal withdrawnAmount; + + /** + * 待审核金额. + */ + private BigDecimal pendingAmount; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawCO.java new file mode 100644 index 00000000..88c6c376 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/activity/LotteryWithdrawCO.java @@ -0,0 +1,91 @@ +package com.red.circle.other.app.dto.clientobject.activity; + +import com.red.circle.framework.dto.ClientObject; +import java.math.BigDecimal; +import java.sql.Timestamp; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 抽奖提现记录CO. + * + * @author system + * @since 2025-10-21 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class LotteryWithdrawCO extends ClientObject { + + /** + * 主键ID. + */ + private Long id; + + /** + * 提现单号. + */ + private String withdrawNo; + + /** + * 用户ID. + */ + private Long userId; + + /** + * 活动ID. + */ + private Long activityId; + + /** + * 提现金额. + */ + private BigDecimal amount; + + /** + * 联系号码. + */ + private String contactNumber; + + /** + * 描述信息. + */ + private String description; + + /** + * 卡片图片(多个用逗号分隔). + */ + private String cardImages; + + /** + * 状态:0-待审核,1-已通过,2-已拒绝,3-已完成. + */ + private Integer status; + + /** + * 状态文本. + */ + private String statusText; + + /** + * 拒绝原因. + */ + private String rejectReason; + + /** + * 审核时间. + */ + private Timestamp auditTime; + + /** + * 完成时间. + */ + private Timestamp completeTime; + + /** + * 创建时间. + */ + private Timestamp createTime; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawCmd.java new file mode 100644 index 00000000..60f08a6c --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawCmd.java @@ -0,0 +1,52 @@ +package com.red.circle.other.app.dto.cmd.activity; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.math.BigDecimal; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 抽奖提现申请CMD. + * + * @author system + * @since 2025-10-21 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class LotteryWithdrawCmd extends AppExtCommand { + + /** + * 活动ID(可选). + */ + private Long activityId; + + /** + * 提现金额. + */ + @NotNull(message = "提现金额不能为空") + @DecimalMin(value = "0.01", message = "提现金额必须大于0") + private BigDecimal amount; + + /** + * 联系号码. + */ + @NotBlank(message = "联系号码不能为空") + private String contactNumber; + + /** + * 描述信息. + */ + private String description; + + /** + * 卡片图片(多个用逗号分隔). + */ + @NotBlank(message = "卡片图片不能为空") + private String cardImages; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawQryCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawQryCmd.java new file mode 100644 index 00000000..1893fb54 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/activity/LotteryWithdrawQryCmd.java @@ -0,0 +1,38 @@ +package com.red.circle.other.app.dto.cmd.activity; + +import com.red.circle.framework.core.dto.PageCommand; +import java.io.Serial; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 抽奖提现记录查询CMD. + * + * @author system + * @since 2025-10-21 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class LotteryWithdrawQryCmd extends PageCommand { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 用户ID. + */ + private Long userId; + + /** + * 活动ID. + */ + private Long activityId; + + /** + * 状态:0-待审核,1-已通过,2-已拒绝,3-已完成. + */ + private Integer status; + +} 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 2e52c0a4..bc1a630c 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 @@ -10,11 +10,15 @@ import com.red.circle.other.app.dto.clientobject.activity.LotteryRankCO; 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.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.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryMultiDrawCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRankQryCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryRecordQryCmd; import com.red.circle.other.app.dto.cmd.activity.LotteryWinnerHistoryQryCmd; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawCmd; +import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawQryCmd; import java.util.List; /** @@ -70,4 +74,19 @@ public interface LotteryActivityRestService { */ List getWinnerHistory(LotteryWinnerHistoryQryCmd cmd); + /** + * 提交提现申请. + */ + void applyWithdraw(LotteryWithdrawCmd cmd); + + /** + * 查询提现记录. + */ + PageResult listWithdrawRecords(LotteryWithdrawQryCmd cmd); + + /** + * 查询可提现金额. + */ + LotteryWithdrawAmountCO getWithdrawAmount(AppExtCommand cmd, Long activityId); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryWithdrawDAO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryWithdrawDAO.java new file mode 100644 index 00000000..7ad3256d --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/activity/LotteryWithdrawDAO.java @@ -0,0 +1,16 @@ +package com.red.circle.other.infra.database.rds.dao.activity; + +import com.red.circle.framework.mybatis.dao.BaseDAO; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; +import org.apache.ibatis.annotations.Mapper; + +/** + * 抽奖提现申请Mapper. + * + * @author system + * @since 2025-10-21 + */ +@Mapper +public interface LotteryWithdrawDAO extends BaseDAO { + +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryWithdraw.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryWithdraw.java new file mode 100644 index 00000000..dd12ff48 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/LotteryWithdraw.java @@ -0,0 +1,116 @@ +package com.red.circle.other.infra.database.rds.entity.activity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +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.math.BigDecimal; +import java.sql.Timestamp; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 抽奖提现申请表. + * + * @author system + * @since 2025-10-21 + */ +@Data +@Accessors(chain = true) +@TableName("lottery_withdraw") +public class LotteryWithdraw { + + /** + * 主键ID. + */ + @TableId("id") + private Long id; + + /** + * 提现单号. + */ + @TableField("withdraw_no") + private String withdrawNo; + + /** + * 用户ID. + */ + @TableField("user_id") + private Long userId; + + /** + * 活动ID. + */ + @TableField("activity_id") + private Long activityId; + + /** + * 提现金额. + */ + @TableField("amount") + private BigDecimal amount; + + /** + * 联系号码. + */ + @TableField("contact_number") + private String contactNumber; + + /** + * 描述信息. + */ + @TableField("description") + private String description; + + /** + * 卡片图片(多个用逗号分隔). + */ + @TableField("card_images") + private String cardImages; + + /** + * 状态:0-待审核,1-已通过,2-已拒绝,3-已完成. + */ + @TableField("status") + private Integer status; + + /** + * 拒绝原因. + */ + @TableField("reject_reason") + private String rejectReason; + + /** + * 审核人. + */ + @TableField("audit_user") + private Long auditUser; + + /** + * 审核时间. + */ + @TableField("audit_time") + private Timestamp auditTime; + + /** + * 完成时间. + */ + @TableField("complete_time") + private Timestamp completeTime; + + /** + * 备注. + */ + @TableField("remark") + private String remark; + + @TableField("create_time") + private Timestamp createTime; + + @TableField("update_time") + 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/LotteryWithdrawService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryWithdrawService.java new file mode 100644 index 00000000..d1b8c8e8 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/LotteryWithdrawService.java @@ -0,0 +1,14 @@ +package com.red.circle.other.infra.database.rds.service.activity; + +import com.red.circle.framework.mybatis.service.BaseService; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; + +/** + * 抽奖提现申请Service. + * + * @author system + * @since 2025-10-21 + */ +public interface LotteryWithdrawService 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/LotteryWithdrawServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryWithdrawServiceImpl.java new file mode 100644 index 00000000..5f9c0f58 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/LotteryWithdrawServiceImpl.java @@ -0,0 +1,19 @@ +package com.red.circle.other.infra.database.rds.service.activity.impl; + +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; +import com.red.circle.other.infra.database.rds.dao.activity.LotteryWithdrawDAO; +import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw; +import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService; +import org.springframework.stereotype.Service; + +/** + * 抽奖提现申请Service实现. + * + * @author system + * @since 2025-10-21 + */ +@Service +public class LotteryWithdrawServiceImpl extends BaseServiceImpl + implements LotteryWithdrawService { + +}