新增抽奖背包流水

This commit is contained in:
tianfeng 2026-01-16 15:59:21 +08:00
parent 0117f1b5f5
commit fdaf2c16b4
12 changed files with 208 additions and 45 deletions

View File

@ -0,0 +1,28 @@
package com.red.circle.other.inner.model.dto.activity;
import lombok.Data;
import java.sql.Timestamp;import java.time.LocalDateTime;
/**
* 抽奖背包流水
*/
@Data
public class LotteryBackpackLogCO {
private Long id;
private String itemType;
private String itemName;
private String itemIcon;
private Integer changeType;
private Integer changeAmount;
private String source;
private Timestamp createdAt;
}

View File

@ -18,22 +18,11 @@ 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.ActivityRewardConfigCO;
import com.red.circle.other.app.dto.clientobject.activity.ClaimRewardResultCO; 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.clientobject.activity.MyTotalDrawCountCO;
import com.red.circle.other.app.dto.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.*;
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.dto.cmd.activity.LotteryExchangeGoldCmd;
import com.red.circle.other.app.dto.cmd.activity.LotteryTransferCmd;
import com.red.circle.other.app.dto.cmd.activity.ActivityRechargeRankCmd;
import com.red.circle.other.app.dto.cmd.activity.UserActivityRechargeCmd;
import com.red.circle.other.app.dto.cmd.activity.ActivityRewardConfigCmd;
import com.red.circle.other.app.dto.cmd.activity.ClaimActivityRewardCmd;
import com.red.circle.other.app.service.activity.LotteryActivityRestService; import com.red.circle.other.app.service.activity.LotteryActivityRestService;
import com.red.circle.other.app.service.activity.ActivityRechargeService; import com.red.circle.other.app.service.activity.ActivityRechargeService;
import com.red.circle.other.app.service.activity.ActivityRewardConfigService; import com.red.circle.other.app.service.activity.ActivityRewardConfigService;
import com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -142,6 +131,18 @@ public class LotteryActivityRestController extends BaseController {
return lotteryActivityRestService.listMyRecords(cmd); return lotteryActivityRestService.listMyRecords(cmd);
} }
/**
* 查询抽奖背包流水
* @eo.name 查询背包流水
* @eo.url /backpack/logs
* @eo.method post
* @eo.request-type json
*/
@PostMapping("/backpack/logs")
public PageResult<LotteryBackpackLogCO> queryBackpackLogs(@RequestBody LotteryBackpackLogQryCmd cmd) {
return lotteryActivityRestService.queryBackpackLogs(cmd);
}
/** /**
* 查询我的抽奖券列表详细信息. * 查询我的抽奖券列表详细信息.
* *

View File

@ -0,0 +1,29 @@
package com.red.circle.other.app.command.activity;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.dto.cmd.activity.LotteryBackpackLogQryCmd;
import com.red.circle.other.infra.gateway.lottery.LotteryBackpackGateway;
import com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 查询抽奖背包流水
*/
@Component
@RequiredArgsConstructor
public class LotteryBackpackLogQryExe {
private final LotteryBackpackGateway lotteryBackpackGateway;
public PageResult<LotteryBackpackLogCO> query(LotteryBackpackLogQryCmd cmd) {
return lotteryBackpackGateway.queryUserLogs(
cmd.getReqUserId(),
cmd.getItemType(),
cmd.getChangeType(),
cmd.getSource(),
cmd.getPageNum(),
cmd.getPageSize()
);
}
}

View File

@ -78,6 +78,7 @@ public class LotteryDrawExe {
private final UserActivityRechargeService userActivityRechargeService; private final UserActivityRechargeService userActivityRechargeService;
private final WalletGoldClient walletGoldClient; private final WalletGoldClient walletGoldClient;
private final LotteryBackpackGateway lotteryBackpackGateway; private final LotteryBackpackGateway lotteryBackpackGateway;
private static final Long FIXED_ACTIVITY_ID = 2004471533988167125L;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public LotteryDrawResultCO execute(LotteryDrawCmd cmd) { public LotteryDrawResultCO execute(LotteryDrawCmd cmd) {
@ -549,8 +550,10 @@ public class LotteryDrawExe {
remaining -= deduct; remaining -= deduct;
String deductBizNo = "lottery_deduct:" + IdWorker.getIdStr(); if (Objects.equals(activityId, FIXED_ACTIVITY_ID)) {
lotteryBackpackGateway.recordTicketDeduct(userId, deduct, "lottery", deductBizNo); String deductBizNo = "lottery_deduct:" + IdWorker.getIdStr();
lotteryBackpackGateway.recordTicketDeduct(userId, deduct, "lottery", deductBizNo);
}
} }
if (!records.isEmpty()) { if (!records.isEmpty()) {

View File

@ -77,6 +77,7 @@ public class LotteryMultiDrawExe {
private final UserActivityRechargeService userActivityRechargeService; private final UserActivityRechargeService userActivityRechargeService;
private final WalletGoldClient walletGoldClient; private final WalletGoldClient walletGoldClient;
private final LotteryBackpackGateway lotteryBackpackGateway; private final LotteryBackpackGateway lotteryBackpackGateway;
private static final Long FIXED_ACTIVITY_ID = 2004471533988167125L;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public LotteryMultiDrawResultCO execute(LotteryMultiDrawCmd cmd) { public LotteryMultiDrawResultCO execute(LotteryMultiDrawCmd cmd) {
@ -522,8 +523,11 @@ public class LotteryMultiDrawExe {
records.add(ticketRecord); records.add(ticketRecord);
remaining -= deduct; remaining -= deduct;
String deductBizNo = "lottery_deduct:" + IdWorker.getTimeId();
lotteryBackpackGateway.recordTicketDeduct(userId, deduct, "lottery", deductBizNo); if (Objects.equals(activityId, FIXED_ACTIVITY_ID)) {
String deductBizNo = "lottery_deduct:" + IdWorker.getTimeId();
lotteryBackpackGateway.recordTicketDeduct(userId, deduct, "lottery", deductBizNo);
}
} }
if (!records.isEmpty()) { if (!records.isEmpty()) {
lotteryTicketRecordService.saveBatch(records); lotteryTicketRecordService.saveBatch(records);

View File

@ -2,21 +2,7 @@ package com.red.circle.other.app.service.activity;
import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.app.command.activity.LotteryActivityDetailQryExe; import com.red.circle.other.app.command.activity.*;
import com.red.circle.other.app.command.activity.LotteryActivityListQryExe;
import com.red.circle.other.app.command.activity.LotteryDrawExe;
import com.red.circle.other.app.command.activity.LotteryMultiDrawExe;
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;
import com.red.circle.other.app.command.activity.LotteryWithdrawQryExe;
import com.red.circle.other.app.command.activity.LotteryExchangeGoldExe;
import com.red.circle.other.app.command.activity.LotteryTransferExe;
import com.red.circle.other.app.dto.clientobject.activity.*; import com.red.circle.other.app.dto.clientobject.activity.*;
import com.red.circle.other.app.dto.cmd.activity.*; import com.red.circle.other.app.dto.cmd.activity.*;
@ -51,6 +37,7 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic
private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe; private final LotteryWithdrawAmountQryExe lotteryWithdrawAmountQryExe;
private final LotteryExchangeGoldExe lotteryExchangeGoldExe; private final LotteryExchangeGoldExe lotteryExchangeGoldExe;
private final LotteryTransferExe lotteryTransferExe; private final LotteryTransferExe lotteryTransferExe;
private final LotteryBackpackLogQryExe lotteryBackpackLogQryExe;
private final DistributedLockUtil distributedLockUtil; private final DistributedLockUtil distributedLockUtil;
private static final String LOCK_KEY_PREFIX = "activity:lottery:draw:lock"; private static final String LOCK_KEY_PREFIX = "activity:lottery:draw:lock";
@ -133,4 +120,9 @@ public class LotteryActivityRestServiceImpl implements LotteryActivityRestServic
lotteryTransferExe.execute(cmd); lotteryTransferExe.execute(cmd);
} }
@Override
public PageResult<com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO> queryBackpackLogs(LotteryBackpackLogQryCmd cmd) {
return lotteryBackpackLogQryExe.query(cmd);
}
} }

View File

@ -0,0 +1,31 @@
package com.red.circle.other.app.dto.cmd.activity;
import com.red.circle.common.business.dto.PageQueryCmd;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 查询抽奖背包流水
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class LotteryBackpackLogQryCmd extends PageQueryCmd {
/**
* 道具类型lottery_ticket-抽奖券, cp_fragment-碎片
*/
private String itemType;
/**
* 变动类型1-增加, 2-扣除
*/
private Integer changeType;
/**
* 来源sign_in-签到, lottery-抽奖, exchange-兑换
*/
private String source;
private Integer pageNum;
private Integer pageSize;
}

View File

@ -13,15 +13,8 @@ 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.LotteryWithdrawAmountCO;
import com.red.circle.other.app.dto.clientobject.activity.LotteryWithdrawCO; 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.clientobject.activity.MyTotalDrawCountCO;
import com.red.circle.other.app.dto.cmd.activity.LotteryDrawCmd; import com.red.circle.other.app.dto.cmd.activity.*;
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.dto.cmd.activity.LotteryExchangeGoldCmd;
import com.red.circle.other.app.dto.cmd.activity.LotteryTransferCmd;
import java.util.List; import java.util.List;
/** /**
@ -107,4 +100,9 @@ public interface LotteryActivityRestService {
*/ */
void transfer(LotteryTransferCmd cmd); void transfer(LotteryTransferCmd cmd);
/**
* 查询抽奖背包流水
*/
PageResult<com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO> queryBackpackLogs(LotteryBackpackLogQryCmd cmd);
} }

View File

@ -1,4 +1,4 @@
package com.red.circle.other.infra.database.rds.dao; package com.red.circle.other.infra.database.rds.dao.activity;
import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.framework.mybatis.dao.BaseDAO;
import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog; import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog;

View File

@ -1,6 +1,10 @@
package com.red.circle.other.infra.database.rds.service.lottery; package com.red.circle.other.infra.database.rds.service.lottery;
import com.red.circle.other.infra.database.rds.dao.LotteryBackpackLogDAO; import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.red.circle.other.infra.database.rds.dao.activity.LotteryBackpackLogDAO;
import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog; import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -26,4 +30,31 @@ public class LotteryBackpackLogDatabaseService {
} }
} }
/**
* 分页查询流水
*/
public IPage<LotteryBackpackLog> queryPage(Long userId, String itemType, Integer changeType,
String source, Integer pageNum, Integer pageSize) {
LambdaQueryWrapper<LotteryBackpackLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LotteryBackpackLog::getUserId, userId);
if (StringUtils.hasText(itemType)) {
wrapper.eq(LotteryBackpackLog::getItemType, itemType);
}
if (changeType != null) {
wrapper.eq(LotteryBackpackLog::getChangeType, changeType);
}
if (StringUtils.hasText(source)) {
wrapper.eq(LotteryBackpackLog::getSource, source);
}
wrapper.orderByDesc(LotteryBackpackLog::getCreatedAt);
Page<LotteryBackpackLog> page = new Page<>(pageNum, pageSize);
return lotteryBackpackLogDAO.selectPage(page, wrapper);
}
} }

View File

@ -1,5 +1,8 @@
package com.red.circle.other.infra.gateway.lottery; package com.red.circle.other.infra.gateway.lottery;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO;
/** /**
* 抽奖背包网关 * 抽奖背包网关
*/ */
@ -24,4 +27,10 @@ public interface LotteryBackpackGateway {
* 记录碎片扣除 * 记录碎片扣除
*/ */
void recordFragmentDeduct(Long userId, Integer amount, String source, String bizNo); void recordFragmentDeduct(Long userId, Integer amount, String source, String bizNo);
/**
* 查询用户流水
*/
PageResult<LotteryBackpackLogCO> queryUserLogs(Long userId, String itemType, Integer changeType,
String source, Integer pageNum, Integer pageSize);
} }

View File

@ -1,12 +1,18 @@
package com.red.circle.other.infra.gateway.lottery.impl; package com.red.circle.other.infra.gateway.lottery.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog; import com.red.circle.other.infra.database.rds.entity.LotteryBackpackLog;
import com.red.circle.other.inner.model.dto.activity.LotteryBackpackLogCO;
import com.red.circle.other.infra.database.rds.service.lottery.LotteryBackpackLogDatabaseService; import com.red.circle.other.infra.database.rds.service.lottery.LotteryBackpackLogDatabaseService;
import com.red.circle.other.infra.gateway.lottery.LotteryBackpackGateway; import com.red.circle.other.infra.gateway.lottery.LotteryBackpackGateway;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 抽奖背包网关实现 * 抽奖背包网关实现
@ -63,4 +69,35 @@ public class LotteryBackpackGatewayImpl implements LotteryBackpackGateway {
log.setCreatedAt(LocalDateTime.now()); log.setCreatedAt(LocalDateTime.now());
return log; return log;
} }
@Override
public PageResult<LotteryBackpackLogCO> queryUserLogs(Long userId, String itemType, Integer changeType,
String source, Integer pageNum, Integer pageSize) {
IPage<LotteryBackpackLog> page = logDatabaseService.queryPage(userId, itemType, changeType, source, pageNum, pageSize);
List<LotteryBackpackLogCO> records = page.getRecords().stream()
.map(this::convertToCO)
.collect(Collectors.toList());
PageResult <LotteryBackpackLogCO> pageResult = new PageResult<>();
pageResult.setRecords(records);
pageResult.setTotal(page.getTotal());
pageResult.setCurrent(page.getCurrent());
pageResult.setSize(page.getSize());
return pageResult;
}
private LotteryBackpackLogCO convertToCO(LotteryBackpackLog log) {
LotteryBackpackLogCO co = new LotteryBackpackLogCO();
co.setId(log.getId());
co.setItemType(log.getItemType());
co.setItemName(log.getItemName());
co.setItemIcon(log.getItemIcon());
co.setChangeType(log.getChangeType());
co.setChangeAmount(log.getChangeAmount());
co.setSource(log.getSource());
co.setCreatedAt(Timestamp.valueOf(log.getCreatedAt()));
return co;
}
} }