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 1fa54ca..76ee4ac 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 @@ -7,9 +7,18 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; +import java.util.List; +import java.util.function.Supplier; +import ch.qos.logback.core.joran.spi.RuleStore; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel; +import com.muyu.marketing.domain.req.ActivityTeamInfoSaveReq; +import com.muyu.marketing.domain.resp.RuleInfo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -18,6 +27,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; /** * 商品拼团信息 @@ -28,13 +38,14 @@ import org.hibernate.validator.constraints.Length; @NoArgsConstructor @AllArgsConstructor @TableName("activity_team_info") -@ApiModel(value = "ProjectInfo", description = "商品拼团信息") +@ApiModel(value = "ProjectInfo", description = "拼团活动信息") public class ActivityTeamInfo extends BaseEntity { /** * 主键 */ + @TableId(value = "id",type = IdType.AUTO) @ApiModelProperty("主键") private Long id; /** @@ -82,6 +93,8 @@ public class ActivityTeamInfo extends BaseEntity { */ @ApiModelProperty("活动结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date endTime; /** * 活动排序 @@ -116,13 +129,8 @@ public class ActivityTeamInfo extends BaseEntity { @ApiModelProperty("策略ID") private Long strategyId; - /** - * 备注 - */ - @ApiModelProperty("备注") - private String remark; /** * 创建人 */ @@ -149,5 +157,28 @@ public class ActivityTeamInfo extends BaseEntity { private Date updateTime; + /** + * 添加构造器 + */ + public static ActivityTeamInfo saveBuildModel(ActivityTeamInfoSaveReq activityTeamInfoAddModel, Supplier createBy){ + return ActivityTeamInfo.builder() + .name(activityTeamInfoAddModel.getName()) + .productId(activityTeamInfoAddModel.getProductId()) + .productImage(activityTeamInfoAddModel.getProductImage()) + .introduction(activityTeamInfoAddModel.getIntroduction()) + .unit(activityTeamInfoAddModel.getUnit()) + .imageList(activityTeamInfoAddModel.getImageList() ) + .endTime(activityTeamInfoAddModel.getEndTime()) + .sort(activityTeamInfoAddModel.getSort()) + .content(activityTeamInfoAddModel.getContent()) + .strategyType(activityTeamInfoAddModel.getStrategyType()) + .strategyId(activityTeamInfoAddModel.getStrategyId()) + .content(activityTeamInfoAddModel.getContent()) + .status(activityTeamInfoAddModel.getStatus()) + .createBy(createBy.get()) + .createTime(new Date()) + .build(); + } + } 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 3fb44a2..c1f94be 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 @@ -8,11 +8,19 @@ import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; +import java.util.function.Supplier; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel; +import com.muyu.marketing.domain.req.ActivityTeamInfoSaveReq; +import com.muyu.marketing.domain.resp.RuleInfo; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; import org.hibernate.validator.constraints.Length; /** @@ -22,13 +30,16 @@ import org.hibernate.validator.constraints.Length; @Data @AllArgsConstructor @NoArgsConstructor -@Builder -public class ActivityTeamProductSkuInfo implements Serializable { +@SuperBuilder +public class ActivityTeamProductSkuInfo { /** * 主键 */ + + + @TableId(value = "id",type = IdType.AUTO) @ApiModelProperty("主键") private Long id; /** @@ -103,5 +114,16 @@ public class ActivityTeamProductSkuInfo implements Serializable { private String remark; +// public static ActivityTeamProductSkuInfo saveBuildModelSkuInfo(ActivityTeamInfoSaveReq activityTeamInfoSaveReq, RuleInfo ruleInfo,Supplier createBy){ +// return ActivityTeamProductSkuInfo.builder() +// .teamId(activityTeamInfoSaveReq.getId()) +// .productSku(ruleInfo.getRuleSku()) +// .teamStock(ruleInfo.getTeamStock()) +// .teamPrice(ruleInfo.getTeamPrice()) +// .productId(activityTeamInfoSaveReq.getProductId()) +// .createTime(new Date()) +// .createBy(createBy) +// .build(); +// } } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/TeamInfo.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/TeamInfo.java new file mode 100644 index 0000000..519c0a3 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/TeamInfo.java @@ -0,0 +1,65 @@ +package com.muyu.marketing.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@TableName("team_info") +@ApiModel(value = "TeamInfo", description = "拼团信息表") +public class TeamInfo { + /** + * 拼团活动Id + */ + private Long id; + /** + * 拼团名称 + */ + private String name; + /** + * 拼团商品图片 + */ + private String productimage; + /** + * 商品价格 + */ + private BigDecimal productPrice; + /** + * 拼团价格 + */ + private BigDecimal teamPrice; + /** + * 拼团人数 + */ + private Long openTeamNumber; + /** + * 开团人数 + */ + private Long addTeamBumber; + /** + * 参团人数 + */ + private Long teamStock; + /** + * 剩余库存 + */ + private Long remainStock; + /** + * 团购结束时间 + */ + private Date endTime; + /** + * 团购状态 + */ + private String status; + + private Long attendNumber; +} diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoAddModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoAddModel.java new file mode 100644 index 0000000..ee5a799 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoAddModel.java @@ -0,0 +1,74 @@ +package com.muyu.marketing.domain.model; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.web.domain.BaseEntity; +import com.muyu.marketing.domain.resp.RuleInfo; +import io.swagger.annotations.ApiModel; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "ActivityTeamInfo", description = "拼团活动表") +public class ActivityTeamInfoAddModel extends BaseEntity { + /** + * 商品ID + */ + private Long productId; + /** + * 商品图片 + */ + private String productImage; + /** + * 活动名称 + */ + private String name; + /** + * 活动简介 + */ + private String intro; + /** + * 商品单位 + */ + private String unit; + /** + * 商品的轮播图 + */ + private List introduction; + /** + * 活动时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date endTime; + /** + * 策略ID + */ + private Long strategyId; + /** + * 策略类型 + */ + private String strategyType; + /** + * 商品规格List + */ + private List ruleInfo ; + /** + * 排序 + */ + private Integer sort; + /** + * 详情 + */ + private String content; + + + +} 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 e154df5..04ee806 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 @@ -8,7 +8,6 @@ import lombok.NoArgsConstructor; import java.math.BigDecimal; import java.util.Date; -import java.util.function.Consumer; import java.util.function.Function; @Data @@ -70,15 +69,8 @@ public class ActivityTeamInfoListModel { 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( diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductDiscountPriceModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductDiscountPriceModel.java index 66e9f6f..915d36a 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductDiscountPriceModel.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductDiscountPriceModel.java @@ -27,13 +27,13 @@ public class TeamProductDiscountPriceModel { private Double disCount; - public static TeamProductStockModel of(BigDecimal productPrice,BigDecimal teamPrice){ - TeamProductDiscountPriceModel.builder() + public static TeamProductDiscountPriceModel of(BigDecimal productPrice,BigDecimal teamPrice){ + return TeamProductDiscountPriceModel.builder() .productPrice(productPrice) .teamPrice(teamPrice) .disCount(productPrice.subtract(teamPrice).divide(productPrice,2, RoundingMode.HALF_UP).doubleValue()) .build(); - return of(productPrice, teamPrice); + } } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductStockModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductStockModel.java index 7cb05a3..3bf9a87 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductStockModel.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/TeamProductStockModel.java @@ -12,5 +12,6 @@ import lombok.NoArgsConstructor; public class TeamProductStockModel { private Long teamStock; private Long remainStock; + private Double discount; } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/req/ActivityTeamInfoSaveReq.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/req/ActivityTeamInfoSaveReq.java new file mode 100644 index 0000000..b8bf448 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/req/ActivityTeamInfoSaveReq.java @@ -0,0 +1,88 @@ +package com.muyu.marketing.domain.req; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.marketing.domain.resp.RuleInfo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@ApiModel(value = "AttributeInfo", description = "商品属性") +public class ActivityTeamInfoSaveReq { + + + @TableId(value = "id",type = IdType.AUTO) + @ApiModelProperty("主键") + private Long id; + /** + * 商品ID + */ + private Long productId; + /** + * 商品图片 + */ + private String productImage; + /** + * 活动名称 + */ + private String name; + /** + * 活动简介 + */ + private String introduction; + /** + * 商品单位 + */ + private String unit; + /** + * 商品的轮播图 + */ + private String imageList; + /** + * 活动时间 + */ + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date endTime; + /** + * 策略ID + */ + private Long strategyId; + /** + * 策略类型 + */ + private String strategyType; + /** + * 商品规格List + */ + private List ruleInfo ; + /** + * 排序 + */ + private Integer sort; + /** + * 详情 + */ + private String content; + + private String status; + + + +} diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/RuleInfo.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/RuleInfo.java new file mode 100644 index 0000000..dfd8a06 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/RuleInfo.java @@ -0,0 +1,41 @@ +package com.muyu.marketing.domain.resp; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName(value = "activity_team_product_sku_info") +public class RuleInfo { + + + /** + * 主键 + */ + + + @TableId(value = "id",type = IdType.AUTO) + @ApiModelProperty("主键") + private Long id; + /** + *规格Sku + */ + private String sku; + /** + *拼团库存 + */ + private Long stock; + /** + * 拼团价格 + */ + private BigDecimal price; + +} diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/TeamInfoListResp.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/TeamInfoListResp.java index 50126b0..c2da945 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/TeamInfoListResp.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/TeamInfoListResp.java @@ -1,6 +1,7 @@ package com.muyu.marketing.domain.resp; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.muyu.marketing.domain.ActivityTeamInfo; import com.muyu.marketing.domain.model.ActivityTeamInfoListModel; import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel; @@ -8,6 +9,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.util.Date; @@ -57,14 +59,18 @@ public class TeamInfoListResp { /** * 团购结束时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date endTime; /** * 团购状态 */ private String status; + private Long attendNumber; + public static TeamInfoListResp listModelBuild(ActivityTeamInfoListModel activityTeamInfoListModel){ return TeamInfoListResp.builder() .id(activityTeamInfoListModel.getId()) 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 5bacc0f..0dc35f2 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 @@ -3,10 +3,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.req.ActivityTeamInfoSaveReq; import com.muyu.marketing.domain.resp.TeamInfoListResp; import com.muyu.marketing.service.ActivityTeamInfoService; +import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -14,12 +15,17 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; - +@Api(tags = "商品拼团信息") @RestController @RequestMapping("/team") public class ActivityTeamController { @Autowired private ActivityTeamInfoService activityTeamInfoService; + /** + * 商品拼团列表 + * @param teamInfoReqListReq + * @return + */ @PostMapping("list") public Result> list(@RequestBody TeamInfoReqListReq teamInfoReqListReq){ TableDataInfo tableDataInfo = activityTeamInfoService.query(teamInfoReqListReq.buildQueryModel()); @@ -32,4 +38,15 @@ public class ActivityTeamController { ); } + + /** + * 商品拼团添加 + * @param teamInfoSaveReq + * @return + */ + @PostMapping("add") + public Result add(@RequestBody ActivityTeamInfoSaveReq teamInfoSaveReq){ + Result addActivityTeamInfo = activityTeamInfoService.add(teamInfoSaveReq); + return addActivityTeamInfo; + } } 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 75d686c..fc00a83 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 @@ -1,19 +1,29 @@ package com.muyu.marketing.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.common.core.domain.Result; 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.req.ActivityTeamInfoSaveReq; import java.util.List; public interface ActivityTeamInfoService extends IService { /** - * 拼团订单列表 + * 拼团活动列表 * @param activityTeamInfoListQueryModel * @return */ public TableDataInfo query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel); + + /** + * 拼团活动添加 + * @param teamInfoSaveReq + * @return + */ + Result add(ActivityTeamInfoSaveReq teamInfoSaveReq); + } 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 e758f1e..dc16fdb 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 @@ -18,5 +18,6 @@ public interface ActivityTeamProductSkuInfoService extends IService implements ActivityTeamInfoService { @@ -35,6 +35,11 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl query (ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -47,15 +52,15 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl { Long openNumberByTeamIdAndType = activityOpenInfoService.getTeamOpenNumberByTeamIdAndType(activityTeamInfo.getId()); Long inNumberByTeamIdAndType = activityOpenInfoService.getTeamInNumberByTeamIdAndType(activityTeamInfo.getId()); - TeamProductDiscountPriceModel discountPrice = activityTeamProductSkuInfoService.getDiscountPrice(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()) + .teamPrice(BigDecimal.valueOf(1)) + .productPrice(BigDecimal.valueOf(1)) .teamStock(teamProductStockModel.getTeamStock()) .remainStock(teamProductStockModel.getRemainStock()) .build(); @@ -68,4 +73,30 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl ruleInfoList = teamInfoSaveReq.getRuleInfo(); + List activityTeamProductSkuInfos = ruleInfoList.stream().map(ruleInfo -> { + ActivityTeamProductSkuInfo productSkuInfo = ActivityTeamProductSkuInfo.builder() + .teamId(activityTeamInfo.getId()) + .productSku(ruleInfo.getSku()) + .teamStock(ruleInfo.getStock()) + .teamPrice(ruleInfo.getPrice()) + .productId(teamInfoSaveReq.getProductId()) + .createTime(new Date()) + .build(); + return productSkuInfo; + }).toList(); + activityTeamProductSkuInfoService.saveBatch(activityTeamProductSkuInfos); + return Result.success(0,"添加成功"); + } } 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 f994919..479abac 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 @@ -2,22 +2,23 @@ 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.exception.ServiceException; 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; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; + import java.util.List; +import java.util.Optional; + + @Service public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl implements ActivityTeamProductSkuInfoService { @@ -26,30 +27,44 @@ public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl 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()); + List teamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId); + //用stream把teamProductSkuInfoList集合里的数据转换给teamProductDiscountPriceModelArrayList + Optional min = teamProductSkuInfoList.stream() + .map(activityTeamProductSkuInfo -> { + ProjectSkuInfo projectSkuInfo = projectSkuCache.getData(Long.valueOf(activityTeamProductSkuInfo.getProductId()),activityTeamProductSkuInfo.getProductSku()); + return TeamProductDiscountPriceModel.of(projectSkuInfo.getPrice(), activityTeamProductSkuInfo.getTeamPrice()); + }).min((o1, o2) -> Double.valueOf(o1.getDisCount() * 100 - o2.getDisCount() * 100).intValue()); - teamProductDiscountPriceModels.add(priceModel); + if(min.isEmpty()){ + throw new ServiceException("团购活动下没有商品了"); } - TeamProductDiscountPriceModel teamProductDiscountPriceModel = teamProductDiscountPriceModels.get(0); - for (TeamProductDiscountPriceModel productDiscountPriceModel : teamProductDiscountPriceModels) { - if(teamProductDiscountPriceModel.getDisCount() < productDiscountPriceModel.getDisCount()){ - teamProductDiscountPriceModel = productDiscountPriceModel; - } - } - return teamProductDiscountPriceModel; + return min.get(); - } + +// 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.getData(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) { diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/resources/拼团活动 b/muyu-modules/muyu-marketing/marketing-server/src/main/resources/拼团活动 new file mode 100644 index 0000000..a007827 --- /dev/null +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/resources/拼团活动 @@ -0,0 +1,21 @@ +{ + "商品id":"Long", + "商品图片":"String", + "拼团活动名称":"String", + "拼团活动简介":"String", + "商品单位":"String", + "商品轮播图":List, + "活动时间":"Date", + "拼团时效":"Integer", + "拼团人数":"Integer", + "购买总量限制":"Integer", + "单词总量限制":"Integer", + "补齐人数":"Integer", + "商品规格id":[ + "商品Sku":"属性名称" + + ], + "排序":"Integer", + "详情":"Text" + +}