碎片兑换完善

This commit is contained in:
tianfeng 2026-01-15 16:48:21 +08:00
parent 114d560d66
commit ed796d3228
3 changed files with 15 additions and 10 deletions

View File

@ -1,9 +1,8 @@
package com.red.circle.other.adapter.app.activity.room;
package com.red.circle.other.adapter.app.activity;
import cn.hutool.core.util.StrUtil;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.activity.LastWeekStarGiftUserRankCO;
import com.red.circle.other.app.dto.clientobject.activity.UserRankCO;
@ -21,6 +20,7 @@ import java.util.Set;
import com.red.circle.other.inner.model.dto.material.FragmentsBackpackDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.*;
* @eo.groupName 活动服务.周星活动
* @eo.path /activity/week-star
*/
@RequestMapping("/activity/week-star")
@RequestMapping(value = "/activity/week-star", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequiredArgsConstructor
public class WeekStarRestController extends BaseController {
@ -155,7 +155,7 @@ public class WeekStarRestController extends BaseController {
* @eo.request-type formdata
*/
@PostMapping("/exchange")
public Long exchange(@Validated WeekStarExchangeCmd cmd) {
public Long exchange(@Validated @RequestBody WeekStarExchangeCmd cmd) {
return weekStarService.exchange(cmd);
}

View File

@ -49,7 +49,7 @@ public class WeekStarExchangeExe {
// 1. 校验碎片背包
List<FragmentsBackpackDTO> backpackList = fragmentsBackpackClientApi
.listByUserIdByFragmentsIds(cmd.getReqUserId(), Set.of(cmd.getFragmentsId()))
.listByUserIdByFragmentsIds(cmd.getUserId(), Set.of(cmd.getFragmentsId()))
.getBody();
ResponseAssert.notEmpty(CommonErrorCode.DATA_ERROR, backpackList);
@ -84,23 +84,20 @@ public class WeekStarExchangeExe {
// 2. 扣除碎片
fragmentsBackpackClientApi.decrFragments(
cmd.getReqUserId(),
cmd.getUserId(),
Set.of(cmd.getFragmentsId()),
needFragments
);
// 发送奖品
sendPropsManager.sendGroup(SendRewardParam.builder()
.acceptUserId(cmd.getReqUserId())
.acceptUserId(cmd.getUserId())
.origin(SendPropsOrigin.EGG)
.sysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin()))
.trackId(cmd.getPropsGroupId())
.build(),
getPrizeDescribes(rewardProps));
// 4. 添加兑换记录 - 暂时不写
// TODO: 添加兑换记录
return 1L; // 返回兑换数量
}

View File

@ -5,6 +5,8 @@ import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 周星碎片兑换命令.
*
@ -14,6 +16,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false)
public class WeekStarExchangeCmd extends AppExtCommand {
@Serial
private static final long serialVersionUID = 1L;
/**
* 道具组ID.
*/
@ -26,4 +31,7 @@ public class WeekStarExchangeCmd extends AppExtCommand {
@NotNull(message = "fragmentsId {not.null}")
private Long fragmentsId;
@NotNull(message = "userId {not.null}")
private Long userId;
}