Compare commits

..
24 Commits
Author SHA1 Message Date
timi c8e2e16ba5 Merge pull request 'v1.0.15' (#24) from dev into master
Reviewed-on: #24
2026-08-15 17:49:51 +00:00
timi 99b44faf09 Merge pull request 'v1.0.15' (#23) from dev into master
Reviewed-on: #23
2026-08-15 17:45:26 +00:00
timi b3e3cbf84b Merge pull request 'v1.0.14' (#22) from dev into master
Reviewed-on: #22
2026-08-14 17:31:11 +00:00
timi 0aee11d824 Merge pull request 'v1.0.14' (#21) from dev into master
Reviewed-on: #21
2026-08-14 17:26:10 +00:00
timi fcf358a768 Merge pull request 'v1.0.13' (#20) from dev into master
Reviewed-on: #20
2026-08-13 09:52:26 +00:00
timi 619369104c Merge pull request 'v1.0.12' (#19) from dev into master
Reviewed-on: #19
2026-08-12 17:02:43 +00:00
timi 4f1408b9d0 Merge pull request 'v1.0.11' (#18) from dev into master
Reviewed-on: #18
2026-08-11 16:49:08 +00:00
timi 029eea70cc Merge pull request 'v1.0.10' (#17) from dev into master
Reviewed-on: #17
2026-08-11 16:45:36 +00:00
timi 22b1e65385 Merge pull request 'v1.0.9' (#16) from dev into master
Reviewed-on: #16
2026-08-11 16:01:10 +00:00
timi 2170c48763 Merge pull request 'v1.0.8' (#15) from dev into master
Reviewed-on: #15
2026-08-03 16:36:19 +00:00
timi c2d1c48aae Merge pull request 'v0.0.18' (#14) from dev into master
Reviewed-on: #14
2026-08-03 11:59:20 +00:00
timi e14958c643 Merge pull request 'v0.0.18' (#13) from dev into master
Reviewed-on: #13
2026-08-03 11:58:16 +00:00
timi da288338cd Merge pull request 'v1.0.7' (#12) from dev into master
Reviewed-on: #12
2026-08-01 09:34:18 +00:00
timi ea430f2468 Merge pull request 'v1.0.6' (#11) from dev into master
Reviewed-on: #11
2026-08-01 09:03:48 +00:00
timi f76f79744a Merge pull request 'v1.0.5' (#10) from dev into master
Reviewed-on: #10
2026-08-01 08:52:52 +00:00
timi 19daaff907 Merge pull request 'v1.0.4' (#9) from dev into master
Reviewed-on: #9
2026-08-01 03:13:00 +00:00
timi db94d8f932 Merge pull request 'v1.0.3' (#8) from dev into master
Reviewed-on: #8
2026-07-31 17:19:48 +00:00
timi 53618fe362 Merge pull request 'v1.0.3' (#7) from dev into master
Reviewed-on: #7
2026-07-31 17:13:37 +00:00
timi 523edffc4e Merge pull request 'v1.0.2' (#6) from dev into master
Reviewed-on: #6
2026-04-13 10:28:11 +00:00
timi c7ddb1a8b0 Merge pull request 'v1.0.1' (#5) from dev into master
Reviewed-on: #5
2026-04-12 16:17:02 +00:00
timi 45c9fc814a Merge pull request 'v1.0.0' (#4) from dev into master
Reviewed-on: #4
2026-04-09 05:16:04 +00:00
timi 407dc13ac4 Merge pull request 'v1.0.0' (#3) from dev into master
Reviewed-on: #3
2026-04-09 04:09:16 +00:00
timi 0c06bf16c2 Merge pull request 'v1.0.0' (#2) from dev into master
Reviewed-on: #2
2026-04-09 04:03:43 +00:00
timi 1db39e77d3 Merge pull request 'v1.0.0' (#1) from dev into master
Reviewed-on: #1
2026-04-08 08:48:12 +00:00
32 changed files with 23 additions and 605 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
<groupId>com.imyeyu.timiserverapi</groupId>
<artifactId>TimiServerAPI</artifactId>
<version>1.0.17</version>
<version>1.0.15</version>
<packaging>jar</packaging>
<name>TimiServerAPI</name>
<description>imyeyu.com API</description>
@@ -50,11 +50,6 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
USER_DELETE("USER:DELETE", "用户删除", false, true),
FEEDBACK_CREATE("FEEDBACK:CREATE", "反馈创建", false, true),
FEEDBACK_READ("FEEDBACK:READ", "反馈读取", false, true),
FEEDBACK_UPDATE("FEEDBACK:UPDATE", "反馈修改", false, true),
FEEDBACK_DELETE("FEEDBACK:DELETE", "反馈删除", false, true),
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
@@ -1,116 +0,0 @@
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.Feedback;
import com.imyeyu.api.modules.common.service.FeedbackService;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.CaptchaValid;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.CaptchaData;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import jakarta.validation.Valid;
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;
/// 通用反馈接口
///
/// @author Codex
/// @since 2026-08-19
@RestController
@RequiredArgsConstructor
@RequestMapping("/feedback")
public class FeedbackController {
private final FeedbackService service;
private final UserLoginService userLoginService;
/// 提交反馈。登录用户和匿名用户均需提交图形验证码,匿名用户按 IP 限流
///
/// @param req 带图形验证码的反馈请求
/// @return 已创建反馈
@AOPLog
@JsonView(ResponseView.Public.class)
@CaptchaValid
@RequestRateLimit(value = 3, inSeconds = 60)
@PostMapping("/submit")
public Feedback submit(@RequestBody @Valid CaptchaData<Feedback> req) {
Feedback feedback = req.getData();
feedback.setIp(TimiSpring.getRequestIP());
if (userLoginService.getLoginUser() != null) {
feedback.setUserId(userLoginService.getLoginUser().getId());
}
service.create(feedback);
return feedback;
}
/// 查询反馈列表
///
/// @param page 分页参数
/// @return 反馈分页
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
@PostMapping("/list")
public PageResult<Feedback> list(@RequestBody Page<Feedback> page) {
return service.page(page);
}
/// 查询反馈详情
///
/// @param id 反馈 ID
/// @return 反馈详情
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
@PostMapping("/detail")
public Feedback detail(@RequestParam String id) {
return service.get(id);
}
/// 后台创建反馈
///
/// @param feedback 反馈
/// @return 反馈
@AOPLog
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_CREATE)
@PostMapping("/create")
public Feedback create(@RequestBody Feedback feedback) {
service.create(feedback);
return feedback;
}
/// 更新反馈
///
/// @param feedback 反馈
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Feedback feedback) {
feedback.setRespondedBy(userLoginService.getRequireLoginUserId());
service.update(feedback);
}
/// 删除反馈
///
/// @param id 反馈 ID
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
}
@@ -28,10 +28,7 @@ public class Article extends UUIDEntity implements SettingSupport {
public enum BizType {
/** 博客 */
BLOG,
/// 反馈
FEEDBACK
BLOG
}
/**
@@ -82,7 +79,4 @@ public class Article extends UUIDEntity implements SettingSupport {
@Transient
protected List<Comment> commentList;
@Transient
protected List<Attachment> attachmentList;
}
@@ -30,8 +30,6 @@ public class Attachment extends UUIDEntity {
/// @since 2026-07-17 20:52
public enum BizType {
ARTICLE,
USER,
GAO_CUSTOMER,
@@ -1,79 +0,0 @@
package com.imyeyu.api.modules.common.entity;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.spring.annotation.table.Transient;
import com.imyeyu.spring.entity.UUIDEntity;
import com.imyeyu.spring.util.ResponseView;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/// 通用反馈
///
/// @author Codex
/// @since 2026-08-19
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class Feedback extends UUIDEntity {
/// 反馈处理状态
public enum Status {
/// 待处理
PENDING,
/// 已回复
REPLIED,
/// 已关闭
CLOSED
}
/// 所属模块
@JsonView(ResponseView.Public.class)
private ModuleCode module;
/// 提交用户 ID匿名反馈为 null
@JsonView(ResponseView.Admin.class)
private String userId;
/// 反馈内容文章 ID
@JsonView(ResponseView.Public.class)
private String contentId;
/// 联系方式
@JsonView(ResponseView.Public.class)
private String contact;
/// 提交 IP
@JsonView(ResponseView.Admin.class)
private String ip;
/// 处理状态
@JsonView(ResponseView.Public.class)
private Status status;
/// 管理员回复文章 ID
@JsonView(ResponseView.Public.class)
private String responseId;
/// 回复用户 ID
@JsonView(ResponseView.Admin.class)
private String respondedBy;
/// 回复时间
@JsonView(ResponseView.Public.class)
private Long respondedAt;
/// 管理员回复文章
@Transient
@JsonView(ResponseView.Public.class)
private Article content;
/// 管理员回复文章
@Transient
@JsonView(ResponseView.Public.class)
private Article response;
}
@@ -32,7 +32,7 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
List<Attachment> selectByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
@@ -1,11 +0,0 @@
package com.imyeyu.api.modules.common.mapper;
import com.imyeyu.api.modules.common.entity.Feedback;
import com.imyeyu.spring.mapper.BaseMapper;
/// 通用反馈 Mapper
///
/// @author Codex
/// @since 2026-08-19
public interface FeedbackMapper extends BaseMapper<Feedback, String> {
}
@@ -1,11 +0,0 @@
package com.imyeyu.api.modules.common.service;
import com.imyeyu.api.modules.common.entity.Feedback;
import com.imyeyu.spring.service.BaseService;
/// 通用反馈服务
///
/// @author Codex
/// @since 2026-08-19
public interface FeedbackService extends BaseService<Feedback, String> {
}
@@ -1,15 +1,8 @@
package com.imyeyu.api.modules.common.service.implement;
import com.imyeyu.api.modules.common.entity.Article;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.mapper.ArticleMapper;
import com.imyeyu.api.modules.common.service.ArticleService;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.java.TimiJava;
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 lombok.RequiredArgsConstructor;
@@ -27,57 +20,10 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class ArticleServiceImplement extends AbstractEntityService<Article, String> implements ArticleService {
private final LoggerService loggerService;
private final AttachmentService attachmentService;
private final ArticleMapper mapper;
@Override
protected BaseMapper<Article, String> mapper() {
return mapper;
}
@Override
public void create(Article article) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_CREATE");
try {
super.create(article);
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
logger.setLevel(Logger.Level.INFO);
logger.setResult(article.getId());
} 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("create article error", e);
throw new TimiException(TimiCode.ERROR, "create article error", e);
} finally {
loggerService.create(logger);
}
}
@Override
public void update(Article article) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_UPDATE");
try {
super.update(article);
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
logger.setLevel(Logger.Level.INFO);
logger.setResult(article.getId());
} 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("update article error", e);
throw new TimiException(TimiCode.ERROR, "update article error", e);
} finally {
loggerService.create(logger);
}
}
}
@@ -319,12 +319,12 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
@Override
public List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes) {
return mapper.selectAllByBizIdList(bizType, List.of(bizId), List.of(attachTypes));
return mapper.selectByBizId(bizType, bizId, List.of(attachTypes), null);
}
@Override
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.selectByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
}
@Override
@@ -1,141 +0,0 @@
package com.imyeyu.api.modules.common.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.common.entity.Feedback;
import com.imyeyu.api.modules.common.mapper.FeedbackMapper;
import com.imyeyu.api.modules.common.service.ArticleService;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.common.service.FeedbackService;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.java.TimiJava;
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 com.imyeyu.utils.Time;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/// 通用反馈服务实现
///
/// @author Codex
/// @since 2026-08-19
@Service
@RequiredArgsConstructor
@Slf4j
public class FeedbackServiceImplement extends AbstractEntityService<Feedback, String> implements FeedbackService {
private static final long ANONYMOUS_ATTACHMENT_MAX_SIZE = 500L * 1024;
private final LoggerService loggerService;
private final ArticleService articleService;
private final UserLoginService userLoginService;
private final AttachmentService attachmentService;
private final FeedbackMapper mapper;
@Override
protected BaseMapper<Feedback, String> mapper() {
return mapper;
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void create(Feedback feedback) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_CREATE");
try {
TimiException.required(feedback, "未找到反馈");
articleService.create(feedback.getContent());
feedback.setContentId(feedback.getContent().getId());
feedback.setStatus(TimiJava.defaultIfNull(feedback.getStatus(), Feedback.Status.PENDING));
super.create(feedback);
logger.setLevel(Logger.Level.INFO);
logger.setResult(feedback.getId());
} 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("create feedback error", e);
throw new TimiException(TimiCode.ERROR, "create feedback error", e);
} finally {
loggerService.create(logger);
}
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void update(Feedback feedback) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_UPDATE");
try {
TimiException.required(feedback, "未找到反馈");
TimiException.required(feedback.getId(), "未找到反馈 ID");
Feedback dbFeedback = get(feedback.getId());
TimiException.required(dbFeedback, "未找到反馈");
feedback.getContent().setId(dbFeedback.getContentId());
articleService.update(feedback.getContent());
dbFeedback.setModule(TimiJava.defaultIfNull(feedback.getModule(), dbFeedback.getModule()));
if (TimiJava.isNotEmpty(feedback.getResponse())) {
if (TimiJava.isEmpty(feedback.getResponseId())) {
articleService.create(feedback.getResponse());
dbFeedback.setResponseId(feedback.getResponse().getId());
dbFeedback.setRespondedAt(Time.now());
} else {
feedback.getResponse().setId(dbFeedback.getResponseId());
articleService.update(feedback.getResponse());
}
dbFeedback.setStatus(Feedback.Status.REPLIED);
dbFeedback.setRespondedBy(userLoginService.getRequireLoginUserId());
}
super.update(dbFeedback);
logger.setLevel(Logger.Level.INFO);
logger.setResult(feedback.getId());
} 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);
}
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void delete(String id) {
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_DELETE");
try {
Feedback feedback = get(id);
articleService.delete(feedback.getContentId());
if (TimiJava.isNotEmpty(feedback.getResponseId())) {
articleService.delete(feedback.getResponseId());
}
super.delete(id);
logger.setLevel(Logger.Level.INFO);
logger.setResult(id);
} 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("delete feedback error", e);
throw new TimiException(TimiCode.ERROR, "delete feedback error", e);
} finally {
loggerService.create(logger);
}
}
}
@@ -21,8 +21,6 @@ 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
@@ -80,19 +78,6 @@ public class GaoPointRuleController {
ruleService.update(rule);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
@PostMapping("/rule/sort")
public void sort(@RequestBody List<String> idList) {
if (idList != null) {
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
checkStore(rule.getStoreId());
}
}
ruleService.sort(idList);
}
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_DELETE)
@@ -7,7 +7,6 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
@@ -58,15 +57,6 @@ public class GaoStoreChartController {
return service.eventRecordDailyStat(req);
}
/// 查询登记事件每日数值合计
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/event/record/number-value/daily")
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDaily(@RequestBody GaoStoreChartReq req) {
return service.eventRecordNumberValueDailyStat(req);
}
/// 查询登记事件日历记录
@AOPLog
@RequestRateLimit
@@ -123,9 +123,7 @@ public class GaoUserController {
{
User user = userService.get(result.getUserId());
user.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.USER, user.getId()));
user.setRoleList(userRoleService.listAllRoleCodeByUserId(user.getId()));
user.setRoleEntityList(userRoleService.listRoleByUserId(user.getId()));
user.setPermissionList(userRoleService.listAllPermissionCodeByUserId(user.getId()));
result.setUser(user);
}
return result;
@@ -30,11 +30,7 @@ public class GaoCustomer extends UUIDEntity {
/// @since 2026-07-27
public enum AttachType {
PHOTO,
POINT_CARD,
OTHER
PHOTO
}
///
@@ -17,7 +17,7 @@ public class GaoPointLedger extends UUIDEntity {
/// 流水变化类型
public enum ChangeType {
/// 登记事件积分变化
/// 登记事件获得积分
EARN,
/// 删除登记记录撤销积分
@@ -5,7 +5,6 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerChartReq;
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
@@ -89,9 +88,6 @@ public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String>
/// @return 每日登记数
List<GaoEventRecordDailyStatView> stateDailyByRange(GaoStoreChartReq req);
/// 按时间范围和事件统计每日登记数值合计
List<GaoEventRecordNumberValueDailyStatView> stateNumberValueDailyByRange(GaoStoreChartReq req);
/// 按时间范围查询登记日历记录
///
/// @param req 门店报表查询请求
@@ -4,7 +4,6 @@ import com.imyeyu.api.modules.gao.entity.GaoPointRule;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/// GAO 客户积分规则 Mapper
@@ -13,8 +12,6 @@ import java.util.List;
/// @since 2026-08-11
public interface GaoPointRuleMapper extends BaseMapper<GaoPointRule, String> {
List<GaoPointRule> selectByIdList(Collection<String> idList);
/// 查询当前时间可匹配的启用规则
///
/// @param storeId 门店 ID
@@ -19,17 +19,6 @@ public interface GaoPointRuleService extends BaseService<GaoPointRule, String> {
/// @return 规则列表
List<GaoPointRule> listActive(String storeId, String eventId, long now);
/// 查询规则 ID 列表
///
/// @param idList 规则 ID 列表
/// @return 规则列表
List<GaoPointRule> listByIdList(List<String> idList);
/// 按客户端提交的顺序更新启用规则优先级
///
/// @param idList 规则 ID 列表
void sort(List<String> idList);
/// 创建积分规则
///
/// @param rule 积分规则
@@ -4,7 +4,6 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import java.util.List;
@@ -24,9 +23,6 @@ public interface GaoStoreChartService {
/// 查询登记事件每日统计
List<GaoEventRecordDailyStatView> eventRecordDailyStat(GaoStoreChartReq req);
/// 查询登记事件每日数值合计
List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDailyStat(GaoStoreChartReq req);
/// 查询登记事件日历记录
List<GaoEventRecordCalendarView> eventRecordCalendar(GaoStoreChartReq req);
}
@@ -377,7 +377,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
}
private void changeInvitedCount(String customerId, long delta) {
if (TimiJava.isEmpty(customerId) || delta == 0) {
if (delta == 0) {
return;
}
GaoCustomer customer = get(customerId);
@@ -10,9 +10,9 @@ import com.imyeyu.api.modules.gao.entity.GaoEvent;
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
import com.imyeyu.api.modules.gao.service.GaoEventService;
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
import com.imyeyu.api.modules.gao.util.EventRecordXSSFBuilder;
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
@@ -321,7 +321,7 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
long today = Time.today(registeredAt);
long noon = today + Time.D / 2;
long beginAt = today, endAt;
if (registeredAt < noon) {
if (today + registeredAt < noon) {
// 上半日
endAt = noon;
} else {
@@ -74,7 +74,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
public GaoPointLedger earn(GaoEventRecord record, GaoPointRule rule, long pointDelta, JsonNode sourcePayload) {
TimiException.required(record, "not found event record");
TimiException.required(rule, "not found point rule");
TimiException.requiredTrue(pointDelta != 0, "pointDelta invalid");
TimiException.requiredTrue(0 < pointDelta, "pointDelta invalid");
String idempotencyKey = "GAO_EVENT_RECORD:%s:RULE:%s:EARN".formatted(record.getId(), rule.getId());
return apply(record.getStoreId(), record.getCustomerId(), GaoPointLedger.ChangeType.EARN, pointDelta, rule.getId(), record.getEventId(), record.getId(), sourcePayload, idempotencyKey, rule.getRemark(), record.getOperatorUserId(), record.getRegisteredAt());
}
@@ -84,7 +84,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
public GaoPointLedger revoke(GaoPointLedger originLedger, GaoEventRecord record) {
TimiException.required(originLedger, "not found origin ledger");
TimiException.required(record, "not found event record");
TimiException.requiredTrue(originLedger.getPointDelta() != 0, "origin ledger pointDelta invalid");
TimiException.requiredTrue(0 < originLedger.getPointDelta(), "origin ledger pointDelta invalid");
String idempotencyKey = "GAO_EVENT_RECORD:%s:LEDGER:%s:REVOKE".formatted(record.getId(), originLedger.getId());
return apply(originLedger.getStoreId(), originLedger.getCustomerId(), GaoPointLedger.ChangeType.REVOKE, -originLedger.getPointDelta(), originLedger.getRuleId(), originLedger.getEventId(), originLedger.getEventRecordId(), originLedger.getSourcePayload(), idempotencyKey, "撤销登记记录积分", userLoginService.getRequireLoginUserId(), Time.now());
}
@@ -16,11 +16,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/// GAO 客户积分规则服务实现
///
@@ -47,32 +42,6 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
return mapper.selectActiveByStoreIdAndEventId(storeId, eventId, now);
}
@Override
public List<GaoPointRule> listByIdList(List<String> idList) {
if (TimiJava.isEmpty(idList)) {
return List.of();
}
return mapper.selectByIdList(new LinkedHashSet<>(idList));
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void sort(List<String> idList) {
if (TimiJava.isEmpty(idList)) {
return;
}
List<String> distinctIdList = new ArrayList<>(new LinkedHashSet<>(idList));
Map<String, GaoPointRule> ruleMap = mapper.selectByIdList(new LinkedHashSet<>(distinctIdList)).stream()
.collect(Collectors.toMap(GaoPointRule::getId, Function.identity()));
TimiException.requiredTrue(ruleMap.size() == distinctIdList.size(), "积分规则列表包含不存在的规则");
for (int i = 0; i < distinctIdList.size(); i++) {
GaoPointRule rule = ruleMap.get(distinctIdList.get(i));
TimiException.requiredTrue(rule.getStatus() == GaoPointRule.Status.ACTIVE, "只能调整启用规则排序");
rule.setPriority(i);
mapper.update(rule);
}
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void create(GaoPointRule rule) {
@@ -158,7 +127,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
TimiException.requiredTrue(rule.getPointMode() == GaoPointRule.PointMode.FIXED, "固定触发规则必须使用 FIXED 积分值模式");
TimiException.required(rule.getPointValue(), "not found rule.pointValue");
TimiException.requiredTrue(rule.getPointValue() != 0, "rule.pointValue invalid");
TimiException.requiredTrue(0 < rule.getPointValue(), "rule.pointValue invalid");
if (rule.getTriggerType() == GaoPointRule.TriggerType.AFTER_COUNT_EVERY_TIME) {
JsonNode condition = requireObjectCondition(rule.getConditionJson());
JsonNode threshold = condition.get("threshold");
@@ -180,7 +149,6 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
TimiException.required(sourceEvent, "TIER.sourceEventId 对应事件不存在");
TimiException.requiredTrue(storeId.equals(sourceEvent.getStoreId()), "TIER 来源事件和规则不属于同一门店");
TimiException.requiredTrue(sourceEvent.getValueType() == GaoEvent.ValueType.NUMBER, "TIER 来源事件必须配置为 NUMBER 类型");
TimiException.required(sourceEvent.getValueUnit(), "TIER 来源事件必须配置数值单位");
JsonNode sourceValueField = condition.get("sourceValueField");
TimiException.requiredTrue(sourceValueField != null && sourceValueField.isTextual() && "numberValue".equals(sourceValueField.asText()), "TIER.sourceValueField 目前只能是 numberValue");
@@ -224,7 +192,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
TimiException.requiredTrue(max == null, "最后一档 TIER.max 必须为空");
}
JsonNode pointValue = tier.get("pointValue");
TimiException.requiredTrue(pointValue != null && pointValue.isIntegralNumber(), "TIER.tiers[%d].pointValue invalid".formatted(i));
TimiException.requiredTrue(pointValue != null && pointValue.isIntegralNumber() && 0 <= pointValue.longValue(), "TIER.tiers[%d].pointValue invalid".formatted(i));
previousMax = max;
}
}
@@ -235,10 +203,9 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
Long max = condition == null || condition.get("max") == null || condition.get("max").isNull() ? null : condition.get("max").isIntegralNumber() ? condition.get("max").longValue() : null;
TimiException.requiredTrue(condition == null || min != null || condition.get("min") == null || condition.get("min").isNull(), "SOURCE_VALUE.min invalid");
TimiException.requiredTrue(condition == null || max != null || condition.get("max") == null || condition.get("max").isNull(), "SOURCE_VALUE.max invalid");
TimiException.requiredTrue(min == null || min != 0, "SOURCE_VALUE.min invalid");
TimiException.requiredTrue(max == null || max != 0, "SOURCE_VALUE.max invalid");
TimiException.requiredTrue(min == null || 0 < min, "SOURCE_VALUE.min invalid");
TimiException.requiredTrue(max == null || 0 < max, "SOURCE_VALUE.max invalid");
TimiException.requiredTrue(min == null || max == null || min <= max, "SOURCE_VALUE.min or SOURCE_VALUE.max invalid");
TimiException.requiredTrue(min == null || max == null || (min < 0) == (max < 0), "SOURCE_VALUE.min or SOURCE_VALUE.max direction invalid");
}
private JsonNode requireObjectCondition(JsonNode conditionJson) {
@@ -62,7 +62,7 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
List<GaoPointRule> ruleList = ruleService.listActive(record.getStoreId(), record.getEventId(), Time.now());
Long count = null;
long pointDeltaTotal = 0L;
long earnedPointValue = 0L;
for (GaoPointRule rule : ruleList) {
RuleResolution resolution = resolveRule(record, rule, count);
if (resolution == null) {
@@ -72,16 +72,16 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
count = count == null ? count(record) : count;
}
long pointDelta = resolution.pointDelta();
if (pointDelta != 0) {
if (0 < pointDelta) {
ledgerService.earn(record, rule, pointDelta, resolution.sourcePayload());
pointDeltaTotal = Math.addExact(pointDeltaTotal, pointDelta);
earnedPointValue = Math.addExact(earnedPointValue, pointDelta);
}
if (Boolean.TRUE.equals(rule.getExclusive())) {
break;
}
}
record.setEarnedPointValue(pointDeltaTotal);
eventRecordMapper.updateEarnedPointValue(record.getId(), pointDeltaTotal);
record.setEarnedPointValue(earnedPointValue);
eventRecordMapper.updateEarnedPointValue(record.getId(), earnedPointValue);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@@ -140,7 +140,7 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
}
permissionChecker.checkAny(ModuleCode.GAO, GaoPermissionCode.POINT_SOURCE_VALUE.getValue());
long pointValue = record.getPointValue();
TimiException.requiredTrue(pointValue != 0, "pointValue invalid");
TimiException.requiredTrue(0 < pointValue, "pointValue invalid");
JsonNode condition = rule.getConditionJson();
if (condition != null) {
JsonNode min = condition.get("min");
@@ -8,7 +8,6 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import com.imyeyu.java.bean.timi.TimiException;
import lombok.RequiredArgsConstructor;
@@ -49,12 +48,6 @@ public class GaoStoreChartServiceImplement implements GaoStoreChartService {
return eventRecordMapper.stateDailyByRange(req);
}
@Override
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDailyStat(GaoStoreChartReq req) {
checkRangeReq(req);
return eventRecordMapper.stateNumberValueDailyByRange(req);
}
@Override
public List<GaoEventRecordCalendarView> eventRecordCalendar(GaoStoreChartReq req) {
checkRangeReq(req);
@@ -1,17 +0,0 @@
package com.imyeyu.api.modules.gao.vo;
import lombok.Data;
/// 登记事件数值每日统计视图
@Data
public class GaoEventRecordNumberValueDailyStatView {
/// 登记事件 ID
private String eventId;
/// 日期值,格式为 yyyyMMdd
private Integer dateValue;
/// 当日登记数值合计
private Long dailyNumberValue;
}
@@ -1,21 +0,0 @@
CREATE TABLE `feedback` (
`id` CHAR(36) NOT NULL COMMENT '主键',
`module` VARCHAR(32) NOT NULL COMMENT '所属模块',
`user_id` CHAR(36) NULL COMMENT '提交用户 ID,匿名反馈为空',
`content_id` VARCHAR(36) NOT NULL COMMENT '反馈内容文章 ID',
`contact` VARCHAR(255) NULL COMMENT '联系方式',
`ip` VARCHAR(64) NULL COMMENT '提交 IP',
`status` VARCHAR(16) NOT NULL DEFAULT 'PENDING' COMMENT '处理状态',
`response_id` VARCHAR(36) NULL COMMENT '管理员回复文章 ID',
`responded_by` CHAR(36) NULL COMMENT '回复用户 ID',
`responded_at` BIGINT NULL COMMENT '回复时间',
`created_at` BIGINT NOT NULL COMMENT '创建时间',
`updated_at` BIGINT NOT NULL COMMENT '更新时间',
`deleted_at` BIGINT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
KEY `idx_feedback_module_status_created` (`module`, `status`, `created_at`),
KEY `idx_feedback_user_created` (`user_id`, `created_at`),
KEY `idx_feedback_content_id` (`content_id`),
KEY `idx_feedback_response_id` (`response_id`),
KEY `idx_feedback_deleted_at` (`deleted_at`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '通用反馈';
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.imyeyu.api.modules.common.mapper.AttachmentMapper">
<select id="selectAllByBizIdList" resultType="com.imyeyu.api.modules.common.entity.Attachment">
<select id="selectByBizIdList" resultType="com.imyeyu.api.modules.common.entity.Attachment">
SELECT
*
FROM `attachment`
@@ -350,22 +350,6 @@
r.`registered_date_value` ASC,
r.`event_id` ASC
</select>
<select id="stateNumberValueDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView">
SELECT
r.`event_id` AS `eventId`,
r.`registered_date_value` AS `dateValue`,
SUM(r.`number_value`) AS `dailyNumberValue`
FROM `gao_event_record` r
WHERE
<include refid="storeChartRangeWhere"/>
AND r.`number_value` IS NOT NULL
GROUP BY
r.`event_id`,
r.`registered_date_value`
ORDER BY
r.`registered_date_value` ASC,
r.`event_id` ASC
</select>
<select id="selectCalendarByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView">
SELECT
r.`id`,
@@ -1,16 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointRuleMapper">
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
SELECT *
FROM gao_point_rule
WHERE deleted_at IS NULL
AND id IN
<foreach collection="idList" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
SELECT *
FROM `gao_point_rule`