Commit 51fdbb81d4dddc9dcb9a8437b17f645437be1cbd
Committed by
Gitee
!1089 【新增】商城: 积分商城 DO
Merge pull request !1089 from puhui999/develop
Showing
16 changed files
with
798 additions
and
2 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -44,7 +44,9 @@ public interface ErrorCodeConstants { | @@ -44,7 +44,9 @@ public interface ErrorCodeConstants { | ||
| 44 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭"); | 44 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭"); |
| 45 | ErrorCode REWARD_ACTIVITY_SCOPE_EXISTS = new ErrorCode(1_013_006_005, "与该时间段满减送活动【{}】商品范围冲突,原因:{}"); | 45 | ErrorCode REWARD_ACTIVITY_SCOPE_EXISTS = new ErrorCode(1_013_006_005, "与该时间段满减送活动【{}】商品范围冲突,原因:{}"); |
| 46 | 46 | ||
| 47 | - // ========== TODO 空着 1-013-007-000 ============ | 47 | + // ========== 积分商城活动 1-013-007-000 ========== |
| 48 | + ErrorCode POINT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_007_000, "积分商城活动不存在"); | ||
| 49 | + ErrorCode POINT_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_007_100, "积分商城商品不存在"); | ||
| 48 | 50 | ||
| 49 | // ========== 秒杀活动 1-013-008-000 ========== | 51 | // ========== 秒杀活动 1-013-008-000 ========== |
| 50 | ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在"); | 52 | ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在"); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityRespVO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO; | ||
| 13 | +import cn.iocoder.yudao.module.promotion.service.point.PointActivityService; | ||
| 14 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 19 | +import jakarta.validation.Valid; | ||
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | +import org.springframework.validation.annotation.Validated; | ||
| 22 | +import org.springframework.web.bind.annotation.*; | ||
| 23 | + | ||
| 24 | +import java.io.IOException; | ||
| 25 | +import java.util.List; | ||
| 26 | + | ||
| 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 29 | + | ||
| 30 | +@Tag(name = "管理后台 - 积分商城活动") | ||
| 31 | +@RestController | ||
| 32 | +@RequestMapping("/promotion/point-activity") | ||
| 33 | +@Validated | ||
| 34 | +public class PointActivityController { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private PointActivityService pointActivityService; | ||
| 38 | + | ||
| 39 | + @PostMapping("/create") | ||
| 40 | + @Operation(summary = "创建积分商城活动") | ||
| 41 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:create')") | ||
| 42 | + public CommonResult<Long> createPointActivity(@Valid @RequestBody PointActivitySaveReqVO createReqVO) { | ||
| 43 | + return success(pointActivityService.createPointActivity(createReqVO)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @PutMapping("/update") | ||
| 47 | + @Operation(summary = "更新积分商城活动") | ||
| 48 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:update')") | ||
| 49 | + public CommonResult<Boolean> updatePointActivity(@Valid @RequestBody PointActivitySaveReqVO updateReqVO) { | ||
| 50 | + pointActivityService.updatePointActivity(updateReqVO); | ||
| 51 | + return success(true); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @DeleteMapping("/delete") | ||
| 55 | + @Operation(summary = "删除积分商城活动") | ||
| 56 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 57 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:delete')") | ||
| 58 | + public CommonResult<Boolean> deletePointActivity(@RequestParam("id") Long id) { | ||
| 59 | + pointActivityService.deletePointActivity(id); | ||
| 60 | + return success(true); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @GetMapping("/get") | ||
| 64 | + @Operation(summary = "获得积分商城活动") | ||
| 65 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 66 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:query')") | ||
| 67 | + public CommonResult<PointActivityRespVO> getPointActivity(@RequestParam("id") Long id) { | ||
| 68 | + PointActivityDO pointActivity = pointActivityService.getPointActivity(id); | ||
| 69 | + return success(BeanUtils.toBean(pointActivity, PointActivityRespVO.class)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @GetMapping("/page") | ||
| 73 | + @Operation(summary = "获得积分商城活动分页") | ||
| 74 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:query')") | ||
| 75 | + public CommonResult<PageResult<PointActivityRespVO>> getPointActivityPage(@Valid PointActivityPageReqVO pageReqVO) { | ||
| 76 | + PageResult<PointActivityDO> pageResult = pointActivityService.getPointActivityPage(pageReqVO); | ||
| 77 | + return success(BeanUtils.toBean(pageResult, PointActivityRespVO.class)); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @GetMapping("/export-excel") | ||
| 81 | + @Operation(summary = "导出积分商城活动 Excel") | ||
| 82 | + @PreAuthorize("@ss.hasPermission('promotion:point-activity:export')") | ||
| 83 | + @ApiAccessLog(operateType = EXPORT) | ||
| 84 | + public void exportPointActivityExcel(@Valid PointActivityPageReqVO pageReqVO, | ||
| 85 | + HttpServletResponse response) throws IOException { | ||
| 86 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 87 | + List<PointActivityDO> list = pointActivityService.getPointActivityPage(pageReqVO).getList(); | ||
| 88 | + // 导出 Excel | ||
| 89 | + ExcelUtils.write(response, "积分商城活动.xls", "数据", PointActivityRespVO.class, | ||
| 90 | + BeanUtils.toBean(list, PointActivityRespVO.class)); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | +} | ||
| 0 | \ No newline at end of file | 94 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - 积分商城活动分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class PointActivityPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "积分商城活动商品", example = "19509") | ||
| 21 | + private Long spuId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "活动状态", example = "2") | ||
| 24 | + private Integer status; | ||
| 25 | + | ||
| 26 | + @Schema(description = "备注", example = "你说的对") | ||
| 27 | + private String remark; | ||
| 28 | + | ||
| 29 | + @Schema(description = "排序") | ||
| 30 | + private Integer sort; | ||
| 31 | + | ||
| 32 | + @Schema(description = "创建时间") | ||
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | + private LocalDateTime[] createTime; | ||
| 35 | + | ||
| 36 | +} | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO; | ||
| 4 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 积分商城活动 Response VO") | ||
| 13 | +@Data | ||
| 14 | +@ExcelIgnoreUnannotated | ||
| 15 | +public class PointActivityRespVO { | ||
| 16 | + | ||
| 17 | + @Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373") | ||
| 18 | + @ExcelProperty("积分商城活动编号") | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | + @Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509") | ||
| 22 | + @ExcelProperty("积分商城活动商品") | ||
| 23 | + private Long spuId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 26 | + @ExcelProperty("活动状态") | ||
| 27 | + private Integer status; | ||
| 28 | + | ||
| 29 | + @Schema(description = "备注", example = "你说的对") | ||
| 30 | + @ExcelProperty("备注") | ||
| 31 | + private String remark; | ||
| 32 | + | ||
| 33 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 34 | + @ExcelProperty("排序") | ||
| 35 | + private Integer sort; | ||
| 36 | + | ||
| 37 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 38 | + @ExcelProperty("创建时间") | ||
| 39 | + private LocalDateTime createTime; | ||
| 40 | + | ||
| 41 | + @Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 42 | + private List<PointProductSaveReqVO> products; | ||
| 43 | + | ||
| 44 | + // ========== 商品字段 ========== | ||
| 45 | + | ||
| 46 | + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | ||
| 47 | + example = "618大促") | ||
| 48 | + private String spuName; | ||
| 49 | + @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 | ||
| 50 | + example = "https://www.iocoder.cn/xx.png") | ||
| 51 | + private String picUrl; | ||
| 52 | + @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 | ||
| 53 | + example = "50") | ||
| 54 | + private Integer marketPrice; | ||
| 55 | + | ||
| 56 | + //======================= 显示所需兑换积分最少的 sku 信息 ======================= | ||
| 57 | + | ||
| 58 | + @Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926") | ||
| 59 | + private Integer maxCount; | ||
| 60 | + | ||
| 61 | + @Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 62 | + private Integer point; | ||
| 63 | + | ||
| 64 | + @Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860") | ||
| 65 | + private Integer price; | ||
| 66 | + | ||
| 67 | +} | ||
| 0 | \ No newline at end of file | 68 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivitySaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 积分商城活动新增/修改 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class PointActivitySaveReqVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + @Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509") | ||
| 18 | + @NotNull(message = "积分商城活动商品不能为空") | ||
| 19 | + private Long spuId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 22 | + @NotNull(message = "活动状态不能为空") | ||
| 23 | + private Integer status; | ||
| 24 | + | ||
| 25 | + @Schema(description = "备注", example = "你说的对") | ||
| 26 | + private String remark; | ||
| 27 | + | ||
| 28 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | + @NotNull(message = "排序不能为空") | ||
| 30 | + private Integer sort; | ||
| 31 | + | ||
| 32 | + @Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | + private List<PointProductSaveReqVO> products; | ||
| 34 | + | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/product/PointProductPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - 积分商城商品分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class PointProductPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "积分商城活动 id", example = "29388") | ||
| 21 | + private Long activityId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "商品 SPU 编号", example = "8112") | ||
| 24 | + private Long spuId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "商品 SKU 编号", example = "2736") | ||
| 27 | + private Long skuId; | ||
| 28 | + | ||
| 29 | + @Schema(description = "可兑换数量", example = "3926") | ||
| 30 | + private Integer maxCount; | ||
| 31 | + | ||
| 32 | + @Schema(description = "兑换积分") | ||
| 33 | + private Integer point; | ||
| 34 | + | ||
| 35 | + @Schema(description = "兑换金额,单位:分", example = "15860") | ||
| 36 | + private Integer price; | ||
| 37 | + | ||
| 38 | + @Schema(description = "兑换类型", example = "2") | ||
| 39 | + private Integer type; | ||
| 40 | + | ||
| 41 | + @Schema(description = "积分商城商品状态", example = "2") | ||
| 42 | + private Integer activityStatus; | ||
| 43 | + | ||
| 44 | + @Schema(description = "创建时间") | ||
| 45 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 46 | + private LocalDateTime[] createTime; | ||
| 47 | + | ||
| 48 | +} | ||
| 0 | \ No newline at end of file | 49 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/product/PointProductRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 积分商城商品 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class PointProductRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718") | ||
| 16 | + @ExcelProperty("积分商城商品编号") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "积分商城活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388") | ||
| 20 | + @ExcelProperty("积分商城活动 id") | ||
| 21 | + private Long activityId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112") | ||
| 24 | + @ExcelProperty("商品 SPU 编号") | ||
| 25 | + private Long spuId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736") | ||
| 28 | + @ExcelProperty("商品 SKU 编号") | ||
| 29 | + private Long skuId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926") | ||
| 32 | + @ExcelProperty("可兑换数量") | ||
| 33 | + private Integer maxCount; | ||
| 34 | + | ||
| 35 | + @Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 36 | + @ExcelProperty("兑换积分") | ||
| 37 | + private Integer point; | ||
| 38 | + | ||
| 39 | + @Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860") | ||
| 40 | + @ExcelProperty("兑换金额,单位:分") | ||
| 41 | + private Integer price; | ||
| 42 | + | ||
| 43 | + @Schema(description = "兑换类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 44 | + @ExcelProperty("兑换类型") | ||
| 45 | + private Integer type; | ||
| 46 | + | ||
| 47 | + @Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 48 | + @ExcelProperty("积分商城商品状态") | ||
| 49 | + private Integer activityStatus; | ||
| 50 | + | ||
| 51 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 52 | + @ExcelProperty("创建时间") | ||
| 53 | + private LocalDateTime createTime; | ||
| 54 | + | ||
| 55 | +} | ||
| 0 | \ No newline at end of file | 56 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/product/PointProductSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - 积分商城商品新增/修改 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class PointProductSaveReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "积分商城活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388") | ||
| 15 | + @NotNull(message = "积分商城活动 id不能为空") | ||
| 16 | + private Long activityId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112") | ||
| 19 | + @NotNull(message = "商品 SPU 编号不能为空") | ||
| 20 | + private Long spuId; | ||
| 21 | + | ||
| 22 | + @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736") | ||
| 23 | + @NotNull(message = "商品 SKU 编号不能为空") | ||
| 24 | + private Long skuId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926") | ||
| 27 | + @NotNull(message = "可兑换数量不能为空") | ||
| 28 | + private Integer maxCount; | ||
| 29 | + | ||
| 30 | + @Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 31 | + @NotNull(message = "兑换积分不能为空") | ||
| 32 | + private Integer point; | ||
| 33 | + | ||
| 34 | + @Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860") | ||
| 35 | + @NotNull(message = "兑换金额,单位:分不能为空") | ||
| 36 | + private Integer price; | ||
| 37 | + | ||
| 38 | + @Schema(description = "兑换类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 39 | + @NotNull(message = "兑换类型不能为空") | ||
| 40 | + private Integer type; | ||
| 41 | + | ||
| 42 | + @Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 43 | + @NotNull(message = "积分商城商品状态不能为空") | ||
| 44 | + private Integer activityStatus; | ||
| 45 | + | ||
| 46 | +} | ||
| 0 | \ No newline at end of file | 47 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java
| @@ -54,7 +54,7 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO { | @@ -54,7 +54,7 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO { | ||
| 54 | example = "50") | 54 | example = "50") |
| 55 | private Integer marketPrice; | 55 | private Integer marketPrice; |
| 56 | 56 | ||
| 57 | - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | 57 | + @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 58 | private Integer seckillPrice; // 从 products 获取最小 price 读取 | 58 | private Integer seckillPrice; // 从 products 获取最小 price 读取 |
| 59 | 59 | ||
| 60 | } | 60 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/point/PointActivityDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.EqualsAndHashCode; | ||
| 10 | +import lombok.ToString; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 积分商城活动 DO | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@TableName(value = "promotion_point_activity", autoResultMap = true) | ||
| 18 | +@KeySequence("promotion_point_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 19 | +@Data | ||
| 20 | +@EqualsAndHashCode(callSuper = true) | ||
| 21 | +@ToString(callSuper = true) | ||
| 22 | +public class PointActivityDO extends BaseDO { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 积分商城活动编号 | ||
| 26 | + */ | ||
| 27 | + @TableId | ||
| 28 | + private Long id; | ||
| 29 | + /** | ||
| 30 | + * 积分商城活动商品 | ||
| 31 | + */ | ||
| 32 | + private Long spuId; | ||
| 33 | + /** | ||
| 34 | + * 活动状态 | ||
| 35 | + * | ||
| 36 | + * 枚举 {@link CommonStatusEnum 对应的类} | ||
| 37 | + */ | ||
| 38 | + private Integer status; | ||
| 39 | + /** | ||
| 40 | + * 备注 | ||
| 41 | + */ | ||
| 42 | + private String remark; | ||
| 43 | + /** | ||
| 44 | + * 排序 | ||
| 45 | + */ | ||
| 46 | + private Integer sort; | ||
| 47 | + | ||
| 48 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/point/PointProductDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | +import lombok.*; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分商城商品 DO | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +@TableName("promotion_point_product") | ||
| 16 | +@KeySequence("promotion_point_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class PointProductDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 积分商城商品编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 积分商城活动 id | ||
| 32 | + * | ||
| 33 | + * 关联 {@link PointActivityDO#getId()} | ||
| 34 | + */ | ||
| 35 | + private Long activityId; | ||
| 36 | + /** | ||
| 37 | + * 商品 SPU 编号 | ||
| 38 | + */ | ||
| 39 | + private Long spuId; | ||
| 40 | + /** | ||
| 41 | + * 商品 SKU 编号 | ||
| 42 | + */ | ||
| 43 | + private Long skuId; | ||
| 44 | + /** | ||
| 45 | + * 可兑换数量 | ||
| 46 | + */ | ||
| 47 | + private Integer maxCount; | ||
| 48 | + /** | ||
| 49 | + * 兑换积分 | ||
| 50 | + */ | ||
| 51 | + private Integer point; | ||
| 52 | + /** | ||
| 53 | + * 兑换金额,单位:分 | ||
| 54 | + */ | ||
| 55 | + private Integer price; | ||
| 56 | + /** | ||
| 57 | + * 兑换类型 | ||
| 58 | + * 1. 积分 | ||
| 59 | + * 2. 积分 + 钱 | ||
| 60 | + * 3. 直接购买 | ||
| 61 | + */ | ||
| 62 | + private Integer type; | ||
| 63 | + /** | ||
| 64 | + * 积分商城商品状态 | ||
| 65 | + * | ||
| 66 | + * 枚举 {@link CommonStatusEnum 对应的类} | ||
| 67 | + */ | ||
| 68 | + private Integer activityStatus; | ||
| 69 | + | ||
| 70 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/pointproduct/PointProductDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.dataobject.pointproduct; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 积分商城商品 DO | ||
| 11 | + * | ||
| 12 | + * @author HUIHUI | ||
| 13 | + */ | ||
| 14 | +@TableName("promotion_point_product") | ||
| 15 | +@KeySequence("promotion_point_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 16 | +@Data | ||
| 17 | +@EqualsAndHashCode(callSuper = true) | ||
| 18 | +@ToString(callSuper = true) | ||
| 19 | +@Builder | ||
| 20 | +@NoArgsConstructor | ||
| 21 | +@AllArgsConstructor | ||
| 22 | +public class PointProductDO extends BaseDO { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 积分商城商品编号 | ||
| 26 | + */ | ||
| 27 | + @TableId | ||
| 28 | + private Long id; | ||
| 29 | + /** | ||
| 30 | + * 积分商城活动 id | ||
| 31 | + */ | ||
| 32 | + private Long activityId; | ||
| 33 | + /** | ||
| 34 | + * 商品 SPU 编号 | ||
| 35 | + */ | ||
| 36 | + private Long spuId; | ||
| 37 | + /** | ||
| 38 | + * 商品 SKU 编号 | ||
| 39 | + */ | ||
| 40 | + private Long skuId; | ||
| 41 | + /** | ||
| 42 | + * 可兑换数量 | ||
| 43 | + */ | ||
| 44 | + private Integer maxCount; | ||
| 45 | + /** | ||
| 46 | + * 兑换积分 | ||
| 47 | + */ | ||
| 48 | + private Integer point; | ||
| 49 | + /** | ||
| 50 | + * 兑换金额,单位:分 | ||
| 51 | + */ | ||
| 52 | + private Integer price; | ||
| 53 | + /** | ||
| 54 | + * 兑换类型 | ||
| 55 | + */ | ||
| 56 | + private Integer type; | ||
| 57 | + /** | ||
| 58 | + * 积分商城商品状态 | ||
| 59 | + */ | ||
| 60 | + private Integer activityStatus; | ||
| 61 | + | ||
| 62 | +} | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分商城活动 Mapper | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface PointActivityMapper extends BaseMapperX<PointActivityDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>() | ||
| 20 | + .eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId()) | ||
| 21 | + .eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus()) | ||
| 22 | + .eqIfPresent(PointActivityDO::getRemark, reqVO.getRemark()) | ||
| 23 | + .eqIfPresent(PointActivityDO::getSort, reqVO.getSort()) | ||
| 24 | + .betweenIfPresent(PointActivityDO::getCreateTime, reqVO.getCreateTime()) | ||
| 25 | + .orderByDesc(PointActivityDO::getId)); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | +} | ||
| 0 | \ No newline at end of file | 29 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointProductMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.pointproduct.PointProductDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分商城商品 Mapper | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface PointProductMapper extends BaseMapperX<PointProductDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<PointProductDO> selectPage(PointProductPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<PointProductDO>() | ||
| 20 | + .eqIfPresent(PointProductDO::getActivityId, reqVO.getActivityId()) | ||
| 21 | + .eqIfPresent(PointProductDO::getSpuId, reqVO.getSpuId()) | ||
| 22 | + .eqIfPresent(PointProductDO::getSkuId, reqVO.getSkuId()) | ||
| 23 | + .eqIfPresent(PointProductDO::getMaxCount, reqVO.getMaxCount()) | ||
| 24 | + .eqIfPresent(PointProductDO::getPoint, reqVO.getPoint()) | ||
| 25 | + .eqIfPresent(PointProductDO::getPrice, reqVO.getPrice()) | ||
| 26 | + .eqIfPresent(PointProductDO::getType, reqVO.getType()) | ||
| 27 | + .eqIfPresent(PointProductDO::getActivityStatus, reqVO.getActivityStatus()) | ||
| 28 | + .betweenIfPresent(PointProductDO::getCreateTime, reqVO.getCreateTime()) | ||
| 29 | + .orderByDesc(PointProductDO::getId)); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | +} | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 积分商城活动 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author HUIHUI | ||
| 13 | + */ | ||
| 14 | +public interface PointActivityService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建积分商城活动 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + * @return 编号 | ||
| 21 | + */ | ||
| 22 | + Long createPointActivity(@Valid PointActivitySaveReqVO createReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新积分商城活动 | ||
| 26 | + * | ||
| 27 | + * @param updateReqVO 更新信息 | ||
| 28 | + */ | ||
| 29 | + void updatePointActivity(@Valid PointActivitySaveReqVO updateReqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 删除积分商城活动 | ||
| 33 | + * | ||
| 34 | + * @param id 编号 | ||
| 35 | + */ | ||
| 36 | + void deletePointActivity(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获得积分商城活动 | ||
| 40 | + * | ||
| 41 | + * @param id 编号 | ||
| 42 | + * @return 积分商城活动 | ||
| 43 | + */ | ||
| 44 | + PointActivityDO getPointActivity(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得积分商城活动分页 | ||
| 48 | + * | ||
| 49 | + * @param pageReqVO 分页查询 | ||
| 50 | + * @return 积分商城活动分页 | ||
| 51 | + */ | ||
| 52 | + PageResult<PointActivityDO> getPointActivityPage(PointActivityPageReqVO pageReqVO); | ||
| 53 | + | ||
| 54 | +} | ||
| 0 | \ No newline at end of file | 55 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.point; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | ||
| 6 | +import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | ||
| 7 | +import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | ||
| 8 | +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO; | ||
| 13 | +import cn.iocoder.yudao.module.promotion.dal.mysql.point.PointActivityMapper; | ||
| 14 | +import cn.iocoder.yudao.module.promotion.dal.mysql.point.PointProductMapper; | ||
| 15 | +import jakarta.annotation.Resource; | ||
| 16 | +import org.springframework.stereotype.Service; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | + | ||
| 19 | +import java.util.List; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 23 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 24 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; | ||
| 25 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | ||
| 26 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.POINT_ACTIVITY_NOT_EXISTS; | ||
| 27 | +import static java.util.Collections.singletonList; | ||
| 28 | + | ||
| 29 | +// TODO @puhui999: 下次提交完善 | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * 积分商城活动 Service 实现类 | ||
| 33 | + * | ||
| 34 | + * @author HUIHUI | ||
| 35 | + */ | ||
| 36 | +@Service | ||
| 37 | +@Validated | ||
| 38 | +public class PointActivityServiceImpl implements PointActivityService { | ||
| 39 | + | ||
| 40 | + @Resource | ||
| 41 | + private PointActivityMapper pointActivityMapper; | ||
| 42 | + @Resource | ||
| 43 | + private PointProductMapper pointProductMapper; | ||
| 44 | + | ||
| 45 | + @Resource | ||
| 46 | + private ProductSpuApi productSpuApi; | ||
| 47 | + @Resource | ||
| 48 | + private ProductSkuApi productSkuApi; | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public Long createPointActivity(PointActivitySaveReqVO createReqVO) { | ||
| 52 | + // 1. 校验商品是否存在 | ||
| 53 | + validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); | ||
| 54 | + // 插入 | ||
| 55 | + PointActivityDO pointActivity = BeanUtils.toBean(createReqVO, PointActivityDO.class); | ||
| 56 | + pointActivityMapper.insert(pointActivity); | ||
| 57 | + // 返回 | ||
| 58 | + return pointActivity.getId(); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public void updatePointActivity(PointActivitySaveReqVO updateReqVO) { | ||
| 63 | + // 1.1 校验存在 | ||
| 64 | + validatePointActivityExists(updateReqVO.getId()); | ||
| 65 | + // 1.2 校验商品是否存在 | ||
| 66 | + validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); | ||
| 67 | + | ||
| 68 | + // 更新 | ||
| 69 | + PointActivityDO updateObj = BeanUtils.toBean(updateReqVO, PointActivityDO.class); | ||
| 70 | + pointActivityMapper.updateById(updateObj); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Override | ||
| 74 | + public void deletePointActivity(Long id) { | ||
| 75 | + // 校验存在 | ||
| 76 | + validatePointActivityExists(id); | ||
| 77 | + // 删除 | ||
| 78 | + pointActivityMapper.deleteById(id); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + private void validatePointActivityExists(Long id) { | ||
| 82 | + if (pointActivityMapper.selectById(id) == null) { | ||
| 83 | + throw exception(POINT_ACTIVITY_NOT_EXISTS); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 校验秒杀商品是否都存在 | ||
| 89 | + * | ||
| 90 | + * @param spuId 商品 SPU 编号 | ||
| 91 | + * @param products 秒杀商品 | ||
| 92 | + */ | ||
| 93 | + private void validateProductExists(Long spuId, List<PointProductSaveReqVO> products) { | ||
| 94 | + // 1. 校验商品 spu 是否存在 | ||
| 95 | + ProductSpuRespDTO spu = productSpuApi.getSpu(spuId); | ||
| 96 | + if (spu == null) { | ||
| 97 | + throw exception(SPU_NOT_EXISTS); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + // 2. 校验商品 sku 都存在 | ||
| 101 | + List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)); | ||
| 102 | + Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId); | ||
| 103 | + products.forEach(product -> { | ||
| 104 | + if (!skuMap.containsKey(product.getSkuId())) { | ||
| 105 | + throw exception(SKU_NOT_EXISTS); | ||
| 106 | + } | ||
| 107 | + }); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + public PointActivityDO getPointActivity(Long id) { | ||
| 112 | + return pointActivityMapper.selectById(id); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 116 | + public PageResult<PointActivityDO> getPointActivityPage(PointActivityPageReqVO pageReqVO) { | ||
| 117 | + return pointActivityMapper.selectPage(pageReqVO); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | +} | ||
| 0 | \ No newline at end of file | 121 | \ No newline at end of file |