From d1d9109b43ffe4e22cafbf1ae15d962af75d3e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=90=E8=8B=B1=E6=9D=B0?= <3427731738@qq.com> Date: Sat, 30 Nov 2024 14:28:33 +0800 Subject: [PATCH] =?UTF-8?q?2204A-cyj(=E5=9B=9E=E6=98=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/ActivityTeamInfoSelectModel.java | 41 ++++++++++--------- .../domain/resp/ActivityTeamInfoResp.java | 9 ++-- .../domain/resp/ProjectFindSkuInfoResp.java | 2 +- .../controller/ActivityTeamController.java | 14 +++---- .../team/service/ActivityTeamInfoService.java | 9 +++- .../impl/ActivityTeamInfoServiceImpl.java | 12 +++--- 6 files changed, 46 insertions(+), 41 deletions(-) diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoSelectModel.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoSelectModel.java index 9aa4e50..04dbded 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoSelectModel.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/model/ActivityTeamInfoSelectModel.java @@ -12,6 +12,7 @@ import lombok.NoArgsConstructor; import java.util.Date; import java.util.List; +import java.util.function.Function; /** * 团购活动查询模型 @@ -67,7 +68,7 @@ public class ActivityTeamInfoSelectModel { /** * 商品SkU集合 */ - private List teamProjectSkuInfoResp; + private List activityTeamProductSkuModels; /** * 活动详情 */ @@ -84,28 +85,28 @@ public class ActivityTeamInfoSelectModel { * 策略ID */ private Long strategyId; + private Long remainStock; /** 回显 构造 ActivityTeamInfoSelectModel*/ - public static ActivityTeamInfoSelectModel getTeamInfoSelectModel(ActivityTeamInfo activityTeamInfo, List list) { - return ActivityTeamInfoSelectModel.builder() - .teamId(activityTeamInfo.getId()) - .name(activityTeamInfo.getName()) - .productId(activityTeamInfo.getProductId()) - .productImage(activityTeamInfo.getProductImage()) - .introduction(activityTeamInfo.getIntroduction()) - .unit(activityTeamInfo.getUnit()) - .imageList(activityTeamInfo.getImageList()) - .endTime(activityTeamInfo.getEndTime()) - .sort(activityTeamInfo.getSort()) - .teamProjectSkuInfoResp( list.stream().map(skuInfo -> - TeamProjectSkuInfoResp.getSkuInfoResp(skuInfo) - ).toList()) - .content(activityTeamInfo.getContent()) - .status(activityTeamInfo.getStatus()) - .strategyType(activityTeamInfo.getStrategyType()) - .strategyId(activityTeamInfo.getStrategyId()) - .build(); + public static ActivityTeamInfoSelectModel getTeamInfoSelectModel(ActivityTeamInfo activityTeamInfo, + Function function) { + return function.apply( + ActivityTeamInfoSelectModel.builder() + .teamId(activityTeamInfo.getId()) + .name(activityTeamInfo.getName()) + .productId(activityTeamInfo.getProductId()) + .productImage(activityTeamInfo.getProductImage()) + .introduction(activityTeamInfo.getIntroduction()) + .unit(activityTeamInfo.getUnit()) + .imageList(activityTeamInfo.getImageList()) + .endTime(activityTeamInfo.getEndTime()) + .sort(activityTeamInfo.getSort()) + .content(activityTeamInfo.getContent()) + .status(activityTeamInfo.getStatus()) + .strategyType(activityTeamInfo.getStrategyType()) + .strategyId(activityTeamInfo.getStrategyId()) + ); } } diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ActivityTeamInfoResp.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ActivityTeamInfoResp.java index c731747..9172e46 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ActivityTeamInfoResp.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ActivityTeamInfoResp.java @@ -71,7 +71,7 @@ public class ActivityTeamInfoResp extends BaseEntity { /** * 商品SkU集合 */ - private List teamProjectSkuInfoResp; + private List projectFindSkuInfoResps; /** * 活动详情 */ @@ -90,7 +90,7 @@ public class ActivityTeamInfoResp extends BaseEntity { private Long strategyId; /** 构造ActivityTeamInfoResp */ - public static ActivityTeamInfoResp select(ActivityTeamInfoSelectModel teamSelectModel) { + public static ActivityTeamInfoResp teamInfoFindByIdBuild(ActivityTeamInfoSelectModel teamSelectModel) { return ActivityTeamInfoResp.builder() .teamId(teamSelectModel.getTeamId()) @@ -102,13 +102,16 @@ public class ActivityTeamInfoResp extends BaseEntity { .imageList(teamSelectModel.getImageList()) .endTime(teamSelectModel.getEndTime()) .sort(teamSelectModel.getSort()) - .teamProjectSkuInfoResp(teamSelectModel.getTeamProjectSkuInfoResp()) + .projectFindSkuInfoResps( + teamSelectModel.getActivityTeamProductSkuModels() + .stream().map(ProjectFindSkuInfoResp::projectFindSkuInfoBuild).toList()) .content(teamSelectModel.getContent()) .status(teamSelectModel.getStatus()) .strategyType(teamSelectModel.getStrategyType()) .strategyId(teamSelectModel.getStrategyId()) .build(); } + /** 构造 */ public static ActivityTeamInfoResp client(ActivityTeamInfo activityTeamInfo) { return ActivityTeamInfoResp.builder() diff --git a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ProjectFindSkuInfoResp.java b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ProjectFindSkuInfoResp.java index cf0af4e..7a88eaa 100644 --- a/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ProjectFindSkuInfoResp.java +++ b/muyu-modules/muyu-marketing/marketing-common/src/main/java/com/muyu/marketing/domain/resp/ProjectFindSkuInfoResp.java @@ -11,7 +11,7 @@ import lombok.experimental.SuperBuilder; import java.math.BigDecimal; /** - * 回显resp + * 回显 Sku resp */ @Data @SuperBuilder diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/controller/ActivityTeamController.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/controller/ActivityTeamController.java index 7f5d537..0b000a2 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/controller/ActivityTeamController.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/controller/ActivityTeamController.java @@ -39,11 +39,11 @@ public class ActivityTeamController { * 客户端拼团列表 */ @PostMapping("/clientList") - public Result> clientList(@RequestBody TeamInfoListReq teamInfoListReq){ + public Result> clientList(@RequestBody TeamInfoListReq teamInfoListReq){ PageUtils.startPage(teamInfoListReq.getPageNum(),teamInfoListReq.getPageSize()); List activityTeamInfoRespList=activityTeamInfoService.clientList(teamInfoListReq); PageInfo pageInfo = new PageInfo<>(activityTeamInfoRespList); - return Result.success(pageInfo.getList()); + return Result.success(pageInfo); } @@ -82,13 +82,9 @@ public class ActivityTeamController { * 回显拼团活动 * @teamId 拼团活动id */ - @GetMapping("/{teamId}") - public Result getTeamInfo(@PathVariable Long teamId){ - //调用Service方法 获取回显Model - ActivityTeamInfoSelectModel activityTeamInfoSelectModel = activityTeamInfoService.selectTeamInfo(teamId); - // 将 回显的Model 构造 成 Resp - ActivityTeamInfoResp activityTeamInfoResp = ActivityTeamInfoResp.select(activityTeamInfoSelectModel); - return Result.success(activityTeamInfoResp); + @GetMapping("/getById/{teamId}") + public Result getTeamInfo(@PathVariable("teamId") Long teamId){ + return Result.success(ActivityTeamInfoResp.teamInfoFindByIdBuild(activityTeamInfoService.findDetailById(teamId))); } /** 修改拼团活动*/ diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/ActivityTeamInfoService.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/ActivityTeamInfoService.java index 00fc69b..df40981 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/ActivityTeamInfoService.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/ActivityTeamInfoService.java @@ -30,9 +30,12 @@ public interface ActivityTeamInfoService extends IService { public void save(ActivityTeamInfoAddModel activityTeamInfoAddModel); /** - * 查询拼团活动(回显) + * 根据ID查询商品的详情 + * @param id 团购活动ID + * @return 团购详情 */ - public ActivityTeamInfoSelectModel selectTeamInfo(Long teamId); + ActivityTeamInfoSelectModel findDetailById(Long id); +// public ActivityTeamInfoSelectModel selectTeamInfo(Long teamId); /** * 修改活动 @@ -42,4 +45,6 @@ public interface ActivityTeamInfoService extends IService { /** 客户端列表*/ List clientList(TeamInfoListReq teamInfoListReq); + + } diff --git a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/impl/ActivityTeamInfoServiceImpl.java b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/impl/ActivityTeamInfoServiceImpl.java index edbc177..f36aeb5 100644 --- a/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/impl/ActivityTeamInfoServiceImpl.java +++ b/muyu-modules/muyu-marketing/marketing-server/src/main/java/com/muyu/marketing/team/service/impl/ActivityTeamInfoServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.marketing.domain.ActivityTeamInfo; +import com.muyu.marketing.domain.ActivityTeamOpenInfo; import com.muyu.marketing.domain.ActivityTeamProductSkuInfo; import com.muyu.marketing.domain.model.*; import com.muyu.marketing.domain.req.TeamInfoListReq; @@ -91,15 +92,14 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl activityTeamProductSkuInfoList = activityTeamProductSkuInfoService.getActivityTeamProductSkuInfoByTeamId(teamId); - //构造成 ActivityTeamInfoSelectModel - ActivityTeamInfoSelectModel teamInfoSelectModel = ActivityTeamInfoSelectModel.getTeamInfoSelectModel(activityTeamInfo, activityTeamProductSkuInfoList); - return teamInfoSelectModel; + List activityTeamProductSkuModelList = activityTeamProductSkuInfoService.findListByTeamId(teamId); + return ActivityTeamInfoSelectModel.getTeamInfoSelectModel(activityTeamInfo, + (teamInfoFindByIdRespModelBuilder) -> teamInfoFindByIdRespModelBuilder.activityTeamProductSkuModels(activityTeamProductSkuModelList).build() + ); } /**