第九天
parent
45df13936b
commit
91ea6b0498
|
@ -11,10 +11,12 @@ public interface Cache <K, V> extends DecorationKey<K> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过Key获取value值
|
* 通过Key获取value值
|
||||||
|
*
|
||||||
* @param key 键
|
* @param key 键
|
||||||
|
* @param productSku
|
||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
public V get(K key);
|
public V get(K key, String productSku);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存添加/修改
|
* 缓存添加/修改
|
||||||
|
|
|
@ -28,11 +28,13 @@ public abstract class CacheAbs<K, V> implements Cache<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过Key获取value值
|
* 通过Key获取value值
|
||||||
|
*
|
||||||
* @param key 键
|
* @param key 键
|
||||||
|
* @param productSku
|
||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public V get (K key) {
|
public V get (K key, String productSku) {
|
||||||
V value = redisService.getCacheObject(encode(key));
|
V value = redisService.getCacheObject(encode(key));
|
||||||
if (value == null){
|
if (value == null){
|
||||||
value = getData(key);
|
value = getData(key);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.common.core.enums.market.team;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参团类型枚举类
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
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.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class QueryModel<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引
|
||||||
|
*/
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数
|
||||||
|
*/
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序列
|
||||||
|
*/
|
||||||
|
private String orderByColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序的方向desc或者asc
|
||||||
|
*/
|
||||||
|
private boolean isAsc = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询分页对象
|
||||||
|
* @param pageDomain 分页查询
|
||||||
|
* @return 模型分页对象
|
||||||
|
*/
|
||||||
|
public T domainBuild(PageDomain pageDomain) {
|
||||||
|
this.pageNum = pageDomain.getPageNum();
|
||||||
|
this.pageSize = pageDomain.getPageSize();
|
||||||
|
this.orderByColumn = pageDomain.getOrderByColumn();
|
||||||
|
this.isAsc = "asc".equals(pageDomain.getIsAsc())?true:false;
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询分页对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public <I> Page<I> buildPage(){
|
||||||
|
Page<I> page = Page.of(this.getPageNum(), this.getPageSize());
|
||||||
|
page.setOrders(Arrays.asList(this.isAsc()
|
||||||
|
?OrderItem.asc(this.getOrderByColumn())
|
||||||
|
: OrderItem.desc(this.getOrderByColumn())));
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,19 @@
|
||||||
package com.muyu.common.core.web.page;
|
package com.muyu.common.core.web.page;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
|
||||||
public class PageDomain {
|
public class PageDomain {
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引
|
* 当前记录起始索引
|
||||||
|
@ -40,29 +47,6 @@ public class PageDomain {
|
||||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageNum () {
|
|
||||||
return pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageNum (Integer pageNum) {
|
|
||||||
this.pageNum = pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageSize () {
|
|
||||||
return pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageSize (Integer pageSize) {
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrderByColumn () {
|
|
||||||
return orderByColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrderByColumn (String orderByColumn) {
|
|
||||||
this.orderByColumn = orderByColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsAsc () {
|
public String getIsAsc () {
|
||||||
return isAsc;
|
return isAsc;
|
||||||
|
@ -87,7 +71,4 @@ public class PageDomain {
|
||||||
return reasonable;
|
return reasonable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReasonable (Boolean reasonable) {
|
|
||||||
this.reasonable = reasonable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.security.config.mybatisplus;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加分页插件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
||||||
|
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,6 +35,21 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-common-core</artifactId>
|
<artifactId>muyu-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-annotation</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -14,6 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.xmlbeans.impl.xb.xsdschema.AttributeGroup;
|
import org.apache.xmlbeans.impl.xb.xsdschema.AttributeGroup;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,44 +28,63 @@ import java.util.function.Function;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@TableName("activity_team_info")
|
@TableName("activity_team_info")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "activity_team_info", description = "商品拼团信息")
|
@ApiModel(value = "activity_team_info", description = "商品拼团信息")
|
||||||
public class ActivityTeamInfo extends BaseEntity {
|
public class ActivityTeamInfo extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 拼团名称
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
private BigInteger productId;
|
private BigInteger productId;
|
||||||
private String productName;
|
|
||||||
|
/**
|
||||||
|
* 商品活动图
|
||||||
|
*/
|
||||||
private String productImage;
|
private String productImage;
|
||||||
|
/**
|
||||||
|
* 活动简介
|
||||||
|
*/
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
private String unit;
|
private String unit;
|
||||||
|
/**
|
||||||
|
* 轮播图
|
||||||
|
*/
|
||||||
private String imageList;
|
private String imageList;
|
||||||
private String endTime;
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 活动排序
|
||||||
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
/**
|
||||||
|
* 活动详情
|
||||||
|
*/
|
||||||
private String content;
|
private String content;
|
||||||
|
/**
|
||||||
|
* 活动状态
|
||||||
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
/**
|
||||||
|
* 策略类型
|
||||||
|
*/
|
||||||
private String strategyType;
|
private String strategyType;
|
||||||
|
/**
|
||||||
|
* 策略ID
|
||||||
|
*/
|
||||||
private BigInteger strategyId;
|
private BigInteger strategyId;
|
||||||
private String remark;
|
|
||||||
private String createBy;
|
|
||||||
private Date createTime;
|
|
||||||
private String updateBy;
|
|
||||||
private Date updateTime;
|
|
||||||
private Integer pageNum=1;
|
|
||||||
private Integer pageSize=3;
|
|
||||||
|
|
||||||
|
|
||||||
public static ActivityTeamInfo queryBuild(ActivityTeamInfoReq activityTeamInfoReq) {
|
|
||||||
return ActivityTeamInfo.builder()
|
|
||||||
.name(activityTeamInfoReq.getName())
|
|
||||||
.status(activityTeamInfoReq.getStatus())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ActivityTeamInfo groupFunBuild (ActivityTeamInfo activityTeamInfo, Function<Long, List<ActivityTeamInfo>> function) {
|
|
||||||
return ActivityTeamInfo.builder()
|
|
||||||
.id(activityTeamInfo.getId())
|
|
||||||
.name(activityTeamInfo.getName())
|
|
||||||
.status(activityTeamInfo.status)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.muyu.marketing.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品拼团规格信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("activity_team_open_info")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "activity_team_open_info", description = "团购活动执行表")
|
||||||
|
public class ActivityTeamOpenInfo extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 团购活动ID
|
||||||
|
*/
|
||||||
|
private Long teamId;
|
||||||
|
/**
|
||||||
|
* 团购类型
|
||||||
|
*/
|
||||||
|
private String teamType;
|
||||||
|
/**
|
||||||
|
* 团购策略
|
||||||
|
*/
|
||||||
|
private Long teamStrategyId;
|
||||||
|
/**
|
||||||
|
* 参团类型
|
||||||
|
*/
|
||||||
|
private String executiveType;
|
||||||
|
/**
|
||||||
|
* 结束团购时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
private Long productId;
|
||||||
|
/**
|
||||||
|
* 商品名称
|
||||||
|
*/
|
||||||
|
private String productName;
|
||||||
|
/**
|
||||||
|
* 商品规格
|
||||||
|
*/
|
||||||
|
private String productSku;
|
||||||
|
/**
|
||||||
|
* 开团标识
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
/**
|
||||||
|
* 订单ID
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 开团状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.muyu.marketing.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品拼团规格信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("activity_team_product_sku_info")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "activity_team_product_sku_info", description = "商品拼团规格信息表")
|
||||||
|
public class ActivityTeamProductSkuInfo extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 活动ID
|
||||||
|
*/
|
||||||
|
private Long teamId;
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
private Long productId;
|
||||||
|
/**
|
||||||
|
* 商品SKU
|
||||||
|
*/
|
||||||
|
private String productSku;
|
||||||
|
/**
|
||||||
|
* 拼团库存
|
||||||
|
*/
|
||||||
|
private Long teamStock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剩余库存
|
||||||
|
*/
|
||||||
|
private Long remainStock;
|
||||||
|
/**
|
||||||
|
* 拼团价格
|
||||||
|
*/
|
||||||
|
private BigDecimal teamPrice;
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.muyu.marketing.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.marketing.domain.ActivityTeamInfo;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
//@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class ActivityTeamInfoAddModel extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 拼团名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 商品图片
|
||||||
|
*/
|
||||||
|
private String productImage;
|
||||||
|
/**
|
||||||
|
* 轮播图片
|
||||||
|
*/
|
||||||
|
private String imageList;
|
||||||
|
/**
|
||||||
|
* 拼团库存
|
||||||
|
*/
|
||||||
|
private Long teamStock;
|
||||||
|
/**
|
||||||
|
* 商品价格
|
||||||
|
*/
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团购优惠价格
|
||||||
|
*/
|
||||||
|
private BigDecimal teamPrice;
|
||||||
|
/**
|
||||||
|
* 拼团人数
|
||||||
|
*/
|
||||||
|
private Long attendTeamNumber;
|
||||||
|
/**
|
||||||
|
* 参团人数
|
||||||
|
*/
|
||||||
|
private Long addTeamNumber;
|
||||||
|
/**
|
||||||
|
* 开团人数
|
||||||
|
*/
|
||||||
|
private Long openTeamNumber;
|
||||||
|
/**
|
||||||
|
* 拼团剩余库存
|
||||||
|
*/
|
||||||
|
private Long remainStock;
|
||||||
|
/**
|
||||||
|
* 活动状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
// public ActivityTeamInfoAddModel AddBuild(){
|
||||||
|
// return ActivityTeamInfoAddModel.builder()
|
||||||
|
// .name(this.name)
|
||||||
|
// .productImage(this.getProductImage())
|
||||||
|
// .imageList(this.getImageList())
|
||||||
|
// .teamStock(this.getTeamStock())
|
||||||
|
// .productPrice(this.getProductPrice())
|
||||||
|
// .teamPrice(this.getTeamPrice())
|
||||||
|
// .attendTeamNumber(this.getAttendTeamNumber())
|
||||||
|
// .addTeamNumber(this.getAddTeamNumber())
|
||||||
|
// .openTeamNumber(this.getOpenTeamNumber())
|
||||||
|
// .remainStock(this.getRemainStock())
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团购活动列表查询结果模型
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class ActivityTeamInfoListModel {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 拼团名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 参团人数
|
||||||
|
*/
|
||||||
|
private Long addTeamNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开团人数
|
||||||
|
*/
|
||||||
|
private Long openTeamNumber;
|
||||||
|
/**
|
||||||
|
* 拼团人数
|
||||||
|
*/
|
||||||
|
private Long attendTeamNumber;
|
||||||
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
private String productImage;
|
||||||
|
/**
|
||||||
|
* 拼团价格
|
||||||
|
*/
|
||||||
|
private BigDecimal teamPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品价格
|
||||||
|
*/
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
/**
|
||||||
|
* 团购库存
|
||||||
|
*/
|
||||||
|
private Long teamStock;
|
||||||
|
/**
|
||||||
|
* 总库存
|
||||||
|
*/
|
||||||
|
private Long totalStock;
|
||||||
|
/**
|
||||||
|
* 剩余库存
|
||||||
|
*/
|
||||||
|
private Long RemainStock;
|
||||||
|
/**
|
||||||
|
* 活动状态
|
||||||
|
*/
|
||||||
|
private String Status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.marketing.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.model.QueryModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class ActivityTeamInfoListQueryModel extends QueryModel<ActivityTeamInfoListQueryModel> {
|
||||||
|
/**
|
||||||
|
* 搜索关键词
|
||||||
|
*/
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private String states;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.muyu.marketing.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团购商品优惠券模型
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class TeamProductDisCountPriceModel {
|
||||||
|
/**
|
||||||
|
* 商品价格
|
||||||
|
*/
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
/**
|
||||||
|
* 团购优惠价格
|
||||||
|
*/
|
||||||
|
private BigDecimal teamPrice;
|
||||||
|
/**
|
||||||
|
* 优惠力度
|
||||||
|
*/
|
||||||
|
private BigDecimal discount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过商品价格和团购价格计算出优惠力度
|
||||||
|
* @param productPrice 商品价格
|
||||||
|
* @param teamPrice 团购价格
|
||||||
|
* @return 优惠力度
|
||||||
|
*/
|
||||||
|
public static TeamProductDisCountPriceModel of(BigDecimal productPrice, BigDecimal teamPrice) {
|
||||||
|
return TeamProductDisCountPriceModel.builder()
|
||||||
|
.productPrice(productPrice)
|
||||||
|
.teamPrice(teamPrice)
|
||||||
|
.discount(
|
||||||
|
BigDecimal.valueOf(productPrice.subtract(teamPrice).divide(productPrice, 2, BigDecimal.ROUND_HALF_UP).doubleValue())
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.marketing.domain.model;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团购商品库存模型
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class TeamProductStockModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团库存
|
||||||
|
*/
|
||||||
|
private Long teamStock;
|
||||||
|
/**
|
||||||
|
* 拼团剩余库存
|
||||||
|
*/
|
||||||
|
private Long remainStock;
|
||||||
|
|
||||||
|
}
|
|
@ -1,26 +1,40 @@
|
||||||
package com.muyu.marketing.domain.req;
|
package com.muyu.marketing.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.page.PageDomain;
|
||||||
import com.muyu.marketing.domain.ActivityTeamInfo;
|
import com.muyu.marketing.domain.ActivityTeamInfo;
|
||||||
|
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ActivityTeamInfoReq extends ActivityTeamInfo {
|
@Builder
|
||||||
private static final long serialVersionUID = 1L;
|
public class ActivityTeamInfoReq extends PageDomain {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组名称
|
* 搜索关键词
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(name = "组名称", value = "组名称")
|
private String keyWord;
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(name = "状态", value = "状态")
|
|
||||||
private String states;
|
private String states;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过当前对象重构查询模型
|
||||||
|
* @return 业务查询模型
|
||||||
|
*/
|
||||||
|
public ActivityTeamInfoListQueryModel buildQueryModel(){
|
||||||
|
return ActivityTeamInfoListQueryModel.builder()
|
||||||
|
.keyWord(this.keyWord)
|
||||||
|
.states(this.states)
|
||||||
|
.build()
|
||||||
|
.domainBuild(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.muyu.marketing.domain.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品拼团列表信息响应
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class TeamInfoListResp {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 拼团名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 参团人数
|
||||||
|
*/
|
||||||
|
private Long addTeamNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开团人数
|
||||||
|
*/
|
||||||
|
private Long openTeamNumber;
|
||||||
|
/**
|
||||||
|
* 拼团人数
|
||||||
|
*/
|
||||||
|
private Long attendTeamNumber;
|
||||||
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
private String productImage;
|
||||||
|
/**
|
||||||
|
* 拼团价格
|
||||||
|
*/
|
||||||
|
private BigDecimal teamPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品价格
|
||||||
|
*/
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
/**
|
||||||
|
* 总库存
|
||||||
|
*/
|
||||||
|
private Long totalStock;
|
||||||
|
/**
|
||||||
|
* 团购库存
|
||||||
|
*/
|
||||||
|
private Long teamStock;
|
||||||
|
/**
|
||||||
|
* 剩余库存
|
||||||
|
*/
|
||||||
|
private Long RemainStock;
|
||||||
|
/**
|
||||||
|
* 活动状态
|
||||||
|
*/
|
||||||
|
private String Status;
|
||||||
|
|
||||||
|
}
|
|
@ -79,20 +79,17 @@
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.dtflys.forest</groupId>
|
|
||||||
<artifactId>forest-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>marketing-common</artifactId>
|
<artifactId>marketing-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-product-cache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,12 @@ package com.muyu.marketing;
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统模块
|
* 团购模块
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
//@MapperScan("com.muyu.marketing.mapper")
|
||||||
public class MuYuMarketingApplication {
|
public class MuYuMarketingApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(MuYuMarketingApplication.class, args);
|
SpringApplication.run(MuYuMarketingApplication.class, args);
|
||||||
|
|
|
@ -1,44 +1,47 @@
|
||||||
package com.muyu.marketing.controller;
|
package com.muyu.marketing.controller;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.common.log.annotation.Log;
|
import com.muyu.common.log.annotation.Log;
|
||||||
import com.muyu.common.log.enums.BusinessType;
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.marketing.domain.ActivityTeamInfo;
|
import com.muyu.marketing.domain.ActivityTeamInfo;
|
||||||
|
import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
|
||||||
|
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
|
||||||
import com.muyu.marketing.domain.req.ActivityTeamInfoReq;
|
import com.muyu.marketing.domain.req.ActivityTeamInfoReq;
|
||||||
|
import com.muyu.marketing.domain.resp.TeamInfoListResp;
|
||||||
import com.muyu.marketing.service.ActivityTeamInfoService;
|
import com.muyu.marketing.service.ActivityTeamInfoService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.muyu.common.core.utils.PageUtils.startPage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品拼团信息 controller
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Api(tags = "商品拼团信息")
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/activityTeamInfo")
|
@RequestMapping("/activity")
|
||||||
public class ActivityTeamInfoController {
|
public class ActivityTeamInfoController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActivityTeamInfoService activityTeamInfoService;
|
private ActivityTeamInfoService activityTeamInfoService;
|
||||||
|
@PostMapping("list")
|
||||||
|
public Result<TableDataInfo<TeamInfoListResp>> list(@RequestBody ActivityTeamInfoReq activityTeamInfoReq){
|
||||||
|
activityTeamInfoService.query(activityTeamInfoReq.buildQueryModel());
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品拼团信息列表
|
* 新增属性组
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("获取商品拼团信息列表")
|
@Log(title = "属性组", businessType = BusinessType.INSERT)
|
||||||
@GetMapping("/list")
|
@PostMapping
|
||||||
public Result<TableDataInfo<ActivityTeamInfo>> list(@RequestBody ActivityTeamInfoReq activityTeamInfoReq) {
|
@ApiOperation("新增拼团")
|
||||||
return activityTeamInfoService.list(activityTeamInfoReq);
|
public Result<String> add(@RequestBody ActivityTeamInfo activityTeamInfo) {
|
||||||
|
// return toAjax(
|
||||||
|
// activityTeamInfoService.add(ActivityTeamInfoAddModel.AddBuild(activityTeamInfo))
|
||||||
|
// );
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package com.muyu.marketing.mapper;
|
package com.muyu.marketing.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.marketing.domain.ActivityTeamInfo;
|
import com.muyu.marketing.domain.ActivityTeamInfo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ActivityTeamInfoMapper {
|
public interface ActivityTeamInfoMapper extends BaseMapper<ActivityTeamInfo> {
|
||||||
List<ActivityTeamInfo> list();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.marketing.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.marketing.domain.ActivityTeamOpenInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ActivityTeamOpenInfoMapper extends BaseMapper<ActivityTeamOpenInfo> {
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.marketing.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.marketing.domain.ActivityTeamProductSkuInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ActivityTeamProductSkuInfoMapper extends BaseMapper<ActivityTeamProductSkuInfo> {
|
||||||
|
}
|
|
@ -1,19 +1,18 @@
|
||||||
package com.muyu.marketing.service;
|
package com.muyu.marketing.service;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.marketing.domain.ActivityTeamInfo;
|
import com.muyu.marketing.domain.ActivityTeamInfo;
|
||||||
|
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
|
||||||
|
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ActivityTeamInfoService {
|
public interface ActivityTeamInfoService extends IService<ActivityTeamInfo> {
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 通过查询模型团购活动表
|
||||||
* @param activityTeamInfo
|
* @param activityTeamInfoListQueryModel 团购查询模型
|
||||||
* @return
|
* @return 团购活动列表
|
||||||
*/
|
*/
|
||||||
Result list(ActivityTeamInfo activityTeamInfo);
|
public TableDataInfo<ActivityTeamInfoListModel> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.muyu.marketing.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.enums.market.team.TeamOpenTypeEnum;
|
||||||
|
import com.muyu.marketing.domain.ActivityTeamOpenInfo;
|
||||||
|
|
||||||
|
public interface ActivityTeamOpenInfoService extends IService<ActivityTeamOpenInfo> {
|
||||||
|
/**
|
||||||
|
* 根据活动id和类型获取团队人数
|
||||||
|
* @param teamId 活动id
|
||||||
|
* @param teamOpenType 开团类型
|
||||||
|
* @return 开团数量
|
||||||
|
*/
|
||||||
|
public Long getTeamOpenNumberByTeamIdAndType(Long teamId, TeamOpenTypeEnum teamOpenType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据活动id获取开团人数
|
||||||
|
* @param teamId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public default Long getTeamOpenNumberByTeamId(Long teamId) {
|
||||||
|
return getTeamOpenNumberByTeamIdAndType(teamId, TeamOpenTypeEnum.OPEN_TEAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据活动id获取参团人数
|
||||||
|
* @param teamId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public default Long getTeamInNumberByTeamId(Long teamId) {
|
||||||
|
return getTeamOpenNumberByTeamIdAndType(teamId, TeamOpenTypeEnum.IN_TEAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.marketing.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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.ActivityTeamProductSkuInfo;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
public interface ActivityTeamProductSkuInfoService extends IService<ActivityTeamProductSkuInfo> {
|
||||||
|
|
||||||
|
public default List<ActivityTeamProductSkuInfo> getActivityTeamProductSkuInfoByTeamId(Long teamId) {
|
||||||
|
LambdaQueryWrapper<ActivityTeamProductSkuInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId, teamId);
|
||||||
|
return this.list(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据拼团id获取拼团价格
|
||||||
|
*
|
||||||
|
* @param teamId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public TeamProductDisCountPriceModel getDiscountPrice(Long teamId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过活动id获取剩余库存
|
||||||
|
*
|
||||||
|
* @param teamId
|
||||||
|
* @return 库存
|
||||||
|
*/
|
||||||
|
public TeamProductStockModel getStock(Long teamId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,36 +1,82 @@
|
||||||
package com.muyu.marketing.service.impl;
|
package com.muyu.marketing.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.muyu.common.core.domain.Result;
|
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.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.marketing.domain.ActivityTeamInfo;
|
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.ActivityTeamInfoMapper;
|
import com.muyu.marketing.mapper.ActivityTeamInfoMapper;
|
||||||
import com.muyu.marketing.service.ActivityTeamInfoService;
|
import com.muyu.marketing.service.ActivityTeamInfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import com.muyu.marketing.service.ActivityTeamOpenInfoService;
|
||||||
|
import com.muyu.marketing.service.ActivityTeamProductSkuInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
public class ActivityTeamInfoServiceImpl implements ActivityTeamInfoService {
|
public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMapper, ActivityTeamInfo> implements ActivityTeamInfoService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActivityTeamInfoMapper activityTeamInfoMapper;
|
private ActivityTeamOpenInfoService activityTeamOpenInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result list(ActivityTeamInfo activityTeamInfo) {
|
public TableDataInfo<ActivityTeamInfoListModel> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) {
|
||||||
PageHelper.startPage(activityTeamInfo.getPageNum(),activityTeamInfo.getPageSize());
|
|
||||||
List<ActivityTeamInfo> list=activityTeamInfoMapper.list();
|
LambdaQueryWrapper<ActivityTeamInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getKeyWord()), ActivityTeamInfo::getName, activityTeamInfoListQueryModel.getKeyWord());
|
||||||
return Result.success(pageInfo);
|
queryWrapper.like(StringUtils.isNotEmpty(activityTeamInfoListQueryModel.getStates()), ActivityTeamInfo::getStatus, activityTeamInfoListQueryModel.getStates());
|
||||||
|
|
||||||
|
|
||||||
|
Page<ActivityTeamInfo> activityTeamInfoPage = this.page(
|
||||||
|
activityTeamInfoListQueryModel.buildPage()
|
||||||
|
, queryWrapper);
|
||||||
|
|
||||||
|
TableDataInfo<ActivityTeamInfoListModel> tableDataInfo = new TableDataInfo();
|
||||||
|
List<ActivityTeamInfo> activityTeamInfoList = activityTeamInfoPage.getRecords();
|
||||||
|
List<ActivityTeamInfoListModel> activityTeamInfoListModels = activityTeamInfoList.stream()
|
||||||
|
.map(activityTeamInfo -> {
|
||||||
|
Long addTeamNumber = activityTeamOpenInfoService.getTeamOpenNumberByTeamId(activityTeamInfo.getId());
|
||||||
|
|
||||||
|
Long openTeamNumber = activityTeamOpenInfoService.getTeamInNumberByTeamId(activityTeamInfo.getId());
|
||||||
|
|
||||||
|
TeamProductDisCountPriceModel discountPrice = activityTeamProductSkuInfoService.getDiscountPrice(activityTeamInfo.getId());
|
||||||
|
|
||||||
|
TeamProductStockModel productStockModel = activityTeamProductSkuInfoService.getStock(activityTeamInfo.getId());
|
||||||
|
|
||||||
|
return ActivityTeamInfoListModel.builder()
|
||||||
|
.id(activityTeamInfo.getId())
|
||||||
|
.name(activityTeamInfo.getName())
|
||||||
|
.addTeamNumber(addTeamNumber)
|
||||||
|
.openTeamNumber(openTeamNumber)
|
||||||
|
.attendTeamNumber(openTeamNumber+addTeamNumber)
|
||||||
|
.endTime(activityTeamInfo.getEndTime())
|
||||||
|
.productImage(activityTeamInfo.getProductImage())
|
||||||
|
.teamPrice(discountPrice.getTeamPrice())
|
||||||
|
.productPrice(discountPrice.getProductPrice())
|
||||||
|
.teamStock(productStockModel.getTeamStock())
|
||||||
|
.RemainStock(productStockModel.getRemainStock())
|
||||||
|
.Status(activityTeamInfo.getStatus())
|
||||||
|
.build();
|
||||||
|
}).toList();
|
||||||
|
tableDataInfo.setTotal(activityTeamInfoPage.getTotal());
|
||||||
|
tableDataInfo.setRows(activityTeamInfoListModels);
|
||||||
|
return tableDataInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,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.enums.market.team.TeamOpenTypeEnum;
|
||||||
|
import com.muyu.marketing.domain.ActivityTeamOpenInfo;
|
||||||
|
import com.muyu.marketing.mapper.ActivityTeamOpenInfoMapper;
|
||||||
|
import com.muyu.marketing.service.ActivityTeamOpenInfoService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ActivityTeamOpenInfoServiceImpl extends ServiceImpl<ActivityTeamOpenInfoMapper, ActivityTeamOpenInfo> implements ActivityTeamOpenInfoService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getTeamOpenNumberByTeamIdAndType(Long teamId, TeamOpenTypeEnum teamOpenType) {
|
||||||
|
LambdaQueryWrapper<ActivityTeamOpenInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(ActivityTeamOpenInfo::getTeamId, teamId);
|
||||||
|
queryWrapper.eq(ActivityTeamOpenInfo::getTeamType, teamOpenType.code());
|
||||||
|
return (long) this.count(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
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.ActivityTeamProductSkuInfoMapper;
|
||||||
|
import com.muyu.marketing.service.ActivityTeamProductSkuInfoService;
|
||||||
|
import com.muyu.product.cache.ProjectSkuCache;
|
||||||
|
import com.muyu.product.domain.ProjectSkuInfo;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.rmi.ServerException;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityTeamProductSkuInfoMapper, ActivityTeamProductSkuInfo> implements ActivityTeamProductSkuInfoService {
|
||||||
|
@Autowired
|
||||||
|
private ProjectSkuCache projectSkuCache;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public TeamProductDisCountPriceModel getDiscountPrice(Long teamId) {
|
||||||
|
List<ActivityTeamProductSkuInfo> activityTeamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
|
||||||
|
|
||||||
|
Optional<TeamProductDisCountPriceModel> disCountPriceModelOptional = activityTeamProductSkuInfoList.stream().map(
|
||||||
|
activityTeamProductSkuInfo -> {
|
||||||
|
ProjectSkuInfo projectSkuInfo = projectSkuCache.get(activityTeamProductSkuInfo.getProductId(), activityTeamProductSkuInfo.getProductSku());
|
||||||
|
|
||||||
|
return TeamProductDisCountPriceModel.of(projectSkuInfo.getPrice(), activityTeamProductSkuInfo.getTeamPrice());
|
||||||
|
}).sorted(Comparator.comparing(TeamProductDisCountPriceModel::getDiscount))
|
||||||
|
.findFirst();
|
||||||
|
if (disCountPriceModelOptional.isEmpty()) {
|
||||||
|
throw new ServerException("没有找到商品拼团信息");
|
||||||
|
}
|
||||||
|
return disCountPriceModelOptional.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeamProductStockModel getStock(Long teamId) {
|
||||||
|
List<ActivityTeamProductSkuInfo> activityTeamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
|
||||||
|
return TeamProductStockModel.builder()
|
||||||
|
.teamStock(activityTeamProductSkuInfoList.stream().mapToLong(ActivityTeamProductSkuInfo::getTeamStock).sum())
|
||||||
|
.remainStock(activityTeamProductSkuInfoList.stream().mapToLong(ActivityTeamProductSkuInfo::getRemainStock).sum())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,3 +28,8 @@ spring:
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.system.mapper: DEBUG
|
||||||
|
mybatis-plus:
|
||||||
|
mapper-locations:
|
||||||
|
- classpath*:mapper/*Mapper.xml
|
||||||
|
# 搜索指定包别名
|
||||||
|
typeAliasesPackage: com.muyu.marketing.domain
|
||||||
|
|
|
@ -3,8 +3,27 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.marketing.mapper.ActivityTeamInfoMapper">
|
<mapper namespace="com.muyu.marketing.mapper.ActivityTeamInfoMapper">
|
||||||
|
<resultMap type="com.muyu.marketing.domain.ActivityTeamInfo" id="AsAttributeGroupResult">
|
||||||
<select id="list" resultType="com.muyu.marketing.domain.ActivityTeamInfo">
|
<result property="id" column="id" />
|
||||||
select * from activity_team_info
|
<result property="name" column="name" />
|
||||||
</select>
|
<result property="productId" column="product_id" />
|
||||||
|
<result property="productImage" column="product_image" />
|
||||||
|
<result property="introduction" column="introduction" />
|
||||||
|
<result property="unit" column="unit" />
|
||||||
|
<result property="imageList" column="image_list" />
|
||||||
|
<result property="endTime" column="end_time" />
|
||||||
|
<result property="sort" column="sort" />
|
||||||
|
<result property="content" column="content" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="strategyType" column="strategy_type" />
|
||||||
|
<result property="strategyId" column="strategy_id" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="AsAttributeGroupResult">
|
||||||
|
select id, name, product_id, product_image, introduction, unit, image_list, end_time, sort, content, status, strategy_type, strategy_id, create_by, create_time, update_by, update_time, remark from as_attribute_group
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.muyu.marketing.mapper.ActivityTeamProductSkuInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -158,7 +158,7 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
|
||||||
ProjectSkuInfo projectSkuInfo
|
ProjectSkuInfo projectSkuInfo
|
||||||
= projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
|
= projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
|
||||||
ProjectInfo projectInfo
|
ProjectInfo projectInfo
|
||||||
= projectInfoCache.get(cartInfo.getProjectId());
|
= projectInfoCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
|
||||||
Long stock = projectSkuStockCache.get(
|
Long stock = projectSkuStockCache.get(
|
||||||
SkuStockKey.builder()
|
SkuStockKey.builder()
|
||||||
.projectId(cartInfo.getProjectId())
|
.projectId(cartInfo.getProjectId())
|
||||||
|
|
Loading…
Reference in New Issue