mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
commit
51fdbb81d4
@ -44,7 +44,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭");
|
||||
ErrorCode REWARD_ACTIVITY_SCOPE_EXISTS = new ErrorCode(1_013_006_005, "与该时间段满减送活动【{}】商品范围冲突,原因:{}");
|
||||
|
||||
// ========== TODO 空着 1-013-007-000 ============
|
||||
// ========== 积分商城活动 1-013-007-000 ==========
|
||||
ErrorCode POINT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_007_000, "积分商城活动不存在");
|
||||
ErrorCode POINT_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_007_100, "积分商城商品不存在");
|
||||
|
||||
// ========== 秒杀活动 1-013-008-000 ==========
|
||||
ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在");
|
||||
|
@ -0,0 +1,93 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.point.PointActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 积分商城活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/point-activity")
|
||||
@Validated
|
||||
public class PointActivityController {
|
||||
|
||||
@Resource
|
||||
private PointActivityService pointActivityService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建积分商城活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:create')")
|
||||
public CommonResult<Long> createPointActivity(@Valid @RequestBody PointActivitySaveReqVO createReqVO) {
|
||||
return success(pointActivityService.createPointActivity(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新积分商城活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:update')")
|
||||
public CommonResult<Boolean> updatePointActivity(@Valid @RequestBody PointActivitySaveReqVO updateReqVO) {
|
||||
pointActivityService.updatePointActivity(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除积分商城活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:delete')")
|
||||
public CommonResult<Boolean> deletePointActivity(@RequestParam("id") Long id) {
|
||||
pointActivityService.deletePointActivity(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得积分商城活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:query')")
|
||||
public CommonResult<PointActivityRespVO> getPointActivity(@RequestParam("id") Long id) {
|
||||
PointActivityDO pointActivity = pointActivityService.getPointActivity(id);
|
||||
return success(BeanUtils.toBean(pointActivity, PointActivityRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得积分商城活动分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:query')")
|
||||
public CommonResult<PageResult<PointActivityRespVO>> getPointActivityPage(@Valid PointActivityPageReqVO pageReqVO) {
|
||||
PageResult<PointActivityDO> pageResult = pointActivityService.getPointActivityPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PointActivityRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出积分商城活动 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportPointActivityExcel(@Valid PointActivityPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PointActivityDO> list = pointActivityService.getPointActivityPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "积分商城活动.xls", "数据", PointActivityRespVO.class,
|
||||
BeanUtils.toBean(list, PointActivityRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城活动分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PointActivityPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "积分商城活动商品", example = "19509")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城活动 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PointActivityRespVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
@ExcelProperty("积分商城活动编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
@ExcelProperty("积分商城活动商品")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("活动状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<PointProductSaveReqVO> products;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
//======================= 显示所需兑换积分最少的 sku 信息 =======================
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
private Integer price;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城活动新增/修改 Request VO")
|
||||
@Data
|
||||
public class PointActivitySaveReqVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
@NotNull(message = "积分商城活动商品不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "活动状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<PointProductSaveReqVO> products;
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PointProductPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "积分商城活动 id", example = "29388")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", example = "8112")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", example = "2736")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", example = "3926")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "兑换积分")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", example = "15860")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "兑换类型", example = "2")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "积分商城商品状态", example = "2")
|
||||
private Integer activityStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PointProductRespVO {
|
||||
|
||||
@Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718")
|
||||
@ExcelProperty("积分商城商品编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388")
|
||||
@ExcelProperty("积分商城活动 id")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112")
|
||||
@ExcelProperty("商品 SPU 编号")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736")
|
||||
@ExcelProperty("商品 SKU 编号")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
@ExcelProperty("可兑换数量")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("兑换积分")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
@ExcelProperty("兑换金额,单位:分")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "兑换类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("兑换类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("积分商城商品状态")
|
||||
private Integer activityStatus;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品新增/修改 Request VO")
|
||||
@Data
|
||||
public class PointProductSaveReqVO {
|
||||
|
||||
@Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388")
|
||||
@NotNull(message = "积分商城活动 id不能为空")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112")
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
@NotNull(message = "可兑换数量不能为空")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "兑换积分不能为空")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
@NotNull(message = "兑换金额,单位:分不能为空")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "兑换类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "兑换类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "积分商城商品状态不能为空")
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
@ -54,7 +54,7 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer seckillPrice; // 从 products 获取最小 price 读取
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 积分商城活动 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName(value = "promotion_point_activity", autoResultMap = true)
|
||||
@KeySequence("promotion_point_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PointActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 积分商城活动编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 积分商城活动商品
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 积分商城商品 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("promotion_point_product")
|
||||
@KeySequence("promotion_point_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PointProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 积分商城商品编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 积分商城活动 id
|
||||
*
|
||||
* 关联 {@link PointActivityDO#getId()}
|
||||
*/
|
||||
private Long activityId;
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 可兑换数量
|
||||
*/
|
||||
private Integer maxCount;
|
||||
/**
|
||||
* 兑换积分
|
||||
*/
|
||||
private Integer point;
|
||||
/**
|
||||
* 兑换金额,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 兑换类型
|
||||
* 1. 积分
|
||||
* 2. 积分 + 钱
|
||||
* 3. 直接购买
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 积分商城商品状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.pointproduct;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 积分商城商品 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("promotion_point_product")
|
||||
@KeySequence("promotion_point_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PointProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 积分商城商品编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 积分商城活动 id
|
||||
*/
|
||||
private Long activityId;
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 可兑换数量
|
||||
*/
|
||||
private Integer maxCount;
|
||||
/**
|
||||
* 兑换积分
|
||||
*/
|
||||
private Integer point;
|
||||
/**
|
||||
* 兑换金额,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 兑换类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 积分商城商品状态
|
||||
*/
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 积分商城活动 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface PointActivityMapper extends BaseMapperX<PointActivityDO> {
|
||||
|
||||
default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>()
|
||||
.eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(PointActivityDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(PointActivityDO::getSort, reqVO.getSort())
|
||||
.betweenIfPresent(PointActivityDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PointActivityDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointproduct.PointProductDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 积分商城商品 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface PointProductMapper extends BaseMapperX<PointProductDO> {
|
||||
|
||||
default PageResult<PointProductDO> selectPage(PointProductPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PointProductDO>()
|
||||
.eqIfPresent(PointProductDO::getActivityId, reqVO.getActivityId())
|
||||
.eqIfPresent(PointProductDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(PointProductDO::getSkuId, reqVO.getSkuId())
|
||||
.eqIfPresent(PointProductDO::getMaxCount, reqVO.getMaxCount())
|
||||
.eqIfPresent(PointProductDO::getPoint, reqVO.getPoint())
|
||||
.eqIfPresent(PointProductDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(PointProductDO::getType, reqVO.getType())
|
||||
.eqIfPresent(PointProductDO::getActivityStatus, reqVO.getActivityStatus())
|
||||
.betweenIfPresent(PointProductDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PointProductDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 积分商城活动 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface PointActivityService {
|
||||
|
||||
/**
|
||||
* 创建积分商城活动
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPointActivity(@Valid PointActivitySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新积分商城活动
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePointActivity(@Valid PointActivitySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除积分商城活动
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePointActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分商城活动
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 积分商城活动
|
||||
*/
|
||||
PointActivityDO getPointActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分商城活动分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 积分商城活动分页
|
||||
*/
|
||||
PageResult<PointActivityDO> getPointActivityPage(PointActivityPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.point.PointActivityMapper;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.point.PointProductMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.POINT_ACTIVITY_NOT_EXISTS;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
// TODO @puhui999: 下次提交完善
|
||||
|
||||
/**
|
||||
* 积分商城活动 Service 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PointActivityServiceImpl implements PointActivityService {
|
||||
|
||||
@Resource
|
||||
private PointActivityMapper pointActivityMapper;
|
||||
@Resource
|
||||
private PointProductMapper pointProductMapper;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
@Resource
|
||||
private ProductSkuApi productSkuApi;
|
||||
|
||||
@Override
|
||||
public Long createPointActivity(PointActivitySaveReqVO createReqVO) {
|
||||
// 1. 校验商品是否存在
|
||||
validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts());
|
||||
// 插入
|
||||
PointActivityDO pointActivity = BeanUtils.toBean(createReqVO, PointActivityDO.class);
|
||||
pointActivityMapper.insert(pointActivity);
|
||||
// 返回
|
||||
return pointActivity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePointActivity(PointActivitySaveReqVO updateReqVO) {
|
||||
// 1.1 校验存在
|
||||
validatePointActivityExists(updateReqVO.getId());
|
||||
// 1.2 校验商品是否存在
|
||||
validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts());
|
||||
|
||||
// 更新
|
||||
PointActivityDO updateObj = BeanUtils.toBean(updateReqVO, PointActivityDO.class);
|
||||
pointActivityMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePointActivity(Long id) {
|
||||
// 校验存在
|
||||
validatePointActivityExists(id);
|
||||
// 删除
|
||||
pointActivityMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePointActivityExists(Long id) {
|
||||
if (pointActivityMapper.selectById(id) == null) {
|
||||
throw exception(POINT_ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验秒杀商品是否都存在
|
||||
*
|
||||
* @param spuId 商品 SPU 编号
|
||||
* @param products 秒杀商品
|
||||
*/
|
||||
private void validateProductExists(Long spuId, List<PointProductSaveReqVO> products) {
|
||||
// 1. 校验商品 spu 是否存在
|
||||
ProductSpuRespDTO spu = productSpuApi.getSpu(spuId);
|
||||
if (spu == null) {
|
||||
throw exception(SPU_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 校验商品 sku 都存在
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(singletonList(spuId));
|
||||
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId);
|
||||
products.forEach(product -> {
|
||||
if (!skuMap.containsKey(product.getSkuId())) {
|
||||
throw exception(SKU_NOT_EXISTS);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointActivityDO getPointActivity(Long id) {
|
||||
return pointActivityMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PointActivityDO> getPointActivityPage(PointActivityPageReqVO pageReqVO) {
|
||||
return pointActivityMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user