拼团列表优化

master
‘mahaoran’ 2024-11-22 09:39:55 +08:00
parent 59e961dba0
commit 7063e0f6c6
25 changed files with 506 additions and 501 deletions

View File

@ -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;
}
}

View File

@ -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<T> {
private boolean isAsc = true;
public T domainBuild(PageDomain pageDomain){
this.pageNum=pageDomain.getPageNum();
this.pageSize=pageDomain.getPageSize();
@ -42,4 +45,14 @@ public class QueryModel<T> {
this.isAsc="asc".equals(pageDomain.getIsAsc()) ? true : false;
return (T) this;
}
public <T> Page<T> buildPage(){
Page<T> page = Page.of(this.getPageNum(), this.getPageSize());
page.setOrders(List.of(this.isAsc()
? OrderItem.asc(this.getOrderByColumn()) : OrderItem.desc(this.getOrderByColumn())));
return page;
}
}

View File

@ -36,7 +36,7 @@ public class ActivityTeamInfo extends BaseEntity {
*/
@ApiModelProperty("主键")
private Integer id;
private Long id;
/**
*
*/

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<ActivityTeamInfoListModel.ActivityTeamInfoListModelBuilder,ActivityTeamInfoListModel> 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())
);
}
}

View File

@ -19,6 +19,7 @@ public class ActivityTeamInfoListQueryModel extends QueryModel<ActivityTeamInfoL
/**
*
*/
private Integer status;
private String status;
}

View File

@ -0,0 +1,39 @@
package com.muyu.marketing.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.math.RoundingMode;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TeamProductDiscountPriceModel {
/**
*
*/
private BigDecimal productPrice;
/**
*
*/
private BigDecimal teamPrice;
/**
*
*/
private Double disCount;
public static TeamProductStockModel of(BigDecimal productPrice,BigDecimal teamPrice){
TeamProductDiscountPriceModel.builder()
.productPrice(productPrice)
.teamPrice(teamPrice)
.disCount(productPrice.subtract(teamPrice).divide(productPrice,2, RoundingMode.HALF_UP).doubleValue())
.build();
return of(productPrice, teamPrice);
}
}

View File

@ -0,0 +1,16 @@
package com.muyu.marketing.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TeamProductStockModel {
private Long teamStock;
private Long remainStock;
}

View File

@ -24,20 +24,28 @@ public class TeamInfoReqListReq extends PageDomain {
/**
*
*/
private Integer status;
private String status;
public ActivityTeamInfoListQueryModel activityTeamInfoListModel (){
ActivityTeamInfoListQueryModel build = ActivityTeamInfoListQueryModel.builder()
.keyWord(this.keyWord)
.status(this.status)
.build();
build.domainBuild(this);
public ActivityTeamInfoListQueryModel buildQueryModel() {
return ActivityTeamInfoListQueryModel.builder()
.keyWord(this.keyWord)
.status(this.status)
.build()
.domainBuild(this);
}
// public ActivityTeamInfoListQueryModel activityTeamInfoListModel (){
// ActivityTeamInfoListQueryModel build = ActivityTeamInfoListQueryModel.builder()
// .keyWord(this.keyWord)
// .status(this.status)
// .build();
// build.domainBuild(this);
// return ActivityTeamInfoListQueryModel.builder()
// .keyWord(this.keyWord)
// .status(this.status)
// .build()
// .domainBuild(this);
//
// }
}

View File

@ -2,11 +2,16 @@ package com.muyu.marketing.domain.resp;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ -16,7 +21,7 @@ public class TeamInfoListResp {
/**
* Id
*/
private String id;
private Long id;
/**
*
*/
@ -28,34 +33,53 @@ public class TeamInfoListResp {
/**
*
*/
private String productPrice;
private BigDecimal productPrice;
/**
*
*/
private String teamPrice;
private BigDecimal teamPrice;
/**
*
*/
private String openTeamNumber;
private Long openTeamNumber;
/**
*
*/
private String addTeamBumber;
private Long addTeamBumber;
/**
*
*/
private String teamStock;
private Long teamStock;
/**
*
*/
private String remainStock;
private Long remainStock;
/**
*
*/
private String endTime;
private Date endTime;
/**
*
*/
private String status;
private Long attendNumber;
public static TeamInfoListResp listModelBuild(ActivityTeamInfoListModel activityTeamInfoListModel){
return TeamInfoListResp.builder()
.id(activityTeamInfoListModel.getId())
.name(activityTeamInfoListModel.getName())
.openTeamNumber(activityTeamInfoListModel.getOpenTeamNumber())
.addTeamBumber(activityTeamInfoListModel.getAddTeamNumber())
.endTime(activityTeamInfoListModel.getEndTime())
.teamPrice(activityTeamInfoListModel.getTeamPrice())
.productimage(activityTeamInfoListModel.getProductImage())
.productPrice(activityTeamInfoListModel.getProductPrice())
.remainStock(activityTeamInfoListModel.getRemainStock())
.status(activityTeamInfoListModel.getStatus())
.teamStock(activityTeamInfoListModel.getTeamStock())
.attendNumber(activityTeamInfoListModel.getAttendNumber())
.build();
}
}

View File

@ -16,6 +16,10 @@
</description>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-product-cache</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>

View File

@ -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<TableDataInfo<TeamInfoListResp>> list(@RequestBody TeamInfoReqListReq teamInfoReqListReq){
TableDataInfo<ActivityTeamInfoListModel> tableDataInfo = activityTeamInfoService.query(teamInfoReqListReq.buildQueryModel());
List<TeamInfoListResp> respList = tableDataInfo.getRows().stream().map(TeamInfoListResp::listModelBuild).toList();
return Result.success(
new TableDataInfo<>(){{
setRows(respList);
setTotal(tableDataInfo.getTotal());
}}
);
}
}

View File

@ -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<ActivityTeamInfo> {
}

View File

@ -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<ActivityTeamOpenInfo> {
}

View File

@ -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<ActivityTeamProductSkuInfo> {
}

View File

@ -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<ActivityTeamOpenInfo> {
/**
*
* @param teamId
* @return
*/
public Long getTeamOpenNumberByTeamIdAndType(Long teamId);
/**
*
* @param teamId
* @return
*/
public Long getTeamInNumberByTeamIdAndType(Long teamId);
}

View File

@ -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<ActivityTeamInfo> {
public TableDataInfo<ActivityTeamInfo> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel);
/**
*
* @param activityTeamInfoListQueryModel
* @return
*/
public TableDataInfo<ActivityTeamInfoListModel> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel);
}

View File

@ -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<ActivityTeamProductSkuInfo>{
public default List<ActivityTeamProductSkuInfo> getActivityTeamProductSkuInfoByTeamId(Long teamId){
LambdaQueryWrapper<ActivityTeamProductSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId,teamId);
return this.list(queryWrapper);
}
public TeamProductDiscountPriceModel getDiscountPrice(Long teamId);
public TeamProductStockModel getStock(Long teamId);
}

View File

@ -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<ActivityTeamOpenInfoMapper, ActivityTeamOpenInfo> implements ActivityOpenInfoService {
@Override
public Long getTeamOpenNumberByTeamIdAndType(Long teamId) {
LambdaQueryWrapper<ActivityTeamOpenInfo> 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<ActivityTeamOpenInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActivityTeamOpenInfo::getTeamId,teamId);
queryWrapper.eq(ActivityTeamOpenInfo::getTeamType,TeamOpenTypeEnum.IN_TEAM.Code());
return this.count(queryWrapper);
}
}

View File

@ -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<ActivityInfoMapper,ActivityTeamInfo> implements ActivityTeamInfoService {
public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMapper,ActivityTeamInfo> implements ActivityTeamInfoService {
public TableDataInfo<ActivityTeamInfo> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) {
Page<ActivityTeamInfo> page = new Page<>();
page.setCurrent(activityTeamInfoListQueryModel.getPageNum());
page.setSize(activityTeamInfoListQueryModel.getPageSize());
activityTeamInfoListQueryModel.getOrderByColumn();
activityTeamInfoListQueryModel.isAsc();
page.setOrders(Arrays.asList(new OrderItem()));
Page<ActivityTeamInfo> activityTeamInfoPage = this.page(new Page<ActivityTeamInfo>(), new LambdaQueryWrapper<ActivityTeamInfo>());
@Autowired
private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService;
ArrayList<ActivityTeamInfo> 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<ActivityTeamInfo> tableDataInfo = new TableDataInfo<>();
@Override
public TableDataInfo<ActivityTeamInfoListModel> query (ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) {
LambdaQueryWrapper<ActivityTeamInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getKeyWord()),ActivityTeamInfo::getName , activityTeamInfoListQueryModel.getKeyWord());
queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getStatus()),ActivityTeamInfo::getStatus , activityTeamInfoListQueryModel.getStatus());
Page<ActivityTeamInfo> activityTeamInfoPage = this.page(activityTeamInfoListQueryModel.buildPage(),queryWrapper);
List<ActivityTeamInfo> activityTeamInfoList = activityTeamInfoPage.getRecords();
List<ActivityTeamInfoListModel> 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<ActivityTeamInfoListModel> tableDataInfo = new TableDataInfo<>();
tableDataInfo.setTotal(activityTeamInfoPage.getTotal());
tableDataInfo.setRows(activityTeamInfoPage.getRecords());
tableDataInfo.setRows(activityTeamInfoListModels);
return tableDataInfo;

View File

@ -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<ActivityTeamProductSkuInfoMapper,ActivityTeamProductSkuInfo> implements ActivityTeamProductSkuInfoService {
@Autowired
private ProjectSkuCache projectSkuCache;
@Override
public TeamProductDiscountPriceModel getDiscountPrice(Long teamId) {
LambdaQueryWrapper<ActivityTeamProductSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId,teamId);
List<ActivityTeamProductSkuInfo> productSkuInfos = this.list(queryWrapper);
ArrayList<TeamProductDiscountPriceModel> 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<ActivityTeamProductSkuInfo> 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();
}
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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 {
}