From 7063e0f6c6d0a38f30737ede1195d2f86598c21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98mahaoran=E2=80=99?= <2570310046@qq.com> Date: Fri, 22 Nov 2024 09:39:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E5=88=97=E8=A1=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/market/team/TeamOpenTypeEnum.java | 27 ++ .../common/core/web/model/QueryModel.java | 15 +- .../marketing/domain/ActivityTeamInfo.java | 2 +- .../domain/ActivityTeamOpenInfo.java | 307 ++---------------- .../domain/ActivityTeamProductSkuInfo.java | 205 ++---------- .../model/ActivityTeamInfoListModel.java | 85 ++++- .../model/ActivityTeamInfoListQueryModel.java | 3 +- .../model/TeamProductDiscountPriceModel.java | 39 +++ .../domain/model/TeamProductStockModel.java | 16 + .../domain/req/TeamInfoReqListReq.java | 24 +- .../domain/resp/TeamInfoListResp.java | 40 ++- .../muyu-marketing/marketing-server/pom.xml | 4 + .../controller/ActivityTeamController.java | 21 +- .../mapper/ActivityTeamInfoMapper.java | 7 + .../mapper/ActivityTeamOpenInfoMapper.java | 7 + .../ActivityTeamProductSkuInfoMapper.java | 7 + .../service/ActivityOpenInfoService.java | 18 +- .../service/ActivityTeamInfoService.java | 9 +- .../ActivityTeamProductSkuInfoService.java | 20 +- .../impl/ActivityOpenInfoServiceImpl.java | 24 +- .../impl/ActivityTeamInfoServiceImpl.java | 62 ++-- ...ActivityTeamProductSkuInfoServiceImpl.java | 59 +++- ...amStrategyExemptionHundredServiceImpl.java | 2 + ...mStrategyExemptionOrdinaryServiceImpl.java | 2 + .../TeamStrategyExemptionServiceImpl.java | 2 + 25 files changed, 506 insertions(+), 501 deletions(-) create mode 100644 muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/enums/market/team/TeamOpenTypeEnum.java create mode 100644 muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductDiscountPriceModel.java create mode 100644 muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductStockModel.java create mode 100644 muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamInfoMapper.java create mode 100644 muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamOpenInfoMapper.java create mode 100644 muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamProductSkuInfoMapper.java diff --git a/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/enums/market/team/TeamOpenTypeEnum.java b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/enums/market/team/TeamOpenTypeEnum.java new file mode 100644 index 0000000..b1b167a --- /dev/null +++ b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/enums/market/team/TeamOpenTypeEnum.java @@ -0,0 +1,27 @@ +package com.muyu.common.core.enums.market.team; + +import lombok.Data; + + +public enum TeamOpenTypeEnum { + OPEN_TEAM("open_team","开团"), + + IN_TEAM("in_team","参团"); + + private final String code; + private final String label; + + + TeamOpenTypeEnum(String code, String label) { + this.code = code; + this.label = label; + } + + public String Code() { + return code; + } + + public String Label() { + return label; + } +} diff --git a/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/web/model/QueryModel.java b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/web/model/QueryModel.java index 41d8d8e..3bc4c93 100644 --- a/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/web/model/QueryModel.java +++ b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/web/model/QueryModel.java @@ -1,5 +1,7 @@ package com.muyu.common.core.web.model; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.muyu.common.core.web.page.PageDomain; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,6 +9,8 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import java.util.List; + @Data @SuperBuilder @NoArgsConstructor @@ -34,7 +38,6 @@ public class QueryModel { private boolean isAsc = true; - public T domainBuild(PageDomain pageDomain){ this.pageNum=pageDomain.getPageNum(); this.pageSize=pageDomain.getPageSize(); @@ -42,4 +45,14 @@ public class QueryModel { this.isAsc="asc".equals(pageDomain.getIsAsc()) ? true : false; return (T) this; } + + public Page buildPage(){ + Page page = Page.of(this.getPageNum(), this.getPageSize()); + page.setOrders(List.of(this.isAsc() + ? OrderItem.asc(this.getOrderByColumn()) : OrderItem.desc(this.getOrderByColumn()))); + return page; + + + } + } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamInfo.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamInfo.java index 102895a..1fa54ca 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamInfo.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamInfo.java @@ -36,7 +36,7 @@ public class ActivityTeamInfo extends BaseEntity { */ @ApiModelProperty("主键") - private Integer id; + private Long id; /** * 拼团名称 */ diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamOpenInfo.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamOpenInfo.java index 99d45b5..5d01d61 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamOpenInfo.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamOpenInfo.java @@ -8,18 +8,26 @@ import java.io.Serializable; import java.util.Date; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.hibernate.validator.constraints.Length; /** * 团购活动执行表 * @TableName activity_team_open_info */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class ActivityTeamOpenInfo implements Serializable { /** * 主键 */ - @NotNull(message="[主键]不能为空") + @ApiModelProperty("主键") private Integer id; /** @@ -31,86 +39,78 @@ public class ActivityTeamOpenInfo implements Serializable { /** * 团购类型 */ - @NotBlank(message="[团购类型]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("团购类型") - @Length(max= 255,message="编码长度不能超过255") + private String teamType; /** * 团购策略 */ - @NotBlank(message="[团购策略]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("团购策略") - @Length(max= 255,message="编码长度不能超过255") + private String teamStrategyId; /** * 参团类型 */ - @NotBlank(message="[参团类型]不能为空") - @Size(max= 32,message="编码长度不能超过32") + @ApiModelProperty("参团类型") - @Length(max= 32,message="编码长度不能超过32") + private String executiveType; /** * 结束团购时间 */ - @NotNull(message="[结束团购时间]不能为空") + @ApiModelProperty("结束团购时间") private Date endTime; /** * 商品ID */ - @NotBlank(message="[商品ID]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("商品ID") - @Length(max= 255,message="编码长度不能超过255") + private String productId; /** * 商品名称 */ - @NotBlank(message="[商品名称]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("商品名称") - @Length(max= 255,message="编码长度不能超过255") + private String productName; /** * 商品规格 */ - @NotBlank(message="[商品规格]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("商品规格") - @Length(max= 255,message="编码长度不能超过255") + private String productSku; /** * 开团标识 */ - @NotBlank(message="[开团标识]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("开团标识") - @Length(max= 255,message="编码长度不能超过255") + private String key; /** * 订单ID */ - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("订单ID") - @Length(max= 255,message="编码长度不能超过255") + private String orderId; /** * 开团状态 */ - @NotBlank(message="[开团状态]不能为空") - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("开团状态") - @Length(max= 255,message="编码长度不能超过255") + private String status; /** * 创建人 */ - @Size(max= 32,message="编码长度不能超过32") + @ApiModelProperty("创建人") - @Length(max= 32,message="编码长度不能超过32") + private String createBy; /** * 创建时间 @@ -120,9 +120,9 @@ public class ActivityTeamOpenInfo implements Serializable { /** * 修改人 */ - @Size(max= 32,message="编码长度不能超过32") + @ApiModelProperty("修改人") - @Length(max= 32,message="编码长度不能超过32") + private String updateBy; /** * 修改时间 @@ -132,248 +132,9 @@ public class ActivityTeamOpenInfo implements Serializable { /** * 备注 */ - @Size(max= 900,message="编码长度不能超过900") + @ApiModelProperty("备注") - @Length(max= 900,message="编码长度不能超过900") + private String remark; - /** - * 主键 - */ - private void setId(Integer id){ - this.id = id; - } - - /** - * 团购活动ID - */ - private void setTeamId(Long teamId){ - this.teamId = teamId; - } - - /** - * 团购类型 - */ - private void setTeamType(String teamType){ - this.teamType = teamType; - } - - /** - * 团购策略 - */ - private void setTeamStrategyId(String teamStrategyId){ - this.teamStrategyId = teamStrategyId; - } - - /** - * 参团类型 - */ - private void setExecutiveType(String executiveType){ - this.executiveType = executiveType; - } - - /** - * 结束团购时间 - */ - private void setEndTime(Date endTime){ - this.endTime = endTime; - } - - /** - * 商品ID - */ - private void setProductId(String productId){ - this.productId = productId; - } - - /** - * 商品名称 - */ - private void setProductName(String productName){ - this.productName = productName; - } - - /** - * 商品规格 - */ - private void setProductSku(String productSku){ - this.productSku = productSku; - } - - /** - * 开团标识 - */ - private void setKey(String key){ - this.key = key; - } - - /** - * 订单ID - */ - private void setOrderId(String orderId){ - this.orderId = orderId; - } - - /** - * 开团状态 - */ - private void setStatus(String status){ - this.status = status; - } - - /** - * 创建人 - */ - private void setCreateBy(String createBy){ - this.createBy = createBy; - } - - /** - * 创建时间 - */ - private void setCreateTime(Date createTime){ - this.createTime = createTime; - } - - /** - * 修改人 - */ - private void setUpdateBy(String updateBy){ - this.updateBy = updateBy; - } - - /** - * 修改时间 - */ - private void setUpdateTime(Date updateTime){ - this.updateTime = updateTime; - } - - /** - * 备注 - */ - private void setRemark(String remark){ - this.remark = remark; - } - - - /** - * 主键 - */ - private Integer getId(){ - return this.id; - } - - /** - * 团购活动ID - */ - private Long getTeamId(){ - return this.teamId; - } - - /** - * 团购类型 - */ - private String getTeamType(){ - return this.teamType; - } - - /** - * 团购策略 - */ - private String getTeamStrategyId(){ - return this.teamStrategyId; - } - - /** - * 参团类型 - */ - private String getExecutiveType(){ - return this.executiveType; - } - - /** - * 结束团购时间 - */ - private Date getEndTime(){ - return this.endTime; - } - - /** - * 商品ID - */ - private String getProductId(){ - return this.productId; - } - - /** - * 商品名称 - */ - private String getProductName(){ - return this.productName; - } - - /** - * 商品规格 - */ - private String getProductSku(){ - return this.productSku; - } - - /** - * 开团标识 - */ - private String getKey(){ - return this.key; - } - - /** - * 订单ID - */ - private String getOrderId(){ - return this.orderId; - } - - /** - * 开团状态 - */ - private String getStatus(){ - return this.status; - } - - /** - * 创建人 - */ - private String getCreateBy(){ - return this.createBy; - } - - /** - * 创建时间 - */ - private Date getCreateTime(){ - return this.createTime; - } - - /** - * 修改人 - */ - private String getUpdateBy(){ - return this.updateBy; - } - - /** - * 修改时间 - */ - private Date getUpdateTime(){ - return this.updateTime; - } - - /** - * 备注 - */ - private String getRemark(){ - return this.remark; - } - } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamProductSkuInfo.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamProductSkuInfo.java index 411b4ce..3fb44a2 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamProductSkuInfo.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/ActivityTeamProductSkuInfo.java @@ -6,62 +6,76 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.hibernate.validator.constraints.Length; /** * 商品拼团规格信息表 * @TableName activity_team_product_sku_info */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder public class ActivityTeamProductSkuInfo implements Serializable { /** * 主键 */ - @NotNull(message="[主键]不能为空") + @ApiModelProperty("主键") - private Integer id; + private Long id; /** * 活动ID */ - @NotNull(message="[活动ID]不能为空") + @ApiModelProperty("活动ID") private Long teamId; /** * 商品ID */ - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("商品ID") - @Length(max= 255,message="编码长度不能超过255") - private String productId; + + private Long productId; /** * 商品SKU */ - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("商品SKU") @Length(max= 255,message="编码长度不能超过255") private String productSku; /** * 拼团库存 */ - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("拼团库存") - @Length(max= 255,message="编码长度不能超过255") - private String teamStock; + + private Long teamStock; + + /** + * 剩余库存 + */ + private Long remainStock; /** * 拼团价格 */ - @Size(max= 255,message="编码长度不能超过255") + @ApiModelProperty("拼团价格") - @Length(max= 255,message="编码长度不能超过255") - private String teamPrice; + + private BigDecimal teamPrice; /** * 创建人 */ - @Size(max= 32,message="编码长度不能超过32") + @ApiModelProperty("创建人") - @Length(max= 32,message="编码长度不能超过32") + private String createBy; /** * 创建时间 @@ -71,9 +85,9 @@ public class ActivityTeamProductSkuInfo implements Serializable { /** * 修改人 */ - @Size(max= 32,message="编码长度不能超过32") + @ApiModelProperty("修改人") - @Length(max= 32,message="编码长度不能超过32") + private String updateBy; /** * 修改时间 @@ -83,164 +97,11 @@ public class ActivityTeamProductSkuInfo implements Serializable { /** * 备注 */ - @Size(max= 900,message="编码长度不能超过900") + @ApiModelProperty("备注") - @Length(max= 900,message="编码长度不能超过900") + private String remark; - /** - * 主键 - */ - private void setId(Integer id){ - this.id = id; - } - /** - * 活动ID - */ - private void setTeamId(Long teamId){ - this.teamId = teamId; - } - - /** - * 商品ID - */ - private void setProductId(String productId){ - this.productId = productId; - } - - /** - * 商品SKU - */ - private void setProductSku(String productSku){ - this.productSku = productSku; - } - - /** - * 拼团库存 - */ - private void setTeamStock(String teamStock){ - this.teamStock = teamStock; - } - - /** - * 拼团价格 - */ - private void setTeamPrice(String teamPrice){ - this.teamPrice = teamPrice; - } - - /** - * 创建人 - */ - private void setCreateBy(String createBy){ - this.createBy = createBy; - } - - /** - * 创建时间 - */ - private void setCreateTime(Date createTime){ - this.createTime = createTime; - } - - /** - * 修改人 - */ - private void setUpdateBy(String updateBy){ - this.updateBy = updateBy; - } - - /** - * 修改时间 - */ - private void setUpdateTime(Date updateTime){ - this.updateTime = updateTime; - } - - /** - * 备注 - */ - private void setRemark(String remark){ - this.remark = remark; - } - - - /** - * 主键 - */ - private Integer getId(){ - return this.id; - } - - /** - * 活动ID - */ - private Long getTeamId(){ - return this.teamId; - } - - /** - * 商品ID - */ - private String getProductId(){ - return this.productId; - } - - /** - * 商品SKU - */ - private String getProductSku(){ - return this.productSku; - } - - /** - * 拼团库存 - */ - private String getTeamStock(){ - return this.teamStock; - } - - /** - * 拼团价格 - */ - private String getTeamPrice(){ - return this.teamPrice; - } - - /** - * 创建人 - */ - private String getCreateBy(){ - return this.createBy; - } - - /** - * 创建时间 - */ - private Date getCreateTime(){ - return this.createTime; - } - - /** - * 修改人 - */ - private String getUpdateBy(){ - return this.updateBy; - } - - /** - * 修改时间 - */ - private Date getUpdateTime(){ - return this.updateTime; - } - - /** - * 备注 - */ - private String getRemark(){ - return this.remark; - } } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListModel.java index e4726eb..e154df5 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListModel.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListModel.java @@ -1,15 +1,94 @@ package com.muyu.marketing.domain.model; +import com.muyu.marketing.domain.ActivityTeamInfo; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; +import java.math.BigDecimal; import java.util.Date; +import java.util.function.Consumer; +import java.util.function.Function; @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class ActivityTeamInfoListModel { - private Integer id; + /** + * 主建 + */ + private Long id; + /** + *拼团名称 + */ private String name; - private String addTeamNumber; - private String attendNumber; + /** + *参团人数 + */ + private Long addTeamNumber; + /** + *开团人数 + */ + private Long openTeamNumber; + /** + *拼团人数 + */ + private Long attendNumber; + /** + *结束时间 + */ private Date endTime; + /** + *图片 + */ + private String productImage; + /** + *拼团价格 + */ + private BigDecimal teamPrice; + /** + *商品价格 + */ + private BigDecimal productPrice; + /** + *团购库存 + */ + private Long teamStock; + /** + *剩余库存 + */ + private Long remainStock; + /** + *活动状态 + */ private String status; + + + public static ActivityTeamInfoListModel infoBuild(ActivityTeamInfo activityTeamInfo, Function function){ + ActivityTeamInfoListModel builder = ActivityTeamInfoListModel.builder() + .id(activityTeamInfo.getId()) + .name(activityTeamInfo.getName()) +// .addTeamNumber("00") +// .openTeamNumber("00") +// .attendNumber("00") + .endTime(activityTeamInfo.getEndTime()) + .productImage(activityTeamInfo.getProductImage()) +// .teamPrice("0") +// .productPrice("0") +// .remainStock("0") +// .teamStock("0") + .status(activityTeamInfo.getStatus()) + .build(); + return function.apply( + ActivityTeamInfoListModel.builder() + .id(activityTeamInfo.getId()) + .name(activityTeamInfo.getName()) + .endTime(activityTeamInfo.getEndTime()) + .productImage(activityTeamInfo.getProductImage()) + .status(activityTeamInfo.getStatus()) + ); + } + } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListQueryModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListQueryModel.java index a83228b..a667417 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListQueryModel.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoListQueryModel.java @@ -19,6 +19,7 @@ public class ActivityTeamInfoListQueryModel extends QueryModel + + com.muyu + muyu-product-cache + com.muyu diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/controller/ActivityTeamController.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/controller/ActivityTeamController.java index ccfab02..5bacc0f 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/controller/ActivityTeamController.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/controller/ActivityTeamController.java @@ -1,9 +1,11 @@ package com.muyu.marketing.controller; import com.muyu.common.core.domain.Result; +import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.marketing.domain.model.ActivityTeamInfoListModel; import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel; import com.muyu.marketing.domain.req.TeamInfoReqListReq; +import com.muyu.marketing.domain.resp.TeamInfoListResp; import com.muyu.marketing.service.ActivityTeamInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -11,18 +13,23 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController @RequestMapping("/team") public class ActivityTeamController { @Autowired private ActivityTeamInfoService activityTeamInfoService; @PostMapping("list") - public Result list(@RequestBody TeamInfoReqListReq teamInfoReqListReq){ - ActivityTeamInfoListQueryModel queryModel = new ActivityTeamInfoListQueryModel(); - queryModel.domainBuild(teamInfoReqListReq); - queryModel.setKeyWord(teamInfoReqListReq.getKeyWord()); - queryModel.setStatus(teamInfoReqListReq.getStatus()); - activityTeamInfoService.query(queryModel); - return Result.success(); + public Result> list(@RequestBody TeamInfoReqListReq teamInfoReqListReq){ + TableDataInfo tableDataInfo = activityTeamInfoService.query(teamInfoReqListReq.buildQueryModel()); + List respList = tableDataInfo.getRows().stream().map(TeamInfoListResp::listModelBuild).toList(); + return Result.success( + new TableDataInfo<>(){{ + setRows(respList); + setTotal(tableDataInfo.getTotal()); + }} + ); + } } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamInfoMapper.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamInfoMapper.java new file mode 100644 index 0000000..3c96257 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamInfoMapper.java @@ -0,0 +1,7 @@ +package com.muyu.marketing.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.marketing.domain.ActivityTeamInfo; + +public interface ActivityTeamInfoMapper extends BaseMapper { +} diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamOpenInfoMapper.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamOpenInfoMapper.java new file mode 100644 index 0000000..2a5b2e5 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamOpenInfoMapper.java @@ -0,0 +1,7 @@ +package com.muyu.marketing.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.marketing.domain.ActivityTeamOpenInfo; + +public interface ActivityTeamOpenInfoMapper extends BaseMapper { +} diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamProductSkuInfoMapper.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamProductSkuInfoMapper.java new file mode 100644 index 0000000..7a677df --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/mapper/ActivityTeamProductSkuInfoMapper.java @@ -0,0 +1,7 @@ +package com.muyu.marketing.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.marketing.domain.ActivityTeamProductSkuInfo; + +public interface ActivityTeamProductSkuInfoMapper extends BaseMapper { +} diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityOpenInfoService.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityOpenInfoService.java index 76fb098..78f0b8c 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityOpenInfoService.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityOpenInfoService.java @@ -1,4 +1,20 @@ package com.muyu.marketing.service; -public interface ActivityOpenInfoService { +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.common.core.enums.market.team.TeamOpenTypeEnum; +import com.muyu.marketing.domain.ActivityTeamOpenInfo; + +public interface ActivityOpenInfoService extends IService { + /** + * 查询开团数量 + * @param teamId + * @return + */ + public Long getTeamOpenNumberByTeamIdAndType(Long teamId); + /** + * 查询参团数量 + * @param teamId + * @return + */ + public Long getTeamInNumberByTeamIdAndType(Long teamId); } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamInfoService.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamInfoService.java index 16d9c23..75d686c 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamInfoService.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamInfoService.java @@ -3,12 +3,17 @@ package com.muyu.marketing.service; import com.baomidou.mybatisplus.extension.service.IService; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.marketing.domain.ActivityTeamInfo; +import com.muyu.marketing.domain.model.ActivityTeamInfoListModel; import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel; import java.util.List; public interface ActivityTeamInfoService extends IService { - - public TableDataInfo query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel); + /** + * 拼团订单列表 + * @param activityTeamInfoListQueryModel + * @return + */ + public TableDataInfo query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel); } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamProductSkuInfoService.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamProductSkuInfoService.java index 545a2c1..e758f1e 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamProductSkuInfoService.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/ActivityTeamProductSkuInfoService.java @@ -1,4 +1,22 @@ package com.muyu.marketing.service; -public interface ActivityTeamProductSkuInfoService { +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.marketing.domain.ActivityTeamProductSkuInfo; +import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel; +import com.muyu.marketing.domain.model.TeamProductStockModel; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface ActivityTeamProductSkuInfoService extends IService{ + public default List getActivityTeamProductSkuInfoByTeamId(Long teamId){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId,teamId); + return this.list(queryWrapper); + } + + public TeamProductDiscountPriceModel getDiscountPrice(Long teamId); + public TeamProductStockModel getStock(Long teamId); } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityOpenInfoServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityOpenInfoServiceImpl.java index 4a51f46..597e33e 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityOpenInfoServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityOpenInfoServiceImpl.java @@ -1,6 +1,28 @@ package com.muyu.marketing.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.enums.market.team.TeamOpenTypeEnum; +import com.muyu.marketing.domain.ActivityTeamOpenInfo; +import com.muyu.marketing.mapper.ActivityTeamOpenInfoMapper; import com.muyu.marketing.service.ActivityOpenInfoService; +import org.springframework.stereotype.Service; -public class ActivityOpenInfoServiceImpl implements ActivityOpenInfoService { +@Service +public class ActivityOpenInfoServiceImpl extends ServiceImpl implements ActivityOpenInfoService { + @Override + public Long getTeamOpenNumberByTeamIdAndType(Long teamId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActivityTeamOpenInfo::getTeamId,teamId); + queryWrapper.eq(ActivityTeamOpenInfo::getTeamType,TeamOpenTypeEnum.OPEN_TEAM.Code()); + return this.count(queryWrapper); + } + + @Override + public Long getTeamInNumberByTeamIdAndType(Long teamId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActivityTeamOpenInfo::getTeamId,teamId); + queryWrapper.eq(ActivityTeamOpenInfo::getTeamType,TeamOpenTypeEnum.IN_TEAM.Code()); + return this.count(queryWrapper); + } } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamInfoServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamInfoServiceImpl.java index 30402a7..f16ebc6 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamInfoServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamInfoServiceImpl.java @@ -6,44 +6,64 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.marketing.domain.ActivityTeamInfo; import com.muyu.marketing.domain.model.ActivityTeamInfoListModel; import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel; +import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel; +import com.muyu.marketing.domain.model.TeamProductStockModel; import com.muyu.marketing.mapper.ActivityInfoMapper; +import com.muyu.marketing.mapper.ActivityTeamInfoMapper; +import com.muyu.marketing.service.ActivityOpenInfoService; import com.muyu.marketing.service.ActivityTeamInfoService; +import com.muyu.marketing.service.ActivityTeamProductSkuInfoService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; @Service -public class ActivityTeamInfoServiceImpl extends ServiceImpl implements ActivityTeamInfoService { +public class ActivityTeamInfoServiceImpl extends ServiceImpl implements ActivityTeamInfoService { - public TableDataInfo query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) { - Page page = new Page<>(); - page.setCurrent(activityTeamInfoListQueryModel.getPageNum()); - page.setSize(activityTeamInfoListQueryModel.getPageSize()); - activityTeamInfoListQueryModel.getOrderByColumn(); - activityTeamInfoListQueryModel.isAsc(); - page.setOrders(Arrays.asList(new OrderItem())); - Page activityTeamInfoPage = this.page(new Page(), new LambdaQueryWrapper()); + @Autowired + private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService; - ArrayList list = new ArrayList<>(); - for (ActivityTeamInfo activityTeamInfo : list) { - ActivityTeamInfoListModel activityTeamInfoListModel = new ActivityTeamInfoListModel(); - activityTeamInfoListModel.setId(activityTeamInfo.getId()); - activityTeamInfoListModel.setName(activityTeamInfo.getName()); - activityTeamInfoListModel.setAddTeamNumber("00"); - activityTeamInfoListModel.setAttendNumber("00"); - activityTeamInfoListModel.setEndTime(activityTeamInfo.getEndTime()); - activityTeamInfoListModel.setStatus(activityTeamInfo.getStatus()); - } + @Autowired + private ActivityOpenInfoService activityOpenInfoService; - TableDataInfo tableDataInfo = new TableDataInfo<>(); + @Override + public TableDataInfo query (ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getKeyWord()),ActivityTeamInfo::getName , activityTeamInfoListQueryModel.getKeyWord()); + queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getStatus()),ActivityTeamInfo::getStatus , activityTeamInfoListQueryModel.getStatus()); + Page activityTeamInfoPage = this.page(activityTeamInfoListQueryModel.buildPage(),queryWrapper); + List activityTeamInfoList = activityTeamInfoPage.getRecords(); + List activityTeamInfoListModels = activityTeamInfoList.stream() + .map(activityTeamInfo -> ActivityTeamInfoListModel.infoBuild(activityTeamInfo, + (activityTeamInfoListModelBuilder) -> { + Long openNumberByTeamIdAndType = activityOpenInfoService.getTeamOpenNumberByTeamIdAndType(activityTeamInfo.getId()); + Long inNumberByTeamIdAndType = activityOpenInfoService.getTeamInNumberByTeamIdAndType(activityTeamInfo.getId()); + TeamProductDiscountPriceModel discountPrice = activityTeamProductSkuInfoService.getDiscountPrice(activityTeamInfo.getId()); + TeamProductStockModel teamProductStockModel = activityTeamProductSkuInfoService.getStock(activityTeamInfo.getId()); + + return activityTeamInfoListModelBuilder + .openTeamNumber(openNumberByTeamIdAndType) + .addTeamNumber(inNumberByTeamIdAndType) + .attendNumber(openNumberByTeamIdAndType + inNumberByTeamIdAndType) + .teamPrice(discountPrice.getTeamPrice()) + .productPrice(discountPrice.getProductPrice()) + .teamStock(teamProductStockModel.getTeamStock()) + .remainStock(teamProductStockModel.getRemainStock()) + .build(); + + })).toList(); + TableDataInfo tableDataInfo = new TableDataInfo<>(); tableDataInfo.setTotal(activityTeamInfoPage.getTotal()); - tableDataInfo.setRows(activityTeamInfoPage.getRecords()); + tableDataInfo.setRows(activityTeamInfoListModels); return tableDataInfo; diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamProductSkuInfoServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamProductSkuInfoServiceImpl.java index 627b24b..f994919 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamProductSkuInfoServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/ActivityTeamProductSkuInfoServiceImpl.java @@ -1,6 +1,63 @@ package com.muyu.marketing.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.marketing.domain.ActivityTeamProductSkuInfo; +import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel; +import com.muyu.marketing.domain.model.TeamProductStockModel; +import com.muyu.marketing.mapper.ActivityTeamOpenInfoMapper; +import com.muyu.marketing.mapper.ActivityTeamProductSkuInfoMapper; import com.muyu.marketing.service.ActivityTeamProductSkuInfoService; +import com.muyu.product.cache.ProjectSkuCache; +import com.muyu.product.cache.datasource.ProjectSkuData; +import com.muyu.product.domain.ProjectSkuInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; -public class ActivityTeamProductSkuInfoServiceImpl implements ActivityTeamProductSkuInfoService { +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +@Service +public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl implements ActivityTeamProductSkuInfoService { + + @Autowired + private ProjectSkuCache projectSkuCache; + + @Override + public TeamProductDiscountPriceModel getDiscountPrice(Long teamId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId,teamId); + List productSkuInfos = this.list(queryWrapper); + ArrayList teamProductDiscountPriceModels = new ArrayList<>(); + for (ActivityTeamProductSkuInfo productSkuInfo : productSkuInfos) { + ProjectSkuInfo skuInfo = projectSkuCache.get(productSkuInfo.getProductId(), productSkuInfo.getProductSku()); + BigDecimal price = skuInfo.getPrice(); + BigDecimal teamPrice = productSkuInfo.getTeamPrice(); + TeamProductDiscountPriceModel priceModel = new TeamProductDiscountPriceModel(); + priceModel.setProductPrice(price); + priceModel.setTeamPrice(teamPrice); + priceModel.setDisCount(price.subtract(teamPrice).divide(price,2, RoundingMode.HALF_UP).doubleValue()); + + teamProductDiscountPriceModels.add(priceModel); + } + TeamProductDiscountPriceModel teamProductDiscountPriceModel = teamProductDiscountPriceModels.get(0); + for (TeamProductDiscountPriceModel productDiscountPriceModel : teamProductDiscountPriceModels) { + if(teamProductDiscountPriceModel.getDisCount() < productDiscountPriceModel.getDisCount()){ + teamProductDiscountPriceModel = productDiscountPriceModel; + } + } + return teamProductDiscountPriceModel; + + } + + @Override + public TeamProductStockModel getStock(Long teamId) { + List teamProductSkuInfosList = this.getActivityTeamProductSkuInfoByTeamId(teamId); + + return TeamProductStockModel.builder() + .teamStock(teamProductSkuInfosList.stream().map(ActivityTeamProductSkuInfo::getTeamStock).reduce(0L,Long::sum)) + .remainStock(teamProductSkuInfosList.stream().map(ActivityTeamProductSkuInfo::getRemainStock).reduce(0L,Long::sum)) + .build(); + } } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionHundredServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionHundredServiceImpl.java index 04ced23..3a2502d 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionHundredServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionHundredServiceImpl.java @@ -1,6 +1,8 @@ package com.muyu.marketing.service.impl; import com.muyu.marketing.service.TeamStrategyExemptionHundredService; +import org.springframework.stereotype.Service; +@Service public class TeamStrategyExemptionHundredServiceImpl implements TeamStrategyExemptionHundredService { } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionOrdinaryServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionOrdinaryServiceImpl.java index eac478e..81c3e00 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionOrdinaryServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionOrdinaryServiceImpl.java @@ -1,6 +1,8 @@ package com.muyu.marketing.service.impl; import com.muyu.marketing.service.TeamStrategyExemptionOrdinaryService; +import org.springframework.stereotype.Service; +@Service public class TeamStrategyExemptionOrdinaryServiceImpl implements TeamStrategyExemptionOrdinaryService { } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionServiceImpl.java index 14a2d50..13000de 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/service/impl/TeamStrategyExemptionServiceImpl.java @@ -1,6 +1,8 @@ package com.muyu.marketing.service.impl; import com.muyu.marketing.service.TeamStrategyExemptionService; +import org.springframework.stereotype.Service; +@Service public class TeamStrategyExemptionServiceImpl implements TeamStrategyExemptionService { }