Compare commits

...
61 Commits
Author SHA1 Message Date
timi 15d69f9361 Merge pull request 'v1.0.39' (#51) from dev into master
Reviewed-on: #51
2026-09-10 06:10:30 +00:00
Timi b000390a75 v1.0.39
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-09-10 14:09:49 +08:00
Timi 1b9f92caf5 add setting map 2026-09-10 14:09:38 +08:00
Timi 7b08641acc add customer order map 2026-09-10 14:09:30 +08:00
Timi 66c13062b2 fix notify fail 2026-09-10 12:47:29 +08:00
timi 2b4089ef59 Merge pull request 'v1.0.38' (#50) from dev into master
Reviewed-on: #50
2026-09-09 17:33:25 +00:00
Timi cdf8a426e9 v1.0.38
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-10 01:31:20 +08:00
Timi a2d69fe721 support gift 2026-09-10 01:31:06 +08:00
Timi 19db357b44 update article CRUD 2026-09-10 01:30:50 +08:00
Timi 07ffef3e2a add cancel operator 2026-09-09 17:14:29 +08:00
timi 20c3e1f422 Merge pull request 'v1.0.37' (#49) from dev into master
Reviewed-on: #49
2026-09-09 06:21:55 +00:00
Timi f93ec3cd4d v1.0.37
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-09 14:21:18 +08:00
Timi 3cdac98832 add allowDecimalQuantity 2026-09-09 14:21:04 +08:00
Timi c122c35376 refactor LoggerService.excute 2026-09-09 13:04:16 +08:00
timi 3b19d9e930 Merge pull request 'v1.0.36' (#48) from dev into master
Reviewed-on: #48
2026-09-08 17:52:47 +00:00
Timi 2ea06fb5c0 v1.0.36
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-09 01:49:52 +08:00
Timi 00bb300755 support split fulfillment by base unit 2026-09-09 01:49:40 +08:00
Timi ea44dd5c0e update point rule groovy script 2026-09-09 01:08:45 +08:00
Timi 818207d6c9 fix FileController 2026-09-08 18:09:31 +08:00
Timi af76eb43b8 update SystemSetting 2026-09-08 16:52:32 +08:00
timi 5fd11e9caf Merge pull request 'v1.0.35' (#47) from dev into master
Reviewed-on: #47
2026-09-07 17:06:28 +00:00
Timi d920b8630d v1.0.35
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-08 01:05:45 +08:00
timi 0b98dcdfe9 Merge pull request 'v1.0.34' (#46) from dev into master
Reviewed-on: #46
2026-09-07 15:11:06 +00:00
Timi 1e62576d36 v1.0.34
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 23:10:27 +08:00
timi b373cbbe46 Merge pull request 'v1.0.33' (#45) from dev into master
Reviewed-on: #45
2026-09-07 09:40:39 +00:00
Timi bb5abcb48e v1.0.33
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 17:40:06 +08:00
timi acd97c7b9b Merge pull request 'v1.0.32' (#44) from dev into master
Reviewed-on: #44
2026-09-07 08:42:29 +00:00
Timi 4a549e77cb v1.0.32
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 16:41:53 +08:00
timi 118bdb1666 Merge pull request 'v1.0.31' (#43) from dev into master
Reviewed-on: #43
2026-09-07 07:40:03 +00:00
Timi 461af4d581 v1.0.31
CI / build-deploy (pull_request) Successful in 39s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 15:33:29 +08:00
Timi 37dc1c9904 add gao product SKU 2026-09-07 12:07:18 +08:00
Timi 3a4386261c add gao user remind 2026-09-07 12:06:38 +08:00
Timi 01d33a1122 add product/order chart 2026-09-06 17:56:47 +08:00
Timi db2fca5715 update customer package 2026-09-06 15:49:57 +08:00
Timi f3166f0413 add sales order 2026-09-06 12:09:58 +08:00
Timi 41f692aad9 add groovy script 2026-09-04 20:38:17 +08:00
Timi df16ac3c8e rename GaoStockRecord to GaoProductStockRecord 2026-09-04 10:37:43 +08:00
Timi 913dc3d278 update product unit 2026-09-03 15:16:16 +08:00
Timi 731c777b8b add gao product 2026-09-03 10:47:58 +08:00
timi 944de228f7 Merge pull request 'v1.0.30' (#42) from dev into master
Reviewed-on: #42
2026-09-01 17:44:48 +00:00
Timi a81c8476e7 v1.0.30
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-02 01:44:32 +08:00
timi 25c9cd4dfc Merge pull request 'v1.0.30' (#41) from dev into master
Reviewed-on: #41
2026-09-01 17:42:44 +00:00
Timi e7cf1a72e3 v1.0.30
CI / build-deploy (pull_request) Failing after 6s
CI / notify-on-failure (pull_request) Successful in 0s
2026-09-02 01:42:24 +08:00
timi 882cd226ec Merge pull request 'v1.0.30' (#40) from dev into master
Reviewed-on: #40
2026-09-01 17:38:50 +00:00
Timi eec665109e v1.0.30
CI / build-deploy (pull_request) Failing after 3s
CI / notify-on-failure (pull_request) Successful in 0s
2026-09-02 01:37:47 +08:00
Timi f6a2f5a6f5 support half paid 2026-09-01 14:07:04 +08:00
Timi 9ba610de86 update store diary attachment 2026-09-01 14:06:13 +08:00
Timi e59dc363f4 v1.0.29
CI / build-deploy (pull_request) Skipped
CI / notify-on-failure (pull_request) Skipped
2026-09-01 01:17:10 +08:00
Timi eeb7b5b32e add GaoPackage 2026-09-01 01:16:52 +08:00
Timi b4b6a13f8d add GaoPackage 2026-08-31 20:31:28 +08:00
Timi 4a7de1909c fix store diary page 2026-08-31 17:26:33 +08:00
Timi b7fcecfa7b add store diary 2026-08-31 15:10:25 +08:00
Timi 3b68e6dd85 update event status 2026-08-31 12:20:51 +08:00
timi feb4d7af66 Merge pull request 'v1.0.28' (#38) from dev into master
Reviewed-on: #38
2026-08-30 15:51:37 +00:00
Timi 5cfcd24657 v1.0.28
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-30 23:51:06 +08:00
Timi 712118556b add event option 2026-08-30 23:50:47 +08:00
timi d75ab1ed5f Merge pull request 'v1.0.27' (#37) from dev into master
Reviewed-on: #37
2026-08-29 17:49:23 +00:00
Timi 4496619eeb v1.0.27
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-30 01:46:02 +08:00
Timi c85b400a94 fix require photo event 2026-08-30 01:25:22 +08:00
Timi 94c99e3444 fix update customer code 2026-08-29 16:05:24 +08:00
Timi 44c2095d77 add event verify 2026-08-29 15:35:11 +08:00
336 changed files with 18240 additions and 940 deletions
+7 -2
View File
@@ -11,7 +11,7 @@
<groupId>com.imyeyu.timiserverapi</groupId> <groupId>com.imyeyu.timiserverapi</groupId>
<artifactId>TimiServerAPI</artifactId> <artifactId>TimiServerAPI</artifactId>
<version>1.0.26</version> <version>1.0.39</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>TimiServerAPI</name> <name>TimiServerAPI</name>
<description>imyeyu.com API</description> <description>imyeyu.com API</description>
@@ -180,6 +180,11 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.29</version>
</dependency>
<dependency> <dependency>
<groupId>com.imyeyu.spring</groupId> <groupId>com.imyeyu.spring</groupId>
<artifactId>timi-spring</artifactId> <artifactId>timi-spring</artifactId>
@@ -198,7 +203,7 @@
<dependency> <dependency>
<groupId>com.imyeyu.java</groupId> <groupId>com.imyeyu.java</groupId>
<artifactId>timi-java</artifactId> <artifactId>timi-java</artifactId>
<version>0.0.7</version> <version>0.0.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.imyeyu.utils</groupId> <groupId>com.imyeyu.utils</groupId>
@@ -1,35 +0,0 @@
package com.imyeyu.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 启用配置注解
*
* @author 夜雨
* @since 2023-07-15 10:00
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EnableSetting {
/**
*
*
* @author 夜雨
* @since 2026-04-27 14:45
*/
enum Logic {
AND,
OR
}
Logic logic() default Logic.AND;
/** @return 未启用配置时响应消息语言映射键 */
String message() default "service.offline";
}
@@ -1,55 +0,0 @@
package com.imyeyu.api.annotation;
import com.imyeyu.api.modules.common.service.SettingService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
* 启用配置注解处理器
*
* @author 夜雨
* @since 2023-07-15 10:01
*/
@Component
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class EnableSettingInterceptor implements HandlerInterceptor {
private final SettingService service;
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) throws InvocationTargetException, IllegalAccessException {
if (handler instanceof HandlerMethod handlerMethod) {
EnableSetting annotation = handlerMethod.getMethodAnnotation(EnableSetting.class);
if (annotation == null) {
return true;
}
EnableSetting.Logic logic = annotation.logic();
List<Boolean> valueList = new ArrayList<>();
for (Method method : annotation.getClass().getMethods()) {
if (method.getName().equals("message")) {
continue;
}
Enum<?>[] enums = (Enum<?>[]) method.invoke(annotation);
for (Enum<?> anEnum : enums) {
valueList.add(service.getSystem(anEnum).isTrue());
}
}
if (logic == EnableSetting.Logic.AND) {
return valueList.stream().allMatch(Boolean::booleanValue);
} else {
return valueList.stream().anyMatch(Boolean::booleanValue);
}
}
return true;
}
}
@@ -0,0 +1,17 @@
package com.imyeyu.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
///
///
/// @author 夜雨
/// @since 2026-09-08 15:22
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface SettingBizType {
String value();
}
@@ -45,6 +45,11 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
TAG_UPDATE("TAG:UPDATE", "标签修改", false, true), TAG_UPDATE("TAG:UPDATE", "标签修改", false, true),
TAG_DELETE("TAG:DELETE", "标签删除", false, true), TAG_DELETE("TAG:DELETE", "标签删除", false, true),
ARTICLE_CREATE("ARTICLE:CREATE", "文章创建", false, true),
ARTICLE_READ("ARTICLE:READ", "文章读取", false, true),
ARTICLE_UPDATE("ARTICLE:UPDATE", "文章修改", false, true),
ARTICLE_DELETE("ARTICLE:DELETE", "文章删除", false, true),
USER_CREATE("USER:CREATE", "用户创建", false, true), USER_CREATE("USER:CREATE", "用户创建", false, true),
USER_READ("USER:READ", "用户读取", false, true), USER_READ("USER:READ", "用户读取", false, true),
USER_UPDATE("USER:UPDATE", "用户修改", false, true), USER_UPDATE("USER:UPDATE", "用户修改", false, true),
@@ -0,0 +1,27 @@
package com.imyeyu.api.bean;
import com.imyeyu.api.annotation.SettingBizType;
import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.utils.Text;
///
///
/// @author 夜雨
/// @since 2026-09-08 15:18
public interface SettingEnum {
default String getBizType() {
Class<? extends SettingEnum> implEnum = getClass();
SettingBizType bizType = implEnum.getAnnotation(SettingBizType.class);
if (bizType == null) {
return Text.bizClassName(implEnum);
}
return bizType.value();
}
String name();
String getDefaultValue();
Setting.ValueType getValueType();
}
@@ -32,4 +32,22 @@ public class ThreadPoolConfig {
executor.initialize(); executor.initialize();
return executor; return executor;
} }
/// 创建操作审计线程池
///
/// @return 操作审计线程池
@Bean(name = "auditTaskExecutor")
public ThreadPoolTaskExecutor auditTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(8);
executor.setQueueCapacity(2000);
executor.setKeepAliveSeconds(60);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationSeconds(60);
executor.setThreadNamePrefix("audit-task-executor-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
}
} }
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.imyeyu.api.annotation.EnableSettingInterceptor;
import com.imyeyu.api.annotation.RequestRateLimitInterceptor; import com.imyeyu.api.annotation.RequestRateLimitInterceptor;
import com.imyeyu.api.annotation.RequireCorePermissionInterceptor; import com.imyeyu.api.annotation.RequireCorePermissionInterceptor;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor; import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor;
@@ -40,7 +39,6 @@ public class WebConfig implements WebMvcConfigurer {
private final ObjectMapper jackson; private final ObjectMapper jackson;
private final SystemAPIInterceptor systemAPIInterceptor; private final SystemAPIInterceptor systemAPIInterceptor;
private final JournalAPIInterceptor journalAPIInterceptor; private final JournalAPIInterceptor journalAPIInterceptor;
private final EnableSettingInterceptor enableSettingInterceptor;
private final RequestRateLimitInterceptor requestRateLimitInterceptor; private final RequestRateLimitInterceptor requestRateLimitInterceptor;
private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor; private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor;
private final RequireCorePermissionInterceptor requireCorePermissionInterceptor; private final RequireCorePermissionInterceptor requireCorePermissionInterceptor;
@@ -54,7 +52,6 @@ public class WebConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(systemAPIInterceptor).addPathPatterns(SystemAPIInterceptor.PATH); registry.addInterceptor(systemAPIInterceptor).addPathPatterns(SystemAPIInterceptor.PATH);
registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH); registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH);
registry.addInterceptor(enableSettingInterceptor).addPathPatterns("/**");
registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**"); registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**");
registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**"); registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**");
registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**"); registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**");
@@ -0,0 +1,9 @@
package com.imyeyu.api.modules.common.bean;
/// Groovy 脚本执行结果
///
/// @param <T> 脚本返回值类型
/// @author Codex
/// @since 2026-09-04
public record GroovyScriptExecutionResult<T>(String scriptId, String versionId, Integer version, String checksum, T result) {
}
@@ -1,52 +0,0 @@
package com.imyeyu.api.modules.common.bean;
import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 设置模块
*
* @author 夜雨
* @since 2026-04-24 00:59
*/
@Getter
@AllArgsConstructor
public enum SettingModule {
COMMON(Setting.Module.Common.class),
DOMAIN(Setting.Module.Domain.class),
FOREVER_MC(Setting.Module.ForeverMC.class),
MULTILINGUAL(Setting.Module.Multilingual.class),
GITEA(Setting.Module.Gitea.class),
MUSIC(Setting.Module.Music.class),
JOURNAL(Setting.Module.Journal.class),
TEMP_FILE(Setting.Module.TempFile.class),
USER(Setting.Module.User.class),
SYSTEM(Setting.Module.System.class),
SYSTEM_STATUS(Setting.Module.SystemStatus.class);
/** 模块枚举类 */
final Class<? extends Enum<?>> clazz;
public static <T extends Enum<?>> SettingModule fromClass(Class<T> clazz) {
for (SettingModule value : values()) {
if (value.clazz.equals(clazz)) {
return value;
}
}
throw new TimiException(TimiCode.ERROR, "not found System Module: %s".formatted(clazz.getName()));
}
}
@@ -0,0 +1,41 @@
package com.imyeyu.api.modules.common.bean;
import com.imyeyu.api.annotation.SettingBizType;
import com.imyeyu.api.bean.SettingEnum;
import com.imyeyu.api.modules.common.entity.Setting;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:47
*/
@Getter
@SettingBizType("TEMP_FILE")
@AllArgsConstructor
public enum TempFileSetting implements SettingEnum {
/** 启用服务 */
ENABLE(Boolean.TRUE.toString(), Setting.ValueType.BOOLEAN),
/** 最小缓存时长 */
TTL_MIN("1h", Setting.ValueType.TIME),
/** 默认缓存时长 */
TTL_DEFAULT("3d", Setting.ValueType.TIME),
/** 最大缓存时长 */
TTL_MAX("7d", Setting.ValueType.TIME),
/** 已过期文件残留时长 */
RESIDUE_TTL("90d", Setting.ValueType.TIME),
/** 每个 IP 限制有效临时文件容量 */
LIMIT_SIZE_OF_IP("10 GB", Setting.ValueType.BYTE_SIZE);
final String defaultValue;
final Setting.ValueType valueType;
}
@@ -0,0 +1,95 @@
package com.imyeyu.api.modules.common.controller;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.annotation.RequireCorePermission;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.modules.common.entity.Article;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.ArticleService;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/// 文章接口
///
/// @author Codex
/// @since 2026-09-09
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/article")
public class ArticleController {
private final ArticleService service;
private final AttachmentService attachmentService;
/// 查询文章列表
///
/// @param page 分页参数
/// @return 文章分页
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/list")
public PageResult<Article> list(@RequestBody Page<Article> page) {
return service.page(page);
}
/// 查询文章详情
///
/// @param id 文章 ID
/// @return 文章详情
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/detail")
public Article detail(@RequestParam String id) {
Article article = service.get(id);
article.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.ARTICLE, article.getId()));
return article;
}
/// 创建文章
///
/// @param article 文章
/// @return 创建后的文章
@AOPLog
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_CREATE)
@PostMapping("/create")
public Article create(@RequestBody Article article) {
service.create(article);
return article;
}
/// 更新文章
///
/// @param article 文章
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Article article) {
service.update(article);
}
/// 删除文章
///
/// @param id 文章 ID
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
}
@@ -1,5 +1,6 @@
package com.imyeyu.api.modules.common.controller; package com.imyeyu.api.modules.common.controller;
import com.imyeyu.api.modules.common.vo.ClientLogRequest;
import com.imyeyu.api.modules.system.entity.Logger; import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService; import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.spring.annotation.AOPLog; import com.imyeyu.spring.annotation.AOPLog;
@@ -29,7 +30,9 @@ public class LoggerController {
@AOPLog @AOPLog
@RequiredToken @RequiredToken
@PostMapping("/create") @PostMapping("/create")
public void create(@Valid @RequestBody Logger logger) { public void create(@Valid @RequestBody ClientLogRequest request) {
Logger logger = Logger.info(Logger.Module.COMMON, "CLIENT_LOG");
logger.setContent(request.getContent());
service.create(logger); service.create(logger);
} }
} }
@@ -58,6 +58,14 @@ public class NotifyController {
@RequiredToken @RequiredToken
@PostMapping("/create") @PostMapping("/create")
public Notify create(@RequestBody Notify notify) { public Notify create(@RequestBody Notify notify) {
String sendFrom = userLoginService.isLogged() ? userLoginService.getRequireLoginUserId() : null;
notify.setCreatedBy(sendFrom);
for (NotifyDetail detail : notify.getDetailList()) {
detail.setNotifyId(notify.getId());
if (TimiJava.isNotEmpty(sendFrom)) {
detail.setSendFrom(sendFrom);
}
}
service.create(notify); service.create(notify);
return notify; return notify;
} }
@@ -15,8 +15,12 @@ import lombok.extern.slf4j.Slf4j;
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;
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.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/** /**
* *
* *
@@ -26,11 +30,30 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/system/setting") @RequestMapping("/setting")
public class SettingController { public class SettingController {
private final SettingService service; private final SettingService service;
/**
* 查询公开配置映射
*
* @param bizType 业务类型
* @param bizId 业务 ID,可为空
* @param code 配置代码列表,可为空
* @return 公开配置映射
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@RequestMapping("/map")
public Map<String, Setting> map(
@RequestParam String bizType,
@RequestParam(required = false) String bizId,
@RequestParam(required = false) List<String> code
) {
return service.mapPublic(bizType, bizId, code);
}
/** /**
* 查询配置列表 * 查询配置列表
* *
@@ -53,6 +76,7 @@ public class SettingController {
*/ */
@JsonView(ResponseView.Admin.class) @JsonView(ResponseView.Admin.class)
@RequestRateLimit @RequestRateLimit
@RequireCorePermission(CorePermissionCode.SETTING_READ)
@PostMapping("/detail") @PostMapping("/detail")
public Setting detail(@RequestBody String id) { public Setting detail(@RequestBody String id) {
return service.get(id); return service.get(id);
@@ -66,6 +90,7 @@ public class SettingController {
*/ */
@AOPLog @AOPLog
@JsonView(ResponseView.Admin.class) @JsonView(ResponseView.Admin.class)
@RequireCorePermission(CorePermissionCode.SETTING_CREATE)
@RequestRateLimit @RequestRateLimit
@PostMapping("/create") @PostMapping("/create")
public Setting create(@RequestBody Setting setting) { public Setting create(@RequestBody Setting setting) {
@@ -80,6 +105,7 @@ public class SettingController {
*/ */
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireCorePermission(CorePermissionCode.SETTING_UPDATE)
@PostMapping("/update") @PostMapping("/update")
public void update(@RequestBody Setting setting) { public void update(@RequestBody Setting setting) {
service.update(setting); service.update(setting);
@@ -1,6 +1,7 @@
package com.imyeyu.api.modules.common.entity; package com.imyeyu.api.modules.common.entity;
import com.imyeyu.api.modules.common.bean.attachment.SettingSupport; import com.imyeyu.api.modules.common.bean.attachment.SettingSupport;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.PageIgnore; import com.imyeyu.spring.annotation.table.PageIgnore;
import com.imyeyu.spring.annotation.table.Transient; import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity; import com.imyeyu.spring.entity.UUIDEntity;
@@ -30,6 +31,11 @@ public class Article extends UUIDEntity implements SettingSupport {
/** 博客 */ /** 博客 */
BLOG, BLOG,
/// GAO 门店日记
GAO_STORE_DIARY,
GAO_SYSTEM,
/// 反馈 /// 反馈
FEEDBACK FEEDBACK
} }
@@ -93,6 +99,12 @@ public class Article extends UUIDEntity implements SettingSupport {
/** 文章状态 */ /** 文章状态 */
protected Status status; protected Status status;
/// 最后更新用户 ID
protected String updatedBy;
@Transient
protected User updater;
@Transient @Transient
protected List<Setting> settingList; protected List<Setting> settingList;
@@ -38,8 +38,20 @@ public class Attachment extends UUIDEntity {
GAO_CUSTOMER, GAO_CUSTOMER,
GAO_PRODUCT,
GAO_PRODUCT_SKU,
GAO_EVENT_RECORD, GAO_EVENT_RECORD,
GAO_FUND_RECORD,
GAO_STOCK_RECORD,
GAO_ORDER_FULFILLMENT,
GAO_SALES_ORDER,
TEMP_FILE, TEMP_FILE,
MIRROR MIRROR
@@ -0,0 +1,46 @@
package com.imyeyu.api.modules.common.entity;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// Groovy 脚本
///
/// @author Codex
/// @since 2026-09-04
@Data
@EqualsAndHashCode(callSuper = true)
public class GroovyScript extends UUIDEntity {
///
///
/// @author 夜雨
/// @since 2026/9/4 14:54
public enum BizType {
/// GAO 积分规则
GAO_POINT_RULE
}
/// 业务归属
private BizType bizType;
/// 业务内唯一代码
private String code;
/// 名称
private String name;
/// 说明
private String description;
/// true 为允许执行已发布版本
private Boolean enabled;
/// 当前发布版本 ID
private String publishedVersionId;
@Transient
private GroovyScriptVersion latest;
}
@@ -0,0 +1,26 @@
package com.imyeyu.api.modules.common.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// Groovy 脚本版本
///
/// @author Codex
/// @since 2026-09-04
@Data
@EqualsAndHashCode(callSuper = true)
public class GroovyScriptVersion extends UUIDEntity {
/// 脚本 ID
private String scriptId;
/// 版本号
private Integer version;
/// 脚本内容
private String content;
/// 脚本内容 SHA-256
private String checksum;
}
@@ -20,11 +20,11 @@ public class Notify extends UUIDEntity {
/** 业务类型 */ /** 业务类型 */
private String bizType; private String bizType;
/** 提醒业务类型 */ /** 业务提醒类型 */
private String bizRemindedType; private String bizRemindedType;
/** 提醒业务 ID */ /** 业务提醒查重键 */
private String bizRemindedId; private String bizRemindedKey;
/** 参数 */ /** 参数 */
private String args; private String args;
@@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.imyeyu.api.TimiServerAPI; import com.imyeyu.api.TimiServerAPI;
import com.imyeyu.api.modules.common.bean.SettingModule;
import com.imyeyu.spring.annotation.table.Transient; import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity; import com.imyeyu.spring.entity.UUIDEntity;
import com.imyeyu.spring.util.ResponseView; import com.imyeyu.spring.util.ResponseView;
@@ -62,6 +61,9 @@ public class Setting extends UUIDEntity {
/** 时间 */ /** 时间 */
TIME, TIME,
/// 字节大小
BYTE_SIZE,
/** 时长 */ /** 时长 */
DURATION, DURATION,
@@ -102,16 +104,6 @@ public class Setting extends UUIDEntity {
@Transient @Transient
private Enum<?> keyRaw; private Enum<?> keyRaw;
public Setting(Enum<?> key) {
setKeyRaw(key);
}
public Setting(Enum<?> key, Object value, ValueType valueType) {
setKeyRaw(key);
this.value = value.toString();
this.valueType = valueType;
}
/** /**
* 以字符串形式返回配置值 * 以字符串形式返回配置值
* *
@@ -221,298 +213,4 @@ public class Setting extends UUIDEntity {
throw new IllegalArgumentException("setting value is not valid json: %s".formatted(value), e); throw new IllegalArgumentException("setting value is not valid json: %s".formatted(value), e);
} }
} }
public void setKeyRaw(Enum<?> key) {
this.keyRaw = key;
this.bizType = SettingModule.fromClass(key.getClass()).toString();
this.code = key.toString();
}
public boolean is(Enum<?> key) {
return SettingModule.fromClass(key.getClass()).toString().equals(bizType) && key.toString().equals(code);
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:23
*/
public static final class Module {
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:39
*/
public enum Common {
/** 微信收款码 */
WECHAT_RECEIVE_QR_CODE
}
/**
* 域名
*
* @author 夜雨
* @since 2026-04-26 17:18
*/
public enum Domain {
ROOT,
API,
GIT,
BLOG,
SPACE,
FOREVER_MC
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:14
*/
public enum Blog {
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:03
*/
public enum User {
/** 启用登录 */
ENABLE_LOGIN,
/** 启用注册 */
ENABLE_REGISTER,
/** 允许数据更新 */
ENABLE_PROFILE_UPDATE,
/** 令牌有效期 */
TOKEN_TTL
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:21
*/
public enum Comment {
/** 启用服务 */
ENABLE
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:03
*/
public enum ICP {
IMYEYU_COM
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 15:01
*/
public enum ForeverMC {
PLAYER_BIND_MAX,
LOGIN_TOKEN_TTL
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:57
*/
public enum Multilingual {
/** 翻译 API */
TRANSLATE_API,
/** 翻译 AppId */
TRANSLATE_APP_ID,
/** 翻译密钥 */
TRANSLATE_KEY,
/** 翻译计划任务表达式 */
TRANSLATE_CORN,
/** 缓存时长 */
CACHE_TTL
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:55
*/
public enum Gitea {
/** 接口地址 */
API,
/** 关于页面所属文章 ID */
ABOUT_ARTICLE_ID,
/** 仓库文件地址 */
REPOSITORY_PATH
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:52
*/
public enum Music {
/** 启用服务 */
ENABLE,
/** 通信消息最大帧长度 */
MAX_FRAME_LENGTH,
/** 受控端 IP */
PLAYER_IP,
/** 受控端端口 */
PLAYER_PORT,
/** 控制端 IP */
CONTROLLER_IP,
/** 控制端端口 */
CONTROLLER_PORT,
/** 控制端入口地址 */
CONTROLLER_URI,
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:49
*/
public enum Journal {
/** 启用服务 */
ENABLE,
/** 审核中 */
REVIEWING,
/** 访问密钥 */
KEY,
/** 微信小程序 AppId */
APP_ID,
/** 微信小程序 AppSecret */
APP_SECRET,
/** 备忘录内容 */
MEMO,
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:47
*/
public enum TempFile {
/** 启用服务 */
ENABLE,
/** 最小缓存时长 */
TTL_MIN,
/** 默认缓存时长 */
TTL_DEFAULT,
/** 最大缓存时长 */
TTL_MAX,
/** 已过期文件残留时长 */
RESIDUE_TTL,
/** 每个 IP 限制有效临时文件容量 */
LIMIT_SIZE_OF_IP
}
/**
*
*
* @author 夜雨
* @since 2026-04-27 14:35
*/
public enum FileSync {
ENABLE,
CRON,
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:23
*/
public enum System {
/** 文件系统基准路径 */
FILE_BASE_PATH,
/** 设置缓存时长 */
SETTING_TTL,
/** 哀悼滤镜 */
ENABLE_MOURN_FILTER,
}
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:23
*/
public enum SystemStatus {
/** 状态采集数据量 */
LIMIT,
/** 状态采集网卡 */
NETWORK_MAC,
/** 状态采集频率 */
RATE,
}
}
} }
@@ -34,6 +34,8 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes); List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
List<Attachment> selectImageByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String attachType);
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes); long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
@Select("SELECT * FROM attachment WHERE `is_destroyed` = FALSE AND `destroy_at` < " + UNIX_TIME) @Select("SELECT * FROM attachment WHERE `is_destroyed` = FALSE AND `destroy_at` < " + UNIX_TIME)
@@ -0,0 +1,11 @@
package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.GroovyScript;
import com.imyeyu.spring.mapper.BaseMapper;
/// Groovy 脚本 Mapper
///
/// @author Codex
/// @since 2026-09-04
public interface GroovyScriptMapper extends BaseMapper<GroovyScript, String> {
}
@@ -0,0 +1,15 @@
package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.GroovyScriptVersion;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
/// Groovy 脚本版本 Mapper
///
/// @author Codex
/// @since 2026-09-04
public interface GroovyScriptVersionMapper extends BaseMapper<GroovyScriptVersion, String> {
@Select("SELECT * FROM `groovy_script_version` WHERE `script_id` = #{scriptId} " + NOT_DELETE + " ORDER BY `version` DESC " + LIMIT_1)
GroovyScriptVersion selectLatest(String scriptId);
}
@@ -2,8 +2,8 @@ package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.Notify; import com.imyeyu.api.modules.common.entity.Notify;
import com.imyeyu.api.modules.common.vo.NotifyManagementItem; import com.imyeyu.api.modules.common.vo.NotifyManagementItem;
import org.apache.ibatis.annotations.Param;
import com.imyeyu.spring.mapper.BaseMapper; import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@@ -15,6 +15,9 @@ import java.util.List;
*/ */
public interface NotifyMapper extends BaseMapper<Notify, String> { public interface NotifyMapper extends BaseMapper<Notify, String> {
/// 原子创建业务提醒
int insertIfAbsent(Notify notify);
/// 分页查询管理端通知 /// 分页查询管理端通知
/// ///
/// @param userId 管理员用户 ID /// @param userId 管理员用户 ID
@@ -3,6 +3,8 @@ package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.Setting; import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.spring.mapper.BaseMapper; import com.imyeyu.spring.mapper.BaseMapper;
import java.util.List;
/** /**
* 系统配置 * 系统配置
* *
@@ -10,4 +12,6 @@ import com.imyeyu.spring.mapper.BaseMapper;
* @since 2021-07-20 22:26 * @since 2021-07-20 22:26
*/ */
public interface SettingMapper extends BaseMapper<Setting, String> { public interface SettingMapper extends BaseMapper<Setting, String> {
List<Setting> selectPublicByQuery(String bizType, String bizId, List<String> codeList);
} }
@@ -3,6 +3,8 @@ package com.imyeyu.api.modules.common.service;
import com.imyeyu.api.modules.common.entity.Article; import com.imyeyu.api.modules.common.entity.Article;
import com.imyeyu.spring.service.BaseService; import com.imyeyu.spring.service.BaseService;
import java.util.List;
/** /**
* 文章服务 * 文章服务
* *
@@ -10,4 +12,10 @@ import com.imyeyu.spring.service.BaseService;
* @since 2021-02-23 21:33 * @since 2021-02-23 21:33
*/ */
public interface ArticleService extends BaseService<Article, String> { public interface ArticleService extends BaseService<Article, String> {
/// 按示例查询文章
///
/// @param example 查询示例
/// @return 文章列表
List<Article> listByExample(Article example);
} }
@@ -45,6 +45,12 @@ public interface AttachmentService extends BaseService<Attachment, String> {
*/ */
List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes); List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes);
default Map<String, Attachment> mapFirstImageByIdList(Attachment.BizType bizType, Collection<String> bizIdList) {
return mapFirstImageByIdList(bizType, bizIdList, null);
}
Map<String, Attachment> mapFirstImageByIdList(Attachment.BizType bizType, Collection<String> bizIdList, String attachType);
/** /**
* 根据多个业务 ID 批量获取附件 * 根据多个业务 ID 批量获取附件
* *
@@ -0,0 +1,109 @@
package com.imyeyu.api.modules.common.service;
import com.imyeyu.api.modules.common.bean.GroovyScriptExecutionResult;
import com.imyeyu.api.modules.common.entity.GroovyScript;
import com.imyeyu.api.modules.common.entity.GroovyScriptVersion;
import com.imyeyu.spring.service.BaseService;
import java.util.List;
import java.util.Map;
/// Groovy 脚本服务
///
/// 脚本仅限可信管理员维护,不能作为不可信用户代码的执行环境
///
/// @author Codex
/// @since 2026-09-04
public interface GroovyScriptService extends BaseService<GroovyScript, String> {
/// 按业务归属查询脚本列表
///
/// @param bizType 业务归属
/// @return 脚本列表
List<GroovyScript> listByBizType(GroovyScript.BizType bizType);
/// 按业务归属和代码查询脚本
///
/// @param bizType 业务归属
/// @param code 业务内唯一代码
/// @return 脚本,不存在时返回 null
GroovyScript getByCode(GroovyScript.BizType bizType, String code);
/// 设置脚本启用状态
///
/// @param id 脚本 ID
/// @param enabled true 为允许执行已发布版本
void setEnabled(String id, boolean enabled);
GroovyScriptVersion getLatestVersion(String scriptId);
/// 创建不可变的脚本版本
///
/// @param scriptId 脚本 ID
/// @param content 脚本内容
/// @return 新版本
GroovyScriptVersion createVersion(String scriptId, String content);
/// 查询脚本的全部版本
///
/// @param scriptId 脚本 ID
/// @return 按版本号升序的版本列表
List<GroovyScriptVersion> listVersion(String scriptId);
/// 发布指定版本
///
/// @param scriptId 脚本 ID
/// @param versionId 脚本版本 ID
void publish(String scriptId, String versionId);
/// 取消当前发布版本
///
/// @param scriptId 脚本 ID
void unpublish(String scriptId);
/// 执行已发布且启用的脚本
///
/// @param bizType 业务归属
/// @param code 业务内唯一代码
/// @param bindings 传给脚本的变量
/// @return 脚本返回值
Object execute(GroovyScript.BizType bizType, String code, Map<String, Object> bindings);
/// 执行已发布且启用的脚本并返回实际执行版本
///
/// @param bizType 业务归属
/// @param code 业务内唯一代码
/// @param bindings 传给脚本的变量
/// @param resultType 返回值类型
/// @param <T> 返回值类型
/// @return 脚本执行结果
<T> GroovyScriptExecutionResult<T> executePublished(GroovyScript.BizType bizType, String code, Map<String, Object> bindings, Class<T> resultType);
/// 按指定历史版本执行脚本
///
/// 用于按积分发生时的脚本版本复算,脚本当前是否发布或启用不影响执行;脚本返回 null 表示未命中,属合法结果
///
/// @param versionId 脚本版本 ID
/// @param bindings 传给脚本的变量
/// @param resultType 返回值类型
/// @param <T> 返回值类型
/// @return 脚本执行结果
<T> GroovyScriptExecutionResult<T> executeVersion(String versionId, Map<String, Object> bindings, Class<T> resultType);
/// 执行已发布且启用的脚本并验证返回值类型
///
/// @param bizType 业务归属
/// @param code 业务内唯一代码
/// @param bindings 传给脚本的变量
/// @param resultType 返回值类型
/// @param <T> 返回值类型
/// @return 脚本返回值
<T> T execute(GroovyScript.BizType bizType, String code, Map<String, Object> bindings, Class<T> resultType);
/// 清除脚本的本地编译缓存
///
/// 多实例部署时,其他节点在收到脚本变更通知后调用此方法
///
/// @param scriptId 脚本 ID
void invalidate(String scriptId);
}
@@ -14,6 +14,11 @@ import com.imyeyu.spring.service.BaseService;
*/ */
public interface NotifyService extends BaseService<Notify, String> { public interface NotifyService extends BaseService<Notify, String> {
/// 原子创建业务提醒,重复查重键不会创建通知详情
///
/// @param notify 通知
void createIfAbsent(Notify notify);
/// 分页查询当前用户创建的通知 /// 分页查询当前用户创建的通知
/// ///
/// @param page 分页参数 /// @param page 分页参数
@@ -1,12 +1,13 @@
package com.imyeyu.api.modules.common.service; package com.imyeyu.api.modules.common.service;
import com.imyeyu.api.modules.common.bean.SettingModule; import com.imyeyu.api.bean.SettingEnum;
import com.imyeyu.api.modules.common.bean.attachment.SettingSupport; import com.imyeyu.api.modules.common.bean.attachment.SettingSupport;
import com.imyeyu.api.modules.common.entity.Setting; import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.java.TimiJava; import com.imyeyu.java.TimiJava;
import com.imyeyu.spring.service.BaseService; import com.imyeyu.spring.service.BaseService;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 配置服务 * 配置服务
@@ -18,12 +19,22 @@ public interface SettingService extends BaseService<Setting, String> {
Setting getByCode(String bizType, String bizId, String code); Setting getByCode(String bizType, String bizId, String code);
default Setting getSystem(Enum<?> bizType) { default Setting getSystem(SettingEnum setting) {
return getByCode(SettingModule.fromClass(bizType.getClass()).name(), TimiJava.ZERO_UUID, bizType.toString()); return getByCode(setting.getBizType(), TimiJava.ZERO_UUID, setting.name());
} }
List<Setting> listByBizId(String bizType, String bizId); List<Setting> listByBizId(String bizType, String bizId);
/**
* 查询公开配置映射
*
* @param bizType 业务类型
* @param bizId 业务 ID,可为空
* @param code 配置代码列表,可为空
* @return 公开配置映射
*/
Map<String, Setting> mapPublic(String bizType, String bizId, List<String> code);
default List<Setting> listBySettingSupport(SettingSupport settingSupport) { default List<Setting> listBySettingSupport(SettingSupport settingSupport) {
String bizType = settingSupport.getClass().getSimpleName().toUpperCase(); String bizType = settingSupport.getClass().getSimpleName().toUpperCase();
return listByBizId(bizType, settingSupport.getId()); return listByBizId(bizType, settingSupport.getId());
@@ -16,6 +16,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 文章服务实现 * 文章服务实现
* *
@@ -37,6 +39,11 @@ public class ArticleServiceImplement extends AbstractEntityService<Article, Stri
return mapper; return mapper;
} }
@Override
public List<Article> listByExample(Article example) {
return mapper.selectAllByExample(example);
}
@Override @Override
public void create(Article article) { public void create(Article article) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_CREATE"); Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_CREATE");
@@ -34,10 +34,12 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -244,9 +246,14 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
return mapper.selectAllByBizIdList(bizType, List.of(bizId), List.of(attachTypes)); return mapper.selectAllByBizIdList(bizType, List.of(bizId), List.of(attachTypes));
} }
@Override
public Map<String, Attachment> mapFirstImageByIdList(Attachment.BizType bizType, Collection<String> bizIdList, String attachType) {
return mapper.selectImageByBizIdList(bizType, new HashSet<>(bizIdList), attachType).stream().collect(Collectors.toMap(Attachment::getBizId, Function.identity()));
}
@Override @Override
public Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String... attachTypes) { public Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String... attachTypes) {
return mapper.selectAllByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId)); return mapper.selectAllByBizIdList(bizType, new HashSet<>(bizIdList), List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
} }
@Override @Override
@@ -59,6 +59,7 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
private static final long THUMB_CACHE_TTL = Time.D * 7; private static final long THUMB_CACHE_TTL = Time.D * 7;
private static final long THUMB_LOCK_TTL = Time.M * 10; private static final long THUMB_LOCK_TTL = Time.M * 10;
private static final double THUMB_TARGET_SECONDS = 2; private static final double THUMB_TARGET_SECONDS = 2;
private static final int VARIANT_NAME_MAX_LENGTH = 255;
private static final String THUMB_OUTPUT_FORMAT = "png"; private static final String THUMB_OUTPUT_FORMAT = "png";
private static final String THUMB_ALGORITHM_VERSION = "v3"; private static final String THUMB_ALGORITHM_VERSION = "v3";
private static final String THUMB_LOCK_KEY_PREFIX = "ATTACHMENT:THUMB:LOCK:"; private static final String THUMB_LOCK_KEY_PREFIX = "ATTACHMENT:THUMB:LOCK:";
@@ -158,7 +159,7 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
thumbFile = createThumbFile(source, requestWidth, requestHeight, fitMode, isImage); thumbFile = createThumbFile(source, requestWidth, requestHeight, fitMode, isImage);
variant = new AttachmentVariant(); variant = new AttachmentVariant();
variant.setId(UUID.randomUUID().toString()); variant.setId(UUID.randomUUID().toString());
variant.setName(Network.simpleURIFileName(source.getName()) + "." + THUMB_OUTPUT_FORMAT); variant.setName(buildVariantName(source.getName()));
variant.setMimeType("image/" + THUMB_OUTPUT_FORMAT); variant.setMimeType("image/" + THUMB_OUTPUT_FORMAT);
long expireAt = Time.now() + THUMB_CACHE_TTL; long expireAt = Time.now() + THUMB_CACHE_TTL;
variant.setSourceAttachmentId(source.getId()); variant.setSourceAttachmentId(source.getId());
@@ -257,6 +258,20 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
); );
} }
/// 构建不超过数据库字段长度的变体名称
///
/// @param sourceName 源附件名称
/// @return 变体名称
private String buildVariantName(String sourceName) {
String suffix = "." + THUMB_OUTPUT_FORMAT;
String baseName = Network.simpleURIFileName(sourceName);
int maxBaseLength = VARIANT_NAME_MAX_LENGTH - suffix.length();
if (maxBaseLength < baseName.codePointCount(0, baseName.length())) {
baseName = baseName.substring(0, baseName.offsetByCodePoints(0, maxBaseLength));
}
return baseName + suffix;
}
private File createThumbFile( private File createThumbFile(
Attachment source, Attachment source,
Integer requestWidth, Integer requestWidth,
@@ -0,0 +1,299 @@
package com.imyeyu.api.modules.common.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.common.bean.GroovyScriptExecutionResult;
import com.imyeyu.api.modules.common.entity.GroovyScript;
import com.imyeyu.api.modules.common.entity.GroovyScriptVersion;
import com.imyeyu.api.modules.common.mapper.GroovyScriptMapper;
import com.imyeyu.api.modules.common.mapper.GroovyScriptVersionMapper;
import com.imyeyu.api.modules.common.service.GroovyScriptService;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService;
import groovy.lang.Binding;
import groovy.lang.GroovyClassLoader;
import groovy.lang.Script;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/// Groovy 脚本服务实现
///
/// 每个已编译版本使用独立类加载器,缓存失效后可释放对应类及其元数据
///
/// @author Codex
/// @since 2026-09-04
@Slf4j
@Service
@RequiredArgsConstructor
public class GroovyScriptServiceImplement extends AbstractEntityService<GroovyScript, String> implements GroovyScriptService {
private final GroovyScriptMapper mapper;
private final GroovyScriptVersionMapper versionMapper;
private final Map<String, CompiledScript> compiledScriptMap = new ConcurrentHashMap<>();
@Override
protected BaseMapper<GroovyScript, String> mapper() {
return mapper;
}
@Override
public List<GroovyScript> listByBizType(GroovyScript.BizType bizType) {
TimiException.required(bizType, "未找到脚本业务归属");
GroovyScript example = new GroovyScript();
example.setBizType(bizType);
return mapper.selectAllByExample(example);
}
@Override
public GroovyScript getByCode(GroovyScript.BizType bizType, String code) {
GroovyScript example = new GroovyScript();
example.setBizType(bizType);
example.setCode(code);
return mapper.selectByExample(example);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void create(GroovyScript script) {
TimiException.required(script, "未找到脚本");
TimiException.required(script.getBizType(), "未找到脚本业务归属");
TimiException.required(script.getCode(), "未找到脚本代码");
TimiException.required(script.getName(), "未找到脚本名称");
TimiException.requiredNull(getByCode(script.getBizType(), script.getCode()), "Groovy 脚本已存在");
script.setEnabled(false);
script.setPublishedVersionId(null);
super.create(script);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void update(GroovyScript script) {
TimiException.required(script, "未找到脚本");
TimiException.required(script.getId(), "未找到脚本 ID");
TimiException.required(script.getName(), "未找到脚本名称");
GroovyScript dbScript = get(script.getId());
TimiException.required(dbScript, "未找到脚本");
dbScript.setName(script.getName());
dbScript.setDescription(script.getDescription());
mapper.update(dbScript);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void setEnabled(String id, boolean enabled) {
GroovyScript script = requireScript(id);
script.setEnabled(enabled);
mapper.update(script);
invalidateAfterCommit(script.getId());
}
@Override
public GroovyScriptVersion getLatestVersion(String scriptId) {
return versionMapper.selectLatest(scriptId);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public GroovyScriptVersion createVersion(String scriptId, String content) {
requireScript(scriptId);
TimiException.required(content, "未找到脚本内容");
TimiException.requiredTrue(!content.isBlank(), "脚本内容不能为空");
GroovyScriptVersion version = new GroovyScriptVersion();
version.setScriptId(scriptId);
version.setVersion(versionMapper.selectLatest(scriptId).getVersion() + 1);
version.setContent(content);
version.setChecksum(checksum(content));
versionMapper.insert(version);
return version;
}
@Override
public List<GroovyScriptVersion> listVersion(String scriptId) {
TimiException.required(scriptId, "未找到脚本 ID");
GroovyScriptVersion example = new GroovyScriptVersion();
example.setScriptId(scriptId);
List<GroovyScriptVersion> versionList = new ArrayList<>(versionMapper.selectAllByExample(example));
versionList.sort(Comparator.comparing(GroovyScriptVersion::getVersion));
return versionList;
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void publish(String scriptId, String versionId) {
GroovyScript script = requireScript(scriptId);
GroovyScriptVersion version = requireVersion(versionId);
TimiException.requiredTrue(script.getId().equals(version.getScriptId()), "脚本版本不属于当前脚本");
script.setPublishedVersionId(version.getId());
mapper.update(script);
invalidateAfterCommit(script.getId());
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void unpublish(String scriptId) {
GroovyScript script = requireScript(scriptId);
script.setPublishedVersionId(null);
mapper.update(script);
invalidateAfterCommit(script.getId());
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void delete(String id) {
requireScript(id);
super.delete(id);
invalidateAfterCommit(id);
}
@Override
public Object execute(GroovyScript.BizType bizType, String code, Map<String, Object> bindings) {
return executePublished(bizType, code, bindings, Object.class).result();
}
@Override
public <T> GroovyScriptExecutionResult<T> executePublished(GroovyScript.BizType bizType, String code, Map<String, Object> bindings, Class<T> resultType) {
TimiException.required(bizType, "未找到脚本业务归属");
TimiException.required(code, "未找到脚本代码");
TimiException.required(resultType, "未找到返回值类型");
GroovyScript script = getByCode(bizType, code);
TimiException.required(script, "未找到 Groovy 脚本");
TimiException.requiredTrue(Boolean.TRUE.equals(script.getEnabled()), "Groovy 脚本已停用");
TimiException.required(script.getPublishedVersionId(), "Groovy 脚本尚未发布");
GroovyScriptExecutionResult<T> result = executeVersion(script.getPublishedVersionId(), bindings, resultType);
TimiException.requiredTrue(script.getId().equals(result.scriptId()), "Groovy 脚本已发布版本无效");
return result;
}
@Override
public <T> T execute(GroovyScript.BizType bizType, String code, Map<String, Object> bindings, Class<T> resultType) {
return executePublished(bizType, code, bindings, resultType).result();
}
@Override
public <T> GroovyScriptExecutionResult<T> executeVersion(String versionId, Map<String, Object> bindings, Class<T> resultType) {
TimiException.required(resultType, "未找到返回值类型");
GroovyScriptVersion version = requireVersion(versionId);
CompiledScript compiledScript = compiledScriptMap.computeIfAbsent(cacheKey(version), key -> compile(version.getScriptId(), version));
try {
Object result = compiledScript.execute(bindings);
TimiException.requiredTrue(result == null || resultType.isInstance(result), "Groovy 脚本返回值类型不匹配");
return new GroovyScriptExecutionResult<>(version.getScriptId(), version.getId(), version.getVersion(), version.getChecksum(), resultType.cast(result));
} catch (TimiException e) {
throw e;
} catch (RuntimeException e) {
log.warn("Groovy 脚本执行失败,scriptId={}, versionId={}", version.getScriptId(), version.getId(), e);
throw new TimiException(TimiCode.ERROR, "Groovy 脚本执行失败");
}
}
@Override
public void invalidate(String scriptId) {
if (scriptId == null) {
return;
}
compiledScriptMap.entrySet().removeIf(entry -> {
if (!scriptId.equals(entry.getValue().scriptId())) {
return false;
}
entry.getValue().close();
return true;
});
}
private GroovyScript requireScript(String id) {
TimiException.required(id, "未找到脚本 ID");
GroovyScript script = get(id);
TimiException.required(script, "未找到脚本");
return script;
}
private GroovyScriptVersion requireVersion(String id) {
TimiException.required(id, "未找到脚本版本 ID");
GroovyScriptVersion version = versionMapper.select(id);
TimiException.required(version, "未找到脚本版本");
return version;
}
private String cacheKey(GroovyScriptVersion version) {
return "%s:%s".formatted(version.getId(), version.getChecksum());
}
private CompiledScript compile(String scriptId, GroovyScriptVersion version) {
GroovyClassLoader classLoader = new GroovyClassLoader(getClass().getClassLoader());
try {
Class<?> type = classLoader.parseClass(version.getContent(), "GroovyScript_%s_%d.groovy".formatted(version.getId().replace('-', '_'), version.getVersion()));
return new CompiledScript(scriptId, type.asSubclass(Script.class), classLoader);
} catch (RuntimeException e) {
close(classLoader);
log.warn("Groovy 脚本编译失败,scriptId={}, versionId={}", scriptId, version.getId(), e);
throw new TimiException(TimiCode.ERROR, "Groovy 脚本编译失败");
}
}
private String checksum(String content) {
try {
return java.util.HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(content.getBytes(StandardCharsets.UTF_8)));
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("JVM 缺少 SHA-256 算法", e);
}
}
private void invalidateAfterCommit(String scriptId) {
if (!TransactionSynchronizationManager.isSynchronizationActive()) {
invalidate(scriptId);
return;
}
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
invalidate(scriptId);
}
});
}
private void close(GroovyClassLoader classLoader) {
try {
classLoader.close();
} catch (IOException e) {
log.warn("关闭 Groovy 脚本类加载器失败", e);
}
}
private record CompiledScript(String scriptId, Class<? extends Script> type, GroovyClassLoader classLoader) {
private Object execute(Map<String, Object> bindings) {
try {
Script script = type.getDeclaredConstructor().newInstance();
script.setBinding(new Binding(bindings == null ? Map.of() : new HashMap<>(bindings)));
return script.run();
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("Groovy 脚本实例化失败", e);
}
}
private void close() {
try {
classLoader.close();
} catch (IOException ignored) {
}
}
}
}
@@ -6,10 +6,9 @@ import com.imyeyu.api.modules.common.entity.NotifyDetail;
import com.imyeyu.api.modules.common.mapper.NotifyMapper; import com.imyeyu.api.modules.common.mapper.NotifyMapper;
import com.imyeyu.api.modules.common.service.NotifyDetailService; import com.imyeyu.api.modules.common.service.NotifyDetailService;
import com.imyeyu.api.modules.common.service.NotifyService; import com.imyeyu.api.modules.common.service.NotifyService;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.api.modules.common.vo.NotifyManagementItem; import com.imyeyu.api.modules.common.vo.NotifyManagementItem;
import com.imyeyu.api.modules.user.service.UserLoginService; import com.imyeyu.api.modules.system.audit.AuditOperation;
import com.imyeyu.api.modules.system.audit.OperationAudit;
import com.imyeyu.java.TimiJava; import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode; import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException; import com.imyeyu.java.bean.timi.TimiException;
@@ -17,12 +16,13 @@ import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult; import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.mapper.BaseMapper; import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService; import com.imyeyu.spring.service.AbstractEntityService;
import com.imyeyu.utils.Time;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
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 java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* 通知服务实现 * 通知服务实现
@@ -30,13 +30,10 @@ import java.util.List;
* @author 夜雨 * @author 夜雨
* @since 2026-05-13 14:46 * @since 2026-05-13 14:46
*/ */
@Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class NotifyServiceImplement extends AbstractEntityService<Notify, String> implements NotifyService { public class NotifyServiceImplement extends AbstractEntityService<Notify, String> implements NotifyService {
private final LoggerService loggerService;
private final UserLoginService userLoginService;
private final NotifyDetailService detailService; private final NotifyDetailService detailService;
private final NotifyMapper mapper; private final NotifyMapper mapper;
@@ -49,37 +46,50 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
/// 创建通知并级联创建通知详情 /// 创建通知并级联创建通知详情
/// ///
/// @param notify 通知 /// @param notify 通知
@OperationAudit(AuditOperation.COMMON_NOTIFY_CREATE)
@Transactional(TimiServerDBConfig.ROLLBACKER) @Transactional(TimiServerDBConfig.ROLLBACKER)
@Override @Override
public void create(Notify notify) { public void create(Notify notify) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_NOTIFY_CREATE"); prepareCreate(notify);
try { super.create(notify);
TimiException.required(notify, "未找到通知"); createDetails(notify);
TimiException.required(notify.getDetailList(), "未找到通知详情列表"); }
String sendFrom = userLoginService.isLogged() ? userLoginService.getRequireLoginUserId() : null;
notify.setCreatedBy(sendFrom);
super.create(notify);
for (NotifyDetail detail : notify.getDetailList()) { /// 原子创建业务提醒并级联创建通知详情
detail.setNotifyId(notify.getId()); ///
if (TimiJava.isNotEmpty(sendFrom)) { /// @param notify 通知
detail.setSendFrom(sendFrom); @OperationAudit(AuditOperation.COMMON_NOTIFY_CREATE)
} @Transactional(TimiServerDBConfig.ROLLBACKER)
detailService.create(detail); @Override
} public void createIfAbsent(Notify notify) {
logger.setLevel(Logger.Level.INFO); prepareCreate(notify);
logger.setResult(notify.getId()); if (mapper.insertIfAbsent(notify) == 0) {
} catch (TimiException e) { return;
logger.setLevel(Logger.Level.WARN); }
logger.setException(e.getMessage()); createDetails(notify);
throw e; }
} catch (Exception e) {
logger.setLevel(Logger.Level.ERROR); /// 校验并补全通知创建字段
logger.setException(TimiJava.serializeThrowable(e)); ///
log.error("创建通知失败", e); /// @param notify 通知
throw new TimiException(TimiCode.ERROR, "创建通知失败", e); private void prepareCreate(Notify notify) {
} finally { TimiException.required(notify, "未找到通知");
loggerService.create(logger); TimiException.required(notify.getDetailList(), "未找到通知详情列表");
notify.setId(TimiJava.defaultIfEmpty(notify.getId(), UUID.randomUUID().toString()));
notify.setCreatedBy(TimiJava.defaultIfEmpty(notify.getCreatedBy(), TimiJava.ZERO_UUID));
notify.setCreatedAt(TimiJava.defaultIfNull(notify.getCreatedAt(), Time.now()));
notify.setUpdatedAt(null);
notify.setDeletedAt(null);
}
/// 创建通知详情
///
/// @param notify 通知
private void createDetails(Notify notify) {
for (NotifyDetail detail : notify.getDetailList()) {
detail.setNotifyId(notify.getId());
detail.setSendFrom(TimiJava.defaultIfEmpty(detail.getSendFrom(), TimiJava.ZERO_UUID));
detailService.create(detail);
} }
} }
@@ -117,6 +127,8 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
/// @param notifyId 通知 ID /// @param notifyId 通知 ID
/// @param userId 用户 ID /// @param userId 用户 ID
@Override @Override
@Transactional(TimiServerDBConfig.ROLLBACKER)
@OperationAudit(AuditOperation.COMMON_NOTIFY_DELETE)
public void deleteManagement(String notifyId, String userId) { public void deleteManagement(String notifyId, String userId) {
getManagement(notifyId, userId); getManagement(notifyId, userId);
delete(notifyId); delete(notifyId);
@@ -127,6 +139,7 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
/// @param notifyId 通知 ID /// @param notifyId 通知 ID
/// @param userId 用户 ID /// @param userId 用户 ID
@Override @Override
@Transactional(TimiServerDBConfig.ROLLBACKER)
public void cancelManagement(String notifyId, String userId) { public void cancelManagement(String notifyId, String userId) {
getManagement(notifyId, userId); getManagement(notifyId, userId);
cancel(notifyId); cancel(notifyId);
@@ -135,32 +148,17 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
/// 删除通知并级联软删除通知详情 /// 删除通知并级联软删除通知详情
/// ///
/// @param notifyId 通知 ID /// @param notifyId 通知 ID
@OperationAudit(AuditOperation.COMMON_NOTIFY_DELETE)
@Transactional(TimiServerDBConfig.ROLLBACKER) @Transactional(TimiServerDBConfig.ROLLBACKER)
@Override @Override
public void delete(String notifyId) { public void delete(String notifyId) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_NOTIFY_DELETE"); TimiException.required(notifyId, "未找到通知 ID");
try { TimiException.required(get(notifyId), "未找到通知");
TimiException.required(notifyId, "未找到通知 ID"); List<NotifyDetail> detailList = detailService.listByNotifyId(notifyId);
TimiException.required(get(notifyId), "未找到通知"); for (NotifyDetail detail : detailList) {
List<NotifyDetail> detailList = detailService.listByNotifyId(notifyId); detailService.delete(detail.getId());
for (NotifyDetail detail : detailList) {
detailService.delete(detail.getId());
}
super.delete(notifyId);
logger.setLevel(Logger.Level.INFO);
logger.setResult(notifyId);
} catch (TimiException e) {
logger.setLevel(Logger.Level.WARN);
logger.setException(e.getMessage());
throw e;
} catch (Exception e) {
logger.setLevel(Logger.Level.ERROR);
logger.setException(TimiJava.serializeThrowable(e));
log.error("删除通知失败", e);
throw new TimiException(TimiCode.ERROR, "删除通知失败", e);
} finally {
loggerService.create(logger);
} }
super.delete(notifyId);
} }
/// 取消通知中尚未成功发送的通知详情 /// 取消通知中尚未成功发送的通知详情
@@ -17,6 +17,8 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
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;
/** /**
* 系统配置服务实现 * 系统配置服务实现
@@ -53,6 +55,12 @@ public class SettingServiceImplement extends AbstractEntityService<Setting, Stri
return mapper.selectAllByExample(example); return mapper.selectAllByExample(example);
} }
@Override
public Map<String, Setting> mapPublic(String bizType, String bizId, List<String> code) {
TimiException.required(bizType, "not found bizType");
return mapper.selectPublicByQuery(bizType, bizId, code).stream().collect(Collectors.toMap(Setting::getCode, Function.identity()));
}
@Transactional(TimiServerDBConfig.ROLLBACKER) @Transactional(TimiServerDBConfig.ROLLBACKER)
@Override @Override
public void updateByBizId(String bizType, String bizId, List<Setting> list) { public void updateByBizId(String bizType, String bizId, List<Setting> list) {
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.common.service.implement;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.imyeyu.api.modules.common.bean.TempFileSetting;
import com.imyeyu.api.modules.common.entity.Attachment; import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Setting; import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.api.modules.common.service.AttachmentService; import com.imyeyu.api.modules.common.service.AttachmentService;
@@ -52,11 +53,11 @@ public class TempFileServiceImplement implements TempFileService {
try { try {
logger.setContent(jackson.writeValueAsString(logRequestArgs(files, ttl))); logger.setContent(jackson.writeValueAsString(logRequestArgs(files, ttl)));
Setting ttlMin = settingService.getSystem(Setting.Module.TempFile.TTL_MIN); Setting ttlMin = settingService.getSystem(TempFileSetting.TTL_MIN);
Setting ttlMax = settingService.getSystem(Setting.Module.TempFile.TTL_MAX); Setting ttlMax = settingService.getSystem(TempFileSetting.TTL_MAX);
Setting ttlDefault = settingService.getSystem(Setting.Module.TempFile.TTL_DEFAULT); Setting ttlDefault = settingService.getSystem(TempFileSetting.TTL_DEFAULT);
Setting residueTime = settingService.getSystem(Setting.Module.TempFile.RESIDUE_TTL); Setting residueTime = settingService.getSystem(TempFileSetting.RESIDUE_TTL);
String limitStr = settingService.getSystem(Setting.Module.TempFile.LIMIT_SIZE_OF_IP).asString(); String limitStr = settingService.getSystem(TempFileSetting.LIMIT_SIZE_OF_IP).asString();
long limit = IOSize.parse(limitStr); long limit = IOSize.parse(limitStr);
@@ -71,6 +72,7 @@ public class TempFileServiceImplement implements TempFileService {
page.setSize(Long.MAX_VALUE); page.setSize(Long.MAX_VALUE);
{ {
Attachment example = new Attachment(); Attachment example = new Attachment();
example.setBizType(BIZ_TYPE);
example.setUploaderIp(TimiSpring.getRequestIP()); example.setUploaderIp(TimiSpring.getRequestIP());
page.setEqualsExample(example); page.setEqualsExample(example);
} }
@@ -0,0 +1,18 @@
package com.imyeyu.api.modules.common.vo;
import jakarta.validation.constraints.Size;
import lombok.Data;
/// 客户端诊断日志请求
///
/// 客户端日志不是操作审计,操作编码、模块、级别、用户和 IP 均由服务端决定
///
/// @author Codex
/// @since 2026-09-09
@Data
public class ClientLogRequest {
/// 日志内容
@Size(max = 32768, message = "日志内容不能超过 32 KB")
private String content;
}
@@ -21,6 +21,14 @@ public enum GaoPermissionCode implements BuiltinPermissionCode {
STORE_DELETE("STORE:DELETE", "门店删除", false, true), STORE_DELETE("STORE:DELETE", "门店删除", false, true),
STORE_DIARY_CREATE("STORE_DIARY:CREATE", "门店日记创建", true, false),
STORE_DIARY_READ("STORE_DIARY:READ", "门店日记读取", true, false),
STORE_DIARY_UPDATE("STORE_DIARY:UPDATE", "门店日记修改", true, false),
STORE_DIARY_DELETE("STORE_DIARY:DELETE", "门店日记删除", true, false),
CUSTOMER_CREATE("CUSTOMER:CREATE", "客户创建", false, false), CUSTOMER_CREATE("CUSTOMER:CREATE", "客户创建", false, false),
CUSTOMER_READ("CUSTOMER:READ", "客户读取", false, false), CUSTOMER_READ("CUSTOMER:READ", "客户读取", false, false),
@@ -43,12 +51,78 @@ public enum GaoPermissionCode implements BuiltinPermissionCode {
EVENT_RECORD_READ("EVENT_RECORD:READ", "登记事件记录读取", false, false), EVENT_RECORD_READ("EVENT_RECORD:READ", "登记事件记录读取", false, false),
EVENT_RECORD_VERIFY("EVENT_RECORD:VERIFY", "登记事件核销", true, false),
EVENT_RECORD_EXPORT("EVENT_RECORD:EXPORT", "登记事件记录导出", true, false), EVENT_RECORD_EXPORT("EVENT_RECORD:EXPORT", "登记事件记录导出", true, false),
EVENT_RECORD_UPDATE("EVENT_RECORD:UPDATE", "登记事件记录修改", false, false), EVENT_RECORD_UPDATE("EVENT_RECORD:UPDATE", "登记事件记录修改", false, false),
EVENT_RECORD_DELETE("EVENT_RECORD:DELETE", "登记事件记录删除", false, false), EVENT_RECORD_DELETE("EVENT_RECORD:DELETE", "登记事件记录删除", false, false),
PRODUCT_CATEGORY_CREATE("PRODUCT_CATEGORY:CREATE", "产品分类创建", true, true),
PRODUCT_CATEGORY_READ("PRODUCT_CATEGORY:READ", "产品分类读取", true, true),
PRODUCT_CATEGORY_UPDATE("PRODUCT_CATEGORY:UPDATE", "产品分类修改", true, true),
PRODUCT_CREATE("PRODUCT:CREATE", "产品创建", true, true),
PRODUCT_READ("PRODUCT:READ", "产品读取", true, true),
PRODUCT_UPDATE("PRODUCT:UPDATE", "产品修改", true, true),
PRODUCT_STOCK_READ("PRODUCT_STOCK:READ", "产品库存读取", true, true),
PRODUCT_STOCK_CREATE("PRODUCT_STOCK:CREATE", "产品库存操作", true, true),
PRODUCT_STOCK_MANUAL_REVOKE("PRODUCT_STOCK:MANUAL_REVOKE", "手工库存流水冲正", true, true),
SALES_ORDER_CREATE("SALES_ORDER:CREATE", "销售订单创建", true, true),
SALES_ORDER_READ("SALES_ORDER:READ", "销售订单读取", true, true),
SALES_ORDER_UPDATE("SALES_ORDER:UPDATE", "销售订单修改", true, true),
SALES_ORDER_CANCEL("SALES_ORDER:CANCEL", "销售订单取消", true, true),
SALES_ORDER_PRICE_OVERRIDE("SALES_ORDER:PRICE_OVERRIDE", "销售订单价格修改", true, true),
ORDER_FULFILLMENT_CREATE("ORDER_FULFILLMENT:CREATE", "统一履约创建", true, true),
ORDER_FULFILLMENT_READ("ORDER_FULFILLMENT:READ", "统一履约读取", true, true),
ORDER_FULFILLMENT_VERIFY("ORDER_FULFILLMENT:VERIFY", "统一履约核销", true, true),
ORDER_FULFILLMENT_REVOKE("ORDER_FULFILLMENT:REVOKE", "统一履约冲正", true, true),
PACKAGE_CONFIG_CREATE("PACKAGE_CONFIG:CREATE", "套餐配置创建", true, true),
PACKAGE_CONFIG_READ("PACKAGE_CONFIG:READ", "套餐配置读取", true, true),
PACKAGE_CONFIG_UPDATE("PACKAGE_CONFIG:UPDATE", "套餐配置修改", true, true),
PACKAGE_CONFIG_DELETE("PACKAGE_CONFIG:DELETE", "套餐配置删除", true, true),
CUSTOMER_PACKAGE_CREATE("CUSTOMER_PACKAGE:CREATE", "客户套餐创建", true, true),
CUSTOMER_PACKAGE_READ("CUSTOMER_PACKAGE:READ", "客户套餐读取", true, true),
CUSTOMER_PACKAGE_CANCEL("CUSTOMER_PACKAGE:CANCEL", "客户套餐取消", true, true),
CUSTOMER_PACKAGE_PRICE_OVERRIDE("CUSTOMER_PACKAGE:PRICE_OVERRIDE", "客户套餐成交价和权益配额调整", true, true),
CUSTOMER_PACKAGE_GIFT_CREATE("CUSTOMER_PACKAGE:GIFT_CREATE", "客户套餐创建赠送", true, true),
FUND_RECORD_READ("FUND_RECORD:READ", "资金流水读取", true, true),
FUND_RECEIVE_CREATE("FUND_RECEIVE:CREATE", "线下收款创建", true, true),
FUND_RECEIVE_VERIFY("FUND_RECEIVE:VERIFY", "线下收款核销", true, true),
FUND_REFUND("FUND:REFUND", "套餐退款", true, true),
FUND_REVOKE("FUND:REVOKE", "资金流水冲正", true, true),
POINT_ACCOUNT_READ("POINT_ACCOUNT:READ", "客户积分账户读取", true, true), POINT_ACCOUNT_READ("POINT_ACCOUNT:READ", "客户积分账户读取", true, true),
POINT_LEDGER_READ("POINT_LEDGER:READ", "客户积分流水读取", true, true), POINT_LEDGER_READ("POINT_LEDGER:READ", "客户积分流水读取", true, true),
@@ -16,7 +16,7 @@ public enum GaoRoleCode implements BuiltinRoleCode {
GLOBAL_MANAGER("门店管理", null), GLOBAL_MANAGER("门店管理", null),
/// 店长 /// 店长
STORE_MANAGER("店长", GLOBAL_MANAGER.name()); STORE_MANAGER("店长", null);
final String defaultName; final String defaultName;
final String parentCode; final String parentCode;
@@ -0,0 +1,27 @@
package com.imyeyu.api.modules.gao.bean;
import com.imyeyu.api.annotation.SettingBizType;
import com.imyeyu.api.bean.SettingEnum;
import com.imyeyu.api.modules.common.entity.Setting;
import lombok.AllArgsConstructor;
import lombok.Getter;
///
///
/// @author 夜雨
/// @since 2026-09-09 16:11
@Getter
@SettingBizType("GAO_SYSTEM")
@AllArgsConstructor
public enum GaoSystemSetting implements SettingEnum {
SERVICE_LICENSE(null, Setting.ValueType.STRING),
PRIVACY_LICENSE(null, Setting.ValueType.STRING),
OPEN_SOURCE_LICENSE(null, Setting.ValueType.STRING);
final String defaultValue;
final Setting.ValueType valueType;
}
@@ -0,0 +1,66 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
import com.imyeyu.api.modules.gao.service.GaoCustomerConsumptionRecordService;
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPageResult;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/// GAO 客户消费事实接口
///
/// @author Codex
/// @since 2026-09-07
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/customer/consumption-record")
public class GaoCustomerConsumptionRecordController {
private final AttachmentService attachmentService;
private final GaoCustomerService customerService;
private final GaoStoreScopeService storeScopeService;
private final GaoCustomerConsumptionRecordService service;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_READ)
@PostMapping("/list")
public GaoCustomerConsumptionRecordPageResult list(@RequestBody GaoCustomerConsumptionRecordPage page) {
TimiException.required(page, "not found consumption record page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
GaoCustomerConsumptionRecordPageResult result = service.pageByQuery(page);
List<String> customerIdList = result.getList()
.stream()
.map(GaoCustomerConsumptionRecord::getCustomerId)
.filter(customerId -> customerId != null && !customerId.isBlank())
.distinct()
.toList();
var customerMap = customerService.mapByIdList(customerIdList);
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList);
for (GaoCustomerConsumptionRecord record : result.getList()) {
var customer = customerMap.get(record.getCustomerId());
if (customer == null) {
continue;
}
customer.setAttachmentList(attachmentMap.getOrDefault(customer.getId(), List.of()));
record.setCustomer(customer);
}
return result;
}
}
@@ -0,0 +1,143 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackage;
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
import com.imyeyu.api.modules.gao.service.GaoCustomerPackageService;
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoOrderFulfillmentService;
import com.imyeyu.api.modules.gao.service.GaoSalesOrderService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerPackageCancelRequest;
import com.imyeyu.api.modules.gao.vo.GaoCustomerPackagePage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerPackagePurchaseRequest;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/// GAO 客户套餐接口
///
/// @author Codex
/// @since 2026-08-31
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/customer/package")
public class GaoCustomerPackageController {
private final GaoCustomerPackageService service;
private final GaoCustomerService customerService;
private final GaoOrderFulfillmentService fulfillmentService;
private final GaoSalesOrderService salesOrderService;
private final AttachmentService attachmentService;
private final GaoStoreScopeService storeScopeService;
private final UserService userService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_PACKAGE_READ)
@PostMapping("/list")
public PageResult<GaoCustomerPackage> list(@RequestBody GaoCustomerPackagePage page) {
TimiException.required(page, "not found page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
PageResult<GaoCustomerPackage> result = service.pageByQuery(page);
fillTransient(result.getList());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_PACKAGE_READ)
@PostMapping("/detail")
public GaoCustomerPackage detail(@RequestParam String id) {
GaoCustomerPackage result = service.get(id);
TimiException.required(result, "not found customer package");
storeScopeService.checkStoreId(result.getStoreId());
fillTransient(List.of(result));
GaoCustomer customer = customerService.get(result.getCustomerId());
if (customer != null) {
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
}
result.setCustomer(customer);
result.setFulfillmentList(fulfillmentService.listBySalesOrderId(result.getSalesOrderId()));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_PACKAGE_CREATE)
@PostMapping("/purchase")
public GaoCustomerPackage purchase(@RequestBody GaoCustomerPackagePurchaseRequest request) {
GaoCustomerPackage result = service.purchase(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_PACKAGE_CANCEL)
@PostMapping("/cancel")
public GaoCustomerPackage cancel(@RequestBody GaoCustomerPackageCancelRequest request) {
GaoCustomerPackage result = service.cancel(request);
fillTransient(List.of(result));
return result;
}
private void fillTransient(List<GaoCustomerPackage> packageList) {
if (packageList == null || packageList.isEmpty()) {
return;
}
Map<String, GaoSalesOrder> orderMap = salesOrderService.mapByIdList(packageList.stream()
.map(GaoCustomerPackage::getSalesOrderId)
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList());
List<String> customerIdList = packageList.stream()
.map(GaoCustomerPackage::getCustomerId)
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
Map<String, GaoCustomer> customerMap = customerIdList.isEmpty() ? Map.of() : customerService.mapByIdList(customerIdList);
Map<String, List<Attachment>> attachmentMap = customerIdList.isEmpty()
? Map.of() : attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList, GaoCustomer.AttachType.PHOTO.name());
List<String> userIdList = packageList.stream()
.map(packageEntity -> orderMap.get(packageEntity.getSalesOrderId()))
.filter(order -> order != null)
.map(GaoSalesOrder::getCancelOperatorUserId)
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
Map<String, User> userMap = userIdList.isEmpty() ? Map.of() : userService.mapByIdList(userIdList);
for (GaoCustomerPackage packageEntity : packageList) {
GaoSalesOrder order = orderMap.get(packageEntity.getSalesOrderId());
packageEntity.setSalesOrder(order);
packageEntity.setStatus(order == null ? null : order.getStatus());
packageEntity.setCancelledAt(order == null ? null : order.getCancelledAt());
packageEntity.setCancelOperatorUserId(order == null ? null : order.getCancelOperatorUserId());
packageEntity.setCancelReason(order == null ? null : order.getCancelReason());
packageEntity.setItemList(order == null ? List.of() : order.getItemList());
GaoCustomer customer = customerMap.get(packageEntity.getCustomerId());
if (customer != null) {
customer.setAttachmentList(attachmentMap.getOrDefault(customer.getId(), List.of()));
}
packageEntity.setCustomer(customer);
String cancelOperatorUserId = order == null ? null : order.getCancelOperatorUserId();
packageEntity.setCancelOperator(cancelOperatorUserId == null ? null : userMap.get(cancelOperatorUserId));
}
}
}
@@ -3,7 +3,11 @@ package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission; import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode; import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoEvent; import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfig;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem;
import com.imyeyu.api.modules.gao.service.GaoEventService; import com.imyeyu.api.modules.gao.service.GaoEventService;
import com.imyeyu.api.modules.gao.service.GaoPackageConfigService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService; import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.java.TimiJava; import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException; import com.imyeyu.java.bean.timi.TimiException;
@@ -31,6 +35,7 @@ import java.util.Map;
public class GaoEventController { public class GaoEventController {
private final GaoEventService service; private final GaoEventService service;
private final GaoPackageConfigService packageConfigService;
private final GaoStoreScopeService storeScopeService; private final GaoStoreScopeService storeScopeService;
@AOPLog @AOPLog
@@ -39,25 +44,67 @@ public class GaoEventController {
@PostMapping("/list") @PostMapping("/list")
public PageResult<GaoEvent> list(@RequestBody Page<GaoEvent> page) { public PageResult<GaoEvent> list(@RequestBody Page<GaoEvent> page) {
TimiException.required(page, "not found page"); TimiException.required(page, "not found page");
resolveStoreScope(page);
PageResult<GaoEvent> result = service.pageWithoutDeleted(page);
return attachEventRelations(result);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_CREATE)
@PostMapping("/list/history")
public PageResult<GaoEvent> listHistory(@RequestBody Page<GaoEvent> page) {
TimiException.required(page, "not found page");
resolveStoreScope(page);
return attachEventRelations(service.page(page));
}
private void resolveStoreScope(Page<GaoEvent> page) {
if (!storeScopeService.hasGlobalScope()) { if (!storeScopeService.hasGlobalScope()) {
GaoEvent example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoEvent()); GaoEvent example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoEvent());
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId())); example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
page.setEqualsExample(example); page.setEqualsExample(example);
} }
PageResult<GaoEvent> result = service.page(page); }
private PageResult<GaoEvent> attachEventRelations(PageResult<GaoEvent> result) {
Map<String, List<String>> roleMap = service.mapRoleCodeListByEventIdList(result.getList().stream().map(GaoEvent::getId).toList()); Map<String, List<String>> roleMap = service.mapRoleCodeListByEventIdList(result.getList().stream().map(GaoEvent::getId).toList());
for (GaoEvent event : result.getList()) { for (GaoEvent event : result.getList()) {
event.setRoleCodeList(roleMap.get(event.getId())); event.setRoleCodeList(roleMap.get(event.getId()));
} }
service.attachOptionGroupList(result.getList());
attachPackageConfig(result.getList());
return result; return result;
} }
private void attachPackageConfig(List<GaoEvent> eventList) {
List<String> packageConfigIdList = eventList.stream()
.map(GaoEvent::getPackageConfigId)
.filter(TimiJava::isNotEmpty)
.distinct()
.toList();
if (packageConfigIdList.isEmpty()) {
return;
}
Map<String, GaoPackageConfig> packageConfigMap = packageConfigService.mapByIdList(packageConfigIdList);
Map<String, List<GaoPackageConfigItem>> itemMap = packageConfigService.mapItemListByPackageConfigIdList(packageConfigIdList);
for (GaoEvent event : eventList) {
GaoPackageConfig packageConfig = packageConfigMap.get(event.getPackageConfigId());
if (packageConfig != null) {
packageConfig.setItemList(itemMap.getOrDefault(packageConfig.getId(), List.of()));
event.setPackageConfig(packageConfig);
}
}
}
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_READ) @RequireGaoPermission(GaoPermissionCode.EVENT_READ)
@PostMapping("/list/valid") @PostMapping("/list/valid")
public List<GaoEvent> listValid(@RequestParam String storeId) { public List<GaoEvent> listValid(@RequestParam String storeId) {
return service.listValid(storeScopeService.resolveStoreId(storeId)); List<GaoEvent> result = service.listValid(storeScopeService.resolveStoreId(storeId));
attachPackageConfig(result);
return result;
} }
@AOPLog @AOPLog
@@ -69,6 +116,8 @@ public class GaoEventController {
TimiException.required(event, "not found event"); TimiException.required(event, "not found event");
storeScopeService.checkStoreId(event.getStoreId()); storeScopeService.checkStoreId(event.getStoreId());
event.setRoleCodeList(service.listRoleCode(event.getId())); event.setRoleCodeList(service.listRoleCode(event.getId()));
service.attachOptionGroupList(List.of(event));
attachPackageConfig(List.of(event));
return event; return event;
} }
@@ -78,6 +127,7 @@ public class GaoEventController {
@PostMapping("/create") @PostMapping("/create")
public void create(@RequestBody GaoEvent event) { public void create(@RequestBody GaoEvent event) {
event.setStoreId(storeScopeService.resolveStoreId(event.getStoreId())); event.setStoreId(storeScopeService.resolveStoreId(event.getStoreId()));
validatePackageConfigBinding(event);
service.create(event); service.create(event);
} }
@@ -92,9 +142,32 @@ public class GaoEventController {
TimiException.required(dbEvent, "not found event"); TimiException.required(dbEvent, "not found event");
storeScopeService.checkStoreId(dbEvent.getStoreId()); storeScopeService.checkStoreId(dbEvent.getStoreId());
event.setStoreId(dbEvent.getStoreId()); event.setStoreId(dbEvent.getStoreId());
validatePackageConfigBinding(event);
service.update(event); service.update(event);
} }
private void validatePackageConfigBinding(GaoEvent event) {
if (event.getBizType() == GaoEvent.BizType.PACKAGE_PURCHASE) {
TimiException.required(event.getPackageConfigId(), "购买套餐事件必须绑定套餐配置");
GaoPackageConfig packageConfig = packageConfigService.get(event.getPackageConfigId());
TimiException.required(packageConfig, "购买套餐事件绑定的套餐配置不存在");
TimiException.requiredTrue(event.getStoreId().equals(packageConfig.getStoreId()), "购买事件和套餐配置不属于同一门店");
} else {
TimiException.requiredNull(event.getPackageConfigId(), "普通事件不能绑定套餐配置");
}
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
@PostMapping("/options/update")
public void updateOptions(@RequestParam String id, @RequestBody List<GaoEventOptionGroup> optionGroupList) {
GaoEvent event = service.get(id);
TimiException.required(event, "not found event");
storeScopeService.checkStoreId(event.getStoreId());
service.updateOptionGroupList(id, optionGroupList);
}
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE) @RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
@@ -13,6 +13,7 @@ import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
import com.imyeyu.api.modules.gao.service.GaoEventService; import com.imyeyu.api.modules.gao.service.GaoEventService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService; import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView; import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
import com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPageResult; import com.imyeyu.api.modules.gao.vo.GaoEventRecordPageResult;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
@@ -78,6 +79,7 @@ public class GaoEventRecordController {
record.setCustomer(customerMap.get(record.getCustomerId())); record.setCustomer(customerMap.get(record.getCustomerId()));
record.getCustomer().setAttachmentList(attachMap.get(record.getCustomerId())); record.getCustomer().setAttachmentList(attachMap.get(record.getCustomerId()));
} }
service.attachSelectedOptionGroupList(result.getList());
} }
return result; return result;
} }
@@ -110,11 +112,28 @@ public class GaoEventRecordController {
record.setCustomer(customerService.get(record.getCustomerId())); record.setCustomer(customerService.get(record.getCustomerId()));
record.getCustomer().setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, record.getCustomerId())); record.getCustomer().setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, record.getCustomerId()));
record.setEvent(eventService.get(record.getEventId())); record.setEvent(eventService.get(record.getEventId()));
eventService.attachOptionGroupList(List.of(record.getEvent()));
record.setOperator(userService.get(record.getOperatorUserId())); record.setOperator(userService.get(record.getOperatorUserId()));
record.setUpdater(userService.get(record.getUpdatedBy()));
if (record.getVerifierUserId() != null) {
record.setVerifier(userService.get(record.getVerifierUserId()));
}
record.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId())); record.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId()));
service.attachSelectedOptionGroupList(List.of(record));
return record; return record;
} }
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_VERIFY)
@PostMapping("/verify")
public void verify(@RequestParam String id) {
GaoEventRecord record = service.get(id);
TimiException.required(record, "not found event record");
storeScopeService.checkStoreId(record.getStoreId());
service.verify(id);
}
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE) @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
@@ -220,6 +239,16 @@ public class GaoEventRecordController {
return result; return result;
} }
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/option/stat")
public List<GaoEventOptionStatView> optionStat(@RequestBody GaoEventRecordPage page) {
TimiException.required(page, "not found page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return service.optionStatByRange(page);
}
private void resolveCreateRecordStore(GaoEventRecord record) { private void resolveCreateRecordStore(GaoEventRecord record) {
TimiException.required(record, "not found event record"); TimiException.required(record, "not found event record");
GaoEvent event = eventService.get(record.getEventId()); GaoEvent event = eventService.get(record.getEventId());
@@ -0,0 +1,133 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoFundRecord;
import com.imyeyu.api.modules.gao.service.GaoFundRecordService;
import com.imyeyu.api.modules.gao.service.GaoOrderPaymentService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoFundRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoFundRevokeRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentRevokeRequest;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
/// GAO 资金流水接口
///
/// @author Codex
/// @since 2026-08-31
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/fund/record")
public class GaoFundRecordController {
private final GaoFundRecordService service;
private final GaoOrderPaymentService orderPaymentService;
private final GaoStoreScopeService storeScopeService;
private final AttachmentService attachmentService;
private final UserService userService;
private final UserLoginService userLoginService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECORD_READ)
@PostMapping("/list")
public PageResult<GaoFundRecord> list(@RequestBody GaoFundRecordPage page) {
TimiException.required(page, "not found page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
PageResult<GaoFundRecord> result = service.pageByQuery(page);
fillTransient(result.getList());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECORD_READ)
@PostMapping("/detail")
public GaoFundRecord detail(@RequestParam String id) {
GaoFundRecord result = service.detail(id);
storeScopeService.checkStoreId(result.getStoreId());
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_CREATE)
@PostMapping("/my-receive/list")
public PageResult<GaoFundRecord> listMyReceive(@RequestBody GaoFundRecordPage page) {
TimiException.required(page, "not found page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
page.setOperatorUserId(userLoginService.getRequireLoginUserId());
page.setOperationType(GaoFundRecord.OperationType.RECEIVE);
PageResult<GaoFundRecord> result = service.pageByQuery(page);
fillTransient(result.getList());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_CREATE)
@PostMapping("/my-receive/detail")
public GaoFundRecord detailMyReceive(@RequestParam String id) {
GaoFundRecord result = service.detail(id);
TimiException.requiredTrue(result.getOperationType() == GaoFundRecord.OperationType.RECEIVE, "not found fund receive record");
TimiException.requiredTrue(userLoginService.getRequireLoginUserId().equals(result.getOperatorUserId()), "只能读取自己提交的收款");
storeScopeService.checkStoreId(result.getStoreId());
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_REVOKE)
@PostMapping("/revoke")
public GaoFundRecord revoke(@RequestBody GaoFundRevokeRequest request) {
GaoOrderPaymentRevokeRequest orderRequest = new GaoOrderPaymentRevokeRequest();
orderRequest.setRequestNo(request.getRequestNo());
orderRequest.setFundRecordId(request.getFundRecordId());
orderRequest.setOccurredAt(request.getOccurredAt());
orderRequest.setReason(request.getReason());
orderRequest.setAttachmentList(request.getAttachmentList());
orderRequest.setRemark(request.getRemark());
GaoFundRecord result = orderPaymentService.revoke(orderRequest);
fillTransient(List.of(result));
return result;
}
private void fillTransient(List<GaoFundRecord> recordList) {
if (recordList == null || recordList.isEmpty()) {
return;
}
List<String> idList = recordList.stream().map(GaoFundRecord::getId).toList();
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_FUND_RECORD, idList);
List<String> userIdList = recordList.stream()
.flatMap(record -> Stream.of(record.getOperatorUserId(), record.getVerifierUserId()))
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
Map<String, User> userMap = userIdList.isEmpty() ? Map.of() : userService.mapByIdList(userIdList);
for (GaoFundRecord record : recordList) {
record.setAttachmentList(attachmentMap.getOrDefault(record.getId(), List.of()));
record.setOperator(userMap.get(record.getOperatorUserId()));
record.setVerifier(userMap.get(record.getVerifierUserId()));
}
}
}
@@ -0,0 +1,163 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment;
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoOrderFulfillmentService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentActionRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentCreateRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentPage;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentPrepareStockRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentRevokeRequest;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
/// GAO 统一履约接口
///
/// @author Codex
/// @since 2026-09-02
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/order/fulfillment")
public class GaoOrderFulfillmentController {
private final GaoOrderFulfillmentService service;
private final GaoStoreScopeService storeScopeService;
private final AttachmentService attachmentService;
private final GaoCustomerService customerService;
private final UserService userService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_READ)
@PostMapping("/list")
public PageResult<GaoOrderFulfillment> list(@RequestBody GaoOrderFulfillmentPage page) {
TimiException.required(page, "not found fulfillment page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
PageResult<GaoOrderFulfillment> result = service.pageByQuery(page);
fillTransient(result.getList());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_READ)
@PostMapping("/detail")
public GaoOrderFulfillment detail(@RequestParam String id) {
GaoOrderFulfillment result = service.detail(id);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_CREATE)
@PostMapping("/create")
public GaoOrderFulfillment create(@RequestBody GaoOrderFulfillmentCreateRequest request) {
GaoOrderFulfillment result = service.create(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_VERIFY)
@PostMapping("/prepare-stock")
public GaoOrderFulfillment prepareStock(@RequestBody GaoOrderFulfillmentPrepareStockRequest request) {
GaoOrderFulfillment result = service.prepareStock(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_VERIFY)
@PostMapping("/verify")
public GaoOrderFulfillment verify(@RequestBody GaoOrderFulfillmentActionRequest request) {
GaoOrderFulfillment result = service.verify(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_VERIFY)
@PostMapping("/reject")
public GaoOrderFulfillment reject(@RequestBody GaoOrderFulfillmentActionRequest request) {
GaoOrderFulfillment result = service.reject(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_CREATE)
@PostMapping("/cancel")
public GaoOrderFulfillment cancel(@RequestBody GaoOrderFulfillmentActionRequest request) {
GaoOrderFulfillment result = service.cancel(request);
fillTransient(List.of(result));
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_REVOKE)
@PostMapping("/revoke")
public GaoOrderFulfillment revoke(@RequestBody GaoOrderFulfillmentRevokeRequest request) {
GaoOrderFulfillment result = service.revoke(request);
fillTransient(List.of(result));
return result;
}
private void fillTransient(List<GaoOrderFulfillment> fulfillmentList) {
if (fulfillmentList == null || fulfillmentList.isEmpty()) {
return;
}
List<String> idList = fulfillmentList.stream().map(GaoOrderFulfillment::getId).toList();
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_ORDER_FULFILLMENT, idList);
List<String> customerIdList = fulfillmentList.stream()
.map(GaoOrderFulfillment::getCustomerId)
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
Map<String, GaoCustomer> customerMap = customerIdList.isEmpty() ? Map.of() : customerService.mapByIdList(customerIdList);
Map<String, List<Attachment>> customerAttachmentMap = customerIdList.isEmpty()
? Map.of()
: attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList, GaoCustomer.AttachType.PHOTO.name());
List<String> userIdList = fulfillmentList.stream()
.flatMap(item -> Stream.of(item.getOperatorUserId(), item.getVerifierUserId()))
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
Map<String, User> userMap = userIdList.isEmpty() ? Map.of() : userService.mapByIdList(userIdList);
for (GaoOrderFulfillment fulfillment : fulfillmentList) {
fulfillment.setAttachmentList(attachmentMap.getOrDefault(fulfillment.getId(), List.of()));
GaoCustomer customer = customerMap.get(fulfillment.getCustomerId());
if (customer != null) {
customer.setAttachmentList(customerAttachmentMap.getOrDefault(customer.getId(), List.of()));
}
fulfillment.setCustomer(customer);
fulfillment.setOperator(userMap.get(fulfillment.getOperatorUserId()));
fulfillment.setVerifier(userMap.get(fulfillment.getVerifierUserId()));
}
}
}
@@ -0,0 +1,149 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfig;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem;
import com.imyeyu.api.modules.gao.entity.GaoProductSku;
import com.imyeyu.api.modules.gao.service.GaoEventService;
import com.imyeyu.api.modules.gao.service.GaoPackageConfigService;
import com.imyeyu.api.modules.gao.service.GaoProductSkuService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoPackageConfigPage;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/// GAO 套餐配置接口
///
/// @author Codex
/// @since 2026-08-31
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/package/config")
public class GaoPackageConfigController {
private final GaoPackageConfigService service;
private final GaoEventService eventService;
private final GaoProductSkuService skuService;
private final GaoStoreScopeService storeScopeService;
private final UserService userService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_READ)
@PostMapping("/list")
public PageResult<GaoPackageConfig> list(@RequestBody GaoPackageConfigPage page) {
TimiException.required(page, "not found page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
PageResult<GaoPackageConfig> result = service.pageByQuery(page);
fillTransient(result.getList(), false);
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_READ)
@PostMapping("/list/valid")
public List<GaoPackageConfig> listValid(@RequestParam String storeId) {
List<GaoPackageConfig> result = service.listValid(storeScopeService.resolveStoreId(storeId));
fillTransient(result, false);
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_READ)
@PostMapping("/detail")
public GaoPackageConfig detail(@RequestParam String id) {
GaoPackageConfig config = service.get(id);
TimiException.required(config, "not found package config");
storeScopeService.checkStoreId(config.getStoreId());
fillTransient(List.of(config), true);
return config;
}
private void fillTransient(List<GaoPackageConfig> configList, boolean includeProductDetail) {
if (configList == null || configList.isEmpty()) {
return;
}
Map<String, List<GaoPackageConfigItem>> itemMap = service.mapItemListByPackageConfigIdList(configList.stream().map(GaoPackageConfig::getId).toList());
List<String> updaterIdList = configList.stream().map(GaoPackageConfig::getUpdatedBy).filter(value -> value != null && !value.isBlank()).distinct().toList();
Map<String, User> updaterMap = updaterIdList.isEmpty() ? Map.of() : userService.mapByIdList(updaterIdList);
for (GaoPackageConfig config : configList) {
config.setItemList(itemMap.getOrDefault(config.getId(), List.of()));
config.setUpdater(updaterMap.get(config.getUpdatedBy()));
}
if (includeProductDetail) {
fillProductDetails(configList);
}
}
private void fillProductDetails(List<GaoPackageConfig> configList) {
List<String> skuIdList = configList.stream()
.flatMap(config -> config.getItemList().stream())
.map(GaoPackageConfigItem::getSkuId)
.filter(value -> value != null && !value.isBlank())
.distinct()
.toList();
if (skuIdList.isEmpty()) {
return;
}
Map<String, GaoProductSku> skuMap = skuIdList.stream()
.collect(java.util.stream.Collectors.toMap(item -> item, skuService::detail));
for (GaoPackageConfig config : configList) {
for (GaoPackageConfigItem item : config.getItemList()) {
item.setSku(skuMap.get(item.getSkuId()));
}
}
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_CREATE)
@PostMapping("/create")
public String create(@RequestBody GaoPackageConfig config) {
TimiException.required(config, "not found package config");
config.setStoreId(storeScopeService.resolveStoreId(config.getStoreId()));
service.create(config);
return config.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_UPDATE)
@PostMapping("/update")
public void update(@RequestBody GaoPackageConfig config) {
TimiException.required(config, "not found package config");
TimiException.required(config.getId(), "not found packageConfig.id");
GaoPackageConfig dbConfig = service.get(config.getId());
TimiException.required(dbConfig, "not found package config");
storeScopeService.checkStoreId(dbConfig.getStoreId());
config.setStoreId(dbConfig.getStoreId());
service.update(config);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
GaoPackageConfig config = service.get(id);
TimiException.required(config, "not found package config");
storeScopeService.checkStoreId(config.getStoreId());
TimiException.requiredTrue(0 == eventService.countByPackageConfigId(id), "套餐配置已绑定购买事件,不能删除");
service.delete(id);
}
}
@@ -1,5 +1,7 @@
package com.imyeyu.api.modules.gao.controller; package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.common.entity.GroovyScript;
import com.imyeyu.api.modules.common.service.GroovyScriptService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission; import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode; import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoPointRule; import com.imyeyu.api.modules.gao.entity.GaoPointRule;
@@ -31,6 +33,7 @@ public class GaoPointRuleController {
private final GaoStoreScopeService storeScopeService; private final GaoStoreScopeService storeScopeService;
private final GaoPointRuleService ruleService; private final GaoPointRuleService ruleService;
private final GroovyScriptService groovyScriptService;
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@@ -54,9 +57,22 @@ public class GaoPointRuleController {
GaoPointRule rule = ruleService.get(id); GaoPointRule rule = ruleService.get(id);
TimiException.required(rule, "not found point rule"); TimiException.required(rule, "not found point rule");
storeScopeService.checkStoreId(rule.getStoreId()); storeScopeService.checkStoreId(rule.getStoreId());
if (rule.getRuleMode() == GaoPointRule.RuleMode.GROOVY) {
GroovyScript script = groovyScriptService.get(rule.getGroovyScriptId());
script.setLatest(groovyScriptService.getLatestVersion(script.getId()));
rule.setGroovyScript(script);
}
return rule; return rule;
} }
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_READ)
@PostMapping("/rule/script/list")
public List<GroovyScript> scriptList() {
return groovyScriptService.listByBizType(GroovyScript.BizType.GAO_POINT_RULE);
}
@AOPLog @AOPLog
@RequestRateLimit @RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_CREATE) @RequireGaoPermission(GaoPermissionCode.POINT_RULE_CREATE)
@@ -0,0 +1,126 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoProductChartService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView;
import com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView;
import com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView;
import com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/// GAO 产品图表接口
///
/// @author Codex
/// @since 2026-09-06
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/product/chart")
public class GaoProductChartController {
private final GaoProductChartService service;
private final GaoStoreScopeService storeScopeService;
/// 查询产品每日销售统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/daily")
public List<GaoProductSalesDailyStatView> salesDaily(@RequestBody GaoProductChartReq req) {
return service.salesDaily(normalize(req));
}
/// 查询产品销售排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/rank")
public List<GaoProductSalesRankView> salesRank(@RequestBody GaoProductChartReq req) {
return service.salesRank(normalize(req));
}
/// 查询产品每日履约统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/fulfillment/daily")
public List<GaoProductFulfillmentDailyStatView> fulfillmentDaily(@RequestBody GaoProductChartReq req) {
return service.fulfillmentDaily(normalize(req));
}
/// 查询产品履约进度排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/fulfillment/rank")
public List<GaoProductFulfillmentRankView> fulfillmentRank(@RequestBody GaoProductChartReq req) {
return service.fulfillmentRank(normalize(req));
}
/// 查询产品每日库存变动统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/stock/movement/daily")
public List<GaoProductStockMovementDailyStatView> stockMovementDaily(@RequestBody GaoProductChartReq req) {
return service.stockMovementDaily(normalize(req));
}
/// 查询产品库存健康度
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/stock/health")
public List<GaoProductStockHealthView> stockHealth(@RequestBody GaoProductChartReq req) {
return service.stockHealth(normalize(req));
}
/// 查询产品类型统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/structure/type")
public List<GaoProductTypeStatView> type(@RequestBody GaoProductChartReq req) {
return service.type(normalize(req));
}
/// 查询产品分类统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/structure/category")
public List<GaoProductCategoryStatView> category(@RequestBody GaoProductChartReq req) {
return service.category(normalize(req));
}
/// 查询产品销售单位排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/unit/rank")
public List<GaoProductUnitSalesRankView> unitSalesRank(@RequestBody GaoProductChartReq req) {
return service.unitSalesRank(normalize(req));
}
private GaoProductChartReq normalize(GaoProductChartReq req) {
TimiException.required(req, "not found product chart req");
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return req;
}
}
@@ -0,0 +1,248 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoProduct;
import com.imyeyu.api.modules.gao.entity.GaoProductCategory;
import com.imyeyu.api.modules.gao.entity.GaoProductSku;
import com.imyeyu.api.modules.gao.service.GaoProductCategoryService;
import com.imyeyu.api.modules.gao.service.GaoProductService;
import com.imyeyu.api.modules.gao.service.GaoProductSkuService;
import com.imyeyu.api.modules.gao.service.GaoProductSpecService;
import com.imyeyu.api.modules.gao.entity.GaoProductSpec;
import com.imyeyu.api.modules.gao.entity.GaoProductSpecValue;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryPage;
import com.imyeyu.api.modules.gao.vo.GaoProductPage;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/// GAO 产品库接口
///
/// @author Codex
/// @since 2026-09-02
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/product")
public class GaoProductController {
private final GaoProductCategoryService categoryService;
private final GaoProductService productService;
private final GaoProductSkuService skuService;
private final GaoProductSpecService specService;
private final GaoStoreScopeService storeScopeService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CATEGORY_READ)
@PostMapping("/category/list")
public PageResult<GaoProductCategory> categoryList(@RequestBody GaoProductCategoryPage page) {
TimiException.required(page, "not found category page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return categoryService.pageByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CATEGORY_CREATE)
@PostMapping("/category/create")
public String categoryCreate(@RequestBody GaoProductCategory category) {
TimiException.required(category, "not found category");
category.setStoreId(storeScopeService.resolveStoreId(category.getStoreId()));
categoryService.create(category);
return category.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CATEGORY_UPDATE)
@PostMapping("/category/update")
public void categoryUpdate(@RequestBody GaoProductCategory request) {
TimiException.required(request, "not found category");
TimiException.required(request.getId(), "not found category.id");
GaoProductCategory category = categoryService.get(request.getId());
TimiException.required(category, "not found category");
storeScopeService.checkStoreId(category.getStoreId());
request.setStoreId(category.getStoreId());
categoryService.update(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CATEGORY_UPDATE)
@PostMapping("/category/sort")
public void categorySort(@RequestBody List<String> idList) {
categoryService.sort(idList);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CATEGORY_UPDATE)
@PostMapping("/category/disable")
public void categoryDisable(@RequestParam String id) {
categoryService.disable(id);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
@PostMapping("/list")
public PageResult<GaoProduct> list(@RequestBody GaoProductPage page) {
TimiException.required(page, "not found product page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return productService.pageByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
@PostMapping("/detail")
public GaoProduct detail(@RequestParam String id) {
GaoProduct result = productService.detail(id);
storeScopeService.checkStoreId(result.getStoreId());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CREATE)
@PostMapping("/create")
public String create(@RequestBody GaoProduct product) {
TimiException.required(product, "not found product");
product.setStoreId(storeScopeService.resolveStoreId(product.getStoreId()));
productService.create(product);
return product.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/update")
public void update(@RequestBody GaoProduct request) {
TimiException.required(request, "not found product");
TimiException.required(request.getId(), "not found product.id");
GaoProduct product = productService.get(request.getId());
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
request.setStoreId(product.getStoreId());
productService.update(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/disable")
public void disable(@RequestParam String id) {
GaoProduct product = productService.get(id);
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
productService.disable(id);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
@PostMapping("/sku/detail")
public GaoProductSku skuDetail(@RequestParam String id) {
GaoProductSku result = skuService.detail(id);
storeScopeService.checkStoreId(result.getStoreId());
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CREATE)
@PostMapping("/sku/create")
public String skuCreate(@RequestBody GaoProductSku sku) {
TimiException.required(sku, "not found product sku");
GaoProduct product = productService.get(sku.getProductId());
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
skuService.create(sku);
return sku.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/sku/update")
public void skuUpdate(@RequestBody GaoProductSku request) {
TimiException.required(request, "not found product sku");
TimiException.required(request.getId(), "not found product sku.id");
GaoProductSku sku = skuService.get(request.getId());
TimiException.required(sku, "not found product sku");
storeScopeService.checkStoreId(sku.getStoreId());
request.setProductId(sku.getProductId());
skuService.update(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/sku/disable")
public void skuDisable(@RequestParam String id) {
GaoProductSku sku = skuService.get(id);
TimiException.required(sku, "not found product sku");
storeScopeService.checkStoreId(sku.getStoreId());
skuService.disable(id);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
@PostMapping("/spec/list")
public List<GaoProductSpec> specList(@RequestParam String productId) {
GaoProduct product = productService.get(productId);
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
return specService.listByProductId(productId);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/spec/create")
public String specCreate(@RequestBody GaoProductSpec spec) {
TimiException.required(spec, "not found product spec");
GaoProduct product = productService.get(spec.getProductId());
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
specService.createSpec(spec);
return spec.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_UPDATE)
@PostMapping("/spec/value/create")
public String specValueCreate(@RequestBody GaoProductSpecValue value) {
TimiException.required(value, "not found product spec value");
String productId = specService.getProductIdBySpecId(value.getSpecId());
TimiException.required(productId, "规格项不存在");
GaoProduct product = productService.get(productId);
TimiException.required(product, "not found product");
storeScopeService.checkStoreId(product.getStoreId());
specService.createValue(value);
return value.getId();
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
@PostMapping("/sellable/list")
public List<GaoProduct> sellableList(@RequestBody GaoProductPage page) {
TimiException.required(page, "not found product page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return productService.listSellable(page);
}
}
@@ -0,0 +1,106 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoProductSkuChartService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuFulfillmentDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuFulfillmentRankView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuSalesDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuSalesRankView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuStockHealthView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuStockMovementDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoProductSkuUnitSalesRankView;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/// GAO SKU 图表接口
///
/// @author Codex
/// @since 2026-09-07
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/product/sku/chart")
public class GaoProductSkuChartController {
private final GaoProductSkuChartService service;
private final GaoStoreScopeService storeScopeService;
/// 查询 SKU 每日销售统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/daily")
public List<GaoProductSkuSalesDailyStatView> salesDaily(@RequestBody GaoProductChartReq req) {
return service.salesDaily(normalize(req));
}
/// 查询 SKU 销售排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/rank")
public List<GaoProductSkuSalesRankView> salesRank(@RequestBody GaoProductChartReq req) {
return service.salesRank(normalize(req));
}
/// 查询 SKU 单位销售排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/sales/unit/rank")
public List<GaoProductSkuUnitSalesRankView> unitSalesRank(@RequestBody GaoProductChartReq req) {
return service.unitSalesRank(normalize(req));
}
/// 查询 SKU 每日履约统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/fulfillment/daily")
public List<GaoProductSkuFulfillmentDailyStatView> fulfillmentDaily(@RequestBody GaoProductChartReq req) {
return service.fulfillmentDaily(normalize(req));
}
/// 查询 SKU 履约进度排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/fulfillment/rank")
public List<GaoProductSkuFulfillmentRankView> fulfillmentRank(@RequestBody GaoProductChartReq req) {
return service.fulfillmentRank(normalize(req));
}
/// 查询 SKU 每日库存变动统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/stock/movement/daily")
public List<GaoProductSkuStockMovementDailyStatView> stockMovementDaily(@RequestBody GaoProductChartReq req) {
return service.stockMovementDaily(normalize(req));
}
/// 查询 SKU 库存健康度
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/stock/health")
public List<GaoProductSkuStockHealthView> stockHealth(@RequestBody GaoProductChartReq req) {
return service.stockHealth(normalize(req));
}
private GaoProductChartReq normalize(GaoProductChartReq req) {
TimiException.required(req, "SKU 图表请求不能为空");
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return req;
}
}
@@ -0,0 +1,140 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoProductStock;
import com.imyeyu.api.modules.gao.entity.GaoProductStockRecord;
import com.imyeyu.api.modules.gao.service.GaoProductStockService;
import com.imyeyu.api.modules.gao.service.GaoProductStockRecordService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoProductStockChangeRequest;
import com.imyeyu.api.modules.gao.vo.GaoProductStockManualRevokeRequest;
import com.imyeyu.api.modules.gao.vo.GaoProductStockPage;
import com.imyeyu.api.modules.gao.vo.GaoProductStockProductView;
import com.imyeyu.api.modules.gao.vo.GaoProductStockRecordPage;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/// GAO 产品库存接口
///
/// @author Codex
/// @since 2026-09-02
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/product/stock")
public class GaoProductStockController {
private final GaoProductStockService stockService;
private final GaoProductStockRecordService recordService;
private final GaoStoreScopeService storeScopeService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_READ)
@PostMapping("/list")
public PageResult<GaoProductStock> list(@RequestBody GaoProductStockPage page) {
TimiException.required(page, "not found stock page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return stockService.pageByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_READ)
@PostMapping("/product-list")
public PageResult<GaoProductStockProductView> productList(@RequestBody GaoProductStockPage page) {
TimiException.required(page, "not found stock product page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return stockService.pageProductByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_READ)
@PostMapping("/detail")
public GaoProductStock detail(@RequestParam(required = false) String storeId, @RequestParam String skuId) {
return stockService.detail(storeScopeService.resolveStoreId(storeId), skuId);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_CREATE)
@PostMapping("/initial-in")
public GaoProductStock initialIn(@RequestBody GaoProductStockChangeRequest request) {
return stockService.initialIn(normalize(request));
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_CREATE)
@PostMapping("/manual-in")
public GaoProductStock manualIn(@RequestBody GaoProductStockChangeRequest request) {
return stockService.manualIn(normalize(request));
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_CREATE)
@PostMapping("/manual-out")
public GaoProductStock manualOut(@RequestBody GaoProductStockChangeRequest request) {
return stockService.manualOut(normalize(request));
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_MANUAL_REVOKE)
@PostMapping("/manual-revoke")
public GaoProductStock manualRevoke(@RequestBody GaoProductStockManualRevokeRequest request) {
return stockService.manualRevoke(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_CREATE)
@PostMapping("/stocktake-gain")
public GaoProductStock stocktakeGain(@RequestBody GaoProductStockChangeRequest request) {
return stockService.stocktakeGain(normalize(request));
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_CREATE)
@PostMapping("/stocktake-loss")
public GaoProductStock stocktakeLoss(@RequestBody GaoProductStockChangeRequest request) {
return stockService.stocktakeLoss(normalize(request));
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_READ)
@PostMapping("/record/list")
public PageResult<GaoProductStockRecord> recordList(@RequestBody GaoProductStockRecordPage page) {
TimiException.required(page, "not found stock record page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return recordService.pageByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.PRODUCT_STOCK_READ)
@PostMapping("/record/detail")
public GaoProductStockRecord recordDetail(@RequestParam String id) {
GaoProductStockRecord result = recordService.detail(id);
storeScopeService.checkStoreId(result.getStoreId());
return result;
}
private GaoProductStockChangeRequest normalize(GaoProductStockChangeRequest request) {
TimiException.required(request, "not found stock change request");
request.setStoreId(storeScopeService.resolveStoreId(request.getStoreId()));
return request;
}
}
@@ -0,0 +1,156 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoSalesOrderChartService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderSkuRankView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderChartReq;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/// GAO 销售订单图表接口
///
/// @author Codex
/// @since 2026-09-06
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/sales/order/chart")
public class GaoSalesOrderChartController {
private final GaoSalesOrderChartService service;
private final GaoStoreScopeService storeScopeService;
/// 查询销售订单每日统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/daily")
public List<GaoSalesOrderDailyStatView> daily(@RequestBody GaoSalesOrderChartReq req) {
return service.daily(normalize(req));
}
/// 查询销售订单类型统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/type")
public List<GaoSalesOrderTypeStatView> type(@RequestBody GaoSalesOrderChartReq req) {
return service.type(normalize(req));
}
/// 查询销售订单付款状态统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/payment")
public List<GaoSalesOrderPaymentStatView> payment(@RequestBody GaoSalesOrderChartReq req) {
return service.payment(normalize(req));
}
/// 查询客户订单排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/rank")
public List<GaoCustomerOrderRankView> customerRank(@RequestBody GaoSalesOrderChartReq req) {
return service.customerRank(normalize(req));
}
/// 查询指定客户订单产品排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/product/rank")
public List<GaoCustomerOrderProductRankView> customerProductRank(@RequestBody GaoSalesOrderChartReq req) {
return service.customerProductRank(normalize(req));
}
/// 查询指定客户订单 SKU 排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/sku/rank")
public List<GaoCustomerOrderSkuRankView> customerSkuRank(@RequestBody GaoSalesOrderChartReq req) {
return service.customerSkuRank(normalize(req));
}
/// 查询销售订单状态统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/status")
public List<GaoSalesOrderStatusStatView> status(@RequestBody GaoSalesOrderChartReq req) {
return service.status(normalize(req));
}
/// 查询销售订单应收统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/receivable")
public GaoSalesOrderReceivableStatView receivable(@RequestBody GaoSalesOrderChartReq req) {
return service.receivable(normalize(req));
}
/// 查询客户每日有效消费统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/consumption/daily")
public List<GaoSalesOrderConsumptionDailyStatView> consumptionDaily(@RequestBody GaoSalesOrderChartReq req) {
return service.consumptionDaily(normalize(req));
}
/// 查询客户订单日历统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/calendar")
public List<GaoSalesOrderCalendarStatView> calendar(@RequestBody GaoSalesOrderChartReq req) {
return service.calendar(normalize(req));
}
/// 查询客户每日复购统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/repeat/daily")
public List<GaoCustomerRepeatDailyStatView> repeatDaily(@RequestBody GaoSalesOrderChartReq req) {
return service.repeatDaily(normalize(req));
}
/// 查询客户复购间隔统计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/customer/repeat/interval")
public List<GaoCustomerRepeatIntervalStatView> repeatInterval(@RequestBody GaoSalesOrderChartReq req) {
return service.repeatInterval(normalize(req));
}
private GaoSalesOrderChartReq normalize(GaoSalesOrderChartReq req) {
TimiException.required(req, "not found sales order chart req");
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return req;
}
}
@@ -0,0 +1,152 @@
package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.bean.PermissionMatchMode;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoFundRecord;
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
import com.imyeyu.api.modules.gao.service.GaoOrderPaymentService;
import com.imyeyu.api.modules.gao.service.GaoSalesOrderService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoDirectProductOrderCreateRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentActionRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentNoRefundRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentReceiveRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentRefundRequest;
import com.imyeyu.api.modules.gao.vo.GaoOrderPaymentRevokeRequest;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCancelRequest;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPage;
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderUpdateRequest;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/// GAO 销售订单和资金接口
///
/// @author Codex
/// @since 2026-09-02
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/sales/order")
public class GaoSalesOrderController {
private final GaoSalesOrderService service;
private final GaoOrderPaymentService paymentService;
private final GaoStoreScopeService storeScopeService;
private final UserService userService;
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_READ)
@PostMapping("/list")
public PageResult<GaoSalesOrder> list(@RequestBody GaoSalesOrderPage page) {
TimiException.required(page, "not found sales order page");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
return service.pageByQuery(page);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_READ)
@PostMapping("/detail")
public GaoSalesOrder detail(@RequestParam String id) {
GaoSalesOrder result = service.detail(id);
if (TimiJava.isNotEmpty(result.getCancelOperatorUserId())) {
result.setCancelOperator(userService.get(result.getCancelOperatorUserId()));
}
return result;
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_CREATE)
@PostMapping("/direct-product/create")
public GaoSalesOrder createDirectProduct(@RequestBody GaoDirectProductOrderCreateRequest request) {
TimiException.required(request, "not found direct product order request");
request.setStoreId(storeScopeService.resolveStoreId(request.getStoreId()));
return service.createDirectProductOrder(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_UPDATE)
@PostMapping("/update")
public GaoSalesOrder update(@RequestBody GaoSalesOrderUpdateRequest request) {
TimiException.required(request, "not found sales order update request");
TimiException.required(request.getId(), "not found sales order.id");
return service.updateRemarkAndAttachments(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_CANCEL)
@PostMapping("/cancel")
public GaoSalesOrder cancel(@RequestBody GaoSalesOrderCancelRequest request) {
return service.cancel(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_CREATE)
@PostMapping("/payment/receive")
public GaoFundRecord receive(@RequestBody GaoOrderPaymentReceiveRequest request) {
return paymentService.receive(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_VERIFY)
@PostMapping("/payment/verify")
public GaoFundRecord verify(@RequestParam String id) {
return paymentService.verify(id);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_VERIFY)
@PostMapping("/payment/reject")
public GaoFundRecord reject(@RequestBody GaoOrderPaymentActionRequest request) {
return paymentService.reject(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(value = {GaoPermissionCode.FUND_RECEIVE_CREATE, GaoPermissionCode.FUND_RECORD_READ}, mode = PermissionMatchMode.ANY)
@PostMapping("/payment/cancel")
public GaoFundRecord cancelPayment(@RequestBody GaoOrderPaymentActionRequest request) {
return paymentService.cancel(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_REFUND)
@PostMapping("/refund")
public GaoFundRecord refund(@RequestBody GaoOrderPaymentRefundRequest request) {
return paymentService.refund(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_REFUND)
@PostMapping("/refund/confirm-none")
public GaoFundRecord confirmNoRefund(@RequestBody GaoOrderPaymentNoRefundRequest request) {
return paymentService.confirmNoRefund(request);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.FUND_REVOKE)
@PostMapping("/fund/revoke")
public GaoFundRecord revoke(@RequestBody GaoOrderPaymentRevokeRequest request) {
return paymentService.revoke(request);
}
}
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission; import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode; import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.api.modules.gao.entity.GaoStore; import com.imyeyu.api.modules.gao.entity.GaoStore;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService; import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.service.GaoStoreService; import com.imyeyu.api.modules.gao.service.GaoStoreService;
@@ -0,0 +1,141 @@
package com.imyeyu.api.modules.gao.controller;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.modules.common.entity.Article;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoStoreDiaryService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoStoreDiaryPage;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.api.modules.user.service.UserService;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/// GAO 门店日记接口
///
/// @author Codex
/// @since 2026-08-31
@RestController
@RequiredArgsConstructor
@RequestMapping("/gao/store/diary")
public class GaoStoreDiaryController {
private final GaoStoreDiaryService service;
private final GaoStoreScopeService storeScopeService;
private final UserLoginService userLoginService;
private final UserService userService;
private final AttachmentService attachmentService;
/// 分页查询门店日记
///
/// @param page 分页查询条件
/// @return 门店日记分页结果
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_READ)
@PostMapping("/list")
@JsonView(ResponseView.Public.class)
public PageResult<Article> list(@RequestBody GaoStoreDiaryPage page) {
TimiException.required(page, "未找到分页参数");
TimiException.required(page.getBeginCreatedAt(), "未找到门店日记开始时间");
TimiException.required(page.getEndCreatedAt(), "未找到门店日记结束时间");
TimiException.requiredTrue(page.getBeginCreatedAt() < page.getEndCreatedAt(), "门店日记时间范围无效");
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
PageResult<Article> result = service.page(page);
{
List<String> articleIdList = result.getList().stream().map(Article::getId).toList();
Map<String, Attachment> attachMap = attachmentService.mapFirstImageByIdList(Attachment.BizType.ARTICLE, articleIdList);
for (Article article : result.getList()) {
Attachment attachment = attachMap.get(article.getId());
article.setAttachmentList(TimiJava.ofList(attachment));
}
}
return result;
}
/// 查询门店日记详情
///
/// @param id 日记 ID
/// @return 门店日记
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_READ)
@PostMapping("/detail")
@JsonView(ResponseView.Public.class)
public Article detail(@RequestParam String id) {
Article article = service.get(id);
storeScopeService.checkStoreId(article.getBizId());
article.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.ARTICLE, article.getId()));
if (TimiJava.isNotEmpty(article.getUpdatedBy())) {
User updater = userService.get(article.getUpdatedBy());
if (updater != null) {
updater.setAttachmentList(attachmentService.listByBizId(
Attachment.BizType.USER,
updater.getId(),
User.AttachType.AVATAR.toString()
));
}
article.setUpdater(updater);
}
return article;
}
/// 创建门店日记
///
/// @param article 门店日记
/// @return 日记 ID
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_CREATE)
@PostMapping("/create")
public String create(@RequestBody Article article) {
article.setBizId(storeScopeService.resolveStoreId(article.getBizId()));
service.create(article, userLoginService.getRequireLoginUserId());
return article.getId();
}
/// 修改门店日记
///
/// @param article 门店日记
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Article article) {
TimiException.required(article, "未找到门店日记");
TimiException.required(article.getId(), "未找到门店日记 ID");
Article dbArticle = service.get(article.getId());
storeScopeService.checkStoreId(dbArticle.getBizId());
service.update(article, userLoginService.getRequireLoginUserId());
}
/// 删除门店日记
///
/// @param id 日记 ID
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STORE_DIARY_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
Article article = service.get(id);
storeScopeService.checkStoreId(article.getBizId());
service.delete(article.getId());
}
}
@@ -0,0 +1,49 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.databind.JsonNode;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// GAO 客户有效消费事实
///
/// @author Codex
/// @since 2026-09-04
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoCustomerConsumptionRecord extends UUIDEntity {
/// 消费来源类型
public enum SourceType {
/// 迁移的旧消费事件
LEGACY_EVENT,
/// 销售订单全额实收
SALES_ORDER
}
/// 消费事实状态
public enum Status {
/// 有效并参与累计
ACTIVE,
/// 已失效,不参与累计
REVOKED
}
private String storeId;
private String customerId;
private SourceType sourceType;
private String sourceId;
private String salesOrderId;
private GaoSalesOrder.OrderType orderType;
private Long amount;
private Long effectiveAt;
private Status status;
private Long revokedAt;
private String revokeReason;
private JsonNode sourcePayload;
/// 客户
@Transient
private GaoCustomer customer;
}
@@ -0,0 +1,75 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 客户实际购买的套餐
///
/// @author Codex
/// @since 2026-08-31
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoCustomerPackage extends UUIDEntity {
/// 门店 ID
private String storeId;
/// 销售订单 ID
private String salesOrderId;
/// 客户 ID
private String customerId;
/// 来源套餐配置 ID
private String packageConfigId;
/// 套餐名称快照
private String packageNameSnapshot;
/// 标准价快照,单位分
private Long standardAmountSnapshot;
/// 订单投影状态
@Transient
private GaoSalesOrder.Status status;
/// 订单投影取消时间
@Transient
private Long cancelledAt;
/// 订单投影取消操作人 ID
@Transient
private String cancelOperatorUserId;
/// 订单投影取消原因
@Transient
private String cancelReason;
/// 备注
private String remark;
/// 客户
@Transient
private GaoCustomer customer;
/// 取消操作人
@Transient
private User cancelOperator;
/// 关联销售订单
@Transient
private GaoSalesOrder salesOrder;
/// 关联订单可履约明细投影
@Transient
private List<GaoSalesOrderItem> itemList;
/// 统一履约历史
@Transient
private List<GaoOrderFulfillment> fulfillmentList;
}
@@ -18,6 +18,19 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class GaoEvent extends UUIDEntity { public class GaoEvent extends UUIDEntity {
/// 事件业务类型
public enum BizType {
/// 普通登记事件
GENERAL,
/// 购买产品套餐
PACKAGE_PURCHASE,
/// 已退役的历史消费事件,仅保留归档和溯源
LEGACY_CONSUMPTION
}
/// ///
/// 登记事件状态 /// 登记事件状态
/// ///
@@ -93,6 +106,16 @@ public class GaoEvent extends UUIDEntity {
/// 统计图表颜色 /// 统计图表颜色
private String color; private String color;
/// 业务类型
private BizType bizType;
/// 购买套餐事件绑定的套餐配置 ID
private String packageConfigId;
/// 购买套餐事件绑定的套餐配置
@Transient
private GaoPackageConfig packageConfig;
/// 登记事件名称 /// 登记事件名称
private String name; private String name;
@@ -117,6 +140,9 @@ public class GaoEvent extends UUIDEntity {
/// true 为登记时要求拍照 /// true 为登记时要求拍照
private Boolean requirePhoto; private Boolean requirePhoto;
/// true 为登记记录需要核销
private Boolean requireVerification;
/// 登记限制类型 /// 登记限制类型
private LimitType limitType; private LimitType limitType;
@@ -135,4 +161,8 @@ public class GaoEvent extends UUIDEntity {
/// 可登记角色代码列表 /// 可登记角色代码列表
@Transient @Transient
private List<String> roleCodeList; private List<String> roleCodeList;
/// 登记事件选项组列表
@Transient
private List<GaoEventOptionGroup> optionGroupList;
} }
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// 登记事件选项
///
/// @author Codex
/// @since 2026-08-30
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoEventOption extends UUIDEntity {
/// 选项组 ID
private String groupId;
/// 选项名称
private String label;
/// 排序值
private Integer sort;
}
@@ -0,0 +1,46 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// 登记事件选项组
///
/// @author Codex
/// @since 2026-08-30
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoEventOptionGroup extends UUIDEntity {
/// 选项选择模式
public enum SelectionMode {
/// 只能选择一个选项
SINGLE,
/// 可以选择多个选项
MULTIPLE
}
/// 登记事件 ID
private String eventId;
/// 选项组名称
private String name;
/// 选择模式
private SelectionMode selectionMode;
/// true 为登记时必须选择至少一个选项
private Boolean required;
/// 排序值
private Integer sort;
/// 选项列表
@Transient
private List<GaoEventOption> optionList;
}
@@ -18,6 +18,23 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class GaoEventRecord extends UUIDEntity { public class GaoEventRecord extends UUIDEntity {
///
/// 登记记录核销状态
///
/// @author Codex
/// @since 2026-08-29
public enum VerificationStatus {
/// 该事件不需要核销
NOT_REQUIRED,
/// 等待核销
PENDING,
/// 已核销
VERIFIED
}
/// ///
/// 登记事件记录附件类型 /// 登记事件记录附件类型
/// ///
@@ -49,6 +66,15 @@ public class GaoEventRecord extends UUIDEntity {
/// 本次登记提交的整数业务数值 /// 本次登记提交的整数业务数值
private Long numberValue; private Long numberValue;
/// 核销状态
private VerificationStatus verificationStatus;
/// 核销用户 ID
private String verifierUserId;
/// 核销时间
private Long verifiedAt;
/// 备注 /// 备注
private String remark; private String remark;
@@ -61,6 +87,9 @@ public class GaoEventRecord extends UUIDEntity {
/// 营业日递增序号 /// 营业日递增序号
private Long businessDayNo; private Long businessDayNo;
/// 最后修改用户 ID
private String updatedBy;
@Transient @Transient
private GaoCustomer customer; private GaoCustomer customer;
@@ -70,10 +99,21 @@ public class GaoEventRecord extends UUIDEntity {
@Transient @Transient
private User operator; private User operator;
@Transient
private User verifier;
/// 最后修改用户
@Transient
private User updater;
@Transient @Transient
private List<Attachment> attachmentList; private List<Attachment> attachmentList;
/// 客户 ID 列表,批量登记时使用 /// 客户 ID 列表,批量登记时使用
@Transient @Transient
private List<String> customerIdList; private List<String> customerIdList;
/// 登记记录已选择的选项组列表
@Transient
private List<GaoEventRecordOptionGroup> selectedOptionGroupList;
} }
@@ -0,0 +1,35 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// 登记事件记录选项关系
///
/// @author Codex
/// @since 2026-08-30
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoEventRecordOption extends UUIDEntity {
/// 登记事件记录 ID
private String eventRecordId;
/// 选项组 ID
private String groupId;
/// 选项 ID
private String optionId;
/// 选项组排序快照
private Integer groupSort;
/// 选项排序快照
private Integer optionSort;
/// 选项组名称快照
private String groupNameSnapshot;
/// 选项名称快照
private String optionLabelSnapshot;
}
@@ -0,0 +1,22 @@
package com.imyeyu.api.modules.gao.entity;
import lombok.Data;
import java.util.List;
/// 登记事件记录选项组视图
///
/// @author Codex
/// @since 2026-08-30
@Data
public class GaoEventRecordOptionGroup {
/// 选项组 ID
private String groupId;
/// 选项组名称
private String groupName;
/// 已选择的选项列表
private List<GaoEventOption> selectedOptionList;
}
@@ -0,0 +1,126 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 销售订单资金操作流水
///
/// @author Codex
/// @since 2026-08-31
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoFundRecord extends UUIDEntity {
/// 资金业务类型
public enum BizType {
/// 销售订单
SALES_ORDER
}
/// 资金操作类型
public enum OperationType {
/// 线下收款
RECEIVE,
/// 退款
REFUND,
/// 确认无需退款
CONFIRM_NO_REFUND,
/// 资金操作冲正
REVOKE
}
/// 资金操作状态
public enum Status {
/// 待店长核销
PENDING,
/// 已生效
VERIFIED,
/// 店长已拒绝
REJECTED,
/// 提交人已撤销
CANCELLED
}
/// 门店 ID
private String storeId;
/// 客户 ID
private String customerId;
/// 资金业务类型
private BizType bizType;
/// 业务对象 ID
private String bizId;
/// 操作类型
private OperationType operationType;
/// 操作状态
private Status status;
/// 金额,单位分
private Long amount;
/// 冲正时关联原资金记录
private String sourceRecordId;
/// 幂等请求号
private String requestNo;
/// 提交操作的用户 ID
private String operatorUserId;
/// 收款核销用户 ID
private String verifierUserId;
/// 收款核销时间
private Long verifiedAt;
/// 线下操作发生时间
private Long occurredAt;
/// 原因
private String reason;
/// 备注
private String remark;
/// 关联的冲正流水 ID
@Transient
private String revokeRecordId;
/// 关联销售订单总价,单位分
@Transient
private Long salesOrderAmount;
/// 流水发生时关联销售订单剩余待收款金额快照,单位分
private Long salesOrderUnpaidAmountSnapshot;
/// 操作人
@Transient
private User operator;
/// 核销人
@Transient
private User verifier;
/// 附件
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,115 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.AutoUUID;
import com.imyeyu.spring.annotation.table.Id;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.Creatable;
import com.imyeyu.spring.entity.IDEntity;
import com.imyeyu.spring.entity.Updatable;
import lombok.Data;
import java.util.List;
/// GAO 统一履约单
///
/// @author Codex
/// @since 2026-09-02
@Data
public class GaoOrderFulfillment implements IDEntity<String>, Creatable, Updatable {
/// 履约状态
public enum Status {
/// 等待库存
WAITING_STOCK,
/// 待核销
PENDING,
/// 已核销
VERIFIED,
/// 店长已拒绝
REJECTED,
/// 提交人已撤销
CANCELLED,
/// 已核销后冲正
REVOKED
}
@Id
@AutoUUID
private String id;
/// 销售订单 ID
private String salesOrderId;
/// 门店 ID
private String storeId;
/// 客户 ID
private String customerId;
/// 履约状态
private Status status;
/// 客户端幂等请求号
private String requestNo;
/// 提交人
private String operatorUserId;
/// 实际履约时间
private Long deliveredAt;
/// 核销或拒绝操作人
private String verifierUserId;
/// 核销或拒绝时间
private Long verifiedAt;
/// 冲正单指向原履约单
private String sourceFulfillmentId;
/// 拒绝、撤销或冲正原因
private String reason;
/// 备注
private String remark;
private Long createdAt;
private Long updatedAt;
/// 提交人
@Transient
private User operator;
/// 客户
@Transient
private GaoCustomer customer;
/// 核销或拒绝操作人
@Transient
private User verifier;
/// 原履约单
@Transient
private GaoOrderFulfillment sourceFulfillment;
/// 履约明细
@Transient
private List<GaoOrderFulfillmentItem> itemList;
/// 库存处理流水
@Transient
private List<GaoProductStockRecord> stockRecordList;
/// 附件
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,85 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.databind.JsonNode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.spring.annotation.table.AutoUUID;
import com.imyeyu.spring.annotation.table.Id;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.Creatable;
import com.imyeyu.spring.entity.IDEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/// GAO 统一履约明细
///
/// @author Codex
/// @since 2026-09-02
@Data
public class GaoOrderFulfillmentItem implements IDEntity<String>, Creatable {
@Id
@AutoUUID
private String id;
/// 履约单 ID
private String fulfillmentId;
/// SKU ID
private String skuId;
/// 本次实际履约 SKU 单位 ID
private String skuUnitId;
/// 产品图片附件
@Transient
private List<Attachment> attachmentList;
/// 来源销售订单明细 ID
private String sourceOrderItemId;
/// 本次履约数量
private BigDecimal quantity;
/// 基础单位数量
private BigDecimal baseQuantity;
/// 操作前待履约基础单位数量
private BigDecimal reservedBaseBefore;
/// 操作后待履约基础单位数量
private BigDecimal reservedBaseAfter;
/// 操作前已履约基础单位数量
private BigDecimal fulfilledBaseBefore;
/// 操作后已履约基础单位数量
private BigDecimal fulfilledBaseAfter;
/// 产品名称快照
private String productNameSnapshot;
/// 产品 ID 快照
private String productIdSnapshot;
/// SKU 编码快照
private String skuCodeSnapshot;
/// SKU 名称快照
private String skuNameSnapshot;
/// 规格摘要快照
private String specSummarySnapshot;
/// SKU 规格结构快照,数组元素包含 specId、specName、specValueId、specValueName
private JsonNode skuSpecSnapshot;
/// 单位快照
private String unitSnapshot;
/// 基础单位数量系数快照
private BigDecimal baseQuantityPerUnitSnapshot;
private Long createdAt;
}
@@ -0,0 +1,66 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 套餐配置
///
/// @author Codex
/// @since 2026-08-31
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoPackageConfig extends UUIDEntity {
/// 套餐配置状态
public enum Status {
/// 草稿,不可销售
DRAFT,
/// 启用,可在有效期内销售
ACTIVE,
/// 停用,不可销售
INACTIVE
}
/// 门店 ID
private String storeId;
/// 套餐名称
private String name;
/// 套餐说明
private String description;
/// 标准总价,单位分
private Long standardAmount;
/// 状态
private Status status;
/// 生效开始时间戳,毫秒,空为不限制
private Long beginAt;
/// 生效结束时间戳,毫秒,空为不限制
private Long endAt;
/// 排序值
private Integer sort;
/// 最后修改用户 ID
private String updatedBy;
/// 最后修改用户
@Transient
private User updater;
/// 配置产品列表
@Transient
private List<GaoPackageConfigItem> itemList;
}
@@ -0,0 +1,60 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/// GAO 套餐配置产品明细
///
/// @author Codex
/// @since 2026-08-31
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoPackageConfigItem extends UUIDEntity {
/// 套餐配置 ID
private String packageConfigId;
/// SKU ID
private String skuId;
/// SKU 单位 ID
private String skuUnitId;
/// 产品名称快照
private String productNameSnapshot;
/// 产品 ID 快照
private String productIdSnapshot;
/// SKU 编码快照
private String skuCodeSnapshot;
/// SKU 名称快照
private String skuNameSnapshot;
/// 规格摘要快照
private String specSummarySnapshot;
/// 单位快照
private String unitSnapshot;
/// 基础单位数量系数快照
private BigDecimal baseQuantityPerUnitSnapshot;
/// 默认数量
private BigDecimal defaultQuantity;
/// 排序值
private Integer sort;
/// 备注
private String remark;
/// SKU 详情
@Transient
private GaoProductSku sku;
}
@@ -17,13 +17,13 @@ public class GaoPointLedger extends UUIDEntity {
/// 流水变化类型 /// 流水变化类型
public enum ChangeType { public enum ChangeType {
/// 登记事件发放积分 /// 规则发放积分
EARN, EARN,
/// 登记事件消费积分 /// 规则扣减积分
CONSUME, CONSUME,
/// 删除登记记录撤销积分 /// 撤销积分
REVOKE, REVOKE,
/// 人工调整积分 /// 人工调整积分
@@ -40,6 +40,16 @@ public class GaoPointLedger extends UUIDEntity {
DECREASE DECREASE
} }
/// 直接触发来源类型
public enum TriggerSourceType {
/// 事件登记
EVENT_RECORD,
/// 订单首次全额实收
SALES_ORDER_PAID
}
/// 客户积分账户 ID /// 客户积分账户 ID
private String accountId; private String accountId;
@@ -67,11 +77,20 @@ public class GaoPointLedger extends UUIDEntity {
/// 命中的积分规则 ID /// 命中的积分规则 ID
private String ruleId; private String ruleId;
/// 登记事件 ID /// 直接触发来源类型
private String eventId; private TriggerSourceType triggerSourceType;
/// 登记记录 ID /// 直接触发来源 ID
private String eventRecordId; private String triggerSourceId;
/// 关联销售订单 ID
private String salesOrderId;
/// 实际执行 Groovy 脚本版本 ID,简单规则为空
private String groovyScriptVersionId;
/// 命中时的规则快照
private JsonNode ruleSnapshot;
/// 来源快照 /// 来源快照
private JsonNode sourcePayload; private JsonNode sourcePayload;
@@ -1,6 +1,7 @@
package com.imyeyu.api.modules.gao.entity; package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.databind.JsonNode; import com.imyeyu.api.modules.common.entity.GroovyScript;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity; import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -29,43 +30,47 @@ public class GaoPointRule extends UUIDEntity {
DELETED DELETED
} }
/// 触发类型 /// 规则模式
public enum TriggerType { public enum RuleMode {
/// 每登记一次触发一次 /// 简单规则,固定积分值
EVERY_TIME, SIMPLE,
/// 客户首次登记该事件触发一次 /// Groovy 脚本规则
FIRST_TIME, GROOVY
/// 客户累计登记达到 N 次后每次触发
AFTER_COUNT_EVERY_TIME,
/// 使用登记接口提交的积分值触发
SOURCE_VALUE,
/// 按来源事件数值累计分档触发
CUSTOMER_EVENT_VALUE_TIER
} }
/// 积分值模式 /// 直接触发来源类型
public enum PointMode { public enum TriggerSourceType {
/// 使用规则固定积分值 /// 事件登记
FIXED, EVENT_RECORD,
/// 使用登记接口提交的积分值 /// 订单首次全额实收
SOURCE_VALUE, SALES_ORDER_PAID
}
/// 使用条件配置中的分档积分值 /// 触发对象筛选类型
TIER public enum TriggerRefType {
/// GAO 登记事件
EVENT
} }
/// 门店 ID /// 门店 ID
private String storeId; private String storeId;
/// 登记事件 ID /// 规则模式
private String eventId; private RuleMode ruleMode;
/// 直接触发来源类型
private TriggerSourceType triggerSourceType;
/// 触发对象筛选类型
private TriggerRefType triggerRefType;
/// 触发对象筛选 ID
private String triggerRefId;
/// 规则名称 /// 规则名称
private String name; private String name;
@@ -73,17 +78,11 @@ public class GaoPointRule extends UUIDEntity {
/// 规则状态 /// 规则状态
private Status status; private Status status;
/// 触发类型 /// 固定积分值,简单规则使用
private TriggerType triggerType;
/// 积分值模式
private PointMode pointMode;
/// 固定积分值
private Long pointValue; private Long pointValue;
/// 条件配置 /// Groovy 脚本 ID,GROOVY 模式使用
private JsonNode conditionJson; private String groovyScriptId;
/// 生效开始时间戳,毫秒,空为不限制 /// 生效开始时间戳,毫秒,空为不限制
private Long beginAt; private Long beginAt;
@@ -99,4 +98,7 @@ public class GaoPointRule extends UUIDEntity {
/// 备注 /// 备注
private String remark; private String remark;
@Transient
private GroovyScript groovyScript;
} }
@@ -0,0 +1,97 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 产品
///
/// @author Codex
/// @since 2026-09-02
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProduct extends UUIDEntity {
/// 产品类型
public enum ProductType {
/// 服务,不管理库存
SERVICE,
/// 实物,默认管理库存
GOODS,
/// 消耗品,可选择是否管理库存
CONSUMABLE
}
/// 产品附件类型
public enum AttachType {
/// 产品图片
PHOTO,
/// 其他产品文件
OTHER
}
/// 产品状态
public enum Status {
/// 启用
ACTIVE,
/// 停用
INACTIVE
}
/// 门店 ID
private String storeId;
/// 分类 ID
private String categoryId;
/// 门店内产品编码
private String code;
/// 产品名称
private String name;
/// 产品类型
private ProductType productType;
/// true 为启用库存管理
private Boolean stockEnabled;
/// 状态
private Status status;
/// 排序值
private Integer sort;
/// 备注
private String remark;
/// 最后修改用户 ID
private String updatedBy;
/// 产品分类
@Transient
private GaoProductCategory category;
/// 产品规格列表
@Transient
private List<GaoProductSpec> specList;
/// 产品 SKU 列表
@Transient
private List<GaoProductSku> skuList;
/// 产品附件列表
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,36 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// GAO 产品分类
///
/// @author Codex
/// @since 2026-09-02
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductCategory extends UUIDEntity {
/// 分类状态
public enum Status {
/// 启用
ACTIVE,
/// 停用
INACTIVE
}
/// 门店 ID
private String storeId;
/// 分类名称
private String name;
/// 排序值
private Integer sort;
/// 状态
private Status status;
}
@@ -0,0 +1,83 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/// GAO 产品 SKU
///
/// @author Codex
/// @since 2026-09-06
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductSku extends UUIDEntity {
/// SKU 状态
public enum Status {
/// 启用
ACTIVE,
/// 停用
INACTIVE
}
/// 门店 ID
private String storeId;
/// 产品 ID
private String productId;
/// 门店内 SKU 编码
private String code;
/// 条码
private String barcode;
/// SKU 展示名称
private String name;
/// 规格摘要
private String specSummary;
/// 规格值组合键
private String specValueKey;
/// true 为启用库存管理
private Boolean stockEnabled;
/// true 为允许业务数量保留小数
private Boolean allowDecimalQuantity;
/// 最低库存数量,基础单位
private BigDecimal minStockQuantity;
/// 状态
private Status status;
/// 排序值
private Integer sort;
/// 备注
private String remark;
/// 最后修改用户 ID
private String updatedBy;
/// 规格值 ID 列表
@Transient
private List<String> specValueIdList;
/// SKU 单位列表
@Transient
private List<GaoProductSkuUnit> unitList;
/// SKU 附件列表
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,29 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.annotation.table.AutoUUID;
import com.imyeyu.spring.annotation.table.Id;
import com.imyeyu.spring.entity.Creatable;
import com.imyeyu.spring.entity.IDEntity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// GAO SKU 规格值关联
///
/// @author Codex
/// @since 2026-09-06
@Data
public class GaoProductSkuSpecValue implements IDEntity<String>, Creatable {
@Id
@AutoUUID
private String id;
/// SKU ID
private String skuId;
/// 规格值 ID
private String specValueId;
private Long createdAt;
}
@@ -0,0 +1,40 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/// GAO 产品 SKU 业务单位
///
/// @author Codex
/// @since 2026-09-06
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductSkuUnit extends UUIDEntity {
/// SKU ID
private String skuId;
/// 单位名称
private String name;
/// 每个业务单位对应的基础单位数量
private BigDecimal baseQuantityPerUnit;
/// 该业务单位建议售价,单位分
private Long salePrice;
/// true 为基础库存单位
private Boolean isBase;
/// true 为允许采购入库
private Boolean allowPurchase;
/// true 为允许销售或套餐配置
private Boolean allowSale;
/// 排序值
private Integer sort;
}
@@ -0,0 +1,36 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 产品规格项
///
/// @author Codex
/// @since 2026-09-06
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductSpec extends UUIDEntity {
/// 前端创建请求中的临时关联键
@Transient
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String clientKey;
/// 产品 ID
private String productId;
/// 规格名称
private String name;
/// 排序值
private Integer sort;
/// 规格值列表
@Transient
private List<GaoProductSpecValue> valueList;
}
@@ -0,0 +1,33 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/// GAO 产品规格值
///
/// @author Codex
/// @since 2026-09-06
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductSpecValue extends UUIDEntity {
/// 前端创建请求中的临时关联键
@Transient
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String clientKey;
/// 规格项 ID
private String specId;
/// 规格值名称
private String name;
/// true 为启用
private Boolean enabled;
/// 排序值
private Integer sort;
}
@@ -0,0 +1,40 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/// GAO 产品库存余额
///
/// @author Codex
/// @since 2026-09-02
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoProductStock extends UUIDEntity {
/// 门店 ID
private String storeId;
/// SKU ID
private String skuId;
/// 实际库存,基础单位
private BigDecimal onHandQuantity;
/// 已预占库存,基础单位
private BigDecimal reservedQuantity;
/// 最后操作人
private String updatedBy;
/// SKU
@Transient
private GaoProductSku sku;
/// 可用库存,基础单位
@Transient
private BigDecimal availableQuantity;
}
@@ -0,0 +1,165 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.databind.JsonNode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.AutoUUID;
import com.imyeyu.spring.annotation.table.Id;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.Creatable;
import com.imyeyu.spring.entity.IDEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/// GAO 库存变更流水
///
/// @author Codex
/// @since 2026-09-02
@Data
public class GaoProductStockRecord implements IDEntity<String>, Creatable {
/// 库存流水业务类型
public enum BizType {
/// 人工库存操作
PRODUCT_STOCK,
/// 订单履约库存操作
ORDER_FULFILLMENT
}
/// 库存操作类型
public enum OperationType {
/// 期初入库
INITIAL_IN,
/// 手工入库
MANUAL_IN,
/// 手工出库
MANUAL_OUT,
/// 手工流水冲正
MANUAL_REVOKE,
/// 履约预占
ORDER_RESERVE,
/// 履约释放预占
ORDER_RELEASE,
/// 履约出库
ORDER_OUT,
/// 履约冲正入库
ORDER_REVOKE,
/// 盘盈
STOCKTAKE_GAIN,
/// 盘亏
STOCKTAKE_LOSS
}
@Id
@AutoUUID
private String id;
/// 门店 ID
private String storeId;
/// SKU ID
private String skuId;
/// SKU 单位 ID
private String skuUnitId;
/// 产品名称快照
private String productNameSnapshot;
/// 产品 ID 快照
private String productIdSnapshot;
/// SKU 编码快照
private String skuCodeSnapshot;
/// SKU 名称快照
private String skuNameSnapshot;
/// 规格摘要快照
private String specSummarySnapshot;
/// SKU 规格结构快照,数组元素包含 specId、specName、specValueId、specValueName
private JsonNode skuSpecSnapshot;
/// 单位名称快照
private String unitSnapshot;
/// 基础单位数量系数快照
private BigDecimal baseQuantityPerUnitSnapshot;
/// 业务数量
private BigDecimal quantity;
/// 基础单位数量
private BigDecimal baseQuantity;
/// 操作类型
private OperationType operationType;
/// 实际库存增量
private BigDecimal onHandDelta;
/// 预占库存增量
private BigDecimal reservedDelta;
/// 操作前实际库存
private BigDecimal onHandBefore;
/// 操作后实际库存
private BigDecimal onHandAfter;
/// 操作前预占库存
private BigDecimal reservedBefore;
/// 操作后预占库存
private BigDecimal reservedAfter;
/// 来源业务类型
private BizType bizType;
/// 来源业务 ID
private String bizId;
/// 冲正来源流水 ID
private String sourceRecordId;
/// 关联的冲正流水 ID
@Transient
private String revokeRecordId;
/// 幂等请求号
private String requestNo;
/// 操作用户 ID
private String operatorUserId;
/// 发生时间
private Long occurredAt;
/// 备注
private String remark;
private Long createdAt;
/// 操作用户
@Transient
private User operator;
/// 附件
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,160 @@
package com.imyeyu.api.modules.gao.entity;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.user.entity.User;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 销售订单
///
/// @author Codex
/// @since 2026-09-02
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoSalesOrder extends UUIDEntity {
/// 订单类型
public enum OrderType {
/// 套餐订单
PACKAGE,
/// 直接产品订单
DIRECT_PRODUCT
}
/// 订单状态
public enum Status {
/// 进行中
ACTIVE,
/// 全部履约
FULFILLED,
/// 已取消
CANCELLED
}
/// 付款状态
public enum PaymentStatus {
/// 未付款
UNPAID,
/// 部分付款
PARTIALLY_PAID,
/// 已付清
PAID
}
/// 退款状态
public enum RefundStatus {
/// 无需退款
NOT_REQUIRED,
/// 待退款或待确认无需退款
PENDING,
/// 已完成退款
REFUNDED
}
/// 门店 ID
private String storeId;
/// 客户 ID
private String customerId;
/// 门店内订单号
private String orderNo;
/// 订单类型
private OrderType orderType;
/// 订单状态
private Status status;
/// 付款状态
private PaymentStatus paymentStatus;
/// 退款状态
private RefundStatus refundStatus;
/// 成交金额,单位分
private Long saleAmount;
/// 待核销收款,单位分
private Long pendingPaidAmount;
/// 有效收款,单位分
private Long paidAmount;
/// 首次全额实收时间
private Long paidAt;
/// 有效退款,单位分
private Long refundedAmount;
/// 来源事件记录 ID
private String sourceEventRecordId;
/// 创建订单幂等号
private String requestNo;
/// 下单时间
private Long purchasedAt;
/// 下单操作人
private String operatorUserId;
/// 取消时间
private Long cancelledAt;
/// 取消操作人
private String cancelOperatorUserId;
/// 取消原因
private String cancelReason;
/// 备注
private String remark;
/// 客户
@Transient
private GaoCustomer customer;
/// 下单操作人
@Transient
private User operator;
/// 取消操作人
@Transient
private User cancelOperator;
/// 销售订单明细
@Transient
private List<GaoSalesOrderItem> itemList;
/// 资金流水
@Transient
private List<GaoFundRecord> fundRecordList;
/// 来源事件记录
@Transient
private GaoEventRecord sourceEventRecord;
/// 未收金额,单位分
@Transient
private Long unpaidAmount;
/// 订单附件
@Transient
private List<Attachment> attachmentList;
}
@@ -0,0 +1,117 @@
package com.imyeyu.api.modules.gao.entity;
import com.fasterxml.jackson.databind.JsonNode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/// GAO 销售订单通用可履约明细
///
/// @author Codex
/// @since 2026-09-02
@Data
@EqualsAndHashCode(callSuper = true)
public class GaoSalesOrderItem extends UUIDEntity {
/// 订单项类型
public enum ItemType {
/// 直接产品
DIRECT_PRODUCT,
/// 套餐权益
PACKAGE_ENTITLEMENT
}
/// 销售订单 ID
private String salesOrderId;
/// 订单项类型
private ItemType itemType;
/// true 为赠送权益
private Boolean gifted;
/// SKU ID
private String skuId;
/// SKU 单位 ID
private String skuUnitId;
/// 产品图片附件
@Transient
private List<Attachment> attachmentList;
/// 产品名称快照
private String productNameSnapshot;
/// 产品 ID 快照
private String productIdSnapshot;
/// SKU 编码快照
private String skuCodeSnapshot;
/// SKU 名称快照
private String skuNameSnapshot;
/// 规格摘要快照
private String specSummarySnapshot;
/// SKU 规格结构快照,数组元素包含 specId、specName、specValueId、specValueName
private JsonNode skuSpecSnapshot;
/// 单位快照
private String unitSnapshot;
/// 基础单位数量系数快照
private BigDecimal baseQuantityPerUnitSnapshot;
/// 当前 SKU 是否允许业务数量保留小数
@Transient
private Boolean allowDecimalQuantity;
/// 当前 SKU 基础单位名称
@Transient
private String baseUnitName;
/// 购买数量
private BigDecimal quantity;
/// 购买基础单位数量
private BigDecimal baseQuantity;
/// 待履约基础单位数量
private BigDecimal reservedBaseQuantity;
/// 已履约基础单位数量
private BigDecimal fulfilledBaseQuantity;
/// 实际单价,单位分
private Long unitPrice;
/// 行金额,单位分
private Long lineAmount;
/// 排序值
private Integer sort;
/// 备注
private String remark;
/// 待核销基础单位数量
@Transient
private BigDecimal pendingBaseQuantity;
/// 当前可履约基础单位数量
@Transient
private BigDecimal availableBaseQuantity;
/// 权益剩余基础单位数量
@Transient
private BigDecimal remainingBaseQuantity;
}
@@ -0,0 +1,27 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoCustomerConsumptionRecord;
import com.imyeyu.api.modules.gao.vo.GaoCustomerConsumptionRecordPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/// GAO 客户有效消费事实 Mapper
///
/// @author Codex
/// @since 2026-09-04
public interface GaoCustomerConsumptionRecordMapper extends BaseMapper<GaoCustomerConsumptionRecord, String> {
GaoCustomerConsumptionRecord selectBySource(@Param("sourceType") GaoCustomerConsumptionRecord.SourceType sourceType, @Param("sourceId") String sourceId);
List<GaoCustomerConsumptionRecord> selectActiveByWindow(@Param("storeId") String storeId, @Param("customerId") String customerId, @Param("beginAt") long beginAt, @Param("endAt") long endAt);
long countByQuery(GaoCustomerConsumptionRecordPage page);
Long sumAmountByPage(GaoCustomerConsumptionRecordPage page);
List<GaoCustomerConsumptionRecord> selectByQuery(GaoCustomerConsumptionRecordPage page);
int revokeBySource(@Param("sourceType") GaoCustomerConsumptionRecord.SourceType sourceType, @Param("sourceId") String sourceId, @Param("revokedAt") long revokedAt, @Param("revokeReason") String revokeReason);
}
@@ -55,5 +55,5 @@ public interface GaoCustomerMapper extends BaseMapper<GaoCustomer, String> {
/// @param customerId 客户 ID /// @param customerId 客户 ID
/// @param delta 变化量 /// @param delta 变化量
@Update("UPDATE `gao_customer` SET `invited_count` = GREATEST(IFNULL(`invited_count`, 0) + #{delta}, 0), `updated_at` = " + UNIX_TIME + " WHERE `id` = #{customerId}" + NOT_DELETE) @Update("UPDATE `gao_customer` SET `invited_count` = GREATEST(IFNULL(`invited_count`, 0) + #{delta}, 0), `updated_at` = " + UNIX_TIME + " WHERE `id` = #{customerId}" + NOT_DELETE)
void updateInvitedCountDelta(@Param("customerId") String customerId, @Param("delta") Long delta); void updateInvitedCountDelta(String customerId, Long delta);
} }
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackage;
import com.imyeyu.api.modules.gao.vo.GaoCustomerPackagePage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/// GAO 客户套餐 Mapper
///
/// @author Codex
/// @since 2026-08-31
public interface GaoCustomerPackageMapper extends BaseMapper<GaoCustomerPackage, String> {
/// 按销售订单查询客户套餐
GaoCustomerPackage selectBySalesOrderId(@Param("salesOrderId") String salesOrderId);
/// 按条件统计客户套餐
long countByQuery(GaoCustomerPackagePage page);
/// 按条件查询客户套餐
java.util.List<GaoCustomerPackage> selectByQuery(GaoCustomerPackagePage page);
}
@@ -1,8 +1,11 @@
package com.imyeyu.api.modules.gao.mapper; package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoEvent; import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.mapper.BaseMapper; import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -14,7 +17,16 @@ import java.util.List;
/// @since 2026-07-27 15:53 /// @since 2026-07-27 15:53
public interface GaoEventMapper extends BaseMapper<GaoEvent, String> { public interface GaoEventMapper extends BaseMapper<GaoEvent, String> {
@SelectProvider(type = GaoEventSQLProvider.class, method = "selectPageWithoutDeleted")
List<GaoEvent> selectPageWithoutDeleted(Page<GaoEvent> page);
@SelectProvider(type = GaoEventSQLProvider.class, method = "countPageWithoutDeleted")
long countPageWithoutDeleted(Page<GaoEvent> page);
List<GaoEvent> selectByIdList(Collection<String> idList); List<GaoEvent> selectByIdList(Collection<String> idList);
List<GaoEvent> selectValidList(@Param("storeId") String storeId, @Param("now") Long now); List<GaoEvent> selectValidList(@Param("storeId") String storeId, @Param("now") Long now);
@Select("SELECT COUNT(*) FROM `gao_event` WHERE `package_config_id` = #{packageConfigId} AND `deleted_at` IS NULL")
long countByPackageConfigId(String packageConfigId);
} }
@@ -0,0 +1,17 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// 登记事件选项组 Mapper
///
/// @author Codex
/// @since 2026-08-30
public interface GaoEventOptionGroupMapper extends BaseMapper<GaoEventOptionGroup, String> {
List<GaoEventOptionGroup> selectAllByEventIdList(@Param("eventIdList") Collection<String> eventIdList);
}
@@ -0,0 +1,17 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoEventOption;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// 登记事件选项 Mapper
///
/// @author Codex
/// @since 2026-08-30
public interface GaoEventOptionMapper extends BaseMapper<GaoEventOption, String> {
List<GaoEventOption> selectAllByGroupIdList(@Param("groupIdList") Collection<String> groupIdList);
}
@@ -8,9 +8,11 @@ import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView; import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
import com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq; import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import com.imyeyu.spring.mapper.BaseMapper; import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@@ -20,6 +22,17 @@ import java.util.List;
/// @since 2026-07-27 14:11 /// @since 2026-07-27 14:11
public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String> { public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String> {
/// 查询事件登记记录数量
///
/// @param eventId 事件 ID
/// @return 登记记录数量
@Select("SELECT COUNT(*) FROM `gao_event_record` WHERE `event_id` = #{eventId} AND `deleted_at` IS NULL")
long countByEventId(String eventId);
/// 查询事件记录是否被订单引用
@Select("SELECT COUNT(*) FROM `gao_sales_order` WHERE `source_event_record_id` = #{recordId}")
long countBySourceEventRecordId(@Param("recordId") String recordId);
Long count(String storeId, String customerId, String eventId, Long beginAt, Long endAt); Long count(String storeId, String customerId, String eventId, Long beginAt, Long endAt);
/// 查询事件中已携带数值的登记记录数量 /// 查询事件中已携带数值的登记记录数量
@@ -44,6 +57,15 @@ public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String>
/// @param earnedPointValue 获得积分总和 /// @param earnedPointValue 获得积分总和
void updateEarnedPointValue(@Param("id") String id, @Param("earnedPointValue") Long earnedPointValue); void updateEarnedPointValue(@Param("id") String id, @Param("earnedPointValue") Long earnedPointValue);
/// 原子更新登记记录核销状态
///
/// @param id 登记记录 ID
/// @param verifierUserId 核销用户 ID
/// @param verifiedAt 核销时间
/// @param updatedBy 最后修改用户 ID
/// @return 更新行数
int verify(@Param("id") String id, @Param("verifierUserId") String verifierUserId, @Param("verifiedAt") Long verifiedAt, @Param("updatedBy") String updatedBy);
/// 按门店和登记日期统计登记记录数 /// 按门店和登记日期统计登记记录数
/// ///
/// @param storeId 门店 ID /// @param storeId 门店 ID
@@ -71,6 +93,12 @@ public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String>
/// @return 登记数值合计 /// @return 登记数值合计
Long sumNumberValueByRange(GaoEventRecordPage page); Long sumNumberValueByRange(GaoEventRecordPage page);
/// 按选项统计登记记录数量
///
/// @param page 登记记录范围查询请求
/// @return 选项统计列表
List<GaoEventOptionStatView> selectOptionStatByRange(GaoEventRecordPage page);
/// 统计客户登记排行榜总数 /// 统计客户登记排行榜总数
/// ///
/// @param page 排行榜分页请求 /// @param page 排行榜分页请求
@@ -0,0 +1,17 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoEventRecordOption;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// 登记事件记录选项 Mapper
///
/// @author Codex
/// @since 2026-08-30
public interface GaoEventRecordOptionMapper extends BaseMapper<GaoEventRecordOption, String> {
List<GaoEventRecordOption> selectAllByEventRecordIdList(@Param("eventRecordIdList") Collection<String> eventRecordIdList);
}
@@ -0,0 +1,32 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.util.SQLProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.builder.annotation.ProviderContext;
/// 登记事件分页查询 SQL 提供器
///
/// @author Codex
public class GaoEventSQLProvider extends SQLProvider {
/// 分页查询未删除的登记事件
public String selectPageWithoutDeleted(ProviderContext context, @Param("page") Page<?> page) {
EntityMeta meta = getEntityMeta(context);
return appendWithoutDeleted(buildSelectByPageSQL(meta, meta.getTable(), page, "#{offset}", "#{limit}"));
}
/// 统计未删除的登记事件
public String countPageWithoutDeleted(ProviderContext context, @Param("page") Page<?> page) {
EntityMeta meta = getEntityMeta(context);
return appendWithoutDeleted(buildCountByPageSQL(meta, meta.getTable(), page));
}
private String appendWithoutDeleted(String sql) {
return sql.replace(
"WHERE 1 = 1",
"WHERE 1 = 1 AND (`status` IS NULL OR `status` <> '%s') AND (`biz_type` IS NULL OR `biz_type` <> '%s')".formatted(GaoEvent.Status.DELETED.name(), GaoEvent.BizType.LEGACY_CONSUMPTION.name())
);
}
}
@@ -0,0 +1,42 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoFundRecord;
import com.imyeyu.api.modules.gao.vo.GaoFundRecordPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/// GAO 资金流水 Mapper
///
/// @author Codex
/// @since 2026-08-31
public interface GaoFundRecordMapper extends BaseMapper<GaoFundRecord, String> {
/// 按门店和请求号查询资金操作
GaoFundRecord selectByRequestNo(@Param("storeId") String storeId, @Param("requestNo") String requestNo);
/// 锁定资金记录
GaoFundRecord selectForUpdate(@Param("id") String id);
/// 查询资金记录及关联销售订单资金摘要
GaoFundRecord selectWithSalesOrderSummary(@Param("id") String id);
/// 查询资金冲正记录
GaoFundRecord selectRevokeBySourceRecordId(@Param("sourceRecordId") String sourceRecordId);
/// 查询客户套餐待核销收款数量
long countPendingReceiveByBizId(@Param("bizId") String bizId);
/// 查询客户套餐资金历史
List<GaoFundRecord> selectByBizId(@Param("bizId") String bizId);
/// 按条件统计资金记录
long countByQuery(GaoFundRecordPage page);
/// 按条件查询资金记录
List<GaoFundRecord> selectByQuery(GaoFundRecordPage page);
/// 带状态条件更新资金记录
int updateStatusIf(@Param("id") String id, @Param("fromStatus") GaoFundRecord.Status fromStatus, @Param("toStatus") GaoFundRecord.Status toStatus, @Param("verifierUserId") String verifierUserId, @Param("verifiedAt") Long verifiedAt, @Param("reason") String reason);
}
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoOrderFulfillmentItem;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/// GAO 统一履约明细 Mapper
///
/// @author Codex
/// @since 2026-09-02
public interface GaoOrderFulfillmentItemMapper extends BaseMapper<GaoOrderFulfillmentItem, String> {
/// 按履约单查询明细
List<GaoOrderFulfillmentItem> selectByFulfillmentId(@Param("fulfillmentId") String fulfillmentId);
/// 批量查询履约明细
List<GaoOrderFulfillmentItem> selectByFulfillmentIdList(@Param("fulfillmentIdList") List<String> fulfillmentIdList);
/// 锁定履约明细
List<GaoOrderFulfillmentItem> selectByFulfillmentIdForUpdate(@Param("fulfillmentId") String fulfillmentId);
}
@@ -0,0 +1,44 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment;
import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/// GAO 统一履约 Mapper
///
/// @author Codex
/// @since 2026-09-02
public interface GaoOrderFulfillmentMapper extends BaseMapper<GaoOrderFulfillment, String> {
/// 按门店和幂等号查询履约单
GaoOrderFulfillment selectByRequestNo(@Param("storeId") String storeId, @Param("requestNo") String requestNo);
/// 按 ID 查询履约单
GaoOrderFulfillment selectById(@Param("id") String id);
/// 锁定履约单
GaoOrderFulfillment selectForUpdate(@Param("id") String id);
/// 按订单查询履约单
List<GaoOrderFulfillment> selectBySalesOrderId(@Param("salesOrderId") String salesOrderId);
/// 按冲正来源查询履约单
GaoOrderFulfillment selectBySourceFulfillmentId(@Param("sourceFulfillmentId") String sourceFulfillmentId);
/// 统计订单中仍占用权益的履约单
long countPendingBySalesOrderId(@Param("salesOrderId") String salesOrderId);
/// 按条件统计履约单
long countByQuery(GaoOrderFulfillmentPage page);
/// 按条件查询履约单
List<GaoOrderFulfillment> selectByQuery(GaoOrderFulfillmentPage page);
/// 更新履约状态
int updateStatus(@Param("id") String id, @Param("status") GaoOrderFulfillment.Status status,
@Param("verifierUserId") String verifierUserId, @Param("verifiedAt") Long verifiedAt,
@Param("reason") String reason);
}
@@ -0,0 +1,27 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.vo.GaoOrderReminderCustomer;
import java.util.List;
/// GAO 订单提醒 Mapper
///
/// @author Codex
/// @since 2026-09-06
public interface GaoOrderReminderMapper {
/// 查询需要收款的订单客户
///
/// @return 订单客户列表
List<GaoOrderReminderCustomer> selectOrderReceiveCustomers();
/// 查询待核销收款客户
///
/// @return 收款客户列表
List<GaoOrderReminderCustomer> selectReceiveVerifyCustomers();
/// 查询待核销履约客户
///
/// @return 履约客户列表
List<GaoOrderReminderCustomer> selectFulfillmentVerifyCustomers();
}
@@ -0,0 +1,28 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// GAO 套餐配置产品 Mapper
///
/// @author Codex
/// @since 2026-08-31
public interface GaoPackageConfigItemMapper extends BaseMapper<GaoPackageConfigItem, String> {
/// 物理删除套餐配置的全部权益模板项
///
/// @param packageConfigId 套餐配置 ID
@Delete("DELETE FROM `gao_package_config_item` WHERE `package_config_id` = #{packageConfigId}")
void destroyByPackageConfigId(@Param("packageConfigId") String packageConfigId);
/// 按套餐配置 ID 查询产品
List<GaoPackageConfigItem> selectByPackageConfigId(@Param("packageConfigId") String packageConfigId);
/// 批量查询套餐配置产品
List<GaoPackageConfigItem> selectByPackageConfigIdList(@Param("packageConfigIdList") Collection<String> packageConfigIdList);
}
@@ -0,0 +1,31 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoPackageConfig;
import com.imyeyu.api.modules.gao.vo.GaoPackageConfigPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// GAO 套餐配置 Mapper
///
/// @author Codex
/// @since 2026-08-31
public interface GaoPackageConfigMapper extends BaseMapper<GaoPackageConfig, String> {
/// 按 ID 列表查询套餐配置
List<GaoPackageConfig> selectByIdList(@Param("idList") Collection<String> idList);
/// 查询有效可购买套餐
List<GaoPackageConfig> selectValidList(@Param("storeId") String storeId, @Param("now") Long now);
/// 按条件统计套餐配置
long countByQuery(GaoPackageConfigPage page);
/// 按条件查询套餐配置
List<GaoPackageConfig> selectByQuery(GaoPackageConfigPage page);
/// 查询门店内同名配置
GaoPackageConfig selectByStoreIdAndName(@Param("storeId") String storeId, @Param("name") String name, @Param("excludeId") String excludeId);
}
@@ -0,0 +1,38 @@
package com.imyeyu.api.modules.gao.mapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/// GAO 积分流水消费事实依赖 Mapper
///
/// @author Codex
/// @since 2026-09-04
public interface GaoPointLedgerConsumptionRecordMapper {
/// 写入积分流水对消费事实的依赖
///
/// @param pointLedgerId 积分流水 ID
/// @param consumptionRecordId 消费事实 ID
/// @param createdAt 创建时间
/// @return 写入行数
@Insert("INSERT IGNORE INTO `gao_point_ledger_consumption_record` (`point_ledger_id`, `consumption_record_id`, `created_at`) VALUES (#{pointLedgerId}, #{consumptionRecordId}, #{createdAt})")
int insert(@Param("pointLedgerId") String pointLedgerId, @Param("consumptionRecordId") String consumptionRecordId, @Param("createdAt") long createdAt);
/// 查询积分流水依赖的消费事实 ID
///
/// @param pointLedgerId 积分流水 ID
/// @return 消费事实 ID 列表
@Select("SELECT `consumption_record_id` FROM `gao_point_ledger_consumption_record` WHERE `point_ledger_id` = #{pointLedgerId}")
List<String> selectConsumptionRecordIdList(@Param("pointLedgerId") String pointLedgerId);
/// 删除积分流水的依赖关系
///
/// @param pointLedgerId 积分流水 ID
/// @return 删除行数
@Delete("DELETE FROM `gao_point_ledger_consumption_record` WHERE `point_ledger_id` = #{pointLedgerId}")
int deleteByPointLedgerId(@Param("pointLedgerId") String pointLedgerId);
}

Some files were not shown because too many files have changed in this diff Show More