Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-cloud
# Conflicts: # yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/config/YudaoApiLogAutoConfiguration.java # yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java # yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java # yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java # yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java # yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/TencentSmsClient.java # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceImpl.java # yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.javapull/140/head
commit
7d9785ad79
|
@ -143,4 +143,21 @@ public class HttpUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP get 请求,基于 {@link cn.hutool.http.HttpUtil} 实现
|
||||||
|
*
|
||||||
|
* 为什么要封装该方法,因为 HttpUtil 默认封装的方法,没有允许传递 headers 参数
|
||||||
|
*
|
||||||
|
* @param url URL
|
||||||
|
* @param headers 请求头
|
||||||
|
* @return 请求结果
|
||||||
|
*/
|
||||||
|
public static String get(String url, Map<String, String> headers) {
|
||||||
|
try (HttpResponse response = HttpRequest.get(url)
|
||||||
|
.addHeaders(headers)
|
||||||
|
.execute()) {
|
||||||
|
return response.body();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
|
||||||
import com.mzt.logapi.beans.LogRecord;
|
import com.mzt.logapi.beans.LogRecord;
|
||||||
import com.mzt.logapi.service.ILogRecordService;
|
import com.mzt.logapi.service.ILogRecordService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -29,7 +28,6 @@ public class LogRecordServiceImpl implements ILogRecordService {
|
||||||
private OperateLogApi operateLogApi;
|
private OperateLogApi operateLogApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
|
||||||
public void record(LogRecord logRecord) {
|
public void record(LogRecord logRecord) {
|
||||||
OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO();
|
OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO();
|
||||||
try {
|
try {
|
||||||
|
@ -42,7 +40,7 @@ public class LogRecordServiceImpl implements ILogRecordService {
|
||||||
fillRequestFields(reqDTO);
|
fillRequestFields(reqDTO);
|
||||||
|
|
||||||
// 2. 异步记录日志
|
// 2. 异步记录日志
|
||||||
operateLogApi.createOperateLog(reqDTO).getCheckedData();
|
operateLogApi.createOperateLogAsync(reqDTO);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
|
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
|
||||||
log.error("[record][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
|
log.error("[record][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
|
||||||
|
|
|
@ -2,15 +2,11 @@ package cn.iocoder.yudao.framework.apilog.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter;
|
import cn.iocoder.yudao.framework.apilog.core.filter.ApiAccessLogFilter;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor;
|
import cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl;
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl;
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
||||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||||
import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
|
import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
|
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
import jakarta.servlet.Filter;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
@ -19,32 +15,19 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
|
|
||||||
@AutoConfiguration(after = YudaoWebAutoConfiguration.class)
|
@AutoConfiguration(after = YudaoWebAutoConfiguration.class)
|
||||||
public class YudaoApiLogAutoConfiguration implements WebMvcConfigurer {
|
public class YudaoApiLogAutoConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Bean
|
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
|
||||||
public ApiAccessLogFrameworkService apiAccessLogFrameworkService(ApiAccessLogApi apiAccessLogApi) {
|
|
||||||
return new ApiAccessLogFrameworkServiceImpl(apiAccessLogApi);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
|
||||||
public ApiErrorLogFrameworkService apiErrorLogFrameworkService(ApiErrorLogApi apiErrorLogApi) {
|
|
||||||
return new ApiErrorLogFrameworkServiceImpl(apiErrorLogApi);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 ApiAccessLogFilter Bean,记录 API 请求日志
|
* 创建 ApiAccessLogFilter Bean,记录 API 请求日志
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(prefix = "yudao.access-log", value = "enable", matchIfMissing = true) // 允许使用 yudao.access-log.enable=false 禁用访问日志
|
@ConditionalOnProperty(prefix = "yudao.access-log", value = "enable", matchIfMissing = true) // 允许使用 yudao.access-log.enable=false 禁用访问日志
|
||||||
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
public FilterRegistrationBean<ApiAccessLogFilter> apiAccessLogFilter(WebProperties webProperties,
|
public FilterRegistrationBean<ApiAccessLogFilter> apiAccessLogFilter(WebProperties webProperties,
|
||||||
@Value("${spring.application.name}") String applicationName,
|
@Value("${spring.application.name}") String applicationName,
|
||||||
ApiAccessLogFrameworkService apiAccessLogFrameworkService) {
|
ApiAccessLogApi apiAccessLogApi) {
|
||||||
ApiAccessLogFilter filter = new ApiAccessLogFilter(webProperties, applicationName, apiAccessLogFrameworkService);
|
ApiAccessLogFilter filter = new ApiAccessLogFilter(webProperties, applicationName, apiAccessLogApi);
|
||||||
return createFilterBean(filter, WebFilterOrderEnum.API_ACCESS_LOG_FILTER);
|
return createFilterBean(filter, WebFilterOrderEnum.API_ACCESS_LOG_FILTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 日志使用到 Feign 的配置项
|
* API 日志使用到 Feign 的配置项
|
||||||
|
@ -12,7 +11,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@EnableFeignClients(clients = {ApiAccessLogApi.class, // 主要是引入相关的 API 服务
|
@EnableFeignClients(clients = {ApiAccessLogApi.class, ApiErrorLogApi.class}) // 主要是引入相关的 API 服务
|
||||||
ApiErrorLogApi.class})
|
|
||||||
public class YudaoApiLogRpcAutoConfiguration {
|
public class YudaoApiLogRpcAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import cn.hutool.core.util.BooleanUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum;
|
import cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
|
@ -18,6 +17,7 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||||
import cn.iocoder.yudao.framework.web.core.filter.ApiRequestFilter;
|
import cn.iocoder.yudao.framework.web.core.filter.ApiRequestFilter;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -36,7 +36,7 @@ import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor.*;
|
import static cn.iocoder.yudao.framework.apilog.core.interceptor.ApiAccessLogInterceptor.ATTRIBUTE_HANDLER_METHOD;
|
||||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,12 +53,12 @@ public class ApiAccessLogFilter extends ApiRequestFilter {
|
||||||
|
|
||||||
private final String applicationName;
|
private final String applicationName;
|
||||||
|
|
||||||
private final ApiAccessLogFrameworkService apiAccessLogFrameworkService;
|
private final ApiAccessLogApi apiAccessLogApi;
|
||||||
|
|
||||||
public ApiAccessLogFilter(WebProperties webProperties, String applicationName, ApiAccessLogFrameworkService apiAccessLogFrameworkService) {
|
public ApiAccessLogFilter(WebProperties webProperties, String applicationName, ApiAccessLogApi apiAccessLogApi) {
|
||||||
super(webProperties);
|
super(webProperties);
|
||||||
this.applicationName = applicationName;
|
this.applicationName = applicationName;
|
||||||
this.apiAccessLogFrameworkService = apiAccessLogFrameworkService;
|
this.apiAccessLogApi = apiAccessLogApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,7 +91,7 @@ public class ApiAccessLogFilter extends ApiRequestFilter {
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apiAccessLogFrameworkService.createApiAccessLog(accessLog);
|
apiAccessLogApi.createApiAccessLogAsync(accessLog);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
log.error("[createApiAccessLog][url({}) log({}) 发生异常]", request.getRequestURI(), toJsonString(accessLog), th);
|
log.error("[createApiAccessLog][url({}) log({}) 发生异常]", request.getRequestURI(), toJsonString(accessLog), th);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.apilog.core.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 访问日志 Framework Service 接口
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
public interface ApiAccessLogFrameworkService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建 API 访问日志
|
|
||||||
*
|
|
||||||
* @param reqDTO API 访问日志
|
|
||||||
*/
|
|
||||||
void createApiAccessLog(ApiAccessLogCreateReqDTO reqDTO);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.apilog.core.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 访问日志 Framework Service 实现类
|
|
||||||
*
|
|
||||||
* 基于 {@link ApiAccessLogApi} 服务,记录访问日志
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService {
|
|
||||||
|
|
||||||
private final ApiAccessLogApi apiAccessLogApi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Async
|
|
||||||
public void createApiAccessLog(ApiAccessLogCreateReqDTO reqDTO) {
|
|
||||||
try {
|
|
||||||
apiAccessLogApi.createApiAccessLog(reqDTO);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
|
|
||||||
log.error("[createApiAccessLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.apilog.core.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 错误日志 Framework Service 接口
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
public interface ApiErrorLogFrameworkService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建 API 错误日志
|
|
||||||
*
|
|
||||||
* @param reqDTO API 错误日志
|
|
||||||
*/
|
|
||||||
void createApiErrorLog(ApiErrorLogCreateReqDTO reqDTO);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.apilog.core.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API 错误日志 Framework Service 实现类
|
|
||||||
*
|
|
||||||
* 基于 {@link ApiErrorLogApi} 服务,记录错误日志
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService {
|
|
||||||
|
|
||||||
private final ApiErrorLogApi apiErrorLogApi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Async
|
|
||||||
public void createApiErrorLog(ApiErrorLogCreateReqDTO reqDTO) {
|
|
||||||
try {
|
|
||||||
apiErrorLogApi.createApiErrorLog(reqDTO);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
|
|
||||||
log.error("[createApiErrorLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +1,12 @@
|
||||||
package cn.iocoder.yudao.framework.web.config;
|
package cn.iocoder.yudao.framework.web.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
||||||
import cn.iocoder.yudao.framework.web.core.filter.CacheRequestBodyFilter;
|
import cn.iocoder.yudao.framework.web.core.filter.CacheRequestBodyFilter;
|
||||||
import cn.iocoder.yudao.framework.web.core.filter.DemoFilter;
|
import cn.iocoder.yudao.framework.web.core.filter.DemoFilter;
|
||||||
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
|
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
|
||||||
import cn.iocoder.yudao.framework.web.core.handler.GlobalResponseBodyHandler;
|
import cn.iocoder.yudao.framework.web.core.handler.GlobalResponseBodyHandler;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
@ -59,8 +59,9 @@ public class YudaoWebAutoConfiguration implements WebMvcConfigurer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogFrameworkService apiErrorLogFrameworkService) {
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
return new GlobalExceptionHandler(applicationName, apiErrorLogFrameworkService);
|
public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogApi apiErrorLogApi) {
|
||||||
|
return new GlobalExceptionHandler(applicationName, apiErrorLogApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
|
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
@ -13,8 +13,13 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
import jakarta.validation.ValidationException;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||||
|
@ -29,11 +34,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||||
|
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.ConstraintViolation;
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.ValidationException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -63,7 +65,7 @@ public class GlobalExceptionHandler {
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
private final String applicationName;
|
private final String applicationName;
|
||||||
|
|
||||||
private final ApiErrorLogFrameworkService apiErrorLogFrameworkService;
|
private final ApiErrorLogApi apiErrorLogApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理所有异常,主要是提供给 Filter 使用
|
* 处理所有异常,主要是提供给 Filter 使用
|
||||||
|
@ -95,10 +97,9 @@ public class GlobalExceptionHandler {
|
||||||
if (ex instanceof NoHandlerFoundException) {
|
if (ex instanceof NoHandlerFoundException) {
|
||||||
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
|
||||||
}
|
}
|
||||||
// 仅 JDK17 + Spring Boot 3.X 才有
|
if (ex instanceof NoResourceFoundException) {
|
||||||
// if (ex instanceof NoResourceFoundException) {
|
return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
|
||||||
// return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
|
}
|
||||||
// }
|
|
||||||
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||||
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
||||||
}
|
}
|
||||||
|
@ -204,15 +205,14 @@ public class GlobalExceptionHandler {
|
||||||
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 仅 JDK17 + Spring Boot 3.X 才有
|
/**
|
||||||
// /**
|
* 处理 SpringMVC 请求地址不存在
|
||||||
// * 处理 SpringMVC 请求地址不存在
|
*/
|
||||||
// */
|
@ExceptionHandler(NoResourceFoundException.class)
|
||||||
// @ExceptionHandler(NoResourceFoundException.class)
|
private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
|
||||||
// private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
|
log.warn("[noResourceFoundExceptionHandler]", ex);
|
||||||
// log.warn("[noResourceFoundExceptionHandler]", ex);
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
|
||||||
// return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 SpringMVC 请求方法不正确
|
* 处理 SpringMVC 请求方法不正确
|
||||||
|
@ -288,7 +288,7 @@ public class GlobalExceptionHandler {
|
||||||
// 初始化 errorLog
|
// 初始化 errorLog
|
||||||
buildExceptionLog(errorLog, req, e);
|
buildExceptionLog(errorLog, req, e);
|
||||||
// 执行插入 errorLog
|
// 执行插入 errorLog
|
||||||
apiErrorLogFrameworkService.createApiErrorLog(errorLog);
|
apiErrorLogApi.createApiErrorLogAsync(errorLog);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th);
|
log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th);
|
||||||
}
|
}
|
||||||
|
@ -315,12 +315,12 @@ public class GlobalExceptionHandler {
|
||||||
errorLog.setApplicationName(applicationName);
|
errorLog.setApplicationName(applicationName);
|
||||||
errorLog.setRequestUrl(request.getRequestURI());
|
errorLog.setRequestUrl(request.getRequestURI());
|
||||||
Map<String, Object> requestParams = MapUtil.<String, Object>builder()
|
Map<String, Object> requestParams = MapUtil.<String, Object>builder()
|
||||||
.put("query", ServletUtils.getParamMap(request))
|
.put("query", JakartaServletUtil.getParamMap(request))
|
||||||
.put("body", ServletUtils.getBody(request)).build();
|
.put("body", JakartaServletUtil.getBody(request)).build();
|
||||||
errorLog.setRequestParams(JsonUtils.toJsonString(requestParams));
|
errorLog.setRequestParams(JsonUtils.toJsonString(requestParams));
|
||||||
errorLog.setRequestMethod(request.getMethod());
|
errorLog.setRequestMethod(request.getMethod());
|
||||||
errorLog.setUserAgent(ServletUtils.getUserAgent(request));
|
errorLog.setUserAgent(ServletUtils.getUserAgent(request));
|
||||||
errorLog.setUserIp(ServletUtils.getClientIP(request));
|
errorLog.setUserIp(JakartaServletUtil.getClientIP(request));
|
||||||
errorLog.setExceptionTime(LocalDateTime.now());
|
errorLog.setExceptionTime(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -70,7 +70,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,9 @@ spring:
|
||||||
embedding:
|
embedding:
|
||||||
transformer:
|
transformer:
|
||||||
onnx:
|
onnx:
|
||||||
model-uri: http://test.yudao.iocoder.cn/model.onnx
|
model-uri: https://raw.gitcode.com/yudaocode/yudao-demo/raw/master/yudao-static/ai/model.onnx
|
||||||
tokenizer:
|
tokenizer:
|
||||||
uri: http://test.yudao.iocoder.cn/tokenizer.json
|
uri: https://raw.gitcode.com/yudaocode/yudao-demo/raw/master/yudao-static/ai/tokenizer.json
|
||||||
qianfan: # 文心一言
|
qianfan: # 文心一言
|
||||||
api-key: x0cuLZ7XsaTCU08vuJWO87Lg
|
api-key: x0cuLZ7XsaTCU08vuJWO87Lg
|
||||||
secret-key: R9mYF9dl9KASgi5RUq0FQt3wRisSnOcK
|
secret-key: R9mYF9dl9KASgi5RUq0FQt3wRisSnOcK
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrat
|
||||||
@Override
|
@Override
|
||||||
public void validateParam(String param) {
|
public void validateParam(String param) {
|
||||||
Set<Long> deptIds = StrUtils.splitToLongSet(param);
|
Set<Long> deptIds = StrUtils.splitToLongSet(param);
|
||||||
deptApi.validateDeptList(deptIds);
|
deptApi.validateDeptList(deptIds).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrat
|
||||||
@Override
|
@Override
|
||||||
public void validateParam(String param) {
|
public void validateParam(String param) {
|
||||||
Set<Long> deptIds = StrUtils.splitToLongSet(param);
|
Set<Long> deptIds = StrUtils.splitToLongSet(param);
|
||||||
deptApi.validateDeptList(deptIds);
|
deptApi.validateDeptList(deptIds).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy {
|
||||||
@Override
|
@Override
|
||||||
public void validateParam(String param) {
|
public void validateParam(String param) {
|
||||||
Set<Long> postIds = StrUtils.splitToLongSet(param);
|
Set<Long> postIds = StrUtils.splitToLongSet(param);
|
||||||
postApi.validPostList(postIds);
|
postApi.validPostList(postIds).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class BpmTaskCandidateRoleStrategy implements BpmTaskCandidateStrategy {
|
||||||
@Override
|
@Override
|
||||||
public void validateParam(String param) {
|
public void validateParam(String param) {
|
||||||
Set<Long> roleIds = StrUtils.splitToLongSet(param);
|
Set<Long> roleIds = StrUtils.splitToLongSet(param);
|
||||||
roleApi.validRoleList(roleIds);
|
roleApi.validRoleList(roleIds).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateParam(String param) {
|
public void validateParam(String param) {
|
||||||
adminUserApi.validateUserList(StrUtils.splitToLongSet(param));
|
adminUserApi.validateUserList(StrUtils.splitToLongSet(param)).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||||
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
||||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||||
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
|
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
|
||||||
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
|
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +47,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||||
templateParams.put("reason", reqDTO.getReason());
|
templateParams.put("reason", reqDTO.getReason());
|
||||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||||
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
|
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
|
||||||
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
|
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)).getCheckedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +58,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||||
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
|
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
|
||||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||||
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(),
|
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(),
|
||||||
BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
|
BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)).getCheckedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProcessInstanceDetailUrl(String taskId) {
|
private String getProcessInstanceDetailUrl(String taskId) {
|
||||||
|
|
|
@ -56,12 +56,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -71,7 +71,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
||||||
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CrmReceivableDO>()
|
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CrmReceivableDO>()
|
||||||
.select("contract_id, SUM(price) AS total_price")
|
.select("contract_id, SUM(price) AS total_price")
|
||||||
.in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过
|
.in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过
|
||||||
CrmAuditStatusEnum.PROCESS, CrmAuditStatusEnum.APPROVE.getStatus())
|
CrmAuditStatusEnum.PROCESS.getStatus(), CrmAuditStatusEnum.APPROVE.getStatus())
|
||||||
.groupBy("contract_id")
|
.groupBy("contract_id")
|
||||||
.in("contract_id", contractIds));
|
.in("contract_id", contractIds));
|
||||||
// 获得金额
|
// 获得金额
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||||
private void validateRelationDataExists(CrmClueSaveReqVO reqVO) {
|
private void validateRelationDataExists(CrmClueSaveReqVO reqVO) {
|
||||||
// 校验负责人
|
// 校验负责人
|
||||||
if (Objects.nonNull(reqVO.getOwnerUserId()) &&
|
if (Objects.nonNull(reqVO.getOwnerUserId()) &&
|
||||||
Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) {
|
Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()).getCheckedData())) {
|
||||||
throw exception(USER_NOT_EXISTS);
|
throw exception(USER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig
|
||||||
* @param deptIds 部门 ids
|
* @param deptIds 部门 ids
|
||||||
*/
|
*/
|
||||||
private void validateUserAndDept(Collection<Long> userIds, Collection<Long> deptIds) {
|
private void validateUserAndDept(Collection<Long> userIds, Collection<Long> deptIds) {
|
||||||
deptApi.validateDeptList(deptIds);
|
deptApi.validateDeptList(deptIds).checkError();
|
||||||
adminUserApi.validateUserList(userIds);
|
adminUserApi.validateUserList(userIds).checkError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -396,7 +396,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
throw exception(CUSTOMER_NOT_EXISTS);
|
throw exception(CUSTOMER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 1.2 校验负责人是否存在
|
// 1.2 校验负责人是否存在
|
||||||
adminUserApi.validateUserList(singletonList(ownerUserId));
|
adminUserApi.validateUserList(singletonList(ownerUserId)).checkError();
|
||||||
// 1.3 校验状态
|
// 1.3 校验状态
|
||||||
customers.forEach(customer -> {
|
customers.forEach(customer -> {
|
||||||
// 校验是否已有负责人
|
// 校验是否已有负责人
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||||
private Long createPermission0(CrmPermissionCreateReqBO createReqBO) {
|
private Long createPermission0(CrmPermissionCreateReqBO createReqBO) {
|
||||||
validatePermissionNotExists(Collections.singletonList(createReqBO));
|
validatePermissionNotExists(Collections.singletonList(createReqBO));
|
||||||
// 1. 校验用户是否存在
|
// 1. 校验用户是否存在
|
||||||
adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId()));
|
adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())).checkError();
|
||||||
// 2. 插入权限
|
// 2. 插入权限
|
||||||
CrmPermissionDO permission = BeanUtils.toBean(createReqBO, CrmPermissionDO.class);
|
CrmPermissionDO permission = BeanUtils.toBean(createReqBO, CrmPermissionDO.class);
|
||||||
permissionMapper.insert(permission);
|
permissionMapper.insert(permission);
|
||||||
|
@ -168,7 +168,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||||
public void createPermissionBatch(List<CrmPermissionCreateReqBO> createReqBOs) {
|
public void createPermissionBatch(List<CrmPermissionCreateReqBO> createReqBOs) {
|
||||||
validatePermissionNotExists(createReqBOs);
|
validatePermissionNotExists(createReqBOs);
|
||||||
// 1. 校验用户是否存在
|
// 1. 校验用户是否存在
|
||||||
adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId));
|
adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)).checkError();
|
||||||
|
|
||||||
// 2. 创建
|
// 2. 创建
|
||||||
List<CrmPermissionDO> permissions = BeanUtils.toBean(createReqBOs, CrmPermissionDO.class);
|
List<CrmPermissionDO> permissions = BeanUtils.toBean(createReqBOs, CrmPermissionDO.class);
|
||||||
|
@ -219,7 +219,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||||
throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName);
|
throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName);
|
||||||
}
|
}
|
||||||
// 1.2 校验新负责人是否存在
|
// 1.2 校验新负责人是否存在
|
||||||
adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId()));
|
adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())).checkError();
|
||||||
|
|
||||||
// 2. 修改新负责人的权限
|
// 2. 修改新负责人的权限
|
||||||
List<CrmPermissionDO> permissions = permissionMapper.selectByBizTypeAndBizId(
|
List<CrmPermissionDO> permissions = permissionMapper.selectByBizTypeAndBizId(
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||||
success = CRM_PRODUCT_CREATE_SUCCESS)
|
success = CRM_PRODUCT_CREATE_SUCCESS)
|
||||||
public Long createProduct(CrmProductSaveReqVO createReqVO) {
|
public Long createProduct(CrmProductSaveReqVO createReqVO) {
|
||||||
// 1. 校验产品
|
// 1. 校验产品
|
||||||
adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId()));
|
adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())).checkError();
|
||||||
validateProductNoDuplicate(null, createReqVO.getNo());
|
validateProductNoDuplicate(null, createReqVO.getNo());
|
||||||
validateProductCategoryExists(createReqVO.getCategoryId());
|
validateProductCategoryExists(createReqVO.getCategoryId());
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -70,7 +70,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -70,7 +70,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@ -21,4 +22,14 @@ public interface ApiAccessLogApi {
|
||||||
@Operation(summary = "创建 API 访问日志")
|
@Operation(summary = "创建 API 访问日志")
|
||||||
CommonResult<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
CommonResult<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【异步】创建 API 访问日志
|
||||||
|
*
|
||||||
|
* @param createDTO 访问日志 DTO
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
default void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
|
||||||
|
createApiAccessLog(createDTO).checkError();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@ -21,4 +22,14 @@ public interface ApiErrorLogApi {
|
||||||
@Operation(summary = "创建 API 异常日志")
|
@Operation(summary = "创建 API 异常日志")
|
||||||
CommonResult<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
CommonResult<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【异步】创建 API 异常日志
|
||||||
|
*
|
||||||
|
* @param createDTO 异常日志 DTO
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
default void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
|
||||||
|
createApiErrorLog(createDTO).checkError();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ public enum CodegenFrontTypeEnum {
|
||||||
|
|
||||||
VUE2(10), // Vue2 Element UI 标准模版
|
VUE2(10), // Vue2 Element UI 标准模版
|
||||||
VUE3(20), // Vue3 Element Plus 标准模版
|
VUE3(20), // Vue3 Element Plus 标准模版
|
||||||
VUE3_SCHEMA(21), // Vue3 Element Plus Schema 模版
|
|
||||||
VUE3_VBEN(30), // Vue3 VBEN 模版
|
VUE3_VBEN(30), // Vue3 VBEN 模版
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||||
* 开启 VirtualStyle 模式
|
* 开启 VirtualStyle 模式
|
||||||
*/
|
*/
|
||||||
private void enableVirtualStyleEndpoint() {
|
private void enableVirtualStyleEndpoint() {
|
||||||
if (StrUtil.containsAll(config.getEndpoint(),
|
if (StrUtil.containsAny(config.getEndpoint(),
|
||||||
S3FileClientConfig.ENDPOINT_TENCENT, // 腾讯云 https://cloud.tencent.com/document/product/436/41284
|
S3FileClientConfig.ENDPOINT_TENCENT, // 腾讯云 https://cloud.tencent.com/document/product/436/41284
|
||||||
S3FileClientConfig.ENDPOINT_VOLCES)) { // 火山云 https://www.volcengine.com/docs/6349/1288493
|
S3FileClientConfig.ENDPOINT_VOLCES)) { // 火山云 https://www.volcengine.com/docs/6349/1288493
|
||||||
client.enableVirtualStyleEndpoint();
|
client.enableVirtualStyleEndpoint();
|
||||||
|
|
|
@ -135,15 +135,6 @@ public class CodegenEngine {
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"),
|
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"),
|
||||||
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
|
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
|
||||||
// Vue3 Schema 模版
|
|
||||||
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"),
|
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
|
|
||||||
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/index.vue"),
|
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
|
|
||||||
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/form.vue"),
|
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
|
|
||||||
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("api/api.ts"),
|
|
||||||
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
|
|
||||||
// Vue3 vben 模版
|
// Vue3 vben 模版
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"),
|
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"),
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
|
||||||
|
@ -496,10 +487,6 @@ public class CodegenEngine {
|
||||||
"src/" + path;
|
"src/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String vue3SchemaTemplatePath(String path) {
|
|
||||||
return "codegen/vue3_schema/" + path + ".vm";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String vue3VbenTemplatePath(String path) {
|
private static String vue3VbenTemplatePath(String path) {
|
||||||
return "codegen/vue3_vben/" + path + ".vm";
|
return "codegen/vue3_vben/" + path + ".vm";
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -75,7 +75,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ yudao:
|
||||||
codegen:
|
codegen:
|
||||||
base-package: cn.iocoder.yudao
|
base-package: cn.iocoder.yudao
|
||||||
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
||||||
front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
||||||
tenant: # 多租户相关配置项
|
tenant: # 多租户相关配置项
|
||||||
enable: true
|
enable: true
|
||||||
ignore-urls:
|
ignore-urls:
|
||||||
|
|
|
@ -286,6 +286,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validate${subSimpleClassName}Exists(${subClassNameVar}.getId());
|
validate${subSimpleClassName}Exists(${subClassNameVar}.getId());
|
||||||
// 更新
|
// 更新
|
||||||
|
${subClassNameVar}.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
|
||||||
${subClassNameVars.get($index)}Mapper.updateById(${subClassNameVar});
|
${subClassNameVars.get($index)}Mapper.updateById(${subClassNameVar});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,11 @@
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.value"
|
:label="dict.label"
|
||||||
>
|
:value="dict.value"
|
||||||
{{ dict.label }}
|
/>
|
||||||
</el-checkbox>
|
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox label="请选择字典生成" />
|
||||||
#end
|
#end
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -85,7 +84,7 @@
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio value="1">请选择字典生成</el-radio>
|
||||||
#end
|
#end
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
@ -92,12 +92,11 @@
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.value"
|
:label="dict.label"
|
||||||
>
|
:value="dict.value"
|
||||||
{{ dict.label }}
|
/>
|
||||||
</el-checkbox>
|
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox label="请选择字典生成" />
|
||||||
#end
|
#end
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -117,7 +116,7 @@
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio value="1">请选择字典生成</el-radio>
|
||||||
#end
|
#end
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -219,12 +218,11 @@
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.value"
|
:label="dict.label"
|
||||||
>
|
:value="dict.value"
|
||||||
{{ dict.label }}
|
/>
|
||||||
</el-checkbox>
|
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox label="请选择字典生成" />
|
||||||
#end
|
#end
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -240,7 +238,7 @@
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio value="1">请选择字典生成</el-radio>
|
||||||
#end
|
#end
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
@ -75,12 +75,11 @@
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.value"
|
:label="dict.label"
|
||||||
>
|
:value="dict.value"
|
||||||
{{ dict.label }}
|
/>
|
||||||
</el-checkbox>
|
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
<el-checkbox label="请选择字典生成" />
|
||||||
#end
|
#end
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -96,7 +95,7 @@
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio value="1">请选择字典生成</el-radio>
|
||||||
#end
|
#end
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
import request from '@/config/axios'
|
|
||||||
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
|
||||||
|
|
||||||
export interface ${simpleClassName}VO {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
|
||||||
${column.javaField}: number
|
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime")
|
|
||||||
${column.javaField}: Date
|
|
||||||
#else
|
|
||||||
${column.javaField}: ${column.javaType.toLowerCase()}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询${table.classComment}列表
|
|
||||||
export const get${simpleClassName}Page = async (params) => {
|
|
||||||
return await request.get({ url: '${baseURL}/page', params })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询${table.classComment}详情
|
|
||||||
export const get${simpleClassName} = async (id: number) => {
|
|
||||||
return await request.get({ url: '${baseURL}/get?id=' + id })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增${table.classComment}
|
|
||||||
export const create${simpleClassName} = async (data: ${simpleClassName}VO) => {
|
|
||||||
return await request.post({ url: '${baseURL}/create', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改${table.classComment}
|
|
||||||
export const update${simpleClassName} = async (data: ${simpleClassName}VO) => {
|
|
||||||
return await request.put({ url: '${baseURL}/update', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除${table.classComment}
|
|
||||||
export const delete${simpleClassName} = async (id: number) => {
|
|
||||||
return await request.delete({ url: '${baseURL}/delete?id=' + id })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出${table.classComment} Excel
|
|
||||||
export const export${simpleClassName}Api = async (params) => {
|
|
||||||
return await request.download({ url: '${baseURL}/export-excel', params })
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
|
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
|
||||||
|
|
||||||
// 表单校验
|
|
||||||
export const rules = reactive({
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
$column.javaField: [required],
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
})
|
|
||||||
|
|
||||||
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
|
|
||||||
const crudSchemas = reactive<CrudSchema[]>([
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($javaType = $column.javaType)
|
|
||||||
{
|
|
||||||
label: '${column.columnComment}',
|
|
||||||
field: '${column.javaField}',
|
|
||||||
## ========= 字典部分 =========
|
|
||||||
#if ("" != $dictType)## 有数据字典
|
|
||||||
dictType: DICT_TYPE.$dictType.toUpperCase(),
|
|
||||||
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
|
||||||
dictClass: 'number',
|
|
||||||
#elseif ($javaType == "String")
|
|
||||||
dictClass: 'string',
|
|
||||||
#elseif ($javaType == "Boolean")
|
|
||||||
dictClass: 'boolean',
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
## ========= Table 表格部分 =========
|
|
||||||
#if (!$column.listOperationResult)
|
|
||||||
isTable: false,
|
|
||||||
#else
|
|
||||||
#if ($column.htmlType == "datetime")
|
|
||||||
formatter: dateFormatter,
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
## ========= Search 表格部分 =========
|
|
||||||
#if ($column.listOperation)
|
|
||||||
isSearch: true,
|
|
||||||
#if ($column.htmlType == "datetime")
|
|
||||||
search: {
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
||||||
type: 'daterange',
|
|
||||||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
## ========= Form 表单部分 =========
|
|
||||||
#if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey)
|
|
||||||
isForm: false,
|
|
||||||
#else
|
|
||||||
#if($column.htmlType == "imageUpload")## 图片上传
|
|
||||||
form: {
|
|
||||||
component: 'UploadImg'
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
|
||||||
form: {
|
|
||||||
component: 'UploadFile'
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
|
||||||
form: {
|
|
||||||
component: 'Editor',
|
|
||||||
componentProps: {
|
|
||||||
valueHtml: '',
|
|
||||||
height: 200
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
|
||||||
form: {
|
|
||||||
component: 'SelectV2'
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
|
||||||
form: {
|
|
||||||
component: 'Checkbox'
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "radio")## 单选框
|
|
||||||
form: {
|
|
||||||
component: 'Radio'
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "datetime")## 时间框
|
|
||||||
form: {
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
type: 'datetime',
|
|
||||||
valueFormat: 'x'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "textarea")## 文本框
|
|
||||||
form: {
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
type: 'textarea',
|
|
||||||
rows: 4
|
|
||||||
},
|
|
||||||
colProps: {
|
|
||||||
span: 24
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框
|
|
||||||
form: {
|
|
||||||
component: 'InputNumber',
|
|
||||||
value: 0
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
label: '操作',
|
|
||||||
field: 'action',
|
|
||||||
isForm: false
|
|
||||||
}
|
|
||||||
])
|
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|
|
@ -1,65 +0,0 @@
|
||||||
<template>
|
|
||||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
|
||||||
<Form ref="formRef" :schema="allSchemas.formSchema" :rules="rules" v-loading="formLoading" />
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
||||||
</template>
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
|
||||||
import { rules, allSchemas } from './${classNameVar}.data'
|
|
||||||
const { t } = useI18n() // 国际化
|
|
||||||
const message = useMessage() // 消息弹窗
|
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
||||||
const dialogTitle = ref('') // 弹窗的标题
|
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
||||||
const formRef = ref() // 表单 Ref
|
|
||||||
|
|
||||||
/** 打开弹窗 */
|
|
||||||
const open = async (type: string, id?: number) => {
|
|
||||||
dialogVisible.value = true
|
|
||||||
dialogTitle.value = t('action.' + type)
|
|
||||||
formType.value = type
|
|
||||||
// 修改时,设置数据
|
|
||||||
if (id) {
|
|
||||||
formLoading.value = true
|
|
||||||
try {
|
|
||||||
const data = await ${simpleClassName}Api.get${simpleClassName}(id)
|
|
||||||
formRef.value.setValues(data)
|
|
||||||
} finally {
|
|
||||||
formLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
||||||
|
|
||||||
/** 提交表单 */
|
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
||||||
const submitForm = async () => {
|
|
||||||
// 校验表单
|
|
||||||
if (!formRef) return
|
|
||||||
const valid = await formRef.value.getElFormRef().validate()
|
|
||||||
if (!valid) return
|
|
||||||
// 提交请求
|
|
||||||
formLoading.value = true
|
|
||||||
try {
|
|
||||||
const data = formRef.value.formModel as ${simpleClassName}Api.${simpleClassName}VO
|
|
||||||
if (formType.value === 'create') {
|
|
||||||
await ${simpleClassName}Api.create${simpleClassName}(data)
|
|
||||||
message.success(t('common.createSuccess'))
|
|
||||||
} else {
|
|
||||||
await ${simpleClassName}Api.update${simpleClassName}(data)
|
|
||||||
message.success(t('common.updateSuccess'))
|
|
||||||
}
|
|
||||||
dialogVisible.value = false
|
|
||||||
// 发送操作成功的事件
|
|
||||||
emit('success')
|
|
||||||
} finally {
|
|
||||||
formLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
|
@ -1,85 +0,0 @@
|
||||||
<template>
|
|
||||||
<!-- 搜索工作栏 -->
|
|
||||||
<ContentWrap>
|
|
||||||
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
|
|
||||||
<!-- 新增等操作按钮 -->
|
|
||||||
<template #actionMore>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
@click="openForm('create')"
|
|
||||||
v-hasPermi="['${permissionPrefix}:create']"
|
|
||||||
>
|
|
||||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</Search>
|
|
||||||
</ContentWrap>
|
|
||||||
|
|
||||||
<!-- 列表 -->
|
|
||||||
<ContentWrap>
|
|
||||||
<Table
|
|
||||||
:columns="allSchemas.tableColumns"
|
|
||||||
:data="tableObject.tableList"
|
|
||||||
:loading="tableObject.loading"
|
|
||||||
:pagination="{
|
|
||||||
total: tableObject.total
|
|
||||||
}"
|
|
||||||
v-model:pageSize="tableObject.pageSize"
|
|
||||||
v-model:currentPage="tableObject.currentPage"
|
|
||||||
>
|
|
||||||
<template #action="{ row }">
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
@click="openForm('update', row.id)"
|
|
||||||
v-hasPermi="['${permissionPrefix}:update']"
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="danger"
|
|
||||||
v-hasPermi="['${permissionPrefix}:delete']"
|
|
||||||
@click="handleDelete(row.id)"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</Table>
|
|
||||||
</ContentWrap>
|
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
|
||||||
<${simpleClassName}Form ref="formRef" @success="getList" />
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts" name="${table.className}">
|
|
||||||
import { allSchemas } from './${classNameVar}.data'
|
|
||||||
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
|
|
||||||
import ${simpleClassName}Form from './${simpleClassName}Form.vue'
|
|
||||||
|
|
||||||
// tableObject:表格的属性对象,可获得分页大小、条数等属性
|
|
||||||
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
|
|
||||||
// 详细可见:https://doc.iocoder.cn/vue3/crud-schema/
|
|
||||||
const { tableObject, tableMethods } = useTable({
|
|
||||||
getListApi: ${simpleClassName}Api.get${simpleClassName}Page, // 分页接口
|
|
||||||
delListApi: ${simpleClassName}Api.delete${simpleClassName} // 删除接口
|
|
||||||
})
|
|
||||||
// 获得表格的各种操作
|
|
||||||
const { getList, setSearchParams } = tableMethods
|
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
|
||||||
const formRef = ref()
|
|
||||||
const openForm = (type: string, id?: number) => {
|
|
||||||
formRef.value.open(type, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
const handleDelete = (id: number) => {
|
|
||||||
tableMethods.delList(id, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 初始化 **/
|
|
||||||
onMounted(() => {
|
|
||||||
getList()
|
|
||||||
})
|
|
||||||
</script>
|
|
|
@ -42,9 +42,17 @@ export const searchFormSchema: FormSchema[] = [
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.listOperation)
|
#if ($column.listOperation)
|
||||||
#set ($dictType=$column.dictType)
|
#set ($dictType=$column.dictType)
|
||||||
|
#set ($javaType = $column.javaType)
|
||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#set ($comment=$column.columnComment)
|
#set ($comment=$column.columnComment)
|
||||||
|
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
||||||
|
#set ($dictMethod = "number")
|
||||||
|
#elseif ($javaType == "String")
|
||||||
|
#set ($dictMethod = "string")
|
||||||
|
#elseif ($javaType == "Boolean")
|
||||||
|
#set ($dictMethod = "boolean")
|
||||||
|
#end
|
||||||
{
|
{
|
||||||
label: '${comment}',
|
label: '${comment}',
|
||||||
field: '${javaField}',
|
field: '${javaField}',
|
||||||
|
@ -54,16 +62,16 @@ export const searchFormSchema: FormSchema[] = [
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else## 未设置 dictType 数据字典的情况
|
#else## 未设置 dictType 数据字典的情况
|
||||||
options: [],
|
options: [],
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
#elseif ($column.htmlType == "radio")
|
#elseif ($column.htmlType == "radio")
|
||||||
component: 'Radio',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else## 未设置 dictType 数据字典的情况
|
#else## 未设置 dictType 数据字典的情况
|
||||||
options: [],
|
options: [],
|
||||||
#end
|
#end
|
||||||
|
@ -87,9 +95,17 @@ export const createFormSchema: FormSchema[] = [
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.createOperation)
|
#if ($column.createOperation)
|
||||||
#set ($dictType = $column.dictType)
|
#set ($dictType = $column.dictType)
|
||||||
|
#set ($javaType = $column.javaType)
|
||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#set ($comment = $column.columnComment)
|
#set ($comment = $column.columnComment)
|
||||||
|
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
||||||
|
#set ($dictMethod = "number")
|
||||||
|
#elseif ($javaType == "String")
|
||||||
|
#set ($dictMethod = "string")
|
||||||
|
#elseif ($javaType == "Boolean")
|
||||||
|
#set ($dictMethod = "boolean")
|
||||||
|
#end
|
||||||
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
||||||
{
|
{
|
||||||
label: '${comment}',
|
label: '${comment}',
|
||||||
|
@ -117,7 +133,7 @@ export const createFormSchema: FormSchema[] = [
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
@ -126,7 +142,7 @@ export const createFormSchema: FormSchema[] = [
|
||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
@ -135,7 +151,7 @@ export const createFormSchema: FormSchema[] = [
|
||||||
component: 'RadioButtonGroup',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
@ -166,9 +182,17 @@ export const updateFormSchema: FormSchema[] = [
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.updateOperation)
|
#if ($column.updateOperation)
|
||||||
#set ($dictType = $column.dictType)
|
#set ($dictType = $column.dictType)
|
||||||
|
#set ($javaType = $column.javaType)
|
||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#set ($comment = $column.columnComment)
|
#set ($comment = $column.columnComment)
|
||||||
|
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
||||||
|
#set ($dictMethod = "number")
|
||||||
|
#elseif ($javaType == "String")
|
||||||
|
#set ($dictMethod = "string")
|
||||||
|
#elseif ($javaType == "Boolean")
|
||||||
|
#set ($dictMethod = "boolean")
|
||||||
|
#end
|
||||||
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
||||||
{
|
{
|
||||||
label: '${comment}',
|
label: '${comment}',
|
||||||
|
@ -196,7 +220,7 @@ export const updateFormSchema: FormSchema[] = [
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
@ -205,7 +229,7 @@ export const updateFormSchema: FormSchema[] = [
|
||||||
component: 'Checkbox',
|
component: 'Checkbox',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
@ -214,7 +238,7 @@ export const updateFormSchema: FormSchema[] = [
|
||||||
component: 'RadioButtonGroup',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
options:[],
|
options:[],
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.api.spu.dto;
|
||||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
// TODO @LeeYan9: ProductSpuRespDTO
|
// TODO @LeeYan9: ProductSpuRespDTO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +78,13 @@ public class ProductSpuRespDTO {
|
||||||
|
|
||||||
// ========== 物流相关字段 =========
|
// ========== 物流相关字段 =========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配送方式数组
|
||||||
|
*
|
||||||
|
* 对应 DeliveryTypeEnum 枚举
|
||||||
|
*/
|
||||||
|
private List<Integer> deliveryTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物流配置模板编号
|
* 物流配置模板编号
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
|
||||||
// 校验 SPU
|
// 校验 SPU
|
||||||
ProductSpuDO spu = validateSpu(sku.getSpuId());
|
ProductSpuDO spu = validateSpu(sku.getSpuId());
|
||||||
// 校验评论
|
// 校验评论
|
||||||
validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId());
|
validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderItemId());
|
||||||
// 获取用户详细信息
|
// 获取用户详细信息
|
||||||
MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()).getCheckedData();
|
MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()).getCheckedData();
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -71,7 +71,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.api.combination;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
|
import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -43,13 +44,13 @@ public interface CombinationRecordApi {
|
||||||
CommonResult<CombinationRecordCreateRespDTO> createCombinationRecord(
|
CommonResult<CombinationRecordCreateRespDTO> createCombinationRecord(
|
||||||
@RequestBody @Valid CombinationRecordCreateReqDTO reqDTO);
|
@RequestBody @Valid CombinationRecordCreateReqDTO reqDTO);
|
||||||
|
|
||||||
@GetMapping(PREFIX + "/is-success")
|
@GetMapping(PREFIX + "/get-by-order-id")
|
||||||
@Operation(summary = "查询拼团记录是否成功")
|
@Operation(summary = "基于订单编号,查询拼团记录")
|
||||||
@Parameters({
|
@Parameters({
|
||||||
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
|
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
|
||||||
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
|
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
|
||||||
})
|
})
|
||||||
CommonResult<Boolean> isCombinationRecordSuccess(@RequestParam("userId") Long userId,
|
CommonResult<CombinationRecordRespDTO> getCombinationRecordByOrderId(@RequestParam("userId") Long userId,
|
||||||
@RequestParam("orderId") Long orderId);
|
@RequestParam("orderId") Long orderId);
|
||||||
|
|
||||||
@GetMapping(PREFIX + "/validate-join")
|
@GetMapping(PREFIX + "/validate-join")
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团记录的创建 Request DTO
|
* 拼团记录的创建 Request DTO
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团记录 Response DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CombinationRecordRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号,主键自增
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团活动编号
|
||||||
|
*
|
||||||
|
* 关联 CombinationActivityDO 的 id 字段
|
||||||
|
*/
|
||||||
|
private Long activityId;
|
||||||
|
/**
|
||||||
|
* 拼团商品单价
|
||||||
|
*
|
||||||
|
* 冗余 CombinationProductDO 的 combinationPrice 字段
|
||||||
|
*/
|
||||||
|
private Integer combinationPrice;
|
||||||
|
/**
|
||||||
|
* SPU 编号
|
||||||
|
*/
|
||||||
|
private Long spuId;
|
||||||
|
/**
|
||||||
|
* 商品名字
|
||||||
|
*/
|
||||||
|
private String spuName;
|
||||||
|
/**
|
||||||
|
* 商品图片
|
||||||
|
*/
|
||||||
|
private String picUrl;
|
||||||
|
/**
|
||||||
|
* SKU 编号
|
||||||
|
*/
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* 购买的商品数量
|
||||||
|
*/
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
private String nickname;
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团长编号
|
||||||
|
*/
|
||||||
|
private Long headId;
|
||||||
|
/**
|
||||||
|
* 开团状态
|
||||||
|
*
|
||||||
|
* 关联 {@link CombinationRecordStatusEnum}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 订单编号
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 开团需要人数
|
||||||
|
*
|
||||||
|
* 关联 CombinationActivityDO 的 userSize 字段
|
||||||
|
*/
|
||||||
|
private Integer userSize;
|
||||||
|
/**
|
||||||
|
* 已加入拼团人数
|
||||||
|
*/
|
||||||
|
private Integer userCount;
|
||||||
|
/**
|
||||||
|
* 是否虚拟成团
|
||||||
|
*/
|
||||||
|
private Boolean virtualGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过期时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime expireTime;
|
||||||
|
/**
|
||||||
|
* 开始时间 (订单付款后开始的时间)
|
||||||
|
*/
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间(成团时间/失败时间)
|
||||||
|
*/
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
}
|
|
@ -3,19 +3,17 @@ package cn.iocoder.yudao.module.promotion.api.coupon;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
|
import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 优惠劵")
|
@Tag(name = "RPC 服务 - 优惠劵")
|
||||||
|
@ -23,16 +21,36 @@ public interface CouponApi {
|
||||||
|
|
||||||
String PREFIX = ApiConstants.PREFIX + "/coupon";
|
String PREFIX = ApiConstants.PREFIX + "/coupon";
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/list-by-user-id")
|
||||||
|
@Operation(summary = "获得用户的优惠劵列表")
|
||||||
|
CommonResult<List<CouponRespDTO>> getCouponListByUserId(@RequestParam("userId") Long userId,
|
||||||
|
@RequestParam("status") Integer status);
|
||||||
|
|
||||||
@PutMapping(PREFIX + "/use")
|
@PutMapping(PREFIX + "/use")
|
||||||
@Operation(summary = "使用优惠劵")
|
@Operation(summary = "使用优惠劵")
|
||||||
CommonResult<Boolean> useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO);
|
CommonResult<Boolean> useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO);
|
||||||
|
|
||||||
@PutMapping(PREFIX + "/return-used")
|
@PutMapping(PREFIX + "/return-used")
|
||||||
|
@Operation(summary = "退还已使用的优惠券")
|
||||||
@Parameter(name = "id", description = "优惠券编号", required = true, example = "1")
|
@Parameter(name = "id", description = "优惠券编号", required = true, example = "1")
|
||||||
CommonResult<Boolean> returnUsedCoupon(@RequestParam("id") Long id);
|
CommonResult<Boolean> returnUsedCoupon(@RequestParam("id") Long id);
|
||||||
|
|
||||||
@GetMapping(PREFIX + "/validate")
|
@PostMapping(PREFIX + "/take-by-admin")
|
||||||
@Operation(summary = "校验优惠劵")
|
@Operation(summary = "【管理员】给指定用户批量发送优惠券") // 返回:优惠券编号列表
|
||||||
CommonResult<CouponRespDTO> validateCoupon(@Valid @SpringQueryMap CouponValidReqDTO validReqDTO);
|
@Parameters({
|
||||||
|
@Parameter(name = "giveCoupons", description = "key: 优惠劵模版编号,value:对应的数量", required = true),
|
||||||
|
@Parameter(name = "userId", description = "用户编号", required = true)
|
||||||
|
})
|
||||||
|
CommonResult<List<Long>> takeCouponsByAdmin(@RequestParam("giveCoupons") Map<Long, Integer> giveCoupons,
|
||||||
|
@RequestParam("userId") Long userId);
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/invalidate-by-admin")
|
||||||
|
@Operation(summary = "【管理员】作废指定用户的指定优惠劵")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "giveCouponIds", description = "赠送的优惠券编号", required = true),
|
||||||
|
@Parameter(name = "userId", description = "用户编号", required = true)
|
||||||
|
})
|
||||||
|
CommonResult<Boolean> invalidateCouponsByAdmin(@RequestParam("赠送的优惠券编号") List<Long> giveCouponIds,
|
||||||
|
@RequestParam("用户编号") Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package cn.iocoder.yudao.module.promotion.api.reward.dto;
|
package cn.iocoder.yudao.module.promotion.api.reward.dto;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 满减送活动的匹配 Response DTO
|
* 满减送活动的匹配 Response DTO
|
||||||
|
@ -21,28 +26,50 @@ public class RewardActivityMatchRespDTO {
|
||||||
* 活动标题
|
* 活动标题
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link CommonStatusEnum}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
/**
|
/**
|
||||||
* 条件类型
|
* 条件类型
|
||||||
*
|
*
|
||||||
* 枚举 {@link PromotionConditionTypeEnum}
|
* 枚举 {@link PromotionConditionTypeEnum}
|
||||||
*/
|
*/
|
||||||
private Integer conditionType;
|
private Integer conditionType;
|
||||||
|
/**
|
||||||
|
* 商品范围
|
||||||
|
*
|
||||||
|
* 枚举 {@link PromotionProductScopeEnum}
|
||||||
|
*/
|
||||||
|
private Integer productScope;
|
||||||
|
/**
|
||||||
|
* 商品 SPU 编号的数组
|
||||||
|
*/
|
||||||
|
private List<Long> productScopeValues;
|
||||||
/**
|
/**
|
||||||
* 优惠规则的数组
|
* 优惠规则的数组
|
||||||
*/
|
*/
|
||||||
private List<Rule> rules;
|
private List<Rule> rules;
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品 SPU 编号的数组
|
|
||||||
*/
|
|
||||||
private List<Long> spuIds;
|
|
||||||
|
|
||||||
// TODO 芋艿:后面 RewardActivityRespDTO 有了之后,Rule 可以放过去
|
|
||||||
/**
|
/**
|
||||||
* 优惠规则
|
* 优惠规则
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public static class Rule {
|
public static class Rule implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠门槛
|
* 优惠门槛
|
||||||
|
@ -64,13 +91,14 @@ public class RewardActivityMatchRespDTO {
|
||||||
*/
|
*/
|
||||||
private Integer point;
|
private Integer point;
|
||||||
/**
|
/**
|
||||||
* 赠送的优惠劵编号的数组
|
* 赠送的优惠劵
|
||||||
|
*
|
||||||
|
* key: 优惠劵模版编号
|
||||||
|
* value:对应的优惠券数量
|
||||||
|
*
|
||||||
|
* 目的:用于订单支付后赠送优惠券
|
||||||
*/
|
*/
|
||||||
private List<Long> couponIds;
|
private Map<Long, Integer> giveCouponTemplateCounts;
|
||||||
/**
|
|
||||||
* 赠送的优惠券数量的数组
|
|
||||||
*/
|
|
||||||
private List<Integer> couponCounts;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1_013_002_000, "Banner 不存在");
|
ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1_013_002_000, "Banner 不存在");
|
||||||
|
|
||||||
// ========== Coupon 相关 1-013-003-000 ============
|
// ========== Coupon 相关 1-013-003-000 ============
|
||||||
ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1_013_003_000, "优惠劵没有可使用的商品!");
|
|
||||||
ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1_013_003_001, "所结算的商品中未满足使用的金额");
|
|
||||||
|
|
||||||
// ========== 优惠劵模板 1-013-004-000 ==========
|
// ========== 优惠劵模板 1-013-004-000 ==========
|
||||||
ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_004_000, "优惠劵模板不存在");
|
ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_004_000, "优惠劵模板不存在");
|
||||||
|
@ -44,7 +42,8 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改");
|
ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改");
|
||||||
ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除");
|
ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除");
|
||||||
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭");
|
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭");
|
||||||
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1_013_006_005, "满减送活动已结束,不能关闭");
|
ErrorCode REWARD_ACTIVITY_SCOPE_ALL_EXISTS = new ErrorCode(1_013_006_005, "已存在商品范围为全场的满减送活动");
|
||||||
|
ErrorCode REWARD_ACTIVITY_SCOPE_CATEGORY_EXISTS = new ErrorCode(1_013_006_006, "存在商品类型参加了其它满减送活动");
|
||||||
|
|
||||||
// ========== TODO 空着 1-013-007-000 ============
|
// ========== TODO 空着 1-013-007-000 ============
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 营销的商品范围枚举
|
* 营销的商品范围枚举
|
||||||
|
@ -15,10 +16,9 @@ import java.util.Arrays;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum PromotionProductScopeEnum implements IntArrayValuable {
|
public enum PromotionProductScopeEnum implements IntArrayValuable {
|
||||||
|
|
||||||
ALL(1, "通用券"), // 全部商品
|
ALL(1, "全部商品"),
|
||||||
SPU(2, "商品券"), // 指定商品
|
SPU(2, "指定商品"),
|
||||||
CATEGORY(3, "品类券"), // 指定品类
|
CATEGORY(3, "指定品类");
|
||||||
;
|
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
|
||||||
|
|
||||||
|
@ -36,4 +36,16 @@ public enum PromotionProductScopeEnum implements IntArrayValuable {
|
||||||
return ARRAYS;
|
return ARRAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAll(Integer scope) {
|
||||||
|
return Objects.equals(scope, ALL.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpu(Integer scope) {
|
||||||
|
return Objects.equals(scope, SPU.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCategory(Integer scope) {
|
||||||
|
return Objects.equals(scope, CATEGORY.scope);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,7 @@ public enum CouponStatusEnum implements IntArrayValuable {
|
||||||
|
|
||||||
UNUSED(1, "未使用"),
|
UNUSED(1, "未使用"),
|
||||||
USED(2, "已使用"),
|
USED(2, "已使用"),
|
||||||
EXPIRE(3, "已过期"),
|
EXPIRE(3, "已过期");
|
||||||
;
|
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray();
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package cn.iocoder.yudao.module.promotion.api.combination;
|
package cn.iocoder.yudao.module.promotion.api.combination;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
|
||||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团活动 API 实现类
|
* 拼团活动 API 实现类
|
||||||
|
@ -41,12 +39,9 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<Boolean> isCombinationRecordSuccess(Long userId, Long orderId) {
|
public CommonResult<CombinationRecordRespDTO> getCombinationRecordByOrderId(Long userId, Long orderId) {
|
||||||
CombinationRecordDO record = combinationRecordService.getCombinationRecord(userId, orderId);
|
CombinationRecordDO record = combinationRecordService.getCombinationRecord(userId, orderId);
|
||||||
if (record == null) {
|
return success(BeanUtils.toBean(record, CombinationRecordRespDTO.class));
|
||||||
throw exception(COMBINATION_RECORD_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
return success(CombinationRecordStatusEnum.isSuccess(record.getStatus()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,16 +2,16 @@ package cn.iocoder.yudao.module.promotion.api.coupon;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ public class CouponApiImpl implements CouponApi {
|
||||||
@Resource
|
@Resource
|
||||||
private CouponService couponService;
|
private CouponService couponService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<CouponRespDTO>> getCouponListByUserId(Long userId, Integer status) {
|
||||||
|
return success(BeanUtils.toBean(couponService.getCouponList(userId, status), CouponRespDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<Boolean> useCoupon(CouponUseReqDTO useReqDTO) {
|
public CommonResult<Boolean> useCoupon(CouponUseReqDTO useReqDTO) {
|
||||||
couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), useReqDTO.getOrderId());
|
couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), useReqDTO.getOrderId());
|
||||||
|
@ -40,9 +45,14 @@ public class CouponApiImpl implements CouponApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<CouponRespDTO> validateCoupon(CouponValidReqDTO validReqDTO) {
|
public CommonResult<List<Long>> takeCouponsByAdmin(Map<Long, Integer> giveCoupons, Long userId) {
|
||||||
CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId());
|
return success(couponService.takeCouponsByAdmin(giveCoupons, userId));
|
||||||
return success(CouponConvert.INSTANCE.convert(coupon));
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<Boolean> invalidateCouponsByAdmin(List<Long> giveCouponIds, Long userId) {
|
||||||
|
couponService.invalidateCouponsByAdmin(giveCouponIds, userId);
|
||||||
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.promotion.controller.admin.combination;
|
package cn.iocoder.yudao.module.promotion.controller.admin.combination;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
@ -16,18 +17,20 @@ import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordSe
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import java.util.Collections;
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.hutool.core.collection.CollectionUtil.newArrayList;
|
import static cn.hutool.core.collection.CollectionUtil.newArrayList;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 拼团活动")
|
@Tag(name = "管理后台 - 拼团活动")
|
||||||
|
@ -87,6 +90,23 @@ public class CombinationActivityController {
|
||||||
return success(CombinationActivityConvert.INSTANCE.convert(activity, products));
|
return success(CombinationActivityConvert.INSTANCE.convert(activity, products));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-by-ids")
|
||||||
|
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
||||||
|
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||||
|
public CommonResult<List<CombinationActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||||
|
// 1. 获得开启的活动列表
|
||||||
|
List<CombinationActivityDO> activityList = combinationActivityService.getCombinationActivityListByIds(ids);
|
||||||
|
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||||
|
if (CollUtil.isEmpty(activityList)) {
|
||||||
|
return success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
// 2. 拼接返回
|
||||||
|
List<CombinationProductDO> productList = combinationActivityService.getCombinationProductListByActivityIds(
|
||||||
|
convertList(activityList, CombinationActivityDO::getId));
|
||||||
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)).getCheckedData();
|
||||||
|
return success(CombinationActivityConvert.INSTANCE.convertList(activityList, productList, spuList));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得拼团活动分页")
|
@Operation(summary = "获得拼团活动分页")
|
||||||
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')")
|
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')")
|
||||||
|
|
|
@ -27,4 +27,14 @@ public class CombinationActivityRespVO extends CombinationActivityBaseVO {
|
||||||
@Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private List<CombinationProductRespVO> products;
|
private List<CombinationProductRespVO> products;
|
||||||
|
|
||||||
|
@Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "一个白菜")
|
||||||
|
private String spuName; // 从 SPU 的 name 读取
|
||||||
|
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096")
|
||||||
|
private String picUrl; // 从 SPU 的 picUrl 读取
|
||||||
|
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
|
private Integer marketPrice; // 从 SPU 的 marketPrice 读取
|
||||||
|
|
||||||
|
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
|
private Integer combinationPrice; // 从 products 获取最小 price 读取
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.reward;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -69,7 +69,7 @@ public class RewardActivityController {
|
||||||
@PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')")
|
@PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')")
|
||||||
public CommonResult<RewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
|
public CommonResult<RewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
|
||||||
RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
|
RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
|
||||||
return success(RewardActivityConvert.INSTANCE.convert(rewardActivity));
|
return success(BeanUtils.toBean(rewardActivity, RewardActivityRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
@ -77,7 +77,7 @@ public class RewardActivityController {
|
||||||
@PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')")
|
@PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')")
|
||||||
public CommonResult<PageResult<RewardActivityRespVO>> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) {
|
public CommonResult<PageResult<RewardActivityRespVO>> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) {
|
||||||
PageResult<RewardActivityDO> pageResult = rewardActivityService.getRewardActivityPage(pageVO);
|
PageResult<RewardActivityDO> pageResult = rewardActivityService.getRewardActivityPage(pageVO);
|
||||||
return success(RewardActivityConvert.INSTANCE.convertPage(pageResult));
|
return success(BeanUtils.toBean(pageResult, RewardActivityRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.AssertTrue;
|
import javax.validation.constraints.AssertTrue;
|
||||||
|
@ -16,13 +15,13 @@ import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RewardActivityBaseVO {
|
public class RewardActivityBaseVO {
|
||||||
|
|
||||||
|
@ -32,12 +31,10 @@ public class RewardActivityBaseVO {
|
||||||
|
|
||||||
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "开始时间不能为空")
|
@NotNull(message = "开始时间不能为空")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime startTime;
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "结束时间不能为空")
|
@NotNull(message = "结束时间不能为空")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
@Future(message = "结束时间必须大于当前时间")
|
@Future(message = "结束时间必须大于当前时间")
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ -54,8 +51,8 @@ public class RewardActivityBaseVO {
|
||||||
@InEnum(value = PromotionProductScopeEnum.class, message = "商品范围必须是 {value}")
|
@InEnum(value = PromotionProductScopeEnum.class, message = "商品范围必须是 {value}")
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
|
@Schema(description = "商品范围编号的数组", example = "[1, 3]")
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠规则的数组
|
* 优惠规则的数组
|
||||||
|
@ -76,24 +73,28 @@ public class RewardActivityBaseVO {
|
||||||
private Integer discountPrice;
|
private Integer discountPrice;
|
||||||
|
|
||||||
@Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
|
@NotNull(message = "规则是否包邮不能为空")
|
||||||
private Boolean freeDelivery;
|
private Boolean freeDelivery;
|
||||||
|
|
||||||
@Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
@Min(value = 1L, message = "赠送的积分必须大于等于 1")
|
|
||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
@Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3")
|
@Schema(description = "赠送的优惠劵编号的数组")
|
||||||
private List<Long> couponIds;
|
private Map<Long, Integer> giveCouponTemplateCounts;
|
||||||
|
|
||||||
@Schema(description = "赠送的优惠券数量的数组", example = "1,2,3")
|
@AssertTrue(message = "赠送的积分不能小于 0")
|
||||||
private List<Integer> couponCounts;
|
|
||||||
|
|
||||||
@AssertTrue(message = "优惠劵和数量必须一一对应")
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isCouponCountsValid() {
|
public boolean isPointValid() {
|
||||||
return CollUtil.size(couponCounts) == CollUtil.size(couponCounts);
|
return point == null || point >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AssertTrue(message = "商品范围编号的数组不能为空")
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isProductScopeValuesValid() {
|
||||||
|
return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
|
||||||
|
|| CollUtil.isNotEmpty(productScopeValues);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.promotion.controller.app.activity;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||||
|
@ -11,7 +14,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivit
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||||
|
@ -21,16 +24,15 @@ import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
|
@ -52,6 +54,9 @@ public class AppActivityController {
|
||||||
@Resource
|
@Resource
|
||||||
private RewardActivityService rewardActivityService;
|
private RewardActivityService rewardActivityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
@GetMapping("/list-by-spu-id")
|
@GetMapping("/list-by-spu-id")
|
||||||
@Operation(summary = "获得单个商品,近期参与的每个活动")
|
@Operation(summary = "获得单个商品,近期参与的每个活动")
|
||||||
@Parameter(name = "spuId", description = "商品编号", required = true)
|
@Parameter(name = "spuId", description = "商品编号", required = true)
|
||||||
|
@ -87,7 +92,7 @@ public class AppActivityController {
|
||||||
// 4. 限时折扣活动
|
// 4. 限时折扣活动
|
||||||
getDiscountActivities(spuIds, now, activityList);
|
getDiscountActivities(spuIds, now, activityList);
|
||||||
// 5. 满减送活动
|
// 5. 满减送活动
|
||||||
getRewardActivities(spuIds, now, activityList);
|
getRewardActivityList(spuIds, now, activityList);
|
||||||
return activityList;
|
return activityList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,28 +149,51 @@ public class AppActivityController {
|
||||||
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
private void getRewardActivityList(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||||
// TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部
|
// 1.1 获得所有的活动
|
||||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt(
|
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityListByStatusAndDateTimeLt(
|
||||||
spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now);
|
CommonStatusEnum.ENABLE.getStatus(), now);
|
||||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 1.2 获得所有的商品信息
|
||||||
Map<Long, Optional<RewardActivityDO>> spuIdAndActivityMap = spuIds.stream()
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(spuIds).getCheckedData();
|
||||||
.collect(Collectors.toMap(
|
if (CollUtil.isEmpty(spuList)) {
|
||||||
spuId -> spuId,
|
return;
|
||||||
spuId -> rewardActivityList.stream()
|
|
||||||
.filter(activity -> activity.getProductSpuIds().contains(spuId))
|
|
||||||
.max(Comparator.comparing(RewardActivityDO::getCreateTime))));
|
|
||||||
for (Long supId : spuIdAndActivityMap.keySet()) {
|
|
||||||
if (!spuIdAndActivityMap.get(supId).isPresent()) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RewardActivityDO rewardActivityDO = spuIdAndActivityMap.get(supId).get();
|
// 2. 构建活动
|
||||||
activityList.add(new AppActivityRespVO(rewardActivityDO.getId(), PromotionTypeEnum.REWARD_ACTIVITY.getType(),
|
for (RewardActivityDO rewardActivity : rewardActivityList) {
|
||||||
rewardActivityDO.getName(), supId, rewardActivityDO.getStartTime(), rewardActivityDO.getEndTime()));
|
// 情况一:所有商品都能参加
|
||||||
|
if (PromotionProductScopeEnum.isAll(rewardActivity.getProductScope())) {
|
||||||
|
buildAppActivityRespVO(rewardActivity, spuIds, activityList);
|
||||||
|
}
|
||||||
|
// 情况二:指定商品参加
|
||||||
|
if (PromotionProductScopeEnum.isSpu(rewardActivity.getProductScope())) {
|
||||||
|
List<Long> fSpuIds = spuList.stream().map(ProductSpuRespDTO::getId).filter(id ->
|
||||||
|
rewardActivity.getProductScopeValues().contains(id)).toList();
|
||||||
|
buildAppActivityRespVO(rewardActivity, fSpuIds, activityList);
|
||||||
|
}
|
||||||
|
// 情况三:指定商品类型参加
|
||||||
|
if (PromotionProductScopeEnum.isCategory(rewardActivity.getProductScope())) {
|
||||||
|
List<Long> fSpuIds = spuList.stream().filter(spuItem -> rewardActivity.getProductScopeValues()
|
||||||
|
.contains(spuItem.getCategoryId())).map(ProductSpuRespDTO::getId).toList();
|
||||||
|
buildAppActivityRespVO(rewardActivity, fSpuIds, activityList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection<Long> spuIds,
|
||||||
|
List<AppActivityRespVO> activityList) {
|
||||||
|
for (Long spuId : spuIds) {
|
||||||
|
// 校验商品是否已经加入过活动
|
||||||
|
if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) &&
|
||||||
|
ObjUtil.equal(appActivity.getSpuId(), spuId))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
activityList.add(new AppActivityRespVO(rewardActivity.getId(),
|
||||||
|
PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId,
|
||||||
|
rewardActivity.getStartTime(), rewardActivity.getEndTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,25 +14,20 @@ import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivity
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
@Tag(name = "用户 APP - 拼团活动")
|
@Tag(name = "用户 APP - 拼团活动")
|
||||||
|
@ -41,45 +36,12 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
@Validated
|
@Validated
|
||||||
public class AppCombinationActivityController {
|
public class AppCombinationActivityController {
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link AppCombinationActivityRespVO} 缓存,通过它异步刷新 {@link #getCombinationActivityList0(Integer)} 所要的首页数据
|
|
||||||
*/
|
|
||||||
private final LoadingCache<Integer, List<AppCombinationActivityRespVO>> combinationActivityListCache = buildCache(Duration.ofSeconds(10L),
|
|
||||||
new CacheLoader<Integer, List<AppCombinationActivityRespVO>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AppCombinationActivityRespVO> load(Integer count) {
|
|
||||||
return getCombinationActivityList0(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CombinationActivityService activityService;
|
private CombinationActivityService activityService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductSpuApi spuApi;
|
private ProductSpuApi spuApi;
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
@Operation(summary = "获得拼团活动列表", description = "用于小程序首页")
|
|
||||||
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
|
||||||
public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList(
|
|
||||||
@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
|
||||||
return success(combinationActivityListCache.getUnchecked(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<AppCombinationActivityRespVO> getCombinationActivityList0(Integer count) {
|
|
||||||
List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByCount(count);
|
|
||||||
if (CollUtil.isEmpty(activityList)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
// 拼接返回
|
|
||||||
List<CombinationProductDO> productList = activityService.getCombinationProductListByActivityIds(
|
|
||||||
convertList(activityList, CombinationActivityDO::getId));
|
|
||||||
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)).getCheckedData();
|
|
||||||
return CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得拼团活动分页")
|
@Operation(summary = "获得拼团活动分页")
|
||||||
public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) {
|
public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) {
|
||||||
|
@ -94,6 +56,23 @@ public class AppCombinationActivityController {
|
||||||
return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList));
|
return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-by-ids")
|
||||||
|
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
||||||
|
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||||
|
public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||||
|
// 1. 获得开启的活动列表
|
||||||
|
List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByIds(ids);
|
||||||
|
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||||
|
if (CollUtil.isEmpty(activityList)) {
|
||||||
|
return success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
// 2. 拼接返回
|
||||||
|
List<CombinationProductDO> productList = activityService.getCombinationProductListByActivityIds(
|
||||||
|
convertList(activityList, CombinationActivityDO::getId));
|
||||||
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)).getCheckedData();
|
||||||
|
return success(CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@Operation(summary = "获得拼团活动明细")
|
@Operation(summary = "获得拼团活动明细")
|
||||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||||
|
|
|
@ -19,15 +19,14 @@ public class AppCombinationActivityRespVO {
|
||||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "一个白菜")
|
||||||
|
private String spuName; // 从 SPU 的 name 读取
|
||||||
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096")
|
@Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096")
|
||||||
// 从 SPU 的 picUrl 读取
|
private String picUrl; // 从 SPU 的 picUrl 读取
|
||||||
private String picUrl;
|
|
||||||
|
|
||||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
// 从 SPU 的 marketPrice 读取
|
private Integer marketPrice; // 从 SPU 的 marketPrice 读取
|
||||||
private Integer marketPrice;
|
|
||||||
|
|
||||||
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
private Integer combinationPrice;
|
private Integer combinationPrice; // 从 products 获取最小 price 读取
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*;
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponTakeReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||||
|
@ -21,7 +23,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
@ -56,14 +57,6 @@ public class AppCouponController {
|
||||||
return success(canTakeAgain);
|
return success(canTakeAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/match-list")
|
|
||||||
@Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表")
|
|
||||||
public CommonResult<List<AppCouponMatchRespVO>> getMatchCouponList(AppCouponMatchReqVO matchReqVO) {
|
|
||||||
// todo: 优化:优惠金额倒序
|
|
||||||
List<CouponDO> list = couponService.getMatchCouponList(getLoginUserId(), matchReqVO);
|
|
||||||
return success(BeanUtils.toBean(list, AppCouponMatchRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "我的优惠劵列表")
|
@Operation(summary = "我的优惠劵列表")
|
||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "用户 App - 优惠劵的匹配 Request VO")
|
|
||||||
@Data
|
|
||||||
public class AppCouponMatchReqVO {
|
|
||||||
|
|
||||||
@Schema(description = "商品金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
@NotNull(message = "商品金额不能为空")
|
|
||||||
private Integer price;
|
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
|
||||||
@NotEmpty(message = "商品 SPU 编号不能为空")
|
|
||||||
private List<Long> spuIds;
|
|
||||||
|
|
||||||
@Schema(description = "商品 SKU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
|
||||||
@NotEmpty(message = "商品 SKU 编号不能为空")
|
|
||||||
private List<Long> skuIds;
|
|
||||||
|
|
||||||
@Schema(description = "分类编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[10, 20]")
|
|
||||||
@NotEmpty(message = "分类编号不能为空")
|
|
||||||
private List<Long> categoryIds;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description = "用户 App - 优惠劵 Response VO")
|
|
||||||
@Data
|
|
||||||
public class AppCouponMatchRespVO extends AppCouponRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "是否匹配", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
|
||||||
private Boolean match;
|
|
||||||
|
|
||||||
@Schema(description = "匹配条件的提示", example = "所结算商品没有符合条件的商品")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
}
|
|
|
@ -42,7 +42,6 @@ public class AppCouponRespVO {
|
||||||
private Integer discountPercent;
|
private Integer discountPercent;
|
||||||
|
|
||||||
@Schema(description = "优惠金额", example = "10")
|
@Schema(description = "优惠金额", example = "10")
|
||||||
@Min(value = 0, message = "优惠金额需要大于等于 0")
|
|
||||||
private Integer discountPrice;
|
private Integer discountPrice;
|
||||||
|
|
||||||
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
@ -127,40 +128,42 @@ public interface CombinationActivityConvert {
|
||||||
.setSpuName(spu.getName()).setPicUrl(sku.getPicUrl());
|
.setSpuName(spu.getName()).setPicUrl(sku.getPicUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list);
|
default List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list,
|
||||||
|
|
||||||
default List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list,
|
|
||||||
List<CombinationProductDO> productList,
|
List<CombinationProductDO> productList,
|
||||||
List<ProductSpuRespDTO> spuList) {
|
List<ProductSpuRespDTO> spuList) {
|
||||||
List<AppCombinationActivityRespVO> activityList = convertAppList(list);
|
List<CombinationActivityRespVO> activityList = BeanUtils.toBean(list, CombinationActivityRespVO.class);
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
Map<Long, List<CombinationProductDO>> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId);
|
Map<Long, List<CombinationProductDO>> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId);
|
||||||
return CollectionUtils.convertList(activityList, item -> {
|
return CollectionUtils.convertList(activityList, item -> {
|
||||||
// 设置 product 信息
|
// 设置 product 信息
|
||||||
item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice));
|
item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice));
|
||||||
// 设置 SPU 信息
|
// 设置 SPU 信息
|
||||||
findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName())
|
||||||
|
.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PageResult<AppCombinationActivityRespVO> convertAppPage(PageResult<CombinationActivityDO> result);
|
default List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list,
|
||||||
|
List<CombinationProductDO> productList,
|
||||||
|
List<ProductSpuRespDTO> spuList) {
|
||||||
|
List<AppCombinationActivityRespVO> activityList = BeanUtils.toBean(list, AppCombinationActivityRespVO.class);
|
||||||
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
|
Map<Long, List<CombinationProductDO>> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId);
|
||||||
|
return CollectionUtils.convertList(activityList, item -> {
|
||||||
|
// 设置 product 信息
|
||||||
|
item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice));
|
||||||
|
// 设置 SPU 信息
|
||||||
|
findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName())
|
||||||
|
.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
default PageResult<AppCombinationActivityRespVO> convertAppPage(PageResult<CombinationActivityDO> result,
|
default PageResult<AppCombinationActivityRespVO> convertAppPage(PageResult<CombinationActivityDO> result,
|
||||||
List<CombinationProductDO> productList,
|
List<CombinationProductDO> productList,
|
||||||
List<ProductSpuRespDTO> spuList) {
|
List<ProductSpuRespDTO> spuList) {
|
||||||
PageResult<AppCombinationActivityRespVO> appPage = convertAppPage(result);
|
return new PageResult<>(convertAppList(result.getList(), productList, spuList), result.getTotal());
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
|
||||||
Map<Long, List<CombinationProductDO>> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId);
|
|
||||||
List<AppCombinationActivityRespVO> list = CollectionUtils.convertList(appPage.getList(), item -> {
|
|
||||||
// 设置 product 信息
|
|
||||||
item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice));
|
|
||||||
// 设置 SPU 信息
|
|
||||||
findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
appPage.setList(list);
|
|
||||||
return appPage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity);
|
AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity);
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.promotion.convert.reward;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 满减送活动 Convert
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface RewardActivityConvert {
|
|
||||||
|
|
||||||
RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class);
|
|
||||||
|
|
||||||
RewardActivityDO convert(RewardActivityCreateReqVO bean);
|
|
||||||
|
|
||||||
RewardActivityDO convert(RewardActivityUpdateReqVO bean);
|
|
||||||
|
|
||||||
RewardActivityRespVO convert(RewardActivityDO bean);
|
|
||||||
|
|
||||||
PageResult<RewardActivityRespVO> convertPage(PageResult<RewardActivityDO> page);
|
|
||||||
|
|
||||||
}
|
|
|
@ -50,7 +50,6 @@ public class CouponDO extends BaseDO {
|
||||||
*
|
*
|
||||||
* 枚举 {@link CouponStatusEnum}
|
* 枚举 {@link CouponStatusEnum}
|
||||||
*/
|
*/
|
||||||
// TODO 芋艿:已作废?
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
// TODO 芋艿:发放 adminid?
|
// TODO 芋艿:发放 adminid?
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.reward;
|
package cn.iocoder.yudao.module.promotion.dal.dataobject.reward;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum;
|
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
|
@ -16,6 +16,7 @@ import lombok.EqualsAndHashCode;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 满减送活动 DO
|
* 满减送活动 DO
|
||||||
|
@ -40,7 +41,7 @@ public class RewardActivityDO extends BaseDO {
|
||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*
|
*
|
||||||
* 枚举 {@link PromotionActivityStatusEnum}
|
* 枚举 {@link CommonStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +72,7 @@ public class RewardActivityDO extends BaseDO {
|
||||||
* 商品 SPU 编号的数组
|
* 商品 SPU 编号的数组
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = LongListTypeHandler.class)
|
@TableField(typeHandler = LongListTypeHandler.class)
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
/**
|
/**
|
||||||
* 优惠规则的数组
|
* 优惠规则的数组
|
||||||
*/
|
*/
|
||||||
|
@ -104,13 +105,14 @@ public class RewardActivityDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Integer point;
|
private Integer point;
|
||||||
/**
|
/**
|
||||||
* 赠送的优惠劵编号的数组
|
* 赠送的优惠劵
|
||||||
|
*
|
||||||
|
* key: 优惠劵模版编号
|
||||||
|
* value:对应的优惠券数量
|
||||||
|
*
|
||||||
|
* 目的:用于订单支付后赠送优惠券
|
||||||
*/
|
*/
|
||||||
private List<Long> couponIds;
|
private Map<Long, Integer> giveCouponTemplateCounts;
|
||||||
/**
|
|
||||||
* 赠送的优惠券数量的数组
|
|
||||||
*/
|
|
||||||
private List<Integer> couponCounts;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
|
package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.github.yulichang.toolkit.MPJWrappers;
|
import com.github.yulichang.toolkit.MPJWrappers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
@ -16,8 +14,6 @@ import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
|
@ -84,22 +80,6 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
||||||
return convertMap(list, map -> MapUtil.getLong(map, templateIdAlias), map -> MapUtil.getInt(map, countAlias));
|
return convertMap(list, map -> MapUtil.getLong(map, templateIdAlias), map -> MapUtil.getInt(map, countAlias));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<CouponDO> selectListByUserIdAndStatusAndUsePriceLeAndProductScope(
|
|
||||||
Long userId, Integer status, Integer usePrice, List<Long> spuIds, List<Long> categoryIds) {
|
|
||||||
Function<List<Long>, String> productScopeValuesFindInSetFunc = ids -> ids.stream()
|
|
||||||
.map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id))
|
|
||||||
.collect(Collectors.joining(" OR "));
|
|
||||||
return selectList(new LambdaQueryWrapperX<CouponDO>()
|
|
||||||
.eq(CouponDO::getUserId, userId)
|
|
||||||
.eq(CouponDO::getStatus, status)
|
|
||||||
.le(CouponDO::getUsePrice, usePrice) // 价格小于等于,满足价格使用条件
|
|
||||||
.and(w -> w.eq(CouponDO::getProductScope, PromotionProductScopeEnum.ALL.getScope()) // 商品范围一:全部
|
|
||||||
.or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.SPU.getScope()) // 商品范围二:满足指定商品
|
|
||||||
.apply(productScopeValuesFindInSetFunc.apply(spuIds)))
|
|
||||||
.or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.CATEGORY.getScope()) // 商品范围三:满足指定分类
|
|
||||||
.apply(productScopeValuesFindInSetFunc.apply(categoryIds)))));
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<CouponDO> selectListByStatusAndValidEndTimeLe(Integer status, LocalDateTime validEndTime) {
|
default List<CouponDO> selectListByStatusAndValidEndTimeLe(Integer status, LocalDateTime validEndTime) {
|
||||||
return selectList(new LambdaQueryWrapperX<CouponDO>()
|
return selectList(new LambdaQueryWrapperX<CouponDO>()
|
||||||
.eq(CouponDO::getStatus, status)
|
.eq(CouponDO::getStatus, status)
|
||||||
|
|
|
@ -30,19 +30,9 @@ public interface RewardActivityMapper extends BaseMapperX<RewardActivityDO> {
|
||||||
.orderByDesc(RewardActivityDO::getId));
|
.orderByDesc(RewardActivityDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<RewardActivityDO> selectListByStatus(Collection<Integer> statuses) {
|
|
||||||
return selectList(RewardActivityDO::getStatus, statuses);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<RewardActivityDO> selectListByProductScopeAndStatus(Integer productScope, Integer status) {
|
|
||||||
return selectList(new LambdaQueryWrapperX<RewardActivityDO>()
|
|
||||||
.eq(RewardActivityDO::getProductScope, productScope)
|
|
||||||
.eq(RewardActivityDO::getStatus, status));
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<RewardActivityDO> selectListBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
default List<RewardActivityDO> selectListBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||||
Function<Collection<Long>, String> productScopeValuesFindInSetFunc = ids -> ids.stream()
|
Function<Collection<Long>, String> productScopeValuesFindInSetFunc = ids -> ids.stream()
|
||||||
.map(id -> StrUtil.format("FIND_IN_SET({}, product_spu_ids) ", id))
|
.map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id))
|
||||||
.collect(Collectors.joining(" OR "));
|
.collect(Collectors.joining(" OR "));
|
||||||
return selectList(new QueryWrapper<RewardActivityDO>()
|
return selectList(new QueryWrapper<RewardActivityDO>()
|
||||||
.eq("status", status)
|
.eq("status", status)
|
||||||
|
@ -53,16 +43,16 @@ public interface RewardActivityMapper extends BaseMapperX<RewardActivityDO> {
|
||||||
* 获取指定活动编号的活动列表且
|
* 获取指定活动编号的活动列表且
|
||||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||||
*
|
*
|
||||||
* @param ids 活动编号
|
* @param status 状态
|
||||||
* @param dateTime 指定日期
|
* @param dateTime 指定日期
|
||||||
* @return 活动列表
|
* @return 活动列表
|
||||||
*/
|
*/
|
||||||
default List<RewardActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, LocalDateTime dateTime) {
|
default List<RewardActivityDO> selectListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||||
return selectList(new LambdaQueryWrapperX<RewardActivityDO>()
|
return selectList(new LambdaQueryWrapperX<RewardActivityDO>()
|
||||||
.in(RewardActivityDO::getId, ids)
|
.eq(RewardActivityDO::getStatus, status)
|
||||||
.lt(RewardActivityDO::getStartTime, dateTime)
|
.lt(RewardActivityDO::getStartTime, dateTime)
|
||||||
.gt(RewardActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
.gt(RewardActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||||
.orderByDesc(RewardActivityDO::getCreateTime)
|
.orderByAsc(RewardActivityDO::getStartTime)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,14 +100,6 @@ public interface CombinationActivityService {
|
||||||
*/
|
*/
|
||||||
List<CombinationActivityDO> getCombinationActivityListByIds(Collection<Long> ids);
|
List<CombinationActivityDO> getCombinationActivityListByIds(Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取正在进行的活动分页数据
|
|
||||||
*
|
|
||||||
* @param count 需要的数量
|
|
||||||
* @return 拼团活动分页
|
|
||||||
*/
|
|
||||||
List<CombinationActivityDO> getCombinationActivityListByCount(Integer count);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取正在进行的活动分页数据
|
* 获取正在进行的活动分页数据
|
||||||
*
|
*
|
||||||
|
|
|
@ -225,11 +225,6 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||||
return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids);
|
return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CombinationActivityDO> getCombinationActivityListByCount(Integer count) {
|
|
||||||
return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<CombinationActivityDO> getCombinationActivityPage(PageParam pageParam) {
|
public PageResult<CombinationActivityDO> getCombinationActivityPage(PageParam pageParam) {
|
||||||
return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus());
|
return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
|
|
@ -27,6 +27,9 @@ import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStat
|
||||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
||||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
@ -34,8 +37,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -232,7 +233,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||||
.setTemplateTitle(COMBINATION_SUCCESS)
|
.setTemplateTitle(COMBINATION_SUCCESS)
|
||||||
.setPage("pages/order/detail?id=" + record.getOrderId()) // 订单详情页
|
.setPage("pages/order/detail?id=" + record.getOrderId()) // 订单详情页
|
||||||
.addMessage("thing1", "商品拼团活动") // 活动标题
|
.addMessage("thing1", "商品拼团活动") // 活动标题
|
||||||
.addMessage("thing2", "恭喜您拼团成功!我们将尽快为您发货。")); // 温馨提示
|
.addMessage("thing2", "恭喜您拼团成功!我们将尽快为您发货。")).checkError(); // 温馨提示
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -338,7 +339,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||||
List<CombinationRecordDO> headAndRecords = updateBatchCombinationRecords(headRecord,
|
List<CombinationRecordDO> headAndRecords = updateBatchCombinationRecords(headRecord,
|
||||||
CombinationRecordStatusEnum.FAILED);
|
CombinationRecordStatusEnum.FAILED);
|
||||||
// 2. 订单取消
|
// 2. 订单取消
|
||||||
headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()));
|
headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId(),
|
||||||
|
TradeOrderCancelTypeEnum.COMBINATION_CLOSE.getType()).checkError());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
|
@ -18,34 +17,6 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public interface CouponService {
|
public interface CouponService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验优惠劵,包括状态、有限期
|
|
||||||
* <p>
|
|
||||||
* 1. 如果校验通过,则返回优惠劵信息
|
|
||||||
* 2. 如果校验不通过,则直接抛出业务异常
|
|
||||||
*
|
|
||||||
* @param id 优惠劵编号
|
|
||||||
* @param userId 用户编号
|
|
||||||
* @return 优惠劵信息
|
|
||||||
*/
|
|
||||||
CouponDO validCoupon(Long id, Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验优惠劵,包括状态、有限期
|
|
||||||
*
|
|
||||||
* @param coupon 优惠劵
|
|
||||||
* @see #validCoupon(Long, Long) 逻辑相同,只是入参不同
|
|
||||||
*/
|
|
||||||
void validCoupon(CouponDO coupon);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得优惠劵分页
|
|
||||||
*
|
|
||||||
* @param pageReqVO 分页查询
|
|
||||||
* @return 优惠劵分页
|
|
||||||
*/
|
|
||||||
PageResult<CouponDO> getCouponPage(CouponPageReqVO pageReqVO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用优惠劵
|
* 使用优惠劵
|
||||||
*
|
*
|
||||||
|
@ -69,42 +40,44 @@ public interface CouponService {
|
||||||
*/
|
*/
|
||||||
void deleteCoupon(Long id);
|
void deleteCoupon(Long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得用户的优惠劵列表
|
|
||||||
*
|
|
||||||
* @param userId 用户编号
|
|
||||||
* @param status 优惠劵状态
|
|
||||||
* @return 优惠劵列表
|
|
||||||
*/
|
|
||||||
List<CouponDO> getCouponList(Long userId, Integer status);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得未使用的优惠劵数量
|
|
||||||
*
|
|
||||||
* @param userId 用户编号
|
|
||||||
* @return 未使用的优惠劵数量
|
|
||||||
*/
|
|
||||||
Long getUnusedCouponCount(Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领取优惠券
|
* 领取优惠券
|
||||||
*
|
*
|
||||||
* @param templateId 优惠券模板编号
|
* @param templateId 优惠券模板编号
|
||||||
* @param userIds 用户编号列表
|
* @param userIds 用户编号列表
|
||||||
* @param takeType 领取方式
|
* @param takeType 领取方式
|
||||||
|
* @return key: userId, value: 优惠券编号列表
|
||||||
*/
|
*/
|
||||||
void takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType);
|
Map<Long, List<Long>> takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【管理员】给用户发送优惠券
|
* 【管理员】给用户发送优惠券
|
||||||
*
|
*
|
||||||
* @param templateId 优惠券模板编号
|
* @param templateId 优惠券模板编号
|
||||||
* @param userIds 用户编号列表
|
* @param userIds 用户编号列表
|
||||||
|
* @return key: userId, value: 优惠券编号列表
|
||||||
*/
|
*/
|
||||||
default void takeCouponByAdmin(Long templateId, Set<Long> userIds) {
|
default Map<Long, List<Long>> takeCouponByAdmin(Long templateId, Set<Long> userIds) {
|
||||||
takeCoupon(templateId, userIds, CouponTakeTypeEnum.ADMIN);
|
return takeCoupon(templateId, userIds, CouponTakeTypeEnum.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【管理员】给指定用户批量发送优惠券
|
||||||
|
*
|
||||||
|
* @param giveCoupons key: 优惠劵模版编号,value:对应的数量
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 优惠券编号列表
|
||||||
|
*/
|
||||||
|
List<Long> takeCouponsByAdmin(Map<Long, Integer> giveCoupons, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【管理员】作废指定用户的指定优惠劵
|
||||||
|
*
|
||||||
|
* @param giveCouponIds 赠送的优惠券编号
|
||||||
|
* @param userId 用户编号
|
||||||
|
*/
|
||||||
|
void invalidateCouponsByAdmin(List<Long> giveCouponIds, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【会员】领取优惠券
|
* 【会员】领取优惠券
|
||||||
*
|
*
|
||||||
|
@ -123,16 +96,38 @@ public interface CouponService {
|
||||||
void takeCouponByRegister(Long userId);
|
void takeCouponByRegister(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会员领取指定优惠券的数量
|
* 过期优惠券
|
||||||
*
|
*
|
||||||
* @param templateId 优惠券模板编号
|
* @return 过期数量
|
||||||
* @param userId 用户编号
|
|
||||||
* @return 领取优惠券的数量
|
|
||||||
*/
|
*/
|
||||||
default Integer getTakeCount(Long templateId, Long userId) {
|
int expireCoupon();
|
||||||
Map<Long, Integer> map = getTakeCountMapByTemplateIds(Collections.singleton(templateId), userId);
|
|
||||||
return MapUtil.getInt(map, templateId, 0);
|
// ======================= 查询相关 =======================
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 获得未使用的优惠劵数量
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 未使用的优惠劵数量
|
||||||
|
*/
|
||||||
|
Long getUnusedCouponCount(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得优惠劵分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 优惠劵分页
|
||||||
|
*/
|
||||||
|
PageResult<CouponDO> getCouponPage(CouponPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得用户的优惠劵列表
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param status 优惠劵状态
|
||||||
|
* @return 优惠劵列表
|
||||||
|
*/
|
||||||
|
List<CouponDO> getCouponList(Long userId, Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计会员领取优惠券的数量
|
* 统计会员领取优惠券的数量
|
||||||
|
@ -144,20 +139,16 @@ public interface CouponService {
|
||||||
Map<Long, Integer> getTakeCountMapByTemplateIds(Collection<Long> templateIds, Long userId);
|
Map<Long, Integer> getTakeCountMapByTemplateIds(Collection<Long> templateIds, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户匹配的优惠券列表
|
* 获取会员领取指定优惠券的数量
|
||||||
*
|
*
|
||||||
|
* @param templateId 优惠券模板编号
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param matchReqVO 匹配参数
|
* @return 领取优惠券的数量
|
||||||
* @return 优惠券列表
|
|
||||||
*/
|
*/
|
||||||
List<CouponDO> getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO);
|
default Integer getTakeCount(Long templateId, Long userId) {
|
||||||
|
Map<Long, Integer> map = getTakeCountMapByTemplateIds(Collections.singleton(templateId), userId);
|
||||||
/**
|
return MapUtil.getInt(map, templateId, 0);
|
||||||
* 过期优惠券
|
}
|
||||||
*
|
|
||||||
* @return 过期数量
|
|
||||||
*/
|
|
||||||
int expireCoupon();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户是否可以领取优惠券
|
* 获取用户是否可以领取优惠券
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.coupon;
|
||||||
import cn.hutool.core.collection.CollStreamUtil;
|
import cn.hutool.core.collection.CollStreamUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
@ -11,7 +12,6 @@ import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||||
|
@ -19,18 +19,19 @@ import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
@ -54,18 +55,9 @@ public class CouponServiceImpl implements CouponService {
|
||||||
private MemberUserApi memberUserApi;
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CouponDO validCoupon(Long id, Long userId) {
|
public void useCoupon(Long id, Long userId, Long orderId) {
|
||||||
CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId);
|
|
||||||
if (coupon == null) {
|
|
||||||
throw exception(COUPON_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
validCoupon(coupon);
|
|
||||||
return coupon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validCoupon(CouponDO coupon) {
|
|
||||||
// 校验状态
|
// 校验状态
|
||||||
|
CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId);
|
||||||
if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) {
|
if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) {
|
||||||
throw exception(COUPON_STATUS_NOT_UNUSED);
|
throw exception(COUPON_STATUS_NOT_UNUSED);
|
||||||
}
|
}
|
||||||
|
@ -73,26 +65,6 @@ public class CouponServiceImpl implements CouponService {
|
||||||
if (!LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) {
|
if (!LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) {
|
||||||
throw exception(COUPON_VALID_TIME_NOT_NOW);
|
throw exception(COUPON_VALID_TIME_NOT_NOW);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<CouponDO> getCouponPage(CouponPageReqVO pageReqVO) {
|
|
||||||
// 获得用户编号
|
|
||||||
if (StrUtil.isNotEmpty(pageReqVO.getNickname())) {
|
|
||||||
List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()).getCheckedData();
|
|
||||||
if (CollUtil.isEmpty(users)) {
|
|
||||||
return PageResult.empty();
|
|
||||||
}
|
|
||||||
pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId));
|
|
||||||
}
|
|
||||||
// 分页查询
|
|
||||||
return couponMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useCoupon(Long id, Long userId, Long orderId) {
|
|
||||||
// 校验优惠劵
|
|
||||||
validCoupon(id, userId);
|
|
||||||
|
|
||||||
// 更新状态
|
// 更新状态
|
||||||
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
|
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
|
||||||
|
@ -146,25 +118,8 @@ public class CouponServiceImpl implements CouponService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CouponDO> getCouponList(Long userId, Integer status) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
return couponMapper.selectListByUserIdAndStatus(userId, status);
|
public Map<Long, List<Long>> takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType) {
|
||||||
}
|
|
||||||
|
|
||||||
private CouponDO validateCouponExists(Long id) {
|
|
||||||
CouponDO coupon = couponMapper.selectById(id);
|
|
||||||
if (coupon == null) {
|
|
||||||
throw exception(COUPON_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
return coupon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getUnusedCouponCount(Long userId) {
|
|
||||||
return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takeType) {
|
|
||||||
CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId);
|
CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId);
|
||||||
// 1. 过滤掉达到领取限制的用户
|
// 1. 过滤掉达到领取限制的用户
|
||||||
removeTakeLimitUser(userIds, template);
|
removeTakeLimitUser(userIds, template);
|
||||||
|
@ -172,10 +127,77 @@ public class CouponServiceImpl implements CouponService {
|
||||||
validateCouponTemplateCanTake(template, userIds, takeType);
|
validateCouponTemplateCanTake(template, userIds, takeType);
|
||||||
|
|
||||||
// 3. 批量保存优惠劵
|
// 3. 批量保存优惠劵
|
||||||
couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId)));
|
List<CouponDO> couponList = convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId));
|
||||||
|
couponMapper.insertBatch(couponList);
|
||||||
|
|
||||||
// 3. 增加优惠劵模板的领取数量
|
// 4. 增加优惠劵模板的领取数量
|
||||||
couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size());
|
couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size());
|
||||||
|
|
||||||
|
return convertMultiMap(couponList, CouponDO::getUserId, CouponDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> takeCouponsByAdmin(Map<Long, Integer> giveCoupons, Long userId) {
|
||||||
|
if (CollUtil.isEmpty(giveCoupons)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Long> couponIds = new ArrayList<>();
|
||||||
|
// 循环发放
|
||||||
|
for (Map.Entry<Long, Integer> entry : giveCoupons.entrySet()) {
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < entry.getValue(); i++) {
|
||||||
|
Map<Long, List<Long>> userCouponIdsMap = getSelf().takeCoupon(entry.getKey(), CollUtil.newHashSet(userId),
|
||||||
|
CouponTakeTypeEnum.ADMIN);
|
||||||
|
findAndThen(userCouponIdsMap, userId, couponIds::addAll);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[takeCouponsByAdmin][coupon({}) 优惠券发放失败]", entry, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return couponIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidateCouponsByAdmin(List<Long> giveCouponIds, Long userId) {
|
||||||
|
// 循环收回
|
||||||
|
for (Long couponId : giveCouponIds) {
|
||||||
|
try {
|
||||||
|
getSelf().invalidateCoupon(couponId, userId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[invalidateCouponsByAdmin][couponId({}) 收回优惠券失败]", couponId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【管理员】收回优惠券
|
||||||
|
*
|
||||||
|
* @param couponId 模版编号
|
||||||
|
* @param userId 用户编号
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void invalidateCoupon(Long couponId, Long userId) {
|
||||||
|
// 1.1 校验优惠券
|
||||||
|
CouponDO coupon = couponMapper.selectByIdAndUserId(couponId, userId);
|
||||||
|
if (coupon == null) {
|
||||||
|
throw exception(COUPON_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
// 1.2 校验模板
|
||||||
|
CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(coupon.getTemplateId());
|
||||||
|
if (couponTemplate == null) {
|
||||||
|
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
// 1.3 校验优惠券是否已经使用,如若使用则先不管
|
||||||
|
if (ObjUtil.equal(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) {
|
||||||
|
log.info("[invalidateCoupon][coupon({}) 已经使用,无法作废]", couponId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.1 减少优惠劵模板的领取数量
|
||||||
|
couponTemplateService.updateCouponTemplateTakeCount(couponTemplate.getId(), -1);
|
||||||
|
// 2.2 作废优惠劵
|
||||||
|
couponMapper.deleteById(couponId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,24 +209,6 @@ public class CouponServiceImpl implements CouponService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<Long, Integer> getTakeCountMapByTemplateIds(Collection<Long> templateIds, Long userId) {
|
|
||||||
if (CollUtil.isEmpty(templateIds)) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CouponDO> getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) {
|
|
||||||
List<CouponDO> list = couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId,
|
|
||||||
CouponStatusEnum.UNUSED.getStatus(),
|
|
||||||
matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds());
|
|
||||||
// 兜底逻辑:如果 CouponExpireJob 未执行,status 未变成 EXPIRE ,但是 validEndTime 已经过期了,需要进行过滤
|
|
||||||
list.removeIf(coupon -> !LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime()));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int expireCoupon() {
|
public int expireCoupon() {
|
||||||
// 1. 查询待过期的优惠券
|
// 1. 查询待过期的优惠券
|
||||||
|
@ -229,27 +233,6 @@ public class CouponServiceImpl implements CouponService {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<Long, Boolean> getUserCanCanTakeMap(Long userId, List<CouponTemplateDO> templates) {
|
|
||||||
// 1. 未登录时,都显示可以领取
|
|
||||||
Map<Long, Boolean> userCanTakeMap = convertMap(templates, CouponTemplateDO::getId, templateId -> true);
|
|
||||||
if (userId == null) {
|
|
||||||
return userCanTakeMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2.1 过滤领取数量无限制的
|
|
||||||
Set<Long> templateIds = convertSet(templates, CouponTemplateDO::getId, template -> template.getTakeLimitCount() != -1);
|
|
||||||
// 2.2 检查用户领取的数量是否超过限制
|
|
||||||
if (CollUtil.isNotEmpty(templateIds)) {
|
|
||||||
Map<Long, Integer> couponTakeCountMap = this.getTakeCountMapByTemplateIds(templateIds, userId);
|
|
||||||
for (CouponTemplateDO template : templates) {
|
|
||||||
Integer takeCount = couponTakeCountMap.get(template.getId());
|
|
||||||
userCanTakeMap.put(template.getId(), takeCount == null || takeCount < template.getTakeLimitCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return userCanTakeMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期单个优惠劵
|
* 过期单个优惠劵
|
||||||
*
|
*
|
||||||
|
@ -321,11 +304,74 @@ public class CouponServiceImpl implements CouponService {
|
||||||
userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount());
|
userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//======================= 查询相关 =======================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getUnusedCouponCount(Long userId) {
|
||||||
|
return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CouponDO> getCouponPage(CouponPageReqVO pageReqVO) {
|
||||||
|
// 获得用户编号
|
||||||
|
if (StrUtil.isNotEmpty(pageReqVO.getNickname())) {
|
||||||
|
List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()).getCheckedData();
|
||||||
|
if (CollUtil.isEmpty(users)) {
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId));
|
||||||
|
}
|
||||||
|
// 分页查询
|
||||||
|
return couponMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CouponDO> getCouponList(Long userId, Integer status) {
|
||||||
|
return couponMapper.selectListByUserIdAndStatus(userId, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, Integer> getTakeCountMapByTemplateIds(Collection<Long> templateIds, Long userId) {
|
||||||
|
if (CollUtil.isEmpty(templateIds)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, Boolean> getUserCanCanTakeMap(Long userId, List<CouponTemplateDO> templates) {
|
||||||
|
// 1. 未登录时,都显示可以领取
|
||||||
|
Map<Long, Boolean> userCanTakeMap = convertMap(templates, CouponTemplateDO::getId, templateId -> true);
|
||||||
|
if (userId == null) {
|
||||||
|
return userCanTakeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.1 过滤领取数量无限制的
|
||||||
|
Set<Long> templateIds = convertSet(templates, CouponTemplateDO::getId, template -> template.getTakeLimitCount() != -1);
|
||||||
|
// 2.2 检查用户领取的数量是否超过限制
|
||||||
|
if (CollUtil.isNotEmpty(templateIds)) {
|
||||||
|
Map<Long, Integer> couponTakeCountMap = this.getTakeCountMapByTemplateIds(templateIds, userId);
|
||||||
|
for (CouponTemplateDO template : templates) {
|
||||||
|
Integer takeCount = couponTakeCountMap.get(template.getId());
|
||||||
|
userCanTakeMap.put(template.getId(), takeCount == null || takeCount < template.getTakeLimitCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userCanTakeMap;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CouponDO getCoupon(Long userId, Long id) {
|
public CouponDO getCoupon(Long userId, Long id) {
|
||||||
return couponMapper.selectByIdAndUserId(id, userId);
|
return couponMapper.selectByIdAndUserId(id, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CouponDO validateCouponExists(Long id) {
|
||||||
|
CouponDO coupon = couponMapper.selectById(id);
|
||||||
|
if (coupon == null) {
|
||||||
|
throw exception(COUPON_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
return coupon;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得自身的代理对象,解决 AOP 生效问题
|
* 获得自身的代理对象,解决 AOP 生效问题
|
||||||
*
|
*
|
||||||
|
@ -334,4 +380,5 @@ public class CouponServiceImpl implements CouponService {
|
||||||
private CouponServiceImpl getSelf() {
|
private CouponServiceImpl getSelf() {
|
||||||
return SpringUtil.getBean(getClass());
|
return SpringUtil.getBean(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,9 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||||
|
|
||||||
private void validateProductScope(Integer productScope, List<Long> productScopeValues) {
|
private void validateProductScope(Integer productScope, List<Long> productScopeValues) {
|
||||||
if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) {
|
if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) {
|
||||||
productSpuApi.validateSpuList(productScopeValues);
|
productSpuApi.validateSpuList(productScopeValues).checkError();
|
||||||
} else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) {
|
} else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) {
|
||||||
productCategoryApi.validateCategoryList(productScopeValues);
|
productCategoryApi.validateCategoryList(productScopeValues).checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,10 @@ public class DiscountActivityServiceImpl implements DiscountActivityService {
|
||||||
}
|
}
|
||||||
// 计算新增的记录
|
// 计算新增的记录
|
||||||
List<DiscountProductDO> newDiscountProducts = convertList(updateReqVO.getProducts(),
|
List<DiscountProductDO> newDiscountProducts = convertList(updateReqVO.getProducts(),
|
||||||
product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId()));
|
product -> DiscountActivityConvert.INSTANCE.convert(product)
|
||||||
|
.setActivityId(updateReqVO.getId())
|
||||||
|
.setActivityStartTime(updateReqVO.getStartTime())
|
||||||
|
.setActivityEndTime(updateReqVO.getEndTime()));
|
||||||
newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch(
|
newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch(
|
||||||
dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的
|
dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的
|
||||||
if (CollectionUtil.isNotEmpty(newDiscountProducts)) {
|
if (CollectionUtil.isNotEmpty(newDiscountProducts)) {
|
||||||
|
|
|
@ -75,11 +75,10 @@ public interface RewardActivityService {
|
||||||
/**
|
/**
|
||||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||||
*
|
*
|
||||||
* @param spuIds spu 编号
|
|
||||||
* @param status 状态
|
* @param status 状态
|
||||||
* @param dateTime 当前日期时间
|
* @param dateTime 当前日期时间
|
||||||
* @return 满减送活动列表
|
* @return 满减送活动列表
|
||||||
*/
|
*/
|
||||||
List<RewardActivityDO> getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection<Long> spuIds, Integer status, LocalDateTime dateTime);
|
List<RewardActivityDO> getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package cn.iocoder.yudao.module.promotion.service.reward;
|
package cn.iocoder.yudao.module.promotion.service.reward;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper;
|
import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.util.PromotionUtils;
|
import cn.iocoder.yudao.module.promotion.util.PromotionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -17,13 +20,13 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static cn.hutool.core.collection.CollUtil.intersectionDistinct;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 满减送活动 Service 实现类
|
* 满减送活动 Service 实现类
|
||||||
|
@ -37,13 +40,20 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
@Resource
|
@Resource
|
||||||
private RewardActivityMapper rewardActivityMapper;
|
private RewardActivityMapper rewardActivityMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductCategoryApi productCategoryApi;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) {
|
public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) {
|
||||||
// 校验商品是否冲突
|
// 1.1 校验商品范围
|
||||||
validateRewardActivitySpuConflicts(null, createReqVO.getProductSpuIds());
|
validateProductScope(createReqVO.getProductScope(), createReqVO.getProductScopeValues());
|
||||||
|
// 1.2 校验商品是否冲突
|
||||||
|
validateRewardActivitySpuConflicts(null, createReqVO);
|
||||||
|
|
||||||
// 插入
|
// 2. 插入
|
||||||
RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO)
|
RewardActivityDO rewardActivity = BeanUtils.toBean(createReqVO, RewardActivityDO.class)
|
||||||
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime()));
|
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime()));
|
||||||
rewardActivityMapper.insert(rewardActivity);
|
rewardActivityMapper.insert(rewardActivity);
|
||||||
// 返回
|
// 返回
|
||||||
|
@ -52,16 +62,18 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) {
|
public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 1.1 校验存在
|
||||||
RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId());
|
RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId());
|
||||||
if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢
|
if (dbRewardActivity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能修改噢
|
||||||
throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED);
|
throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED);
|
||||||
}
|
}
|
||||||
// 校验商品是否冲突
|
// 1.2 校验商品范围
|
||||||
validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds());
|
validateProductScope(updateReqVO.getProductScope(), updateReqVO.getProductScopeValues());
|
||||||
|
// 1.3 校验商品是否冲突
|
||||||
|
validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO);
|
||||||
|
|
||||||
// 更新
|
// 2. 更新
|
||||||
RewardActivityDO updateObj = RewardActivityConvert.INSTANCE.convert(updateReqVO)
|
RewardActivityDO updateObj = BeanUtils.toBean(updateReqVO, RewardActivityDO.class)
|
||||||
.setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime()));
|
.setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime()));
|
||||||
rewardActivityMapper.updateById(updateObj);
|
rewardActivityMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
@ -70,15 +82,12 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
public void closeRewardActivity(Long id) {
|
public void closeRewardActivity(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
|
RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
|
||||||
if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢
|
if (dbRewardActivity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能关闭噢
|
||||||
throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED);
|
throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED);
|
||||||
}
|
}
|
||||||
if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢
|
|
||||||
throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus());
|
RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||||
rewardActivityMapper.updateById(updateObj);
|
rewardActivityMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +95,7 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
public void deleteRewardActivity(Long id) {
|
public void deleteRewardActivity(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
|
RewardActivityDO dbRewardActivity = validateRewardActivityExists(id);
|
||||||
if (!dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢
|
if (dbRewardActivity.getStatus().equals(CommonStatusEnum.ENABLE.getStatus())) { // 未关闭的活动,不能删除噢
|
||||||
throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED);
|
throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,41 +111,39 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @芋艿:逻辑有问题,需要优化;要分成全场、和指定来校验;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验商品参加的活动是否冲突
|
* 校验商品参加的活动是否冲突
|
||||||
*
|
*
|
||||||
* @param id 活动编号
|
* @param id 活动编号
|
||||||
* @param spuIds 商品 SPU 编号数组
|
* @param rewardActivity 请求
|
||||||
*/
|
*/
|
||||||
private void validateRewardActivitySpuConflicts(Long id, Collection<Long> spuIds) {
|
private void validateRewardActivitySpuConflicts(Long id, RewardActivityBaseVO rewardActivity) {
|
||||||
if (CollUtil.isEmpty(spuIds)) {
|
List<RewardActivityDO> list = rewardActivityMapper.selectList(RewardActivityDO::getProductScope,
|
||||||
return;
|
rewardActivity.getProductScope(), RewardActivityDO::getStatus, CommonStatusEnum.ENABLE.getStatus());
|
||||||
}
|
|
||||||
// 查询商品参加的活动
|
|
||||||
List<RewardActivityDO> rewardActivityList = getRewardActivityListBySpuIds(spuIds,
|
|
||||||
asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus()));
|
|
||||||
if (id != null) { // 排除自己这个活动
|
if (id != null) { // 排除自己这个活动
|
||||||
rewardActivityList.removeIf(activity -> id.equals(activity.getId()));
|
list.removeIf(activity -> id.equals(activity.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 情况一:全部商品参加
|
||||||
|
if (PromotionProductScopeEnum.isAll(rewardActivity.getProductScope()) && !list.isEmpty()) {
|
||||||
|
throw exception(REWARD_ACTIVITY_SCOPE_ALL_EXISTS);
|
||||||
|
}
|
||||||
|
if (PromotionProductScopeEnum.isSpu(rewardActivity.getProductScope()) || // 情况二:指定商品参加
|
||||||
|
PromotionProductScopeEnum.isCategory(rewardActivity.getProductScope())) { // 情况三:指定商品类型参加
|
||||||
|
if (anyMatch(list, item -> !intersectionDistinct(item.getProductScopeValues(),
|
||||||
|
rewardActivity.getProductScopeValues()).isEmpty())) {
|
||||||
|
throw exception(PromotionProductScopeEnum.isSpu(rewardActivity.getProductScope()) ?
|
||||||
|
REWARD_ACTIVITY_SPU_CONFLICTS : REWARD_ACTIVITY_SCOPE_CATEGORY_EXISTS);
|
||||||
}
|
}
|
||||||
// 如果非空,则说明冲突
|
|
||||||
if (CollUtil.isNotEmpty(rewardActivityList)) {
|
|
||||||
throw exception(REWARD_ACTIVITY_SPU_CONFLICTS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void validateProductScope(Integer productScope, List<Long> productScopeValues) {
|
||||||
* 获得商品参加的满减送活动的数组
|
if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) {
|
||||||
*
|
productSpuApi.validateSpuList(productScopeValues).checkError();
|
||||||
* @param spuIds 商品 SPU 编号数组
|
} else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) {
|
||||||
* @param statuses 活动状态数组
|
productCategoryApi.validateCategoryList(productScopeValues).checkError();
|
||||||
* @return 商品参加的满减送活动的数组
|
}
|
||||||
*/
|
|
||||||
private List<RewardActivityDO> getRewardActivityListBySpuIds(Collection<Long> spuIds,
|
|
||||||
Collection<Integer> statuses) {
|
|
||||||
List<RewardActivityDO> list = rewardActivityMapper.selectListByStatus(statuses);
|
|
||||||
return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,32 +158,13 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RewardActivityMatchRespDTO> getMatchRewardActivityList(Collection<Long> spuIds) {
|
public List<RewardActivityMatchRespDTO> getMatchRewardActivityList(Collection<Long> spuIds) {
|
||||||
// TODO 芋艿:待实现;先指定,然后再全局的;
|
List<RewardActivityDO> list = rewardActivityMapper.selectListBySpuIdsAndStatus(spuIds, CommonStatusEnum.ENABLE.getStatus());
|
||||||
// // 如果有全局活动,则直接选择它
|
return BeanUtils.toBean(list, RewardActivityMatchRespDTO.class);
|
||||||
// List<RewardActivityDO> allActivities = rewardActivityMapper.selectListByProductScopeAndStatus(
|
|
||||||
// PromotionProductScopeEnum.ALL.getScope(), PromotionActivityStatusEnum.RUN.getStatus());
|
|
||||||
// if (CollUtil.isNotEmpty(allActivities)) {
|
|
||||||
// return MapUtil.builder(allActivities.get(0), spuIds).build();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 查询某个活动参加的活动
|
|
||||||
// List<RewardActivityDO> productActivityList = getRewardActivityListBySpuIds(spuIds,
|
|
||||||
// singleton(PromotionActivityStatusEnum.RUN.getStatus()));
|
|
||||||
// return convertMap(productActivityList, activity -> activity,
|
|
||||||
// rewardActivityDO -> intersectionDistinct(rewardActivityDO.getProductSpuIds(), spuIds)); // 求交集返回
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RewardActivityDO> getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection<Long> spuIds, Integer status, LocalDateTime dateTime) {
|
public List<RewardActivityDO> getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||||
// 1. 查询出指定 spuId 的 spu 参加的活动
|
return rewardActivityMapper.selectListByStatusAndDateTimeLt(status, dateTime);
|
||||||
List<RewardActivityDO> rewardActivityList = rewardActivityMapper.selectListBySpuIdsAndStatus(spuIds, status);
|
|
||||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 查询活动详情
|
|
||||||
return rewardActivityMapper.selectListByIdsAndDateTimeLt(convertSet(rewardActivityList, RewardActivityDO::getId), dateTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -71,7 +71,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,12 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ spring:
|
||||||
primary: master
|
primary: master
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
|
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
|
||||||
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
|
||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例
|
||||||
|
@ -71,7 +71,7 @@ spring:
|
||||||
# password: SYSDBA # DM 连接的示例
|
# password: SYSDBA # DM 连接的示例
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
lazy: true # 开启懒加载,保证启动速度
|
lazy: true # 开启懒加载,保证启动速度
|
||||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,13 @@ public interface TradeOrderApi {
|
||||||
@Parameter(name = "id", description = "订单编号", required = true)
|
@Parameter(name = "id", description = "订单编号", required = true)
|
||||||
CommonResult<TradeOrderRespDTO> getOrder(@RequestParam("id") Long id);
|
CommonResult<TradeOrderRespDTO> getOrder(@RequestParam("id") Long id);
|
||||||
|
|
||||||
// TODO 芋艿:需要优化下;
|
|
||||||
@PutMapping(PREFIX + "/cancel-paid")
|
@PutMapping(PREFIX + "/cancel-paid")
|
||||||
@Parameters({
|
@Parameters({
|
||||||
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
|
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
|
||||||
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
|
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
|
||||||
})
|
})
|
||||||
CommonResult<Boolean> cancelPaidOrder(@RequestParam("userId") Long userId,
|
CommonResult<Boolean> cancelPaidOrder(@RequestParam("userId") Long userId,
|
||||||
@RequestParam("orderId") Long orderId);
|
@RequestParam("orderId") Long orderId,
|
||||||
|
@RequestParam("cancelType") Integer cancelType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
|
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
|
||||||
ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态");
|
ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态");
|
||||||
ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单");
|
ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单");
|
||||||
|
ErrorCode ORDER_CANCEL_PAID_FAIL = new ErrorCode(1_011_000_033, "交易订单取消支付失败,原因:订单不是【{}】状态");
|
||||||
|
|
||||||
// ========== After Sale 模块 1-011-000-100 ==========
|
// ========== After Sale 模块 1-011-000-100 ==========
|
||||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
||||||
|
@ -50,6 +51,7 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1_011_000_110, "退款失败,售后单状态不是【待退款】");
|
ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1_011_000_110, "退款失败,售后单状态不是【待退款】");
|
||||||
ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY =
|
ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY =
|
||||||
new ErrorCode(1_011_000_111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】或【商家待收货】");
|
new ErrorCode(1_011_000_111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】或【商家待收货】");
|
||||||
|
ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_COMBINATION_IN_PROGRESS = new ErrorCode(1_011_000_112, "订单拼团中,无法申请售后");
|
||||||
|
|
||||||
// ========== Cart 模块 1-011-002-000 ==========
|
// ========== Cart 模块 1-011-002-000 ==========
|
||||||
ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1_011_002_000, "购物车项不存在");
|
ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1_011_002_000, "购物车项不存在");
|
||||||
|
@ -59,6 +61,8 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1_011_003_002, "计算快递运费异常,找不到对应的运费模板");
|
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1_011_003_002, "计算快递运费异常,找不到对应的运费模板");
|
||||||
ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵");
|
ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵");
|
||||||
ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量");
|
ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量");
|
||||||
|
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TYPE_ILLEGAL = new ErrorCode(1_011_003_006, "计算快递运费异常,配送方式不匹配");
|
||||||
|
ErrorCode PRICE_CALCULATE_COUPON_CAN_NOT_USE = new ErrorCode(1_011_003_007, "该优惠劵无法使用,原因:{}」");
|
||||||
|
|
||||||
// ========== 物流 Express 模块 1-011-004-000 ==========
|
// ========== 物流 Express 模块 1-011-004-000 ==========
|
||||||
ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在");
|
ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在");
|
||||||
|
|
|
@ -17,7 +17,8 @@ public enum TradeOrderCancelTypeEnum implements IntArrayValuable {
|
||||||
|
|
||||||
PAY_TIMEOUT(10, "超时未支付"),
|
PAY_TIMEOUT(10, "超时未支付"),
|
||||||
AFTER_SALE_CLOSE(20, "退款关闭"),
|
AFTER_SALE_CLOSE(20, "退款关闭"),
|
||||||
MEMBER_CANCEL(30, "买家取消");
|
MEMBER_CANCEL(30, "买家取消"),
|
||||||
|
COMBINATION_CLOSE(40, "拼团关闭");
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray();
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class TradeOrderApiImpl implements TradeOrderApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<Boolean> cancelPaidOrder(Long userId, Long orderId) {
|
public CommonResult<Boolean> cancelPaidOrder(Long userId, Long orderId, Integer cancelType) {
|
||||||
tradeOrderUpdateService.cancelPaidOrder(userId, orderId);
|
tradeOrderUpdateService.cancelPaidOrder(userId, orderId, cancelType);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO;
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
||||||
|
@ -12,14 +12,11 @@ import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
@ -35,6 +32,7 @@ public class AppAfterSaleController {
|
||||||
|
|
||||||
@GetMapping(value = "/page")
|
@GetMapping(value = "/page")
|
||||||
@Operation(summary = "获得售后分页")
|
@Operation(summary = "获得售后分页")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(PageParam pageParam) {
|
public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(PageParam pageParam) {
|
||||||
return success(AfterSaleConvert.INSTANCE.convertPage02(
|
return success(AfterSaleConvert.INSTANCE.convertPage02(
|
||||||
afterSaleService.getAfterSalePage(getLoginUserId(), pageParam)));
|
afterSaleService.getAfterSalePage(getLoginUserId(), pageParam)));
|
||||||
|
@ -43,18 +41,21 @@ public class AppAfterSaleController {
|
||||||
@GetMapping(value = "/get")
|
@GetMapping(value = "/get")
|
||||||
@Operation(summary = "获得售后订单")
|
@Operation(summary = "获得售后订单")
|
||||||
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
|
public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
|
||||||
return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
|
return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/create")
|
@PostMapping(value = "/create")
|
||||||
@Operation(summary = "申请售后")
|
@Operation(summary = "申请售后")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<Long> createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) {
|
public CommonResult<Long> createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) {
|
||||||
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
|
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping(value = "/delivery")
|
@PutMapping(value = "/delivery")
|
||||||
@Operation(summary = "退回货物")
|
@Operation(summary = "退回货物")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<Boolean> deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) {
|
public CommonResult<Boolean> deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) {
|
||||||
afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO);
|
afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
@ -63,6 +64,7 @@ public class AppAfterSaleController {
|
||||||
@DeleteMapping(value = "/cancel")
|
@DeleteMapping(value = "/cancel")
|
||||||
@Operation(summary = "取消售后")
|
@Operation(summary = "取消售后")
|
||||||
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<Boolean> cancelAfterSale(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> cancelAfterSale(@RequestParam("id") Long id) {
|
||||||
afterSaleService.cancelAfterSale(getLoginUserId(), id);
|
afterSaleService.cancelAfterSale(getLoginUserId(), id);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService;
|
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService;
|
||||||
|
@ -33,6 +34,7 @@ public class AppAfterSaleLogController {
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得售后日志列表")
|
@Operation(summary = "获得售后日志列表")
|
||||||
@Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1")
|
@Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<List<AppAfterSaleLogRespVO>> getAfterSaleLogList(
|
public CommonResult<List<AppAfterSaleLogRespVO>> getAfterSaleLogList(
|
||||||
@RequestParam("afterSaleId") Long afterSaleId) {
|
@RequestParam("afterSaleId") Long afterSaleId) {
|
||||||
List<AfterSaleLogDO> logs = afterSaleLogService.getAfterSaleLogList(afterSaleId);
|
List<AfterSaleLogDO> logs = afterSaleLogService.getAfterSaleLogList(afterSaleId);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi
|
||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppBrokerageRecordController {
|
public class AppBrokerageRecordController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BrokerageRecordService brokerageRecordService;
|
private BrokerageRecordService brokerageRecordService;
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ public class AppBrokerageRecordController {
|
||||||
|
|
||||||
@GetMapping("/get-product-brokerage-price")
|
@GetMapping("/get-product-brokerage-price")
|
||||||
@Operation(summary = "获得商品的分销金额")
|
@Operation(summary = "获得商品的分销金额")
|
||||||
|
@PreAuthenticated
|
||||||
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
||||||
return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId));
|
return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId));
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue