feat():团购商品-团购添加完成

pull/2/head
DongZeLiang 2024-11-26 11:19:00 +08:00 committed by 小万的gitee
parent 49ea16c908
commit 090cf65bbe
26 changed files with 326 additions and 39 deletions

View File

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

View File

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

View File

@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: www-mall
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: www-mall
# 配置文件格式
file-extension: yml
# 共享配置
@ -28,12 +30,13 @@ spring:
eager: true
transport:
# 控制台地址
dashboard: 127.0.0.1:8718
dashboard: 113.44.45.42:8718
# nacos配置持久化
datasource:
ds1:
nacos:
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: www-mall
dataId: sentinel-muyu-gateway
groupId: DEFAULT_GROUP
data-type: json

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@ 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 com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
import lombok.*;
import lombok.experimental.SuperBuilder;
@ -70,4 +71,27 @@ public class ActivityTeamInfo extends BaseEntity {
* ID
*/
private long strategyId;
/**
*
* @param activityTeamInfoAddModel
* @return
*/
public static ActivityTeamInfo addModelBuild(ActivityTeamInfoAddModel activityTeamInfoAddModel){
return ActivityTeamInfo.builder()
.name(activityTeamInfoAddModel.getName())
.productId(activityTeamInfoAddModel.getProductId())
.productImage(activityTeamInfoAddModel.getProductImage())
.introduction(activityTeamInfoAddModel.getIntroduction())
.unit(activityTeamInfoAddModel.getUnit())
.imageList(activityTeamInfoAddModel.getImageList())
.endTime(activityTeamInfoAddModel.getEndTime())
.sort(activityTeamInfoAddModel.getSort())
.content(activityTeamInfoAddModel.getContent())
.status(activityTeamInfoAddModel.getStatus())
.strategyType(activityTeamInfoAddModel.getStrategyType())
.strategyId(activityTeamInfoAddModel.getStrategyId())
.build();
}
}

View File

@ -60,6 +60,6 @@ public class ActivityTeamProductSkuInfo extends BaseEntity {
.teamStock(activityTeamProductSkuAddModel.getTeamStock())
.remainStock(activityTeamProductSkuAddModel.getTeamStock())
.teamPrice(activityTeamProductSkuAddModel.getTeamPrice())
.build()
.build();
}
}

View File

@ -2,7 +2,7 @@ package com.muyu.marketing.domain.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.marketing.domain.req.ProjectSkuInfoAddReq;
import com.muyu.marketing.domain.req.ActivityTeamInfoSaveReq;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -78,4 +78,31 @@ public class ActivityTeamInfoAddModel {
* ID
*/
private Long strategyId;
public static ActivityTeamInfoAddModel saveTeamInfoBuild(ActivityTeamInfoSaveReq activityTeamInfoSaveReq){
return ActivityTeamInfoAddModel.builder()
.name(activityTeamInfoSaveReq.getName())
.productId(activityTeamInfoSaveReq.getProductId())
.productImage(activityTeamInfoSaveReq.getProductImage())
.introduction(activityTeamInfoSaveReq.getIntroduction())
.unit(activityTeamInfoSaveReq.getUnit())
.imageList(activityTeamInfoSaveReq.getImageList())
.endTime(activityTeamInfoSaveReq.getEndTime())
.sort(activityTeamInfoSaveReq.getSort())
.content(activityTeamInfoSaveReq.getContent())
.status(activityTeamInfoSaveReq.getStatus())
.strategyType(activityTeamInfoSaveReq.getStrategyType())
.strategyId(activityTeamInfoSaveReq.getStrategyId())
.activityTeamProductSkuAddModelList(
activityTeamInfoSaveReq.getProjectSkuInfoAddReqList()
.stream()
.map(projectSkuInfoAddReq ->ActivityTeamProductSkuAddModel.addReqBulid(projectSkuInfoAddReq,activityTeamInfoSaveReq::getProductId)).toList()
).build();
}
}

View File

@ -0,0 +1,80 @@
package com.muyu.marketing.domain.model;
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;
/**
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ActivityTeamInfoUpdModel {
/**
*
*/
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<ActivityTeamProductSkuAddModel> activityTeamProductSkuAddModelList;
/**
*
*/
private String content;
/**
*
*/
private String status;
/**
*
*/
private String strategyType;
/**
* ID
*/
private Long strategyId;
}

View File

@ -1,12 +1,14 @@
package com.muyu.marketing.domain.model;
import com.muyu.marketing.domain.req.TeamProjectSkuInfoAddReq;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.function.Supplier;
/**
* spu
@ -44,4 +46,13 @@ public class ActivityTeamProductSkuAddModel {
*
*/
private Long teamStock;
public static ActivityTeamProductSkuAddModel addReqBulid(TeamProjectSkuInfoAddReq teamProjectSkuInfoAddReq, Supplier<Long> productId){
return ActivityTeamProductSkuAddModel.builder()
.productId(productId.get())
.sku(teamProjectSkuInfoAddReq.getSku())
.teamPrice(teamProjectSkuInfoAddReq.getTeamPrice())
.teamStock(teamProjectSkuInfoAddReq.getTeamStock())
.build();
}
}

View File

@ -0,0 +1,48 @@
package com.muyu.marketing.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
/**
*
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class ProjectSkuInfoFindeModel {
/**
*
*/
private Long id;
/**
* id
*/
private Long product_id;
/**
* id
*/
private Long teamId;
/**
* SKU
*/
private String sku;
/**
*
*/
private BigDecimal teamPrice;
/**
*
*/
private Long teamStock;
}

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

@ -55,7 +55,7 @@ public class ActivityTeamInfoSaveReq extends BaseEntity {
/**
* SkU
*/
private List<ProjectSkuInfoAddReq> projectSkuInfoAddReqList;
private List<TeamProjectSkuInfoAddReq> projectSkuInfoAddReqList;
/**
*
*/
@ -72,4 +72,11 @@ public class ActivityTeamInfoSaveReq extends BaseEntity {
* ID
*/
private Long strategyId;
public static ActivityTeamInfoSaveReq saveSkuInfosBuild(ActivityTeamInfoSaveReq activityTeamInfoSaveReq){
return ActivityTeamInfoSaveReq.builder()
.projectSkuInfoAddReqList(activityTeamInfoSaveReq.getProjectSkuInfoAddReqList())
.build();
}
}

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

@ -1,27 +1,22 @@
package com.muyu.marketing.domain.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
/**
*
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class ProjectSkuInfoAddReq {
public class TeamProjectSkuInfoAddReq {
/**
* SKU
*/
private String sku;
/**
*
*/

View File

@ -3,10 +3,14 @@ package com.muyu.marketing.team.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.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.TeamInfoListResp;
import com.muyu.marketing.team.service.ActivityTeamInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -21,6 +25,7 @@ import java.util.List;
* @author DongZeLiang
* @date 2024-11-20 14:25
*/
@Slf4j
@RestController
@RequestMapping("/team")
public class ActivityTeamController {
@ -44,4 +49,10 @@ public class ActivityTeamController {
}}
);
}
@PostMapping("/save")
public Result save(@RequestBody ActivityTeamInfoSaveReq activityTeamInfoSaveReq){
activityTeamInfoService.save(ActivityTeamInfoAddModel.saveTeamInfoBuild(activityTeamInfoSaveReq));
return Result.success();
}
}

View File

@ -3,8 +3,10 @@ package com.muyu.marketing.team.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoUpdModel;
import java.util.List;
@ -17,4 +19,15 @@ public interface ActivityTeamInfoService extends IService<ActivityTeamInfo> {
* @return
*/
public TableDataInfo<ActivityTeamInfoListModel> query(ActivityTeamInfoListQueryModel activityTeamInfoListQueryModel);
/**
*
* @param activityTeamInfoAddModel
*/
public void save(ActivityTeamInfoAddModel activityTeamInfoAddModel);
/**
*
*/
// public void uodate(ActivityTeamInfoAddModelityTeamInfoUpdModel activityTeamInfoUpdModel);
}

View File

@ -5,6 +5,7 @@ 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.ActivityTeamProductSkuAddModel;
import com.muyu.marketing.domain.model.ProjectSkuInfoFindeModel;
import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel;
import com.muyu.marketing.domain.model.TeamProductStockModel;
@ -40,5 +41,7 @@ public interface ActivityTeamProductSkuInfoService extends IService<ActivityTeam
* @param activityTeamProductSkuAddModelList SKU
*/
public void batchSave(List<ActivityTeamProductSkuAddModel> activityTeamProductSkuAddModelList);
//
//
// public List<ProjectSkuInfoFindeModel> findById(Long teamId);
}

View File

@ -4,17 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListQueryModel;
import com.muyu.marketing.domain.model.TeamProductDiscountPriceModel;
import com.muyu.marketing.domain.model.TeamProductStockModel;
import com.muyu.marketing.domain.model.*;
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 io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -69,4 +68,20 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMap
tableDataInfo.setRows(activityTeamInfoListModels);
return tableDataInfo;
}
/**
*
*
* @param activityTeamInfoAddModel
*/
@Override
public void save(ActivityTeamInfoAddModel activityTeamInfoAddModel) {
ActivityTeamInfo activityTeamInfo = ActivityTeamInfo.addModelBuild(activityTeamInfoAddModel);
Assert.isTrue(this.save(activityTeamInfo),StringUtils.format("团购活动添加失败:[{}]",activityTeamInfoAddModel));
List<ActivityTeamProductSkuAddModel> productSkuAddModelList = activityTeamInfoAddModel.getActivityTeamProductSkuAddModelList();
productSkuAddModelList.forEach(activityTeamProductSkuAddModel -> activityTeamProductSkuAddModel.setTeamId(activityTeamInfo.getId()));
this.activityTeamProductSkuInfoService.batchSave(productSkuAddModelList);
}
}

View File

@ -26,4 +26,6 @@ public class ActivityTeamOpenInfoServiceImpl extends ServiceImpl<ActivityTeamOpe
queryWrapper.eq(ActivityTeamOpenInfo::getTeamType, teamOpenType.code());
return this.count(queryWrapper);
}
}

View File

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

View File

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

View File

@ -16,10 +16,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: www-mall
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 113.44.45.42:8848
namespace: www-mall
# 配置文件格式
file-extension: yml
# 共享配置

View File

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

View File

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