1. add lottery
This commit is contained in:
2026-02-14 22:47:51 +08:00
parent d4e2bed039
commit f5746394fa
7 changed files with 75 additions and 2 deletions

View File

@@ -181,7 +181,7 @@ public class APPUserController {
@GetMapping("/lottery-prizes")
@ApiOperationSupport(order = 15)
@Operation(summary = "抽奖记录")
@Operation(summary = "奖品列表")
public R<List<CommonLotteryPrizeApiVO>> lotteryPrizes() {
return R.data(lotteryPrizeService.staticList());
}
@@ -200,4 +200,18 @@ public class APPUserController {
return R.data(lotteryPrizeService.draw(request));
}
@GetMapping("/lottery-rules")
@ApiOperationSupport(order = 18)
@Operation(summary = "抽奖记录")
public R<String> lotteryRules() {
return R.data(lotteryPrizeService.rules());
}
@GetMapping("/lottery-winners")
@ApiOperationSupport(order = 19)
@Operation(summary = "获奖名单")
public R<List<CommonLotteryWinnerApiVO>> lotteryWinners() {
return R.data(lotteryRecordService.lotteryWinners());
}
}

View File

@@ -0,0 +1,16 @@
package org.springblade.modules.api.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class CommonLotteryWinnerApiVO implements Serializable {
private String prizeName;
private String account;
private String username;
}

View File

@@ -53,4 +53,6 @@ public interface ICommonLotteryPrizeService extends BaseService<CommonLotteryPri
CommonLotteryPrizeApiVO draw(LotteryDrawRequest request);
List<CommonLotteryPrizeApiVO> staticList();
String rules();
}

View File

@@ -27,6 +27,7 @@ package org.springblade.modules.common.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.springblade.modules.api.vo.CommonLotteryRecordApiVO;
import org.springblade.modules.api.vo.CommonLotteryWinnerApiVO;
import org.springblade.modules.common.pojo.entity.CommonLotteryRecordEntity;
import org.springblade.modules.common.pojo.vo.CommonLotteryRecordVO;
import org.springblade.modules.common.excel.CommonLotteryRecordExcel;
@@ -64,4 +65,7 @@ public interface ICommonLotteryRecordService extends BaseService<CommonLotteryRe
IPage<CommonLotteryRecordApiVO> selectLotteryRecordApiPage(IPage<CommonLotteryRecordApiVO> page, CommonLotteryRecordApiVO vo);
Boolean addRecord(Long userId, BigDecimal amount);
List<CommonLotteryWinnerApiVO> lotteryWinners();
}

View File

@@ -80,6 +80,32 @@ public class CommonLotteryPrizeServiceImpl extends BaseServiceImpl<CommonLottery
private static final CommonLotteryPrizeApiVO PRIZE = new CommonLotteryPrizeApiVO(0L, "谢谢参与");
private static final String RULES = """
活动名称:幸运大抽奖
活动时间:即日起至2026年8月31日 23:59(北京时间)
参与方式:
- 消耗 100 积分 即可参与一次抽奖;
奖品说明:
• 谢谢参与:未中奖,感谢支持;
• 100积分:中奖后立即到账;
• 1000积分:中奖后立即到账;
• 生态礼包:内含精选生态商品组合,包邮到家;
• 黑茶礼盒:高品质黑茶礼盒一份,典雅包装,适合馈赠;
• 幸运锦鲤:超级大奖!包含实物礼包+专属权益,详情请留意中奖通知。
发放规则:
- 积分类奖品:即时到账;
- 实物奖品(生态礼包、黑茶礼盒、幸运锦鲤):中奖后3个工作日内联系您,请保持手机畅通并及时填写收货信息,逾期视为放弃。
温馨提示:
1. 抽奖结果由系统随机生成,公平公正;
2. 禁止使用外挂、脚本等作弊行为,一经发现将取消资格;
3. 本活动最终解释权归平台所有。
""";
@Override
public IPage<CommonLotteryPrizeVO> selectLotteryPrizePage(IPage<CommonLotteryPrizeVO> page, CommonLotteryPrizeVO lotteryPrize) {
return page.setRecords(baseMapper.selectLotteryPrizePage(page, lotteryPrize));
@@ -115,4 +141,9 @@ public class CommonLotteryPrizeServiceImpl extends BaseServiceImpl<CommonLottery
return STATIC_PRIZE_LIST;
}
@Override
public String rules() {
return RULES;
}
}

View File

@@ -27,6 +27,7 @@ package org.springblade.modules.common.service.impl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.api.vo.CommonLotteryRecordApiVO;
import org.springblade.modules.api.vo.CommonLotteryWinnerApiVO;
import org.springblade.modules.common.pojo.entity.CommonLotteryRecordEntity;
import org.springblade.modules.common.pojo.vo.CommonLotteryRecordVO;
import org.springblade.modules.common.excel.CommonLotteryRecordExcel;
@@ -88,4 +89,9 @@ public class CommonLotteryRecordServiceImpl extends BaseServiceImpl<CommonLotter
return save(lotteryRecord);
}
@Override
public List<CommonLotteryWinnerApiVO> lotteryWinners() {
return List.of();
}
}

View File

@@ -87,7 +87,7 @@ public class CommonUserPointServiceImpl extends BaseServiceImpl<CommonUserPointM
BigDecimal lastAmount = userPoint.getAmount();
int i = baseMapper.deductUserPoint(userId, amount, userPoint.getVersion());
if (i > 0) {
if (userPointLogService.recordPointChangeLog(userPoint, lastAmount, LOTTERY.getCode().toUpperCase(), amount, UserPointFlowType.GRANT.getCode(), null, null)) {
if (userPointLogService.recordPointChangeLog(userPoint, lastAmount, LOTTERY.getCode().toUpperCase(), amount.negate(), UserPointFlowType.SPEND.getCode(), null, null)) {
eventPublisher.publishEvent(new SpendUserPointEvent(userId, amount, LOTTERY));
return;
}