Commit 23efe54f by 林永健

refactor(strategy): 重构营销活动相关接口的数据传输方式

- 将多个控制器中的数据传输对象转换为RpcPagination包装类型
- 添加productType字段支持商品和套餐类型的区分查询
- 优化数据库查询方法,统一使用DTO映射和分页参数
- 移除过时的日期格式化工具类方法,改用hutool工具包
- 增强商品/套餐变动检测逻辑并添加相应的日志记录
- 统一错误处理和参数验证机制,提升代码健壮性
- 优化MyBatis映射配置,增加DTO结果映射支持
1 parent fc723696
Showing 28 changed files with 304 additions and 260 deletions
...@@ -15,19 +15,11 @@ import java.util.List; ...@@ -15,19 +15,11 @@ import java.util.List;
* @since 2026/06/16 * @since 2026/06/16
*/ */
@Data @Data
@ApiModel(value = "上架商品分页查询请求") @ApiModel(value = "上架商品查询请求")
public class GoodsPageReqDTO implements Serializable { public class GoodsPageReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 页码 */
@ApiModelProperty(notes = "页码,默认1")
private Integer pageNum;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
/** 适用门店号列表 */ /** 适用门店号列表 */
@ApiModelProperty(notes = "适用门店号列表", required = true) @ApiModelProperty(notes = "适用门店号列表", required = true)
private List<Integer> merchantIds; private List<Integer> merchantIds;
......
...@@ -20,6 +20,10 @@ public class GoodsTypeInfoDTO implements Serializable { ...@@ -20,6 +20,10 @@ public class GoodsTypeInfoDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 商品别名 */
@ApiModelProperty(notes = "商品别名")
private String goodsAlias;
/** 商品类型 */ /** 商品类型 */
@ApiModelProperty(notes = "商品类型") @ApiModelProperty(notes = "商品类型")
private Integer goodsType; private Integer goodsType;
......
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -24,13 +27,25 @@ public class MarketingActivityCreateReqDTO implements Serializable { ...@@ -24,13 +27,25 @@ public class MarketingActivityCreateReqDTO implements Serializable {
@ApiModelProperty(notes = "活动名称,最多30字", required = true) @ApiModelProperty(notes = "活动名称,最多30字", required = true)
private String activityName; private String activityName;
/** 活动开始时间(yyyy-MM-dd HH:00) */ /** 操作人ID(透传,用于记录createdBy) */
@ApiModelProperty(notes = "活动开始时间(yyyy-MM-dd HH:00)", required = true) @ApiModelProperty(notes = "操作人ID")
private String startTime; private String operatorId;
/** 活动结束时间(yyyy-MM-dd HH:00) */ /** 操作人姓名(透传,用于记录createdBy) */
@ApiModelProperty(notes = "活动结束时间(yyyy-MM-dd HH:00)", required = true) @ApiModelProperty(notes = "操作人姓名")
private String endTime; private String operatorName;
/** 活动开始时间 */
@ApiModelProperty(notes = "活动开始时间", required = true)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/** 活动结束时间 */
@ApiModelProperty(notes = "活动结束时间", required = true)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
/** 活动标签名称快照 */ /** 活动标签名称快照 */
@ApiModelProperty(notes = "活动标签名称", required = true) @ApiModelProperty(notes = "活动标签名称", required = true)
......
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 活动详情响应DTO * 活动详情响应DTO
...@@ -29,11 +31,13 @@ public class MarketingActivityDetailRespDTO implements Serializable { ...@@ -29,11 +31,13 @@ public class MarketingActivityDetailRespDTO implements Serializable {
/** 活动开始时间 */ /** 活动开始时间 */
@ApiModelProperty(notes = "活动开始时间") @ApiModelProperty(notes = "活动开始时间")
private String startTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/** 活动结束时间 */ /** 活动结束时间 */
@ApiModelProperty(notes = "活动结束时间") @ApiModelProperty(notes = "活动结束时间")
private String endTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
/** 活动标签 */ /** 活动标签 */
@ApiModelProperty(notes = "活动标签") @ApiModelProperty(notes = "活动标签")
......
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 活动延期请求DTO * 活动延期请求DTO
...@@ -24,6 +27,8 @@ public class MarketingActivityExtendReqDTO implements Serializable { ...@@ -24,6 +27,8 @@ public class MarketingActivityExtendReqDTO implements Serializable {
private Integer activityId; private Integer activityId;
/** 新的结束时间 */ /** 新的结束时间 */
@ApiModelProperty(notes = "新的结束时间(yyyy-MM-dd HH:mm)", required = true) @ApiModelProperty(notes = "新的结束时间", required = true)
private String newEndTime; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date newEndTime;
} }
...@@ -10,19 +10,11 @@ import java.io.Serializable; ...@@ -10,19 +10,11 @@ import java.io.Serializable;
* 活动操作日志分页查询请求DTO * 活动操作日志分页查询请求DTO
*/ */
@Data @Data
@ApiModel(value = "活动操作日志分页查询请求") @ApiModel(value = "活动操作日志查询请求")
public class MarketingActivityLogPageReqDTO implements Serializable { public class MarketingActivityLogPageReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 活动ID */ /** 活动ID */
@ApiModelProperty(notes = "活动ID", required = true) @ApiModelProperty(notes = "活动ID", required = true)
private Integer activityId; private Integer activityId;
/** 页码 */
@ApiModelProperty(notes = "页码,默认1")
private Integer pageNum;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
} }
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 活动分页查询请求DTO * 活动分页查询请求DTO
...@@ -19,14 +22,6 @@ public class MarketingActivityPageReqDTO implements Serializable { ...@@ -19,14 +22,6 @@ public class MarketingActivityPageReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 页码 */
@ApiModelProperty(notes = "页码,默认1")
private Integer pageNum;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
/** 活动名称(模糊) */ /** 活动名称(模糊) */
@ApiModelProperty(notes = "活动名称(模糊查询)") @ApiModelProperty(notes = "活动名称(模糊查询)")
private String activityName; private String activityName;
...@@ -41,9 +36,13 @@ public class MarketingActivityPageReqDTO implements Serializable { ...@@ -41,9 +36,13 @@ public class MarketingActivityPageReqDTO implements Serializable {
/** 活动时间范围-起始 */ /** 活动时间范围-起始 */
@ApiModelProperty(notes = "活动时间范围-起始") @ApiModelProperty(notes = "活动时间范围-起始")
private String startTime; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/** 活动时间范围-结束 */ /** 活动时间范围-结束 */
@ApiModelProperty(notes = "活动时间范围-结束") @ApiModelProperty(notes = "活动时间范围-结束")
private String endTime; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
} }
...@@ -24,6 +24,9 @@ public class MarketingActivityProductItemRespDTO implements Serializable { ...@@ -24,6 +24,9 @@ public class MarketingActivityProductItemRespDTO implements Serializable {
@ApiModelProperty(notes = "子商品ID") @ApiModelProperty(notes = "子商品ID")
private Integer itemId; private Integer itemId;
@ApiModelProperty(notes = "关联套餐记录ID")
private Integer activityProductId;
/** 子商品编码 */ /** 子商品编码 */
@ApiModelProperty(notes = "子商品编码") @ApiModelProperty(notes = "子商品编码")
private String goodsCode; private String goodsCode;
......
...@@ -10,7 +10,7 @@ import java.io.Serializable; ...@@ -10,7 +10,7 @@ import java.io.Serializable;
* 活动商品/套餐分页查询请求DTO * 活动商品/套餐分页查询请求DTO
*/ */
@Data @Data
@ApiModel(value = "活动商品/套餐分页查询请求") @ApiModel(value = "活动商品/套餐查询请求")
public class MarketingActivityProductPageReqDTO implements Serializable { public class MarketingActivityProductPageReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -22,11 +22,7 @@ public class MarketingActivityProductPageReqDTO implements Serializable { ...@@ -22,11 +22,7 @@ public class MarketingActivityProductPageReqDTO implements Serializable {
@ApiModelProperty(notes = "车系ID,不分车系传-1") @ApiModelProperty(notes = "车系ID,不分车系传-1")
private Integer carSeriesId; private Integer carSeriesId;
/** 页码 */ /** 类型: 0-套餐 1-商品 */
@ApiModelProperty(notes = "页码,默认1") @ApiModelProperty(notes = "类型: 0-套餐 1-商品")
private Integer pageNum; private Integer productType;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
} }
...@@ -29,6 +29,9 @@ public class MarketingActivityProductReqDTO implements Serializable { ...@@ -29,6 +29,9 @@ public class MarketingActivityProductReqDTO implements Serializable {
@ApiModelProperty(notes = "类型: 0-套餐 1-商品", required = true) @ApiModelProperty(notes = "类型: 0-套餐 1-商品", required = true)
private Integer productType; private Integer productType;
@ApiModelProperty(notes = "商品|套餐名称")
private String productName;
/** 上架商品编码 */ /** 上架商品编码 */
@ApiModelProperty(notes = "上架商品编码(productType=GOODS时必填)") @ApiModelProperty(notes = "上架商品编码(productType=GOODS时必填)")
private String goodsCode; private String goodsCode;
......
...@@ -10,19 +10,11 @@ import java.io.Serializable; ...@@ -10,19 +10,11 @@ import java.io.Serializable;
* 活动门店分页查询请求DTO * 活动门店分页查询请求DTO
*/ */
@Data @Data
@ApiModel(value = "活动门店分页查询请求") @ApiModel(value = "活动门店查询请求")
public class MarketingActivityStoreReqDTO implements Serializable { public class MarketingActivityStoreReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 活动ID */ /** 活动ID */
@ApiModelProperty(notes = "活动ID", required = true) @ApiModelProperty(notes = "活动ID", required = true)
private Integer activityId; private Integer activityId;
/** 页码 */
@ApiModelProperty(notes = "页码,默认1")
private Integer pageNum;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
} }
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -28,13 +31,25 @@ public class MarketingActivityUpdateReqDTO implements Serializable { ...@@ -28,13 +31,25 @@ public class MarketingActivityUpdateReqDTO implements Serializable {
@ApiModelProperty(notes = "活动名称", required = true) @ApiModelProperty(notes = "活动名称", required = true)
private String activityName; private String activityName;
/** 操作人ID(透传,用于记录updatedBy) */
@ApiModelProperty(notes = "操作人ID")
private String operatorId;
/** 操作人姓名(透传,用于记录updatedBy) */
@ApiModelProperty(notes = "操作人姓名")
private String operatorName;
/** 活动开始时间 */ /** 活动开始时间 */
@ApiModelProperty(notes = "活动开始时间", required = true) @ApiModelProperty(notes = "活动开始时间", required = true)
private String startTime; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
/** 活动结束时间 */ /** 活动结束时间 */
@ApiModelProperty(notes = "活动结束时间", required = true) @ApiModelProperty(notes = "活动结束时间", required = true)
private String endTime; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
/** 活动标签 */ /** 活动标签 */
@ApiModelProperty(notes = "活动标签", required = true) @ApiModelProperty(notes = "活动标签", required = true)
......
package cn.com.glsx.dj.strategy.dto; package cn.com.glsx.dj.strategy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 活动操作日志响应VO * 活动操作日志响应VO
...@@ -21,6 +23,7 @@ public class OperationLogVO implements Serializable { ...@@ -21,6 +23,7 @@ public class OperationLogVO implements Serializable {
@ApiModelProperty(notes = "操作人姓名") @ApiModelProperty(notes = "操作人姓名")
private String operatorName; private String operatorName;
/** 操作时间 */ /** 操作时间 */
@ApiModelProperty(notes = "操作时间(yyyy-MM-dd HH:mm:ss)") @ApiModelProperty(notes = "操作时间")
private String operateTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date operateTime;
} }
...@@ -15,19 +15,11 @@ import java.util.List; ...@@ -15,19 +15,11 @@ import java.util.List;
* @since 2026/06/16 * @since 2026/06/16
*/ */
@Data @Data
@ApiModel(value = "套餐分页查询请求") @ApiModel(value = "套餐查询请求")
public class PackagePageReqDTO implements Serializable { public class PackagePageReqDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 页码 */
@ApiModelProperty(notes = "页码,默认1")
private Integer pageNum;
/** 每页条数 */
@ApiModelProperty(notes = "每页条数,默认10")
private Integer pageSize;
/** 适用门店号列表 */ /** 适用门店号列表 */
@ApiModelProperty(notes = "适用门店号列表", required = true) @ApiModelProperty(notes = "适用门店号列表", required = true)
private List<Integer> merchantIds; private List<Integer> merchantIds;
......
...@@ -22,9 +22,9 @@ import java.util.List; ...@@ -22,9 +22,9 @@ import java.util.List;
public interface MarketingActivityRemote { public interface MarketingActivityRemote {
@ApiMethod("分页查询活动列表") @ApiMethod("分页查询活动列表")
@ApiParam(name = "request", notes = "分页查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("活动分页列表") @ApiResponse("活动分页列表")
RpcResponse<RpcPagination<MarketingActivityRespDTO>> page(MarketingActivityPageReqDTO request); RpcResponse<RpcPagination<MarketingActivityRespDTO>> page(RpcPagination<MarketingActivityPageReqDTO> pagination);
@ApiMethod("创建营销活动") @ApiMethod("创建营销活动")
@ApiParam(name = "request", notes = "创建请求", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "request", notes = "创建请求", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
...@@ -37,19 +37,19 @@ public interface MarketingActivityRemote { ...@@ -37,19 +37,19 @@ public interface MarketingActivityRemote {
RpcResponse<MarketingActivityDetailRespDTO> detail(Integer activityId); RpcResponse<MarketingActivityDetailRespDTO> detail(Integer activityId);
@ApiMethod("查询活动关联门店(分页)") @ApiMethod("查询活动关联门店(分页)")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("门店分页列表") @ApiResponse("门店分页列表")
RpcResponse<RpcPagination<StoreVO>> stores(MarketingActivityStoreReqDTO request); RpcResponse<RpcPagination<StoreVO>> stores(RpcPagination<MarketingActivityStoreReqDTO> pagination);
@ApiMethod("查询活动关联商品/套餐(分页)") @ApiMethod("查询活动关联商品/套餐(分页)")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("商品/套餐分页列表") @ApiResponse("商品/套餐分页列表")
RpcResponse<RpcPagination<MarketingActivityProductRespDTO>> products(MarketingActivityProductPageReqDTO request); RpcResponse<RpcPagination<MarketingActivityProductRespDTO>> products(RpcPagination<MarketingActivityProductPageReqDTO> pagination);
@ApiMethod("查询活动操作日志(分页)") @ApiMethod("查询活动操作日志(分页)")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("操作日志分页列表") @ApiResponse("操作日志分页列表")
RpcResponse<RpcPagination<OperationLogVO>> logs(MarketingActivityLogPageReqDTO request); RpcResponse<RpcPagination<OperationLogVO>> logs(RpcPagination<MarketingActivityLogPageReqDTO> pagination);
@ApiMethod("编辑营销活动") @ApiMethod("编辑营销活动")
@ApiParam(name = "request", notes = "编辑请求", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "request", notes = "编辑请求", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
......
...@@ -24,9 +24,9 @@ import java.util.List; ...@@ -24,9 +24,9 @@ import java.util.List;
public interface MarketingGoodsRemote { public interface MarketingGoodsRemote {
@ApiMethod("分页查询商品") @ApiMethod("分页查询商品")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("商品分页列表") @ApiResponse("商品分页列表")
RpcResponse<RpcPagination<GoodsRespDTO>> page(GoodsPageReqDTO request); RpcResponse<RpcPagination<GoodsRespDTO>> page(RpcPagination<GoodsPageReqDTO> pagination);
@ApiMethod("查询商品/套餐适用门店") @ApiMethod("查询商品/套餐适用门店")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
......
...@@ -23,9 +23,9 @@ import java.util.List; ...@@ -23,9 +23,9 @@ import java.util.List;
public interface MarketingPackageRemote { public interface MarketingPackageRemote {
@ApiMethod("分页查询套餐") @ApiMethod("分页查询套餐")
@ApiParam(name = "request", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("套餐分页列表") @ApiResponse("套餐分页列表")
RpcResponse<RpcPagination<PackageRespDTO>> page(PackagePageReqDTO request); RpcResponse<RpcPagination<PackageRespDTO>> page(RpcPagination<PackagePageReqDTO> pagination);
@ApiMethod("查询套餐下子商品") @ApiMethod("查询套餐下子商品")
@ApiParam(name = "packageId", notes = "套餐ID", dataType = ApiParam.DataTypeEnum.STRING, required = true) @ApiParam(name = "packageId", notes = "套餐ID", dataType = ApiParam.DataTypeEnum.STRING, required = true)
......
package cn.com.glsx.dj.strategy.mapper; package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.dto.ActivityPackageItemDTO; import cn.com.glsx.dj.strategy.dto.ActivityPackageItemDTO;
import cn.com.glsx.dj.strategy.dto.MarketingActivityProductItemRespDTO;
import cn.com.glsx.dj.strategy.model.MarketingActivityProductItem; import cn.com.glsx.dj.strategy.model.MarketingActivityProductItem;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -33,6 +34,8 @@ public interface MarketingActivityProductItemMapper extends OreMapper<MarketingA ...@@ -33,6 +34,8 @@ public interface MarketingActivityProductItemMapper extends OreMapper<MarketingA
*/ */
int deleteByActivityProductId(@Param("activityProductId") Integer activityProductId); int deleteByActivityProductId(@Param("activityProductId") Integer activityProductId);
List<MarketingActivityProductItemRespDTO> selectItemDTOByActivityProductIds(@Param("productIds") List<Integer> productIds);
/** /**
* 按 productId 列表批量查询子商品 * 按 productId 列表批量查询子商品
*/ */
......
package cn.com.glsx.dj.strategy.mapper; package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.dto.MarketingActivityProductPageReqDTO;
import cn.com.glsx.dj.strategy.dto.MarketingActivityProductRespDTO;
import cn.com.glsx.dj.strategy.model.MarketingActivityProduct; import cn.com.glsx.dj.strategy.model.MarketingActivityProduct;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -23,11 +25,9 @@ public interface MarketingActivityProductMapper extends OreMapper<MarketingActiv ...@@ -23,11 +25,9 @@ public interface MarketingActivityProductMapper extends OreMapper<MarketingActiv
int batchInsert(@Param("list") List<MarketingActivityProduct> list); int batchInsert(@Param("list") List<MarketingActivityProduct> list);
/** /**
* 按活动ID+车系ID查询 * 通用查询(DTO映射,支持 productType/carSeriesId 过滤)
*/ */
List<MarketingActivityProduct> selectByActivityIdAndCarSeriesId( List<MarketingActivityProductRespDTO> selectProductDTOList(@Param("query") MarketingActivityProductPageReqDTO query);
@Param("activityId") Integer activityId,
@Param("carSeriesId") Integer carSeriesId);
/** /**
* 按活动ID+车系ID删除 * 按活动ID+车系ID删除
...@@ -37,16 +37,6 @@ public interface MarketingActivityProductMapper extends OreMapper<MarketingActiv ...@@ -37,16 +37,6 @@ public interface MarketingActivityProductMapper extends OreMapper<MarketingActiv
@Param("carSeriesId") Integer carSeriesId); @Param("carSeriesId") Integer carSeriesId);
/** /**
* 按活动ID查询全部
*/
List<MarketingActivityProduct> selectByActivityId(@Param("activityId") Integer activityId);
/**
* 更新单个字段(优惠价/激励等)
*/
int updateSelective(MarketingActivityProduct record);
/**
* 按门店+商品编码查询有效活动商品 * 按门店+商品编码查询有效活动商品
*/ */
List<MarketingActivityProduct> selectActiveByMerchantIdAndGoodsCodes( List<MarketingActivityProduct> selectActiveByMerchantIdAndGoodsCodes(
......
...@@ -28,9 +28,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote { ...@@ -28,9 +28,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote {
private final MarketingActivityService marketingActivityService; private final MarketingActivityService marketingActivityService;
@Override @Override
public RpcResponse<RpcPagination<MarketingActivityRespDTO>> page(MarketingActivityPageReqDTO request) { public RpcResponse<RpcPagination<MarketingActivityRespDTO>> page(RpcPagination<MarketingActivityPageReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.page(request))); return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.page(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("分页查询活动发生业务异常", e); log.error("分页查询活动发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
...@@ -69,9 +69,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote { ...@@ -69,9 +69,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote {
} }
@Override @Override
public RpcResponse<RpcPagination<StoreVO>> stores(MarketingActivityStoreReqDTO request) { public RpcResponse<RpcPagination<StoreVO>> stores(RpcPagination<MarketingActivityStoreReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.stores(request))); return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.stores(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("查询活动门店发生业务异常", e); log.error("查询活动门店发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
...@@ -82,9 +82,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote { ...@@ -82,9 +82,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote {
} }
@Override @Override
public RpcResponse<RpcPagination<MarketingActivityProductRespDTO>> products(MarketingActivityProductPageReqDTO request) { public RpcResponse<RpcPagination<MarketingActivityProductRespDTO>> products(RpcPagination<MarketingActivityProductPageReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.products(request))); return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.products(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("查询活动商品发生业务异常", e); log.error("查询活动商品发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
...@@ -95,9 +95,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote { ...@@ -95,9 +95,9 @@ public class MarketingActivityRemoteImpl implements MarketingActivityRemote {
} }
@Override @Override
public RpcResponse<RpcPagination<OperationLogVO>> logs(MarketingActivityLogPageReqDTO request) { public RpcResponse<RpcPagination<OperationLogVO>> logs(RpcPagination<MarketingActivityLogPageReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.logs(request))); return RpcResponse.success(RpcPagination.copyPage(marketingActivityService.logs(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("查询活动日志发生业务异常", e); log.error("查询活动日志发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
......
...@@ -30,9 +30,9 @@ public class MarketingGoodsRemoteImpl implements MarketingGoodsRemote { ...@@ -30,9 +30,9 @@ public class MarketingGoodsRemoteImpl implements MarketingGoodsRemote {
private final MarketingGoodsService marketingGoodsService; private final MarketingGoodsService marketingGoodsService;
@Override @Override
public RpcResponse<RpcPagination<GoodsRespDTO>> page(GoodsPageReqDTO request) { public RpcResponse<RpcPagination<GoodsRespDTO>> page(RpcPagination<GoodsPageReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingGoodsService.page(request))); return RpcResponse.success(RpcPagination.copyPage(marketingGoodsService.page(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("分页查询商品发生业务异常", e); log.error("分页查询商品发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
......
...@@ -29,9 +29,9 @@ public class MarketingPackageRemoteImpl implements MarketingPackageRemote { ...@@ -29,9 +29,9 @@ public class MarketingPackageRemoteImpl implements MarketingPackageRemote {
private final MarketingPackageService marketingPackageService; private final MarketingPackageService marketingPackageService;
@Override @Override
public RpcResponse<RpcPagination<PackageRespDTO>> page(PackagePageReqDTO request) { public RpcResponse<RpcPagination<PackageRespDTO>> page(RpcPagination<PackagePageReqDTO> pagination) {
try { try {
return RpcResponse.success(RpcPagination.copyPage(marketingPackageService.page(request))); return RpcResponse.success(RpcPagination.copyPage(marketingPackageService.page(pagination)));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("分页查询套餐发生业务异常", e); log.error("分页查询套餐发生业务异常", e);
return RpcResponse.error(e); return RpcResponse.error(e);
......
...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.strategy.enums.ActivityStatusEnum; ...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.strategy.enums.ActivityStatusEnum;
import cn.com.glsx.dj.strategy.enums.ProductTypeEnum; import cn.com.glsx.dj.strategy.enums.ProductTypeEnum;
import cn.com.glsx.dj.strategy.mapper.*; import cn.com.glsx.dj.strategy.mapper.*;
import cn.com.glsx.dj.strategy.model.*; import cn.com.glsx.dj.strategy.model.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.model.request.MerchantOpenRequest; import cn.com.glsx.merchants.model.request.MerchantOpenRequest;
...@@ -14,7 +15,6 @@ import cn.com.glsx.merchants.remote.MerchantRemote; ...@@ -14,7 +15,6 @@ import cn.com.glsx.merchants.remote.MerchantRemote;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum; import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -23,7 +23,6 @@ import org.springframework.util.CollectionUtils; ...@@ -23,7 +23,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -51,8 +50,9 @@ public class MarketingActivityService { ...@@ -51,8 +50,9 @@ public class MarketingActivityService {
// ==================== 查询 ==================== // ==================== 查询 ====================
public Page<MarketingActivityRespDTO> page(MarketingActivityPageReqDTO request) { public Page<MarketingActivityRespDTO> page(RpcPagination<MarketingActivityPageReqDTO> pagination) {
Page<MarketingActivityRespDTO> res = PageHelper.startPage(request.getPageNum(), request.getPageSize()); MarketingActivityPageReqDTO request = pagination.getCondition();
Page<MarketingActivityRespDTO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
marketingActivityMapper.page(request); marketingActivityMapper.page(request);
if (!CollectionUtils.isEmpty(res)) { if (!CollectionUtils.isEmpty(res)) {
res.getResult().forEach(item -> item.setStoreCount(marketingActivityStoreMapper.countByActivityId(item.getActivityId()))); res.getResult().forEach(item -> item.setStoreCount(marketingActivityStoreMapper.countByActivityId(item.getActivityId())));
...@@ -69,8 +69,8 @@ public class MarketingActivityService { ...@@ -69,8 +69,8 @@ public class MarketingActivityService {
MarketingActivityDetailRespDTO dto = new MarketingActivityDetailRespDTO(); MarketingActivityDetailRespDTO dto = new MarketingActivityDetailRespDTO();
dto.setActivityId(activity.getId()); dto.setActivityId(activity.getId());
dto.setActivityName(activity.getActivityName()); dto.setActivityName(activity.getActivityName());
dto.setStartTime(formatDate(activity.getStartTime())); dto.setStartTime(activity.getStartTime());
dto.setEndTime(formatDate(activity.getEndTime())); dto.setEndTime(activity.getEndTime());
dto.setActivityTag(activity.getActivityTag()); dto.setActivityTag(activity.getActivityTag());
dto.setMarketingStage(activity.getMarketingStage()); dto.setMarketingStage(activity.getMarketingStage());
dto.setStatus(activity.getStatus()); dto.setStatus(activity.getStatus());
...@@ -81,9 +81,11 @@ public class MarketingActivityService { ...@@ -81,9 +81,11 @@ public class MarketingActivityService {
/** /**
* 查询活动关联门店(分页) * 查询活动关联门店(分页)
*/ */
public PageInfo<StoreVO> stores(MarketingActivityStoreReqDTO request) { public Page<StoreVO> stores(RpcPagination<MarketingActivityStoreReqDTO> pagination) {
PageHelper.startPage(request.getPageNum(), request.getPageSize()); MarketingActivityStoreReqDTO request = pagination.getCondition();
List<StoreVO> list = marketingActivityStoreMapper.selectStoreVOByActivityId(request.getActivityId()); Page<StoreVO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
marketingActivityStoreMapper.selectStoreVOByActivityId(request.getActivityId());
List<StoreVO> list = res.getResult();
// 补充门店名称和地址 // 补充门店名称和地址
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
Set<Integer> merchantIds = list.stream().map(StoreVO::getMerchantId).collect(Collectors.toSet()); Set<Integer> merchantIds = list.stream().map(StoreVO::getMerchantId).collect(Collectors.toSet());
...@@ -107,74 +109,49 @@ public class MarketingActivityService { ...@@ -107,74 +109,49 @@ public class MarketingActivityService {
log.warn("查询门店信息失败,merchantIds={}", merchantIds, e); log.warn("查询门店信息失败,merchantIds={}", merchantIds, e);
} }
} }
return new PageInfo<>(list); return res;
} }
/** /**
* 查询活动关联商品/套餐(分页) * 查询活动关联商品/套餐(分页)
*/ */
public PageInfo<MarketingActivityProductRespDTO> products(MarketingActivityProductPageReqDTO request) { public Page<MarketingActivityProductRespDTO> products(RpcPagination<MarketingActivityProductPageReqDTO> pagination) {
PageHelper.startPage(request.getPageNum(), request.getPageSize()); MarketingActivityProductPageReqDTO request = pagination.getCondition();
List<MarketingActivityProduct> list; Page<MarketingActivityProductRespDTO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
if (request.getCarSeriesId() != null) { marketingActivityProductMapper.selectProductDTOList(request);
list = marketingActivityProductMapper.selectByActivityIdAndCarSeriesId(request.getActivityId(), request.getCarSeriesId()); if (CollectionUtils.isEmpty(res)) {
} else { return res;
list = marketingActivityProductMapper.selectByActivityId(request.getActivityId()); }
}
PageInfo<MarketingActivityProduct> pageInfo = new PageInfo<>(list); List<MarketingActivityProductRespDTO> list = res.getResult();
// 仅查询 PACKAGE 类型的子商品
List<Integer> productIds = list.stream().map(MarketingActivityProduct::getId).collect(Collectors.toList()); List<Integer> packageProductIds = list.stream()
List<MarketingActivityProductItem> allItems = CollectionUtils.isEmpty(productIds) .filter(p -> ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType()))
? Collections.emptyList() .map(MarketingActivityProductRespDTO::getProductId)
: marketingActivityProductItemMapper.selectByActivityProductIds(productIds); .collect(Collectors.toList());
Map<Integer, List<MarketingActivityProductItem>> itemMap = allItems.stream() if (!CollectionUtils.isEmpty(packageProductIds)) {
.collect(Collectors.groupingBy(MarketingActivityProductItem::getActivityProductId)); List<MarketingActivityProductItemRespDTO> allItems = marketingActivityProductItemMapper.selectItemDTOByActivityProductIds(packageProductIds);
if (CollectionUtils.isEmpty(allItems)) {
List<MarketingActivityProductRespDTO> dtoList = list.stream().map(p -> { return res;
MarketingActivityProductRespDTO pd = new MarketingActivityProductRespDTO(); }
pd.setProductId(p.getId()); Map<Integer, List<MarketingActivityProductItemRespDTO>> itemMap = allItems.stream()
pd.setCarSeriesId(p.getCarSeriesId()); .collect(Collectors.groupingBy(MarketingActivityProductItemRespDTO::getActivityProductId));
pd.setProductType(p.getProductType()); list.stream()
pd.setGoodsCode(p.getGoodsCode()); .filter(p -> ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType()))
pd.setPackageCode(p.getPackageCode()); .forEach(p -> p.setPackageItems(itemMap.getOrDefault(p.getProductId(), Collections.emptyList())));
pd.setSortOrder(p.getSortOrder()); }
pd.setTabName(p.getTabName());
pd.setTabDescription(p.getTabDescription());
pd.setDiscountPrice(p.getDiscountPrice());
pd.setSalesIncentive(p.getSalesIncentive());
pd.setIsMainPush(p.getIsMainPush());
pd.setMainImageUrl(p.getMainImageUrl());
pd.setThumbImageUrl(p.getThumbImageUrl());
pd.setDetailImageUrl(p.getDetailImageUrl());
// 子商品
List<MarketingActivityProductItem> items = itemMap.getOrDefault(p.getId(), Collections.emptyList());
pd.setPackageItems(items.stream().map(i -> {
MarketingActivityProductItemRespDTO idto = new MarketingActivityProductItemRespDTO();
idto.setItemId(i.getId());
idto.setGoodsCode(i.getGoodsCode());
idto.setGoodsName(i.getGoodsName());
idto.setCurrentPrice(i.getCurrentPrice());
idto.setDiscountPrice(i.getDiscountPrice());
idto.setSalesIncentive(i.getSalesIncentive());
return idto;
}).collect(Collectors.toList()));
return pd;
}).collect(Collectors.toList());
PageInfo<MarketingActivityProductRespDTO> result = new PageInfo<>(); return res;
result.setList(dtoList);
result.setTotal(pageInfo.getTotal());
result.setPageNum(pageInfo.getPageNum());
result.setPageSize(pageInfo.getPageSize());
return result;
} }
/** /**
* 查询活动操作日志(分页) * 查询活动操作日志(分页)
*/ */
public PageInfo<OperationLogVO> logs(MarketingActivityLogPageReqDTO request) { public Page<OperationLogVO> logs(RpcPagination<MarketingActivityLogPageReqDTO> pagination) {
PageHelper.startPage(request.getPageNum(), request.getPageSize()); MarketingActivityLogPageReqDTO request = pagination.getCondition();
return new PageInfo<>(marketingActivityOperationLogMapper.selectLogVOByActivityId(request.getActivityId())); Page<OperationLogVO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
marketingActivityOperationLogMapper.selectLogVOByActivityId(request.getActivityId());
return res;
} }
// ==================== 创建 ==================== // ==================== 创建 ====================
...@@ -222,8 +199,8 @@ public class MarketingActivityService { ...@@ -222,8 +199,8 @@ public class MarketingActivityService {
// 更新主表 // 更新主表
activity.setActivityName(request.getActivityName()); activity.setActivityName(request.getActivityName());
activity.setStartTime(parseDate(request.getStartTime())); activity.setStartTime(request.getStartTime());
activity.setEndTime(parseDate(request.getEndTime())); activity.setEndTime(request.getEndTime());
activity.setActivityTag(request.getActivityTag()); activity.setActivityTag(request.getActivityTag());
activity.setMarketingStage(request.getMarketingStage()); activity.setMarketingStage(request.getMarketingStage());
activity.setCarSeriesMode(request.getCarSeriesMode()); activity.setCarSeriesMode(request.getCarSeriesMode());
...@@ -240,7 +217,15 @@ public class MarketingActivityService { ...@@ -240,7 +217,15 @@ public class MarketingActivityService {
batchInsertCarSeries(request.getActivityId(), request.getCarSeriesList(), activity.getUpdatedBy()); batchInsertCarSeries(request.getActivityId(), request.getCarSeriesList(), activity.getUpdatedBy());
} }
// 增量更新商品/套餐: 删旧插新 // 增量更新商品/套餐: 删旧插新,检测是否有变动
MarketingActivityProductPageReqDTO queryDTO = new MarketingActivityProductPageReqDTO();
queryDTO.setActivityId(request.getActivityId());
List<MarketingActivityProductRespDTO> existingProducts = marketingActivityProductMapper.selectProductDTOList(queryDTO);
boolean productChanged = detectProductChange(existingProducts, request.getProducts());
if (productChanged) {
// TODO: 商品/套餐发生变动,触发第三方调用(如通知下游系统)
log.info("活动{}的商品/套餐发生变动,需触发第三方调用", request.getActivityId());
}
marketingActivityProductMapper.deleteByActivityIdAndCarSeriesId(request.getActivityId(), null); marketingActivityProductMapper.deleteByActivityIdAndCarSeriesId(request.getActivityId(), null);
batchInsertProducts(request.getActivityId(), request.getProducts(), activity.getUpdatedBy()); batchInsertProducts(request.getActivityId(), request.getProducts(), activity.getUpdatedBy());
} }
...@@ -302,7 +287,7 @@ public class MarketingActivityService { ...@@ -302,7 +287,7 @@ public class MarketingActivityService {
} }
checkNotExpired(activity); checkNotExpired(activity);
Date newEndTime = parseDate(request.getNewEndTime()); Date newEndTime = request.getNewEndTime();
if (newEndTime == null || !newEndTime.after(activity.getEndTime())) { if (newEndTime == null || !newEndTime.after(activity.getEndTime())) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "新的结束时间必须大于当前结束时间"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "新的结束时间必须大于当前结束时间");
} }
...@@ -311,8 +296,7 @@ public class MarketingActivityService { ...@@ -311,8 +296,7 @@ public class MarketingActivityService {
activity.setUpdatedDate(new Date()); activity.setUpdatedDate(new Date());
marketingActivityMapper.updateByPrimaryKeySelective(activity); marketingActivityMapper.updateByPrimaryKeySelective(activity);
String formattedTime = formatDate(newEndTime); saveExtendLog(activity.getId(), activity.getUpdatedBy(), activity.getUpdatedBy(), cn.hutool.core.date.DateUtil.formatDateTime(newEndTime));
saveExtendLog(activity.getId(), activity.getUpdatedBy(), activity.getUpdatedBy(), formattedTime);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -351,14 +335,6 @@ public class MarketingActivityService { ...@@ -351,14 +335,6 @@ public class MarketingActivityService {
// ==================== 门店可用性校验 ==================== // ==================== 门店可用性校验 ====================
/** /**
* 商品/套餐在适用门店范围内的交集门店数(骨架,待对接业务表)
*/
public int getIntersectionStoreCount(String goodsCode, String packageCode, List<Integer> merchantIds) {
// TODO: 对接业务表查询商品/套餐的原始销售门店,与 merchantIds 取交集
return 0;
}
/**
* 按门店+商品编码批量查询有效活动商品 * 按门店+商品编码批量查询有效活动商品
*/ */
public List<MarketingActivityProduct> batchQueryActivityProducts(Integer merchantId, List<String> goodsCodes) { public List<MarketingActivityProduct> batchQueryActivityProducts(Integer merchantId, List<String> goodsCodes) {
...@@ -443,14 +419,14 @@ public class MarketingActivityService { ...@@ -443,14 +419,14 @@ public class MarketingActivityService {
private MarketingActivity buildActivity(MarketingActivityCreateReqDTO request) { private MarketingActivity buildActivity(MarketingActivityCreateReqDTO request) {
MarketingActivity activity = new MarketingActivity(); MarketingActivity activity = new MarketingActivity();
activity.setActivityName(request.getActivityName()); activity.setActivityName(request.getActivityName());
activity.setStartTime(parseDate(request.getStartTime())); activity.setStartTime(request.getStartTime());
activity.setEndTime(parseDate(request.getEndTime())); activity.setEndTime(request.getEndTime());
activity.setActivityTag(request.getActivityTag()); activity.setActivityTag(request.getActivityTag());
activity.setMarketingStage(request.getMarketingStage()); activity.setMarketingStage(request.getMarketingStage());
activity.setCarSeriesMode(request.getCarSeriesMode() != null ? request.getCarSeriesMode() : 0); activity.setCarSeriesMode(request.getCarSeriesMode());
// TODO: 替换为 CommonUtil.getLoginUser().getUserName() String operator = StringUtils.hasText(request.getOperatorName()) ? request.getOperatorName() : "system";
activity.setCreatedBy("system"); activity.setCreatedBy(operator);
activity.setUpdatedBy(activity.getCreatedBy()); activity.setUpdatedBy(operator);
return activity; return activity;
} }
...@@ -503,22 +479,23 @@ public class MarketingActivityService { ...@@ -503,22 +479,23 @@ public class MarketingActivityService {
p.setSortOrder(req.getSortOrder() != null ? req.getSortOrder() : i); p.setSortOrder(req.getSortOrder() != null ? req.getSortOrder() : i);
// 查询 goods_type/goods_type_name/现售价/最低限价(实时) // 查询 goods_type/goods_type_name/现售价/最低限价(实时)
GoodsTypeInfoDTO goodsTypeInfo = lookupGoodsTypeInfo(req.getGoodsCode(), req.getPackageCode()); GoodsTypeInfoDTO goodsTypeInfo = lookupGoodsTypeInfo(req.getGoodsCode());
p.setGoodsType(goodsTypeInfo.getGoodsType()); p.setGoodsType(goodsTypeInfo.getGoodsType());
p.setGoodsTypeName(goodsTypeInfo.getGoodsTypeName()); p.setGoodsTypeName(goodsTypeInfo.getGoodsTypeName());
p.setCurrentPrice(goodsTypeInfo.getCurrentPrice()); p.setCurrentPrice(goodsTypeInfo.getCurrentPrice());
p.setMinimumPrice(goodsTypeInfo.getMinimumPrice()); p.setMinimumPrice(goodsTypeInfo.getMinimumPrice());
// 价格一致性校验:前端传入的现售价/最低限价必须与实时查询一致 // 价格一致性校验:前端传入的现售价/最低限价必须与实时查询一致
String itemName = StringUtils.hasText(req.getProductName()) ? req.getProductName() : req.getTabName();
if (req.getCurrentPrice() != null && goodsTypeInfo.getCurrentPrice() != null if (req.getCurrentPrice() != null && goodsTypeInfo.getCurrentPrice() != null
&& req.getCurrentPrice().compareTo(goodsTypeInfo.getCurrentPrice()) != 0) { && req.getCurrentPrice().compareTo(goodsTypeInfo.getCurrentPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"商品价格信息已变更,请重新选择商品或套餐"); itemName + "的产品信息存在变更,请重新选择");
} }
if (req.getMinimumPrice() != null && goodsTypeInfo.getMinimumPrice() != null if (req.getMinimumPrice() != null && goodsTypeInfo.getMinimumPrice() != null
&& req.getMinimumPrice().compareTo(goodsTypeInfo.getMinimumPrice()) != 0) { && req.getMinimumPrice().compareTo(goodsTypeInfo.getMinimumPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"商品价格信息已变更,请重新选择商品或套餐"); itemName + "的产品信息存在变更,请重新选择");
} }
p.setTabName(req.getTabName()); p.setTabName(req.getTabName());
...@@ -563,16 +540,17 @@ public class MarketingActivityService { ...@@ -563,16 +540,17 @@ public class MarketingActivityService {
item.setGoodsCode(req.getGoodsCode()); item.setGoodsCode(req.getGoodsCode());
item.setGoodsName(req.getGoodsName()); item.setGoodsName(req.getGoodsName());
// 查询 goods_type/goods_type_name/最低限价(实时) // 查询 goods_type/goods_type_name/最低限价(实时)
GoodsTypeInfoDTO gti = lookupGoodsTypeInfoByGoodsCode(req.getGoodsCode()); GoodsTypeInfoDTO gti = lookupGoodsTypeInfo(req.getGoodsCode());
item.setGoodsType(gti.getGoodsType()); item.setGoodsType(gti.getGoodsType());
item.setGoodsTypeName(gti.getGoodsTypeName()); item.setGoodsTypeName(gti.getGoodsTypeName());
item.setMinimumPrice(gti.getMinimumPrice()); item.setMinimumPrice(gti.getMinimumPrice());
// 价格一致性校验:前端传入的最低限价必须与实时查询一致 // 价格一致性校验:前端传入的最低限价必须与实时查询一致
String itemLabel = StringUtils.hasText(req.getGoodsName()) ? req.getGoodsName() : req.getGoodsCode();
if (req.getMinimumPrice() != null && gti.getMinimumPrice() != null if (req.getMinimumPrice() != null && gti.getMinimumPrice() != null
&& req.getMinimumPrice().compareTo(gti.getMinimumPrice()) != 0) { && req.getMinimumPrice().compareTo(gti.getMinimumPrice()) != 0) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR,
"套餐商品价格信息已变更,请重新选择套餐"); itemLabel + "的产品信息存在变更,请重新选择");
} }
item.setCurrentPrice(req.getCurrentPrice()); item.setCurrentPrice(req.getCurrentPrice());
...@@ -587,40 +565,50 @@ public class MarketingActivityService { ...@@ -587,40 +565,50 @@ public class MarketingActivityService {
} }
/** /**
* 根据 goodsCode 或 packageCode 查询 goods_type/goods_type_name * 检测商品/套餐是否有变动(对比编码)
* 数据链路: merchant_goods_info.upgrade_goods_id -> upgrade_goods.goods_code -> goods_info.goods_type
*/ */
private GoodsTypeInfoDTO lookupGoodsTypeInfo(String goodsCode, String packageCode) { private boolean detectProductChange(List<MarketingActivityProductRespDTO> existing,
if (goodsCode != null && !goodsCode.isEmpty()) { List<MarketingActivityProductReqDTO> incoming) {
return lookupGoodsTypeInfoByGoodsCode(goodsCode); if (existing == null) existing = Collections.emptyList();
} if (incoming == null) incoming = new ArrayList<>();
// 套餐类型: 取第一个子商品的 goods_type 作为套餐的 goods_type
if (packageCode != null && !packageCode.isEmpty()) { Set<String> existingCodes = existing.stream()
List<MarketingActivityProductItemReqDTO> items = null; .filter(p -> ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType())
// 从当前上下文无法直接获取,返回默认值 ? StringUtils.hasLength(p.getPackageCode())
GoodsTypeInfoDTO empty = new GoodsTypeInfoDTO(); : StringUtils.hasLength(p.getGoodsCode()))
empty.setGoodsType(0); .map(p -> "CAR" + p.getCarSeriesId() + "_" +
empty.setGoodsTypeName(""); (ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType())
return empty; ? "PACKAGE:" + p.getPackageCode()
} : "GOODS:" + p.getGoodsCode()))
GoodsTypeInfoDTO empty = new GoodsTypeInfoDTO(); .collect(Collectors.toSet());
empty.setGoodsType(0); Set<String> incomingCodes = incoming.stream()
empty.setGoodsTypeName(""); .filter(p -> ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType())
return empty; ? StringUtils.hasLength(p.getPackageCode())
: StringUtils.hasLength(p.getGoodsCode()))
.map(p -> "CAR" + p.getCarSeriesId() + "_" +
(ProductTypeEnum.PACKAGE.getValue().equals(p.getProductType())
? "PACKAGE:" + p.getPackageCode()
: "GOODS:" + p.getGoodsCode()))
.collect(Collectors.toSet());
boolean equals = existingCodes.equals(incomingCodes);
if (!equals) {
log.info("商品发生变动,old:{}, new:{}", existingCodes, incomingCodes);
}
return !equals;
} }
/** /**
* 根据单个 goodsCode 查询 goods_type * 根据 goodsCode 查询 goods_type/现售价/最低限价
*/ */
private GoodsTypeInfoDTO lookupGoodsTypeInfoByGoodsCode(String goodsCode) { private GoodsTypeInfoDTO lookupGoodsTypeInfo(String goodsCode) {
GoodsTypeInfoDTO result = marketingGoodsQueryMapper.findGoodsTypeInfo(goodsCode); if (goodsCode != null && !goodsCode.isEmpty()) {
if (result != null) { GoodsTypeInfoDTO result = marketingGoodsQueryMapper.findGoodsTypeInfo(goodsCode);
return result; if (result != null) {
} return result;
GoodsTypeInfoDTO empty = new GoodsTypeInfoDTO(); }
empty.setGoodsType(0); }
empty.setGoodsTypeName(""); return new GoodsTypeInfoDTO();
return empty;
} }
private void saveOperationLog(Integer activityId, ActivityEventTypeEnum eventType, String operatorId, String operatorName) { private void saveOperationLog(Integer activityId, ActivityEventTypeEnum eventType, String operatorId, String operatorName) {
...@@ -650,22 +638,4 @@ public class MarketingActivityService { ...@@ -650,22 +638,4 @@ public class MarketingActivityService {
log.setDeletedFlag(DeleteFlagEnum.N.getValue()); log.setDeletedFlag(DeleteFlagEnum.N.getValue());
marketingActivityOperationLogMapper.insert(log); marketingActivityOperationLogMapper.insert(log);
} }
private String formatDate(Date date) {
if (date == null) return null;
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
private Date parseDate(String dateStr) {
if (!StringUtils.hasText(dateStr)) return null;
try {
if (dateStr.length() <= 10) {
return new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
} catch (Exception e) {
log.error("日期解析失败: {}", dateStr, e);
return null;
}
}
} }
...@@ -5,8 +5,11 @@ import cn.com.glsx.dj.strategy.dto.GoodsRespDTO; ...@@ -5,8 +5,11 @@ import cn.com.glsx.dj.strategy.dto.GoodsRespDTO;
import cn.com.glsx.dj.strategy.dto.GoodsStoreReqDTO; import cn.com.glsx.dj.strategy.dto.GoodsStoreReqDTO;
import cn.com.glsx.dj.strategy.dto.GoodsStoreRespDTO; import cn.com.glsx.dj.strategy.dto.GoodsStoreRespDTO;
import cn.com.glsx.dj.strategy.mapper.MarketingGoodsQueryMapper; import cn.com.glsx.dj.strategy.mapper.MarketingGoodsQueryMapper;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -24,13 +27,12 @@ public class MarketingGoodsService { ...@@ -24,13 +27,12 @@ public class MarketingGoodsService {
private final MarketingGoodsQueryMapper marketingGoodsQueryMapper; private final MarketingGoodsQueryMapper marketingGoodsQueryMapper;
public PageInfo<GoodsRespDTO> page(GoodsPageReqDTO request) { public Page<GoodsRespDTO> page(RpcPagination<GoodsPageReqDTO> pagination) {
if (request.getMerchantIds() == null || request.getMerchantIds().isEmpty()) { GoodsPageReqDTO request = pagination.getCondition();
return new PageInfo<>(Collections.emptyList()); RpcAssert.assertNotEmpty(request.getMerchantIds(), DefaultErrorEnum.SERVER_ERROR, "商户ID不能为空");
} Page<GoodsRespDTO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
PageHelper.startPage(request.getPageNum(), request.getPageSize()); marketingGoodsQueryMapper.pageGoods(request);
List<GoodsRespDTO> list = marketingGoodsQueryMapper.pageGoods(request); return res;
return new PageInfo<>(list);
} }
public List<GoodsStoreRespDTO> stores(GoodsStoreReqDTO request) { public List<GoodsStoreRespDTO> stores(GoodsStoreReqDTO request) {
......
...@@ -4,6 +4,9 @@ import cn.com.glsx.dj.strategy.dto.PackageItemRespDTO; ...@@ -4,6 +4,9 @@ import cn.com.glsx.dj.strategy.dto.PackageItemRespDTO;
import cn.com.glsx.dj.strategy.dto.PackagePageReqDTO; import cn.com.glsx.dj.strategy.dto.PackagePageReqDTO;
import cn.com.glsx.dj.strategy.dto.PackageRespDTO; import cn.com.glsx.dj.strategy.dto.PackageRespDTO;
import cn.com.glsx.dj.strategy.mapper.MarketingPackageQueryMapper; import cn.com.glsx.dj.strategy.mapper.MarketingPackageQueryMapper;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -24,11 +27,10 @@ public class MarketingPackageService { ...@@ -24,11 +27,10 @@ public class MarketingPackageService {
private final MarketingPackageQueryMapper marketingPackageQueryMapper; private final MarketingPackageQueryMapper marketingPackageQueryMapper;
public Page<PackageRespDTO> page(PackagePageReqDTO request) { public Page<PackageRespDTO> page(RpcPagination<PackagePageReqDTO> pagination) {
if (request.getMerchantIds() == null || request.getMerchantIds().isEmpty()) { PackagePageReqDTO request = pagination.getCondition();
return null; RpcAssert.assertNotEmpty(request.getMerchantIds(), DefaultErrorEnum.SERVER_ERROR, "商户ID不能为空");
} Page<PackageRespDTO> res = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
Page<PackageRespDTO> res = PageHelper.startPage(request.getPageNum(), request.getPageSize());
marketingPackageQueryMapper.pagePackages(request); marketingPackageQueryMapper.pagePackages(request);
return res; return res;
} }
......
...@@ -16,6 +16,20 @@ ...@@ -16,6 +16,20 @@
</foreach> </foreach>
</insert> </insert>
<!-- 子商品 DTO 映射 -->
<resultMap id="ItemRespDTOResultMap" type="cn.com.glsx.dj.strategy.dto.MarketingActivityProductItemRespDTO">
<id column="id" property="itemId" jdbcType="INTEGER"/>
<result column="activity_product_id" property="activityProductId" jdbcType="INTEGER"/>
<result column="goods_code" property="goodsCode" jdbcType="VARCHAR"/>
<result column="goods_name" property="goodsName" jdbcType="VARCHAR"/>
<result column="goods_type" property="goodsType" jdbcType="INTEGER"/>
<result column="goods_type_name" property="goodsTypeName" jdbcType="VARCHAR"/>
<result column="current_price" property="currentPrice" jdbcType="DECIMAL"/>
<result column="minimum_price" property="minimumPrice" jdbcType="DECIMAL"/>
<result column="discount_price" property="discountPrice" jdbcType="DECIMAL"/>
<result column="sales_incentive" property="salesIncentive" jdbcType="DECIMAL"/>
</resultMap>
<select id="selectByActivityProductId" resultType="cn.com.glsx.dj.strategy.model.MarketingActivityProductItem"> <select id="selectByActivityProductId" resultType="cn.com.glsx.dj.strategy.model.MarketingActivityProductItem">
SELECT * FROM dj_marketing_activity_product_item SELECT * FROM dj_marketing_activity_product_item
WHERE activity_product_id = #{activityProductId} AND deleted_flag = 'N' WHERE activity_product_id = #{activityProductId} AND deleted_flag = 'N'
...@@ -30,6 +44,16 @@ ...@@ -30,6 +44,16 @@
AND deleted_flag = 'N' AND deleted_flag = 'N'
</select> </select>
<select id="selectItemDTOByActivityProductIds" resultMap="ItemRespDTOResultMap">
SELECT *
FROM dj_marketing_activity_product_item
WHERE activity_product_id IN
<foreach collection="productIds" item="pid" open="(" separator="," close=")">
#{pid}
</foreach>
AND deleted_flag = 'N'
</select>
<update id="deleteByActivityProductId"> <update id="deleteByActivityProductId">
UPDATE dj_marketing_activity_product_item SET deleted_flag = 'D', updated_date = NOW() UPDATE dj_marketing_activity_product_item SET deleted_flag = 'D', updated_date = NOW()
WHERE activity_product_id = #{activityProductId} WHERE activity_product_id = #{activityProductId}
......
...@@ -37,6 +37,41 @@ ...@@ -37,6 +37,41 @@
ORDER BY sort_order ORDER BY sort_order
</select> </select>
<!-- 通用查询(DTO 映射) -->
<resultMap id="ProductRespDTOResultMap" type="cn.com.glsx.dj.strategy.dto.MarketingActivityProductRespDTO">
<id column="id" property="productId" jdbcType="INTEGER"/>
<result column="car_series_id" property="carSeriesId" jdbcType="INTEGER"/>
<result column="product_type" property="productType" jdbcType="TINYINT"/>
<result column="goods_type" property="goodsType" jdbcType="INTEGER"/>
<result column="goods_type_name" property="goodsTypeName" jdbcType="VARCHAR"/>
<result column="goods_code" property="goodsCode" jdbcType="VARCHAR"/>
<result column="package_code" property="packageCode" jdbcType="VARCHAR"/>
<result column="sort_order" property="sortOrder" jdbcType="INTEGER"/>
<result column="tab_name" property="tabName" jdbcType="VARCHAR"/>
<result column="tab_description" property="tabDescription" jdbcType="VARCHAR"/>
<result column="discount_price" property="discountPrice" jdbcType="DECIMAL"/>
<result column="current_price" property="currentPrice" jdbcType="DECIMAL"/>
<result column="minimum_price" property="minimumPrice" jdbcType="DECIMAL"/>
<result column="sales_incentive" property="salesIncentive" jdbcType="DECIMAL"/>
<result column="is_main_push" property="isMainPush" jdbcType="TINYINT"/>
<result column="main_image_url" property="mainImageUrl" jdbcType="VARCHAR"/>
<result column="thumb_image_url" property="thumbImageUrl" jdbcType="VARCHAR"/>
<result column="detail_image_url" property="detailImageUrl" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectProductDTOList" resultMap="ProductRespDTOResultMap">
SELECT *
FROM dj_marketing_activity_product
WHERE activity_id = #{query.activityId} AND deleted_flag = 'N'
<if test="query.carSeriesId != null">
AND car_series_id = #{query.carSeriesId}
</if>
<if test="query.productType != null">
AND product_type = #{query.productType}
</if>
ORDER BY sort_order
</select>
<update id="deleteByActivityIdAndCarSeriesId"> <update id="deleteByActivityIdAndCarSeriesId">
UPDATE dj_marketing_activity_product SET deleted_flag = 'D', updated_date = NOW() UPDATE dj_marketing_activity_product SET deleted_flag = 'D', updated_date = NOW()
WHERE activity_id = #{activityId} AND deleted_flag = 'N' WHERE activity_id = #{activityId} AND deleted_flag = 'N'
......
...@@ -65,9 +65,12 @@ ...@@ -65,9 +65,12 @@
<!-- 根据 goodsCode 查询 goods_type/goods_type_name/现售价/最低限价 --> <!-- 根据 goodsCode 查询 goods_type/goods_type_name/现售价/最低限价 -->
<select id="findGoodsTypeInfo" resultType="cn.com.glsx.dj.strategy.dto.GoodsTypeInfoDTO"> <select id="findGoodsTypeInfo" resultType="cn.com.glsx.dj.strategy.dto.GoodsTypeInfoDTO">
SELECT gi.goods_type AS goodsType, gi.goods_type_name AS goodsTypeName, SELECT
COALESCE(mgi.sell_price, 0) AS currentPrice, mgi.goods_alias AS goodsAlias,
COALESCE(mgi.min_sell_price, 0) AS minimumPrice gi.goods_type AS goodsType,
gi.goods_type_name AS goodsTypeName,
COALESCE(mgi.sell_price, 0) AS currentPrice,
COALESCE(mgi.min_sell_price, 0) AS minimumPrice
FROM dj_car_life_merchant_goods_info mgi FROM dj_car_life_merchant_goods_info mgi
JOIN dj_car_life_upgrade_goods ug ON ug.id = mgi.upgrade_goods_id AND ug.deleted_flag = 'N' JOIN dj_car_life_upgrade_goods ug ON ug.id = mgi.upgrade_goods_id AND ug.deleted_flag = 'N'
JOIN dj_car_life_goods_info gi ON gi.goods_code = ug.goods_code AND gi.deleted_flag = 'N' JOIN dj_car_life_goods_info gi ON gi.goods_code = ug.goods_code AND gi.deleted_flag = 'N'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!