main
parent
fcc9be49bd
commit
08b111cf1c
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.common.core.enums.market.team;/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.common.core.enums.market.team
|
||||
* @Project:cloud-server
|
||||
* @name:TeamOpenTypeEnum
|
||||
* @Date:2024/11/21 15:11
|
||||
*/
|
||||
|
||||
/**
|
||||
* @program: cloud-server
|
||||
* @description: 字典
|
||||
* @author: CuiFu Bo
|
||||
* @create: 2024-11-21 15:11
|
||||
**/
|
||||
|
||||
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,50 @@
|
|||
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.List;
|
||||
|
||||
/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.common.core.web
|
||||
* @Project:cloud-server
|
||||
* @name:QueryModel
|
||||
* @Date:2024/11/20 22:26
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryModel<T> {
|
||||
|
||||
private Integer pageNum;
|
||||
|
||||
private Integer pagesSize;
|
||||
|
||||
private String orderByColumn;
|
||||
|
||||
private boolean isAsc = true;
|
||||
|
||||
private boolean reasonable = true;
|
||||
|
||||
public T domainBuild(PageDomain pageDomain){
|
||||
this.pageNum = pageDomain.getPageNum();
|
||||
this.pagesSize = pageDomain.getPageSize();
|
||||
this.orderByColumn = pageDomain.getOrderByColumn();
|
||||
this.isAsc = "asc".equals(pageDomain.getIsAsc());
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public <I> Page<I> buildPage(){
|
||||
Page<I> page = Page.of(this.getPageNum(),this.getPagesSize());
|
||||
page.setOrders(List.of(this.isAsc()?
|
||||
OrderItem.asc(this.getOrderByColumn()) : OrderItem.desc(this.getOrderByColumn())));
|
||||
return page;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,20 @@
|
|||
package com.muyu.common.core.web.page;
|
||||
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分页数据
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageDomain {
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -49,7 +50,7 @@ public class ${ClassName}Controller extends BaseController {
|
|||
@RequiresPermissions("${permissionPrefix}:list")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud)
|
||||
public Result<TableDataInfo<${ClassName}>> list(${ClassName}QueryReq ${className}QueryReq) {
|
||||
public Result<TableDataInfo<${ClassName}T>> list(${ClassName}QueryReq ${className}QueryReq) {
|
||||
startPage();
|
||||
List<${ClassName}> list = ${className}Service.list(${ClassName}.queryBuild(${className}QueryReq));
|
||||
return getDataTable(list);
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-product-cache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
|
|
|
@ -2,13 +2,15 @@ package com.muyu.goods.controller;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.goods.domain.ActivityTeamInfo;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListModel;
|
||||
import com.muyu.goods.domain.req.TeamInfoListReq;
|
||||
import com.muyu.goods.domain.resp.TeamInfoListResp;
|
||||
import com.muyu.goods.service.ActivityTeamInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -34,8 +36,15 @@ public class ActivityTeamInfoController {
|
|||
*/
|
||||
@ApiOperation("商品拼团信息列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<ActivityTeamInfo>> list() {
|
||||
return Result.success(activityTeamInfoService.list());
|
||||
public Result<TableDataInfo<TeamInfoListResp>> query(@RequestBody TeamInfoListReq teamInfoListReq){
|
||||
TableDataInfo<ActivityTeamInfoListModel> tableDataInfo = activityTeamInfoService.querya(teamInfoListReq.buildQueryModel());
|
||||
List<TeamInfoListResp> respList = tableDataInfo.getRows().stream().map(TeamInfoListResp::listModeBuild).toList();
|
||||
return Result.success(
|
||||
new TableDataInfo<>(){{
|
||||
setRows(respList);
|
||||
setTotal(tableDataInfo.getTotal());
|
||||
}}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ActivityTeamInfo implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 拼团名称
|
||||
|
@ -106,6 +106,8 @@ public class ActivityTeamInfo implements Serializable {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private String records;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ActivityTeamOpenInfo implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 团购活动ID
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -19,7 +20,7 @@ public class ActivityTeamProductSkuInfo implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 活动ID
|
||||
|
@ -29,7 +30,7 @@ public class ActivityTeamProductSkuInfo implements Serializable {
|
|||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private String productId;
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
|
@ -39,12 +40,16 @@ public class ActivityTeamProductSkuInfo implements Serializable {
|
|||
/**
|
||||
* 拼团库存
|
||||
*/
|
||||
private String teamStock;
|
||||
private Long teamStock;
|
||||
/**
|
||||
* 剩余库存
|
||||
*/
|
||||
private Long remainStock;
|
||||
|
||||
/**
|
||||
* 拼团价格
|
||||
*/
|
||||
private String teamPrice;
|
||||
private BigDecimal teamPrice;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package com.muyu.goods.domain.Model;
|
||||
|
||||
import com.muyu.goods.domain.ActivityTeamInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.sf.jsqlparser.parser.feature.Feature.function;
|
||||
|
||||
/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain.Model
|
||||
* @Project:cloud-server
|
||||
* @name:ActivityTeamInfoListModel
|
||||
* @Date:2024/11/20 19:57
|
||||
* 团购活动列表结果模型
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode()
|
||||
public class ActivityTeamInfoListModel {
|
||||
/**
|
||||
* 拼团活动ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 拼团名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 参团人数
|
||||
*/
|
||||
private Long addTeamNumber;
|
||||
/**
|
||||
* 拼团人数
|
||||
*/
|
||||
private Long attendNumber;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 开团人数
|
||||
*/
|
||||
private Long openTeamNumber;
|
||||
/**
|
||||
* 拼团商品图片
|
||||
*/
|
||||
private String productImage;
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
* 剩余库存
|
||||
*/
|
||||
private Long remainStock;
|
||||
/**
|
||||
* 团购状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 拼团价格
|
||||
*/
|
||||
private BigDecimal teamPrice;
|
||||
/**
|
||||
* 拼团库存
|
||||
*/
|
||||
private Long teamStock;
|
||||
|
||||
public static ActivityTeamInfoListModel infoBuild(ActivityTeamInfo activityTeamInfo, Function<ActivityTeamInfoListModel.ActivityTeamInfoListModelBuilder,ActivityTeamInfoListModel>function){
|
||||
ActivityTeamInfoListModel activityTeamInfoListModel = ActivityTeamInfoListModel.builder()
|
||||
.id(activityTeamInfo.getId())
|
||||
.name(activityTeamInfo.getName())
|
||||
.endTime(activityTeamInfo.getEndTime())
|
||||
.productImage(activityTeamInfo.getProductImage())
|
||||
.status(activityTeamInfo.getStatus())
|
||||
.build();
|
||||
return function.apply(
|
||||
ActivityTeamInfoListModel.builder()
|
||||
.id(activityTeamInfo.getId())
|
||||
.name(activityTeamInfo.getName())
|
||||
.endTime(activityTeamInfo.getEndTime())
|
||||
.productImage(activityTeamInfo.getProductImage())
|
||||
.status(activityTeamInfo.getStatus())
|
||||
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.goods.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;
|
||||
|
||||
/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain
|
||||
* @Project:cloud-server
|
||||
* @name:ActivityTeamInfoQueryModel
|
||||
* @Date:2024/11/20 19:58
|
||||
*
|
||||
* 团购活动列表查询模型
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode()
|
||||
public class ActivityTeamInfoListQueryModel extends QueryModel<ActivityTeamInfoListQueryModel> {
|
||||
|
||||
private String keyWord;
|
||||
|
||||
private String status;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.goods.domain.Model;/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain.Model
|
||||
* @Project:cloud-server
|
||||
* @name:TeamProductStockModel
|
||||
* @Date:2024/11/21 20:48
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @program: cloud-server
|
||||
* @description: 团购商品库存模型
|
||||
* @author: CuiFu Bo
|
||||
* @create: 2024-11-21 20:48
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TeamProductStockModel {
|
||||
|
||||
/**
|
||||
* 拼团总库存
|
||||
*/
|
||||
private Long teamStock;
|
||||
|
||||
/**
|
||||
* 拼团剩余库存
|
||||
*/
|
||||
private Long remainStock;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.goods.domain;/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain
|
||||
* @Project:cloud-server
|
||||
* @name:TeamProductDiscountPriceMode
|
||||
* @Date:2024/11/21 16:35
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @program: cloud-server
|
||||
* @description: 团购商品优惠力度模型
|
||||
* @author: CuiFu Bo
|
||||
* @create: 2024-11-21 16:35
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TeamProductDiscountPriceMode {
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
|
||||
/**
|
||||
* 团购优惠价格
|
||||
*/
|
||||
private BigDecimal teamPrice;
|
||||
|
||||
/**
|
||||
* 优惠力度 (商品价格 - 团购优惠价格) / 商品价格
|
||||
*/
|
||||
private Double discount;
|
||||
|
||||
public static TeamProductDiscountPriceMode of(BigDecimal productPrice, BigDecimal teamPrice){
|
||||
return TeamProductDiscountPriceMode.builder()
|
||||
.productPrice(productPrice)
|
||||
.teamPrice(teamPrice)
|
||||
.discount(
|
||||
productPrice.subtract(teamPrice).divide(productPrice,2, RoundingMode.HALF_UP).doubleValue()
|
||||
)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -19,32 +19,32 @@ public class TeamStrategyExemption implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 持续时间
|
||||
*/
|
||||
private Integer duration;
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 免单人数
|
||||
*/
|
||||
private Integer exemptionNumber;
|
||||
private Long exemptionNumber;
|
||||
|
||||
/**
|
||||
* 最大购买量
|
||||
*/
|
||||
private Integer maxBuy;
|
||||
private Long maxBuy;
|
||||
|
||||
/**
|
||||
* 单次购买量
|
||||
*/
|
||||
private Integer oneBuy;
|
||||
private Long oneBuy;
|
||||
|
||||
/**
|
||||
* 虚拟人数
|
||||
*/
|
||||
private Integer virtualNumber;
|
||||
private Long virtualNumber;
|
||||
|
||||
/**
|
||||
* 面单类型
|
||||
|
|
|
@ -19,27 +19,27 @@ public class TeamStrategyExemptionHundred implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 持续时间
|
||||
*/
|
||||
private Integer duration;
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 最大购买量
|
||||
*/
|
||||
private Integer maxBuy;
|
||||
private Long maxBuy;
|
||||
|
||||
/**
|
||||
* 单次购买量
|
||||
*/
|
||||
private Integer oneBuy;
|
||||
private Long oneBuy;
|
||||
|
||||
/**
|
||||
* 虚拟人数
|
||||
*/
|
||||
private Integer virtualNumber;
|
||||
private Long virtualNumber;
|
||||
|
||||
/**
|
||||
* 策略状态
|
||||
|
|
|
@ -19,32 +19,32 @@ public class TeamStrategyExemptionOrdinary implements Serializable {
|
|||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 持续时间
|
||||
*/
|
||||
private Integer duration;
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 成团人数
|
||||
*/
|
||||
private Integer teamNumber;
|
||||
private Long teamNumber;
|
||||
|
||||
/**
|
||||
* 最大购买量
|
||||
*/
|
||||
private Integer maxBuy;
|
||||
private Long maxBuy;
|
||||
|
||||
/**
|
||||
* 单次购买量
|
||||
*/
|
||||
private Integer oneBuy;
|
||||
private Long oneBuy;
|
||||
|
||||
/**
|
||||
* 虚拟人数
|
||||
*/
|
||||
private Integer virtualNumber;
|
||||
private Long virtualNumber;
|
||||
|
||||
/**
|
||||
* 策略状态
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.goods.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.page.PageDomain;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListQueryModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain.req
|
||||
* @Project:cloud-server
|
||||
* @name:TeamInfoListReq
|
||||
* @Date:2024/11/20 19:59
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TeamInfoListReq extends PageDomain {
|
||||
private String keyWord;
|
||||
private String status;
|
||||
|
||||
public ActivityTeamInfoListQueryModel buildQueryModel(){
|
||||
return ActivityTeamInfoListQueryModel.builder()
|
||||
.status(this.status)
|
||||
.keyWord(this.keyWord)
|
||||
.build()
|
||||
.domainBuild(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.muyu.goods.domain.resp;
|
||||
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:尚志豪
|
||||
* @Package:com.muyu.goods.domain.resp
|
||||
* @Project:cloud-server
|
||||
* @name:TeamInfoListResp
|
||||
* @Date:2024/11/20 20:00
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class TeamInfoListResp {
|
||||
/**
|
||||
* 拼团活动ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 拼团名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 拼团商品图片
|
||||
*/
|
||||
private String productImage;
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
* 拼团价格
|
||||
*/
|
||||
private BigDecimal teamPrice;
|
||||
/**
|
||||
* 拼团人数
|
||||
*/
|
||||
private Long attendNumber;
|
||||
/**
|
||||
* 开团人数
|
||||
*/
|
||||
private Long openTeamNumber;
|
||||
/**
|
||||
* 参团人数
|
||||
*/
|
||||
private Long addTeamNumber;
|
||||
/**
|
||||
* 团购库存
|
||||
*/
|
||||
private Long teamStock;
|
||||
/**
|
||||
* 剩余库存
|
||||
*/
|
||||
private Long RemainStock;
|
||||
/**
|
||||
* 团购结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 团购状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
public static TeamInfoListResp listModeBuild(ActivityTeamInfoListModel activityTeamInfoListModel){
|
||||
return TeamInfoListResp.builder()
|
||||
.id(activityTeamInfoListModel.getId())
|
||||
.name(activityTeamInfoListModel.getName())
|
||||
.productImage(activityTeamInfoListModel.getProductImage())
|
||||
.productPrice(activityTeamInfoListModel.getProductPrice())
|
||||
.teamPrice(activityTeamInfoListModel.getTeamPrice())
|
||||
.attendNumber(activityTeamInfoListModel.getAttendNumber())
|
||||
.openTeamNumber(activityTeamInfoListModel.getOpenTeamNumber())
|
||||
.addTeamNumber(activityTeamInfoListModel.getAddTeamNumber())
|
||||
.teamStock(activityTeamInfoListModel.getTeamStock())
|
||||
.RemainStock(activityTeamInfoListModel.getRemainStock())
|
||||
.endTime(activityTeamInfoListModel.getEndTime())
|
||||
.status(activityTeamInfoListModel.getStatus())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.muyu.goods.forest.gaode.api.resp;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class District {
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 编码 */
|
||||
@JSONField(name = "citycode")
|
||||
private String code;
|
||||
|
||||
/** 级别 */
|
||||
private String level;
|
||||
|
||||
/** 区域编码 */
|
||||
@JSONField(name = "adcode")
|
||||
private String areaCode;
|
||||
|
||||
/** 中心经纬度 */
|
||||
private String center;
|
||||
|
||||
/**
|
||||
* 子
|
||||
*/
|
||||
private List<District> districts;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.muyu.goods.forest.gaode.api.resp;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 行政区接口返回结果集
|
||||
* @Date 2024/4/11 下午2:31
|
||||
*/
|
||||
@Data
|
||||
public class DistrictResult {
|
||||
|
||||
/**
|
||||
* 返回结果状态值
|
||||
* 值为0或1,0表示失败;1表示成功
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 返回状态说明
|
||||
* 返回状态说明,status为0时,info返回错误原因,否则返回“OK”。
|
||||
*/
|
||||
private String info;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
* 返回状态说明,10000代表正确,详情参阅info状态表
|
||||
*/
|
||||
@JSONField(name = "infocode")
|
||||
private String infoCode;
|
||||
|
||||
/**
|
||||
* 行政区列表
|
||||
*/
|
||||
private List<District> districts;
|
||||
}
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
package com.muyu.goods.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.goods.domain.ActivityTeamInfo;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListModel;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListQueryModel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface ActivityTeamInfoService extends IService<ActivityTeamInfo> {
|
||||
|
||||
TableDataInfo<ActivityTeamInfoListModel> querya(ActivityTeamInfoListQueryModel activityTeamInfoQueryModel);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.goods.service;
|
||||
|
||||
import com.muyu.common.core.enums.market.team.TeamOpenTypeEnum;
|
||||
import com.muyu.goods.domain.ActivityTeamOpenInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
@ -8,4 +9,22 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface ActivityTeamOpenInfoService extends IService<ActivityTeamOpenInfo> {
|
||||
|
||||
/**
|
||||
* 通过活动Id和开团类型查询开团梳理
|
||||
* @return
|
||||
*/
|
||||
public Long getTeamOpenNumberByIdAndType(Long teamId, TeamOpenTypeEnum teamOpenType);
|
||||
|
||||
/**
|
||||
* 根据活动ID获取开团数量
|
||||
*/
|
||||
public default Long getTeamOpenTypeNumberByTeamId(Long teamId){
|
||||
return this.getTeamOpenNumberByIdAndType(teamId,TeamOpenTypeEnum.OPEN_TEAM);
|
||||
};
|
||||
/**
|
||||
* 根据活动Id获取参团数量
|
||||
*/
|
||||
public default Long getTeamInTypeNumberByTeamId(Long teamId){
|
||||
return this.getTeamOpenNumberByIdAndType(teamId, TeamOpenTypeEnum.IN_TEAM);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,34 @@
|
|||
package com.muyu.goods.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.goods.domain.ActivityTeamProductSkuInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.goods.domain.Model.TeamProductStockModel;
|
||||
import com.muyu.goods.domain.TeamProductDiscountPriceMode;
|
||||
|
||||
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 TeamProductDiscountPriceMode getDiscountPrice(Long teamId);
|
||||
|
||||
/**
|
||||
* 通过活动Id获取 剩余库存
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
public TeamProductStockModel getStock(Long teamId);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
package com.muyu.goods.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.goods.domain.ActivityTeamInfo;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListModel;
|
||||
import com.muyu.goods.domain.Model.ActivityTeamInfoListQueryModel;
|
||||
import com.muyu.goods.domain.Model.TeamProductStockModel;
|
||||
import com.muyu.goods.domain.TeamProductDiscountPriceMode;
|
||||
import com.muyu.goods.service.ActivityTeamInfoService;
|
||||
import com.muyu.goods.mapper.ActivityTeamInfoMapper;
|
||||
import com.muyu.goods.service.ActivityTeamOpenInfoService;
|
||||
import com.muyu.goods.service.ActivityTeamProductSkuInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -13,5 +26,69 @@ import org.springframework.stereotype.Service;
|
|||
public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMapper, ActivityTeamInfo>
|
||||
implements ActivityTeamInfoService{
|
||||
|
||||
@Autowired
|
||||
private ActivityTeamOpenInfoService activityTeamOpenInfoService;
|
||||
|
||||
@Autowired
|
||||
private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService;
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo<ActivityTeamInfoListModel> querya(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) -> {
|
||||
TeamProductDiscountPriceMode discountPrice = activityTeamProductSkuInfoService.getDiscountPrice(activityTeamInfo.getId());
|
||||
TeamProductStockModel teamProductStockModel = activityTeamProductSkuInfoService.getStock(activityTeamInfo.getId());
|
||||
Long teamOpenTypeNumber = activityTeamOpenInfoService.getTeamOpenTypeNumberByTeamId(activityTeamInfo.getId());
|
||||
Long teamInTypeNumber = activityTeamOpenInfoService.getTeamInTypeNumberByTeamId(activityTeamInfo.getId());
|
||||
|
||||
return activityTeamInfoListModelBuilder
|
||||
.openTeamNumber(teamOpenTypeNumber)
|
||||
.addTeamNumber(teamInTypeNumber)
|
||||
.attendNumber(teamOpenTypeNumber+teamInTypeNumber)
|
||||
.endTime(activityTeamInfo.getEndTime())
|
||||
.productImage(activityTeamInfo.getProductImage())
|
||||
.teamPrice(discountPrice.getTeamPrice())
|
||||
.productPrice(discountPrice.getProductPrice())
|
||||
.teamStock(teamProductStockModel.getTeamStock())
|
||||
.remainStock(teamProductStockModel.getRemainStock())
|
||||
.status(activityTeamInfo.getStatus())
|
||||
.build();
|
||||
}
|
||||
)).toList();
|
||||
|
||||
|
||||
TableDataInfo<ActivityTeamInfoListModel> tableDataInfo = new TableDataInfo<>();
|
||||
tableDataInfo.setTotal(activityTeamInfoPage.getTotal());
|
||||
tableDataInfo.setRows(activityTeamInfoListModels);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.muyu.goods.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.goods.domain.ActivityTeamOpenInfo;
|
||||
import com.muyu.goods.service.ActivityTeamOpenInfoService;
|
||||
import com.muyu.goods.mapper.ActivityTeamOpenInfoMapper;
|
||||
|
@ -13,4 +15,20 @@ import org.springframework.stereotype.Service;
|
|||
public class ActivityTeamOpenInfoServiceImpl extends ServiceImpl<ActivityTeamOpenInfoMapper, ActivityTeamOpenInfo>
|
||||
implements ActivityTeamOpenInfoService{
|
||||
|
||||
/**
|
||||
* 通过活动Id和开团类型查询开团数量
|
||||
* @param teamId
|
||||
* @param teamOpenType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getTeamOpenNumberByIdAndType(Long teamId, TeamOpenTypeEnum teamOpenType) {
|
||||
LambdaQueryWrapper<ActivityTeamOpenInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ActivityTeamOpenInfo::getTeamId, teamId);
|
||||
queryWrapper.eq(ActivityTeamOpenInfo::getTeamType, teamOpenType.code());
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
package com.muyu.goods.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.goods.domain.ActivityTeamInfo;
|
||||
import com.muyu.goods.domain.ActivityTeamProductSkuInfo;
|
||||
import com.muyu.goods.domain.Model.TeamProductStockModel;
|
||||
import com.muyu.goods.domain.TeamProductDiscountPriceMode;
|
||||
import com.muyu.goods.service.ActivityTeamProductSkuInfoService;
|
||||
import com.muyu.goods.mapper.ActivityTeamProductSkuInfoMapper;
|
||||
import com.muyu.product.cache.ProjectSkuCache;
|
||||
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.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -13,4 +28,34 @@ import org.springframework.stereotype.Service;
|
|||
public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityTeamProductSkuInfoMapper, ActivityTeamProductSkuInfo>
|
||||
implements ActivityTeamProductSkuInfoService{
|
||||
|
||||
@Autowired
|
||||
private ProjectSkuCache projectSkuCache;
|
||||
|
||||
@Override
|
||||
public TeamProductDiscountPriceMode getDiscountPrice(Long teamId) {
|
||||
LambdaQueryWrapper<ActivityTeamProductSkuInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ActivityTeamProductSkuInfo::getTeamId, teamId);
|
||||
List<ActivityTeamProductSkuInfo> teamProductSkuInfoList = this.list(lambdaQueryWrapper);
|
||||
|
||||
// 优惠模型集合
|
||||
Optional<TeamProductDiscountPriceMode> discountPriceModeOptional = teamProductSkuInfoList.stream()
|
||||
.map(activityTeamProductSkuInfo -> {
|
||||
ProjectSkuInfo projectSkuInfo = projectSkuCache.get(activityTeamProductSkuInfo.getProductId(),activityTeamProductSkuInfo.getProductSku());
|
||||
return TeamProductDiscountPriceMode.of(projectSkuInfo.getPrice(),activityTeamProductSkuInfo.getTeamPrice());
|
||||
}).min(((o1, o2) -> Double.valueOf(o1.getDiscount() * 100 - o2.getDiscount() * 100).intValue()));
|
||||
|
||||
if (discountPriceModeOptional.isEmpty()){
|
||||
throw new ServiceException("团购活动下没有商品绑定");
|
||||
}
|
||||
return discountPriceModeOptional.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeamProductStockModel getStock(Long teamId) {
|
||||
List<ActivityTeamProductSkuInfo> teamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
|
||||
return TeamProductStockModel.builder()
|
||||
.teamStock(teamProductSkuInfoList.stream().map(ActivityTeamProductSkuInfo::getTeamStock).reduce(0L,Long::sum))
|
||||
.remainStock(teamProductSkuInfoList.stream().map(ActivityTeamProductSkuInfo::getRemainStock).reduce(0L,Long::sum))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.model.Ids;
|
||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import io.swagger.annotations.*;
|
||||
|
@ -27,7 +25,6 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
|||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.req.AttributeGroupQueryReq;
|
||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.service.AttributeGroupService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
|||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.service.RuleInfoService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.model.Ids;
|
||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
|
@ -11,9 +10,7 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.model.Ids;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||
|
@ -26,8 +23,6 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 属性组Service业务层处理
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
|
|
Loading…
Reference in New Issue