fax():团购策略
parent
6b615b44b5
commit
e9924bcee8
24
doc/策略.md
24
doc/策略.md
|
@ -0,0 +1,24 @@
|
||||||
|
# 功能划分
|
||||||
|
# 普通团
|
||||||
|
商品列表
|
||||||
|
商品详情
|
||||||
|
去参团
|
||||||
|
开团列表
|
||||||
|
参团成功
|
||||||
|
邀请参团
|
||||||
|
拼团成功 查看订单
|
||||||
|
拼团失败 重新开团
|
||||||
|
开团成功
|
||||||
|
邀请参团
|
||||||
|
拼团成功 查看订单
|
||||||
|
拼团失败 重新开团
|
||||||
|
|
||||||
|
# 百人团
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1.商品详情
|
||||||
|
2.评价接口
|
||||||
|
3.拼团人数
|
||||||
|
4.开团列表
|
||||||
|
5.收藏接口
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.muyu.gateway.config.properties;
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class TeamProductDiscountPriceModel {
|
||||||
.productPrice(productPrice)
|
.productPrice(productPrice)
|
||||||
.teamPrice(teamPrice)
|
.teamPrice(teamPrice)
|
||||||
.discount(
|
.discount(
|
||||||
productPrice.subtract(teamPrice).divide(productPrice, 2, RoundingMode.HALF_UP).doubleValue()
|
Double.valueOf(productPrice.subtract(teamPrice).divide(productPrice, 2, RoundingMode.HALF_UP).doubleValue())
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class MuYuMarketIngApplication {
|
public class MuYuMarketingApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(MuYuMarketIngApplication.class, args);
|
SpringApplication.run(MuYuMarketingApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,18 +37,24 @@ public class ActivityTeamProductSkuInfoServiceImpl extends ServiceImpl<ActivityT
|
||||||
@Override
|
@Override
|
||||||
public TeamProductDiscountPriceModel getDiscountPrice(Long teamId) {
|
public TeamProductDiscountPriceModel getDiscountPrice(Long teamId) {
|
||||||
List<ActivityTeamProductSkuInfo> teamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
|
List<ActivityTeamProductSkuInfo> teamProductSkuInfoList = this.getActivityTeamProductSkuInfoByTeamId(teamId);
|
||||||
|
if(teamProductSkuInfoList.size()>0){
|
||||||
|
// 优惠模型集合
|
||||||
|
Optional<TeamProductDiscountPriceModel> discountPriceModelOptional = teamProductSkuInfoList.stream()
|
||||||
|
.map(activityTeamProductSkuInfo -> {
|
||||||
|
ProjectSkuInfo projectSkuInfo = projectSkuCache.get(activityTeamProductSkuInfo.getProductId(), activityTeamProductSkuInfo.getProductSku());
|
||||||
|
return TeamProductDiscountPriceModel.of(projectSkuInfo.getPrice(), activityTeamProductSkuInfo.getTeamPrice());
|
||||||
|
}).min((o1, o2) -> Double.valueOf(o1.getDiscount() * 100 - o2.getDiscount() * 100).intValue());
|
||||||
|
|
||||||
// 优惠模型集合
|
if (discountPriceModelOptional.isEmpty()){
|
||||||
Optional<TeamProductDiscountPriceModel> discountPriceModelOptional = teamProductSkuInfoList.stream()
|
throw new ServiceException("团购活动下没有商品绑定");
|
||||||
.map(activityTeamProductSkuInfo -> {
|
}
|
||||||
ProjectSkuInfo projectSkuInfo = projectSkuCache.get(activityTeamProductSkuInfo.getProductId(), activityTeamProductSkuInfo.getProductSku());
|
return discountPriceModelOptional.get();
|
||||||
return TeamProductDiscountPriceModel.of(projectSkuInfo.getPrice(), activityTeamProductSkuInfo.getTeamPrice());
|
|
||||||
}).min((o1, o2) -> Double.valueOf(o1.getDiscount() * 100 - o2.getDiscount() * 100).intValue());
|
|
||||||
|
|
||||||
if (discountPriceModelOptional.isEmpty()){
|
|
||||||
throw new ServiceException("团购活动下没有商品绑定");
|
|
||||||
}
|
}
|
||||||
return discountPriceModelOptional.get();
|
return TeamProductDiscountPriceModel.builder()
|
||||||
|
.productPrice(BigDecimal.valueOf(0))
|
||||||
|
.teamPrice(BigDecimal.valueOf(0))
|
||||||
|
.discount(0.00)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ server:
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: muyu-buy
|
name: muyu-marketing
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
@ -14,10 +14,10 @@ spring:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 127.0.0.1:8848
|
server-addr: 10.10.10.132:8848
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 127.0.0.1:8848
|
server-addr: 10.10.10.132:8848
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
Loading…
Reference in New Issue