2204A-cyj(客户端拼团列表)

1127/chengyingjie
成英杰 2024-11-29 00:15:23 +08:00
parent 46a7e2e8db
commit e4580e8bd1
9 changed files with 132 additions and 7 deletions

View File

@ -0,0 +1,57 @@
package com.muyu.gateway.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.cors.reactive.CorsUtils;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
/**
*
*
* @author ruoyi
*/
@Configuration
public class CorsConfig {
/**
* header
*/
private static final String ALLOWED_HEADERS = "X-Requested-With, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, Admin-Token, App-Token";
private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD";
private static final String ALLOWED_ORIGIN = "*";
private static final String ALLOWED_EXPOSE = "*";
private static final String MAX_AGE = "18000L";
@Bean
public WebFilter corsFilter()
{
return (ServerWebExchange ctx, WebFilterChain chain) -> {
ServerHttpRequest request = ctx.getRequest();
if (CorsUtils.isCorsRequest(request))
{
ServerHttpResponse response = ctx.getResponse();
HttpHeaders headers = response.getHeaders();
headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE);
headers.add("Access-Control-Max-Age", MAX_AGE);
headers.add("Access-Control-Allow-Credentials", "true");
if (request.getMethod() == HttpMethod.OPTIONS)
{
response.setStatusCode(HttpStatus.OK);
return Mono.empty();
}
}
return chain.filter(ctx);
};
}
}

View File

@ -66,7 +66,6 @@ public class ActivityTeamProductSkuInfo extends BaseEntity {
.productId(activityTeamProductSkuAddModel.getProductId())
.teamId(activityTeamProductSkuAddModel.getTeamId())
.teamStock(activityTeamProductSkuAddModel.getTeamStock())
// .remainStock(activityTeamProductSkuAddModel.getTeamStock())
.teamPrice(activityTeamProductSkuAddModel.getTeamPrice())
.build();
}

View File

@ -37,7 +37,7 @@ public class ActivityTeamProductSkuUpdModel {
/**
* SKU
*/
private String productSku;
private String productSku;
/**
*
*/

View File

@ -6,6 +6,7 @@ package com.muyu.marketing.domain.resp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoSelectModel;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -26,6 +27,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public class ActivityTeamInfoResp extends BaseEntity {
/**
* id
*/
@ -107,4 +109,22 @@ public class ActivityTeamInfoResp extends BaseEntity {
.strategyId(teamSelectModel.getStrategyId())
.build();
}
/** 构造 */
public static ActivityTeamInfoResp client(ActivityTeamInfo activityTeamInfo) {
return ActivityTeamInfoResp.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())
.build();
}
}

View File

@ -9,6 +9,9 @@ import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* Resp
*/
@Data
@Builder
@NoArgsConstructor
@ -86,4 +89,5 @@ public class TeamInfoListResp {
.teamStock(activityTeamInfoListModel.getTeamStock())
.build();
}
}

View File

@ -43,7 +43,7 @@ public class TeamProjectSkuInfoResp {
.ruleId(skuInfo.getId())
.sku(skuInfo.getProductSku())
.teamPrice(skuInfo.getTeamPrice())
// .teamStock(skuInfo.getTeamStock())
.teamStock(skuInfo.getTeamStock())
.build();
}

View File

@ -1,7 +1,9 @@
package com.muyu.marketing.team.controller;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.PageUtils;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.marketing.domain.model.ActivityTeamInfoAddModel;
import com.muyu.marketing.domain.model.ActivityTeamInfoListModel;
@ -31,6 +33,20 @@ public class ActivityTeamController {
@Autowired
private ActivityTeamInfoService activityTeamInfoService;;
/**
*
*/
@PostMapping("/clientList")
public Result<PageInfo<ActivityTeamInfoResp>> clientList(@RequestBody TeamInfoListReq teamInfoListReq){
PageUtils.startPage(teamInfoListReq.getPageNum(),teamInfoListReq.getPageSize());
List<ActivityTeamInfoResp> activityTeamInfoRespList=activityTeamInfoService.clientList(teamInfoListReq);
PageInfo<ActivityTeamInfoResp> pageInfo = new PageInfo<>(activityTeamInfoRespList);
return Result.success(pageInfo);
}
/**
*
* @param teamInfoListReq
@ -54,7 +70,7 @@ public class ActivityTeamController {
* @param activityTeamInfoSaveReq
* @return
*/
@PostMapping
@PostMapping("/add")
public Result<String> save(@RequestBody ActivityTeamInfoSaveReq activityTeamInfoSaveReq) {
activityTeamInfoService.save(ActivityTeamInfoAddModel.addReqBuild(activityTeamInfoSaveReq));
return Result.success();

View File

@ -5,6 +5,10 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.marketing.domain.ActivityTeamInfo;
import com.muyu.marketing.domain.model.*;
import com.muyu.marketing.domain.req.ActivityTeamProductSkuInfoUpdReq;
import com.muyu.marketing.domain.req.TeamInfoListReq;
import com.muyu.marketing.domain.resp.ActivityTeamInfoResp;
import java.util.List;
/**
*
@ -35,4 +39,7 @@ public interface ActivityTeamInfoService extends IService<ActivityTeamInfo> {
*/
void updateTeamInfo(ActivityTeamInfoUpdModel activityTeamInfoUpdModel);
/** 客户端列表*/
List<ActivityTeamInfoResp> clientList(TeamInfoListReq teamInfoListReq);
}

View File

@ -8,16 +8,17 @@ 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.req.ActivityTeamProductSkuInfoUpdReq;
import com.muyu.marketing.domain.req.TeamInfoListReq;
import com.muyu.marketing.domain.resp.ActivityTeamInfoResp;
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.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.List;
/**
@ -91,6 +92,7 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMap
*/
@Override
public ActivityTeamInfoSelectModel selectTeamInfo(Long teamId) {
activityTeamOpenInfoService.getById(teamId);
//根据拼团活动id 查询拼团活动
ActivityTeamInfo activityTeamInfo = this.getById(teamId);
//查询活动中的 商品sku集合
@ -136,8 +138,28 @@ public class ActivityTeamInfoServiceImpl extends ServiceImpl<ActivityTeamInfoMap
}
/** 客户端列表*/
@Override
public List<ActivityTeamInfoResp> clientList(TeamInfoListReq teamInfoListReq) {
LambdaQueryWrapper<ActivityTeamInfo> queryWrapper = new LambdaQueryWrapper<>();
//查询活动状态
if (null != teamInfoListReq.getStatus() && ! "".equals(teamInfoListReq.getStatus())){
queryWrapper.eq(ActivityTeamInfo::getStatus,teamInfoListReq.getStatus());
}
if (null != teamInfoListReq.getKeyWord() && ! "".equals(teamInfoListReq.getKeyWord())){
queryWrapper.eq(ActivityTeamInfo::getStatus,teamInfoListReq.getStatus());
}
//拼团列表
List<ActivityTeamInfo> activityTeamInfos = this.list(queryWrapper);
//构造成Resp
ArrayList<ActivityTeamInfoResp> activityTeamInfoResps = new ArrayList<>();
activityTeamInfos.forEach(activityTeamInfo -> {
ActivityTeamInfoResp client = ActivityTeamInfoResp.client(activityTeamInfo);
activityTeamInfoResps.add(client);
});
return activityTeamInfoResps;
}
}