【功能新增】商城:积分商城

This commit is contained in:
YunaiV
2024-10-04 20:02:08 +08:00
parent 6c325d99e7
commit 39ac641497
27 changed files with 511 additions and 15 deletions

View File

@@ -0,0 +1,54 @@
package cn.iocoder.yudao.module.promotion.api.point;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.point.dto.PointValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 秒杀活动")
public interface PointActivityApi {
String PREFIX = ApiConstants.PREFIX + "/point-activity";
@GetMapping(PREFIX + "/validate-join")
@Operation(summary = "【下单前】校验是否参与积分商城活动")
@Parameters({
@Parameter(name = "activityId", description = "活动编号", required = true, example = "1"),
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"),
})
CommonResult<PointValidateJoinRespDTO> validateJoinPointActivity(@RequestParam("activityId") Long activityId,
@RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count);
@PutMapping(PREFIX + "/update-stock-decr")
@Operation(summary = "更新积分商品库存(减少)")
@Parameters({
@Parameter(name = "id", description = "活动编号", required = true, example = "1"),
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"),
})
CommonResult<Boolean> updatePointStockDecr(@RequestParam("id") Long id,
@RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count);
@PutMapping(PREFIX + "/update-stock-incr")
@Operation(summary = "更新积分商城商品库存(增加)")
@Parameters({
@Parameter(name = "id", description = "活动编号", required = true, example = "1"),
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"),
})
CommonResult<Boolean> updatePointStockIncr(@RequestParam("id") Long id,
@RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count);
}

View File

@@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.promotion.api.point.dto;
import lombok.Data;
/**
* 校验参与积分商城 Response DTO
*/
@Data
public class PointValidateJoinRespDTO {
/**
* 可兑换次数
*/
private Integer count;
/**
* 所需兑换积分
*/
private Integer point;
/**
* 所需兑换金额,单位:分
*/
private Integer price;
}

View File

@@ -40,7 +40,7 @@ public interface SeckillActivityApi {
@RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count);
@GetMapping("/validate-join")
@GetMapping(PREFIX + "/validate-join")
@Operation(summary = "【下单前】校验是否参与秒杀活动") // 如果校验失败,则抛出业务异常
@Parameters({
@Parameter(name = "activityId", description = "活动编号", required = true, example = "1"),

View File

@@ -50,6 +50,10 @@ public interface ErrorCodeConstants {
ErrorCode POINT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_007_002, "积分商城活动已关闭,不能修改");
ErrorCode POINT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_007_003, "积分商城活动未关闭或未结束,不能删除");
ErrorCode POINT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_007_004, "积分商城活动已关闭,不能重复关闭");
ErrorCode POINT_ACTIVITY_JOIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_007_005, "积分商品兑换失败,原因:积分商城活动已关闭");
ErrorCode POINT_ACTIVITY_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_007_006, "积分商品兑换失败,原因:单次限购超出");
ErrorCode POINT_ACTIVITY_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_007_007, "积分商品兑换失败,原因:商品不存在");
ErrorCode POINT_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_007_008, "积分商品兑换失败,原因:积分商品库存不足");
// ========== 秒杀活动 1-013-008-000 ==========
ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在");