feat():营销团购活动的添加和活动的详情

1127/liuheping^2
刘河平 2024-11-27 10:41:04 +08:00
parent 43a18c95d8
commit 7e256f9a95
19 changed files with 353 additions and 33 deletions

View File

@ -0,0 +1,24 @@
{
"团购活动id":"Long"
"商品ID":"Long",
"活动名称":"String",
"活动简介":"String",
"商品图片":"String",
"商品单位":"String",
"商品的轮播图":[
"String","String"
],
"活动时间":"date",
"策略类型":"String",
"策略ID":"Long",
"商品规格List":[
{
"规格id":"Long",
"规格SKU":"String",
"拼团价格":"BigDecimal",
"拼团库存":"Long"
}
],
"排序":"Integer",
"详情":"String"
}

View File

@ -22,7 +22,7 @@ public class ActivityTeamInfo extends BaseEntity {
*
*/
@TableId(value = "id", type = IdType.AUTO)
private long id;
private Long id;
/**
*
*/
@ -30,7 +30,7 @@ public class ActivityTeamInfo extends BaseEntity {
/**
* ID
*/
private long productId;
private Long productId;
/**
*
*/
@ -54,7 +54,7 @@ public class ActivityTeamInfo extends BaseEntity {
/**
*
*/
private long sort;
private Long sort;
/**
*
*/
@ -70,7 +70,7 @@ public class ActivityTeamInfo extends BaseEntity {
/**
* ID
*/
private long strategyId;
private Long strategyId;
/**
*

View File

@ -22,11 +22,11 @@ public class ActivityTeamProductSkuInfo extends BaseEntity {
*
*/
@TableId(value = "id", type = IdType.AUTO)
private long id;
private Long id;
/**
* ID
*/
private long teamId;
private Long teamId;
/**
* ID
*/
@ -60,6 +60,6 @@ public class ActivityTeamProductSkuInfo extends BaseEntity {
.teamStock(activityTeamProductSkuAddModel.getTeamStock())
.remainStock(activityTeamProductSkuAddModel.getTeamStock())
.teamPrice(activityTeamProductSkuAddModel.getTeamPrice())
.build()
.build();
}
}

View File

@ -0,0 +1,41 @@
package com.muyu.marketing.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ActivityProductSkuListModel {
/**
* id
*/
private Long id;
/**
* id
*/
private Long skuId;
/**
* id
*/
private Long productId;
/**
* SKU
*/
private String sku;
/**
*
*/
private BigDecimal teamPrice;
/**
*
*/
private Long teamStock;
}

View File

@ -23,7 +23,6 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class ActivityTeamInfoAddModel {
/**
*
*/
@ -43,12 +42,10 @@ public class ActivityTeamInfoAddModel {
/**
*
*/
private String unit;
/**
*
*/
private String imageList;
/**
*
@ -58,7 +55,7 @@ public class ActivityTeamInfoAddModel {
/**
*
*/
private Integer sort;
private Long sort;
/**
* SkU
*/

View File

@ -36,7 +36,7 @@ public class ActivityTeamProductSkuAddModel {
/**
* SKU
*/
private String sku;
private String productSku;
/**
*
@ -50,8 +50,9 @@ public class ActivityTeamProductSkuAddModel {
public static ActivityTeamProductSkuAddModel addReqBuild(ProjectSkuInfoAddReq projectSkuInfoAddReq, Supplier<Long> getProductId) {
return ActivityTeamProductSkuAddModel.builder()
.teamId(projectSkuInfoAddReq.getId())
.productId(getProductId.get())
.sku(projectSkuInfoAddReq.getSku())
.productSku(projectSkuInfoAddReq.getSku())
.teamStock(projectSkuInfoAddReq.getTeamStock())
.teamPrice(projectSkuInfoAddReq.getTeamPrice())
.build();

View File

@ -44,7 +44,7 @@ public class TeamProductDiscountPriceModel {
* @return
*/
public static TeamProductDiscountPriceModel of(BigDecimal productPrice, BigDecimal teamPrice) {
TeamProductDiscountPriceModel.builder()
return TeamProductDiscountPriceModel.builder()
.productPrice(productPrice)
.teamPrice(teamPrice)
.discount(

View File

@ -36,7 +36,6 @@ public class ActivityTeamInfoSaveReq extends BaseEntity {
/**
*
*/
private String unit;
/**
*
@ -51,7 +50,7 @@ public class ActivityTeamInfoSaveReq extends BaseEntity {
/**
*
*/
private Integer sort;
private Long sort;
/**
* SkU
*/

View File

@ -16,6 +16,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@NoArgsConstructor
public class ProjectSkuInfoAddReq {
private Long id;
/**
* SKU

View File

@ -3,9 +3,10 @@ package com.muyu.marketing.domain.req;
import com.muyu.common.core.web.page.PageDomain;
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
import lombok.*;
import lombok.experimental.SuperBuilder;
@Data
@Builder
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)

View File

@ -0,0 +1,81 @@
package com.muyu.marketing.domain.resp;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
*
*
* @author DongZeLiang
* @date 2024-11-26 09:38
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ActivityTeamInfoDetailResp {
/**
* id
*/
private Long id;
/**
*
*/
private String name;
/**
* ID
*/
private Long productId;
/**
*
*/
private String productImage;
/**
*
*/
private String introduction;
/**
*
*/
private String unit;
/**
*
*/
private String imageList;
/**
*
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private Date endTime;
/**
*
*/
private Integer sort;
/**
* SkU
*/
private List<ActivityTeamProductSkuResp> ActivityTeamProductSkuList;
/**
*
*/
private String content;
/**
*
*/
private String status;
/**
*
*/
private String strategyType;
/**
* ID
*/
private Long strategyId;
}

View File

@ -0,0 +1,33 @@
package com.muyu.marketing.domain.resp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ActivityTeamProductSkuResp {
/**
* id
*/
private Long id;
/**
* SKU
*/
private String sku;
/**
*
*/
private BigDecimal teamPrice;
/**
*
*/
private Long teamStock;
}

View File

@ -7,13 +7,11 @@ import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
import com.muyu.marketing.domain.req.ActivityTeamInfoSaveReq;
import com.muyu.marketing.domain.req.TeamInfoListReq;
import com.muyu.marketing.domain.resp.ActivityTeamInfoDetailResp;
import com.muyu.marketing.domain.resp.TeamInfoListResp;
import com.muyu.marketing.team.service.ActivityTeamInfoService;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.bind.annotation.*;
import java.util.List;
@ -55,4 +53,13 @@ public class ActivityTeamController {
activityTeamInfoService.save(ActivityTeamInfoAddModel.addBuild(activityTeamInfoSaveReq));
return Result.success();
}
/**
*
*/
@GetMapping("getById/{teamId}")
public Result<ActivityTeamInfoDetailResp> getTeamInfo(@PathVariable Long teamId){
return Result.success(activityTeamInfoService.getActivityByTeamId(teamId));
}
}

View File

@ -0,0 +1,28 @@
package com.muyu.marketing.team.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.marketing.domain.model.ActivityProductSkuListModel;
import com.muyu.marketing.team.service.ActivityTeamProductSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("sku")
public class ActivityTeamProductSkuController {
@Autowired
private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService;
/**
*
*/
@GetMapping("getById/{teamId}")
public Result<List<ActivityProductSkuListModel>> getById(@PathVariable Long teamId){
return Result.success(activityTeamProductSkuInfoService.getTeamProductSkuInfoListByTeamId(teamId));
}
}

View File

@ -6,6 +6,7 @@ import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
import com.muyu.marketing.domain.resp.ActivityTeamInfoDetailResp;
import java.util.List;
@ -24,4 +25,11 @@ public interface ActivityTeamInfoService extends IService<ActivityTeamInfo> {
* @param activityTeamInfoAddModel
*/
public void save(ActivityTeamInfoAddModel activityTeamInfoAddModel);
/**
* id
*/
ActivityTeamInfoDetailResp getActivityByTeamId(Long teamId);
}

View File

@ -3,7 +3,7 @@ package com.muyu.marketing.team.service;
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.TeamStrategyExemptionHundred;
import com.muyu.marketing.domain.model.ActivityProductSkuListModel;
import com.muyu.marketing.domain.model.ActivityTeamProductSkuAddModel;
import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel;
import com.muyu.marketing.domain.model.TeamProductStockModel;
@ -41,4 +41,8 @@ public interface ActivityTeamProductSkuInfoService extends IService<ActivityTeam
*/
public void batchSave(List<ActivityTeamProductSkuAddModel> activityTeamProductSkuAddModelList);
/**
* id
*/
public List<ActivityProductSkuListModel> getTeamProductSkuInfoListByTeamId(Long teamId);
}

View File

@ -6,14 +6,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.bean.BeanUtils;
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.*;
import com.muyu.marketing.domain.resp.ActivityTeamInfoDetailResp;
import com.muyu.marketing.domain.resp.ActivityTeamProductSkuResp;
import com.muyu.marketing.team.mapper.ActivityTeamInfoMapper;
import com.muyu.marketing.team.service.ActivityTeamInfoService;
import com.muyu.marketing.team.service.ActivityTeamOpenInfoService;
import com.muyu.marketing.team.service.ActivityTeamProductSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -23,13 +28,16 @@ import java.util.function.Consumer;
@Service
public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMapper, ActivityTeamInfo>
implements ActivityTeamInfoService {
implements ActivityTeamInfoService {
@Autowired
private ActivityTeamOpenInfoService activityTeamOpenInfoService;
@Autowired
private ActivityTeamProductSkuInfoService activityTeamProductSkuInfoService;
// @Autowired
// private ActivityTeamInfoMapper activityTeamInfoMapper;
@Override
public TableDataInfo<ActivityTeamInfoListModel> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel) {
@ -85,6 +93,44 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMap
activityTeamInfoAddModel.getActivityTeamProductSkuAddModelList()
);
}
//添加接口文档
//回显
/**
* id
*
* @param teamId
* @return
*/
@Override
public ActivityTeamInfoDetailResp getActivityByTeamId(Long teamId) {
//根据id查询活动详情
ActivityTeamInfo activityTeamInfo = getById(teamId);
//封装活动详情
ActivityTeamInfoDetailResp activityTeamInfoDetailResp = new ActivityTeamInfoDetailResp();
List<ActivityTeamProductSkuResp> activityTeamProductSkuList = activityTeamInfoDetailResp.getActivityTeamProductSkuList();
//根据活动id查询活动商品SKU集合
List<ActivityProductSkuListModel> teamProductSkuInfoList = activityTeamProductSkuInfoService.getTeamProductSkuInfoListByTeamId(teamId);
if (teamProductSkuInfoList != null) {
//定义一个空集合
ArrayList<ActivityTeamProductSkuResp> activityProductSkuList = new ArrayList<>();
for (ActivityProductSkuListModel activityProductSkuListModel : teamProductSkuInfoList) {
Long id = activityProductSkuListModel.getId();
//根据id查询
ActivityTeamProductSkuInfo activityTeamProductSkuInfo = activityTeamProductSkuInfoService.getById(id);
//添加到集合中
activityProductSkuList.add(
ActivityTeamProductSkuResp.builder()
.id(activityTeamProductSkuInfo.getId())
.sku(activityTeamProductSkuInfo.getProductSku())
.teamPrice(activityTeamProductSkuInfo.getTeamPrice())
.teamStock(activityTeamProductSkuInfo.getTeamStock())
.build()
);
}
activityTeamInfoDetailResp.setActivityTeamProductSkuList(activityProductSkuList);
BeanUtils.copyBeanProp(activityTeamInfoDetailResp, activityTeamInfo);
}
return activityTeamInfoDetailResp;
}
}

View File

@ -1,32 +1,35 @@
package com.muyu.marketing.team.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.marketing.domain.ActivityTeamProductSkuInfo;
import com.muyu.marketing.domain.model.ActivityProductSkuListModel;
import com.muyu.marketing.domain.model.ActivityTeamProductSkuAddModel;
import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel;
import com.muyu.marketing.domain.model.TeamProductStockModel;
import com.muyu.marketing.domain.resp.ActivityTeamInfoDetailResp;
import com.muyu.marketing.domain.resp.ActivityTeamProductSkuResp;
import com.muyu.marketing.team.mapper.ActivityTeamProductSkuInfoMapper;
import com.muyu.marketing.team.service.ActivityTeamInfoService;
import com.muyu.marketing.team.service.ActivityTeamProductSkuInfoService;
import com.muyu.product.cache.ProjectSkuCache;
import com.muyu.product.domain.ProjectSkuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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;
@Service
public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityTeamProductSkuInfoMapper, ActivityTeamProductSkuInfo>
implements ActivityTeamProductSkuInfoService {
implements ActivityTeamProductSkuInfoService {
@Autowired
private ProjectSkuCache projectSkuCache;
@Autowired
private @Lazy ActivityTeamInfoService activityTeamInfoService;
/**
* ID
@ -45,7 +48,7 @@ public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityT
return TeamProductDiscountPriceModel.of(projectSkuInfo.getPrice(), activityTeamProductSkuInfo.getTeamPrice());
}).min((o1, o2) -> Double.valueOf(o1.getDiscount() * 100 - o2.getDiscount() * 100).intValue());
if (discountPriceModelOptional.isEmpty()){
if (discountPriceModelOptional.isEmpty()) {
throw new ServiceException("团购活动下没有商品绑定");
}
return discountPriceModelOptional.get();
@ -80,4 +83,48 @@ public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityT
activityTeamProductSkuAddModelList.stream().map(ActivityTeamProductSkuInfo::modelBuild).toList()
);
}
/**
* IDSKU
*
* @param teamId
* @return
*/
@Override
public List<ActivityProductSkuListModel> getTeamProductSkuInfoListByTeamId(Long teamId) {
//根据活动id查询团购商品SKU集合
List<ActivityTeamProductSkuInfo> activityTeamProductSkuList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
ArrayList<ActivityProductSkuListModel> activityProductSkuList = new ArrayList<>();
for (ActivityTeamProductSkuInfo activityTeamProductSkuInfo : activityTeamProductSkuList) {
activityProductSkuList.add(ActivityProductSkuListModel.builder()
.id(activityTeamProductSkuInfo.getId())
.productId(activityTeamProductSkuInfo.getProductId())
.sku(activityTeamProductSkuInfo.getProductSku())
.teamPrice(activityTeamProductSkuInfo.getTeamPrice())
.teamStock(activityTeamProductSkuInfo.getTeamStock())
.build());
}
return activityProductSkuList;
// //根据活动id查询活动相关信息
// ActivityTeamInfoDetailResp activityTeamInfoDetailResp=activityTeamInfoService.getActivityByTeamId(teamId);
// //获取到活动商品SKU集合
// List<ActivityTeamProductSkuResp> activityTeamProductSkuList = activityTeamInfoDetailResp.getActivityTeamProductSkuList();
// //定义一个空集合
// ArrayList<ActivityProductSkuListModel> activityProductSkuList = new ArrayList<>();
// //遍历SKU集合
// for (ActivityTeamProductSkuResp activityTeamProductSkuResp : activityTeamProductSkuList) {
// //获取到SKU的id
// Long id = activityTeamProductSkuResp.getId();
// //根据id查询
// ActivityTeamProductSkuInfo activityTeamProductSkuInfo = this.getById(id);
// //添加到集合中
// activityProductSkuList.add(ActivityProductSkuListModel.builder()
// .productId(activityTeamProductSkuInfo.getProductId())
// .sku(activityTeamProductSkuInfo.getProductSku())
// .teamPrice(activityTeamProductSkuInfo.getTeamPrice())
// .teamStock(activityTeamProductSkuInfo.getTeamStock())
// .build());
// }
// return activityProductSkuList;
}
}

View File

@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: e6fc646f-719d-4642-9228-b68fb4ed42aa
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: e6fc646f-719d-4642-9228-b68fb4ed42aa
# 配置文件格式
file-extension: yml
# 共享配置